msi/tests: Add a trailing linefeed to a couple of ok() calls.
[wine.git] / dlls / msi / tests / package.c
blobeadef0591fcd8ad9aa28b7c201d8bee2c57d0402
1 /*
2 * tests for Microsoft Installer functionality
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Aric Stewart for CodeWeavers
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.
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.
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
22 #define COBJMACROS
24 #include <assert.h>
25 #include <stdio.h>
26 #include <windows.h>
27 #include <msidefs.h>
28 #include <msi.h>
29 #include <msiquery.h>
30 #include <srrestoreptapi.h>
31 #include <shlobj.h>
33 #include "wine/test.h"
35 static BOOL is_wow64;
36 static const char msifile[] = "winetest-package.msi";
37 static const WCHAR msifileW[] =
38 {'w','i','n','e','t','e','s','t','-','p','a','c','k','a','g','e','.','m','s','i',0};
39 static char CURR_DIR[MAX_PATH];
41 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
42 static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
44 static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL);
45 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
46 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
47 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
48 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
49 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
50 static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
51 static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO);
52 static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR, UINT);
54 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
55 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
57 static void init_functionpointers(void)
59 HMODULE hmsi = GetModuleHandleA("msi.dll");
60 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
61 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
62 HMODULE hshell32 = GetModuleHandleA("shell32.dll");
63 HMODULE hsrclient;
65 #define GET_PROC(mod, func) \
66 p ## func = (void*)GetProcAddress(mod, #func);
68 GET_PROC(hmsi, MsiGetComponentPathExA);
69 GET_PROC(hshell32, SHGetFolderPathA);
71 GET_PROC(hadvapi32, CheckTokenMembership);
72 GET_PROC(hadvapi32, ConvertSidToStringSidA);
73 GET_PROC(hadvapi32, OpenProcessToken);
74 GET_PROC(hadvapi32, RegDeleteKeyExA)
75 GET_PROC(hadvapi32, RegDeleteKeyExW)
76 GET_PROC(hkernel32, IsWow64Process)
77 GET_PROC(hkernel32, GetNativeSystemInfo)
78 GET_PROC(hkernel32, GetSystemInfo)
79 GET_PROC(hkernel32, GetSystemWow64DirectoryA)
81 hsrclient = LoadLibraryA("srclient.dll");
82 GET_PROC(hsrclient, SRRemoveRestorePoint);
83 GET_PROC(hsrclient, SRSetRestorePointA);
84 #undef GET_PROC
87 static BOOL is_process_limited(void)
89 SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
90 PSID Group = NULL;
91 BOOL IsInGroup;
92 HANDLE token;
94 if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE;
96 if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
97 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) ||
98 !pCheckTokenMembership(NULL, Group, &IsInGroup))
100 trace("Could not check if the current user is an administrator\n");
101 FreeSid(Group);
102 return FALSE;
104 FreeSid(Group);
106 if (!IsInGroup)
108 if (!AllocateAndInitializeSid(&NtAuthority, 2,
109 SECURITY_BUILTIN_DOMAIN_RID,
110 DOMAIN_ALIAS_RID_POWER_USERS,
111 0, 0, 0, 0, 0, 0, &Group) ||
112 !pCheckTokenMembership(NULL, Group, &IsInGroup))
114 trace("Could not check if the current user is a power user\n");
115 return FALSE;
117 if (!IsInGroup)
119 /* Only administrators and power users can be powerful */
120 return TRUE;
124 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
126 BOOL ret;
127 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
128 DWORD size;
130 ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
131 CloseHandle(token);
132 return (ret && type == TokenElevationTypeLimited);
134 return FALSE;
137 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
139 if (pRegDeleteKeyExA)
140 return pRegDeleteKeyExA( key, subkey, access, 0 );
141 return RegDeleteKeyA( key, subkey );
144 static char *get_user_sid(void)
146 HANDLE token;
147 DWORD size = 0;
148 TOKEN_USER *user;
149 char *usersid = NULL;
151 if (!pConvertSidToStringSidA)
153 win_skip("ConvertSidToStringSidA is not available\n");
154 return NULL;
156 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
157 GetTokenInformation(token, TokenUser, NULL, size, &size);
159 user = HeapAlloc(GetProcessHeap(), 0, size);
160 GetTokenInformation(token, TokenUser, user, size, &size);
161 pConvertSidToStringSidA(user->User.Sid, &usersid);
162 HeapFree(GetProcessHeap(), 0, user);
164 CloseHandle(token);
165 return usersid;
168 /* RegDeleteTreeW from dlls/advapi32/registry.c */
169 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
171 LONG ret;
172 DWORD dwMaxSubkeyLen, dwMaxValueLen;
173 DWORD dwMaxLen, dwSize;
174 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
175 HKEY hSubKey = hKey;
177 if(lpszSubKey)
179 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
180 if (ret) return ret;
183 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
184 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
185 if (ret) goto cleanup;
187 dwMaxSubkeyLen++;
188 dwMaxValueLen++;
189 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
190 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
192 /* Name too big: alloc a buffer for it */
193 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
195 ret = ERROR_NOT_ENOUGH_MEMORY;
196 goto cleanup;
200 /* Recursively delete all the subkeys */
201 while (TRUE)
203 dwSize = dwMaxLen;
204 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
205 NULL, NULL, NULL)) break;
207 ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
208 if (ret) goto cleanup;
211 if (lpszSubKey)
213 if (pRegDeleteKeyExW)
214 ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
215 else
216 ret = RegDeleteKeyW(hKey, lpszSubKey);
218 else
219 while (TRUE)
221 dwSize = dwMaxLen;
222 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
223 NULL, NULL, NULL, NULL)) break;
225 ret = RegDeleteValueW(hKey, lpszName);
226 if (ret) goto cleanup;
229 cleanup:
230 if (lpszName != szNameBuf)
231 HeapFree(GetProcessHeap(), 0, lpszName);
232 if(lpszSubKey)
233 RegCloseKey(hSubKey);
234 return ret;
237 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
239 DWORD i,n=1;
240 GUID guid;
242 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
243 return FALSE;
245 for(i=0; i<8; i++)
246 out[7-i] = in[n++];
247 n++;
248 for(i=0; i<4; i++)
249 out[11-i] = in[n++];
250 n++;
251 for(i=0; i<4; i++)
252 out[15-i] = in[n++];
253 n++;
254 for(i=0; i<2; i++)
256 out[17+i*2] = in[n++];
257 out[16+i*2] = in[n++];
259 n++;
260 for( ; i<8; i++)
262 out[17+i*2] = in[n++];
263 out[16+i*2] = in[n++];
265 out[32]=0;
266 return TRUE;
269 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
271 WCHAR guidW[MAX_PATH];
272 WCHAR squashedW[MAX_PATH];
273 GUID guid;
274 HRESULT hr;
275 int size;
277 hr = CoCreateGuid(&guid);
278 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
280 size = StringFromGUID2(&guid, guidW, MAX_PATH);
281 ok(size == 39, "Expected 39, got %d\n", hr);
283 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
284 squash_guid(guidW, squashedW);
285 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
288 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
289 LPCSTR guid, LPSTR usersid, BOOL dir)
291 WCHAR guidW[MAX_PATH];
292 WCHAR squashedW[MAX_PATH];
293 CHAR squashed[MAX_PATH];
294 CHAR comppath[MAX_PATH];
295 CHAR prodpath[MAX_PATH];
296 CHAR path[MAX_PATH];
297 LPCSTR prod = NULL;
298 HKEY hkey;
299 REGSAM access = KEY_ALL_ACCESS;
301 if (is_wow64)
302 access |= KEY_WOW64_64KEY;
304 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
305 squash_guid(guidW, squashedW);
306 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
308 if (context == MSIINSTALLCONTEXT_MACHINE)
310 prod = "3D0DAE300FACA1300AD792060BCDAA92";
311 sprintf(comppath,
312 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
313 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
314 lstrcpyA(prodpath,
315 "SOFTWARE\\Classes\\Installer\\"
316 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
318 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
320 prod = "7D2F387510109040002000060BECB6AB";
321 sprintf(comppath,
322 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
323 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
324 sprintf(prodpath,
325 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
326 "Installer\\%s\\Installer\\Products\\"
327 "7D2F387510109040002000060BECB6AB", usersid);
329 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
331 prod = "7D2F387510109040002000060BECB6AB";
332 sprintf(comppath,
333 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
334 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
335 sprintf(prodpath,
336 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
337 "Installer\\Managed\\%s\\Installer\\Products\\"
338 "7D2F387510109040002000060BECB6AB", usersid);
341 RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
343 lstrcpyA(path, CURR_DIR);
344 lstrcatA(path, "\\");
345 if (!dir) lstrcatA(path, filename);
347 RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
348 RegCloseKey(hkey);
350 RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
351 RegCloseKey(hkey);
354 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
356 WCHAR guidW[MAX_PATH];
357 WCHAR squashedW[MAX_PATH];
358 WCHAR substrW[MAX_PATH];
359 CHAR squashed[MAX_PATH];
360 CHAR comppath[MAX_PATH];
361 CHAR prodpath[MAX_PATH];
362 REGSAM access = KEY_ALL_ACCESS;
364 if (is_wow64)
365 access |= KEY_WOW64_64KEY;
367 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
368 squash_guid(guidW, squashedW);
369 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
371 if (context == MSIINSTALLCONTEXT_MACHINE)
373 sprintf(comppath,
374 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
375 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
376 lstrcpyA(prodpath,
377 "SOFTWARE\\Classes\\Installer\\"
378 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
380 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
382 sprintf(comppath,
383 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
384 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
385 sprintf(prodpath,
386 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
387 "Installer\\%s\\Installer\\Products\\"
388 "7D2F387510109040002000060BECB6AB", usersid);
390 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
392 sprintf(comppath,
393 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
394 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
395 sprintf(prodpath,
396 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
397 "Installer\\Managed\\%s\\Installer\\Products\\"
398 "7D2F387510109040002000060BECB6AB", usersid);
401 MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
402 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
404 MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
405 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
408 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
410 MSIHANDLE hview = 0;
411 UINT r, ret;
413 /* open a select query */
414 r = MsiDatabaseOpenViewA(hdb, query, &hview);
415 if (r != ERROR_SUCCESS)
416 return r;
417 r = MsiViewExecute(hview, 0);
418 if (r != ERROR_SUCCESS)
419 return r;
420 ret = MsiViewFetch(hview, phrec);
421 r = MsiViewClose(hview);
422 if (r != ERROR_SUCCESS)
423 return r;
424 r = MsiCloseHandle(hview);
425 if (r != ERROR_SUCCESS)
426 return r;
427 return ret;
430 static UINT run_query( MSIHANDLE hdb, const char *query )
432 MSIHANDLE hview = 0;
433 UINT r;
435 r = MsiDatabaseOpenViewA(hdb, query, &hview);
436 if( r != ERROR_SUCCESS )
437 return r;
439 r = MsiViewExecute(hview, 0);
440 if( r == ERROR_SUCCESS )
441 r = MsiViewClose(hview);
442 MsiCloseHandle(hview);
443 return r;
446 static UINT create_component_table( MSIHANDLE hdb )
448 return run_query( hdb,
449 "CREATE TABLE `Component` ( "
450 "`Component` CHAR(72) NOT NULL, "
451 "`ComponentId` CHAR(38), "
452 "`Directory_` CHAR(72) NOT NULL, "
453 "`Attributes` SHORT NOT NULL, "
454 "`Condition` CHAR(255), "
455 "`KeyPath` CHAR(72) "
456 "PRIMARY KEY `Component`)" );
459 static UINT create_feature_table( MSIHANDLE hdb )
461 return run_query( hdb,
462 "CREATE TABLE `Feature` ( "
463 "`Feature` CHAR(38) NOT NULL, "
464 "`Feature_Parent` CHAR(38), "
465 "`Title` CHAR(64), "
466 "`Description` CHAR(255), "
467 "`Display` SHORT NOT NULL, "
468 "`Level` SHORT NOT NULL, "
469 "`Directory_` CHAR(72), "
470 "`Attributes` SHORT NOT NULL "
471 "PRIMARY KEY `Feature`)" );
474 static UINT create_feature_components_table( MSIHANDLE hdb )
476 return run_query( hdb,
477 "CREATE TABLE `FeatureComponents` ( "
478 "`Feature_` CHAR(38) NOT NULL, "
479 "`Component_` CHAR(72) NOT NULL "
480 "PRIMARY KEY `Feature_`, `Component_` )" );
483 static UINT create_file_table( MSIHANDLE hdb )
485 return run_query( hdb,
486 "CREATE TABLE `File` ("
487 "`File` CHAR(72) NOT NULL, "
488 "`Component_` CHAR(72) NOT NULL, "
489 "`FileName` CHAR(255) NOT NULL, "
490 "`FileSize` LONG NOT NULL, "
491 "`Version` CHAR(72), "
492 "`Language` CHAR(20), "
493 "`Attributes` SHORT, "
494 "`Sequence` SHORT NOT NULL "
495 "PRIMARY KEY `File`)" );
498 static UINT create_remove_file_table( MSIHANDLE hdb )
500 return run_query( hdb,
501 "CREATE TABLE `RemoveFile` ("
502 "`FileKey` CHAR(72) NOT NULL, "
503 "`Component_` CHAR(72) NOT NULL, "
504 "`FileName` CHAR(255) LOCALIZABLE, "
505 "`DirProperty` CHAR(72) NOT NULL, "
506 "`InstallMode` SHORT NOT NULL "
507 "PRIMARY KEY `FileKey`)" );
510 static UINT create_appsearch_table( MSIHANDLE hdb )
512 return run_query( hdb,
513 "CREATE TABLE `AppSearch` ("
514 "`Property` CHAR(72) NOT NULL, "
515 "`Signature_` CHAR(72) NOT NULL "
516 "PRIMARY KEY `Property`, `Signature_`)" );
519 static UINT create_reglocator_table( MSIHANDLE hdb )
521 return run_query( hdb,
522 "CREATE TABLE `RegLocator` ("
523 "`Signature_` CHAR(72) NOT NULL, "
524 "`Root` SHORT NOT NULL, "
525 "`Key` CHAR(255) NOT NULL, "
526 "`Name` CHAR(255), "
527 "`Type` SHORT "
528 "PRIMARY KEY `Signature_`)" );
531 static UINT create_signature_table( MSIHANDLE hdb )
533 return run_query( hdb,
534 "CREATE TABLE `Signature` ("
535 "`Signature` CHAR(72) NOT NULL, "
536 "`FileName` CHAR(255) NOT NULL, "
537 "`MinVersion` CHAR(20), "
538 "`MaxVersion` CHAR(20), "
539 "`MinSize` LONG, "
540 "`MaxSize` LONG, "
541 "`MinDate` LONG, "
542 "`MaxDate` LONG, "
543 "`Languages` CHAR(255) "
544 "PRIMARY KEY `Signature`)" );
547 static UINT create_launchcondition_table( MSIHANDLE hdb )
549 return run_query( hdb,
550 "CREATE TABLE `LaunchCondition` ("
551 "`Condition` CHAR(255) NOT NULL, "
552 "`Description` CHAR(255) NOT NULL "
553 "PRIMARY KEY `Condition`)" );
556 static UINT create_property_table( MSIHANDLE hdb )
558 return run_query( hdb,
559 "CREATE TABLE `Property` ("
560 "`Property` CHAR(72) NOT NULL, "
561 "`Value` CHAR(0) "
562 "PRIMARY KEY `Property`)" );
565 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
567 return run_query( hdb,
568 "CREATE TABLE `InstallExecuteSequence` ("
569 "`Action` CHAR(72) NOT NULL, "
570 "`Condition` CHAR(255), "
571 "`Sequence` SHORT "
572 "PRIMARY KEY `Action`)" );
575 static UINT create_media_table( MSIHANDLE hdb )
577 return run_query( hdb,
578 "CREATE TABLE `Media` ("
579 "`DiskId` SHORT NOT NULL, "
580 "`LastSequence` SHORT NOT NULL, "
581 "`DiskPrompt` CHAR(64), "
582 "`Cabinet` CHAR(255), "
583 "`VolumeLabel` CHAR(32), "
584 "`Source` CHAR(72) "
585 "PRIMARY KEY `DiskId`)" );
588 static UINT create_ccpsearch_table( MSIHANDLE hdb )
590 return run_query( hdb,
591 "CREATE TABLE `CCPSearch` ("
592 "`Signature_` CHAR(72) NOT NULL "
593 "PRIMARY KEY `Signature_`)" );
596 static UINT create_drlocator_table( MSIHANDLE hdb )
598 return run_query( hdb,
599 "CREATE TABLE `DrLocator` ("
600 "`Signature_` CHAR(72) NOT NULL, "
601 "`Parent` CHAR(72), "
602 "`Path` CHAR(255), "
603 "`Depth` SHORT "
604 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
607 static UINT create_complocator_table( MSIHANDLE hdb )
609 return run_query( hdb,
610 "CREATE TABLE `CompLocator` ("
611 "`Signature_` CHAR(72) NOT NULL, "
612 "`ComponentId` CHAR(38) NOT NULL, "
613 "`Type` SHORT "
614 "PRIMARY KEY `Signature_`)" );
617 static UINT create_inilocator_table( MSIHANDLE hdb )
619 return run_query( hdb,
620 "CREATE TABLE `IniLocator` ("
621 "`Signature_` CHAR(72) NOT NULL, "
622 "`FileName` CHAR(255) NOT NULL, "
623 "`Section` CHAR(96)NOT NULL, "
624 "`Key` CHAR(128)NOT NULL, "
625 "`Field` SHORT, "
626 "`Type` SHORT "
627 "PRIMARY KEY `Signature_`)" );
630 static UINT create_custom_action_table( MSIHANDLE hdb )
632 return run_query( hdb,
633 "CREATE TABLE `CustomAction` ("
634 "`Action` CHAR(72) NOT NULL, "
635 "`Type` SHORT NOT NULL, "
636 "`Source` CHAR(75), "
637 "`Target` CHAR(255) "
638 "PRIMARY KEY `Action`)" );
641 static UINT create_dialog_table( MSIHANDLE hdb )
643 return run_query(hdb,
644 "CREATE TABLE `Dialog` ("
645 "`Dialog` CHAR(72) NOT NULL, "
646 "`HCentering` SHORT NOT NULL, "
647 "`VCentering` SHORT NOT NULL, "
648 "`Width` SHORT NOT NULL, "
649 "`Height` SHORT NOT NULL, "
650 "`Attributes` LONG, "
651 "`Title` CHAR(128) LOCALIZABLE, "
652 "`Control_First` CHAR(50) NOT NULL, "
653 "`Control_Default` CHAR(50), "
654 "`Control_Cancel` CHAR(50) "
655 "PRIMARY KEY `Dialog`)");
658 static UINT create_control_table( MSIHANDLE hdb )
660 return run_query(hdb,
661 "CREATE TABLE `Control` ("
662 "`Dialog_` CHAR(72) NOT NULL, "
663 "`Control` CHAR(50) NOT NULL, "
664 "`Type` CHAR(20) NOT NULL, "
665 "`X` SHORT NOT NULL, "
666 "`Y` SHORT NOT NULL, "
667 "`Width` SHORT NOT NULL, "
668 "`Height` SHORT NOT NULL, "
669 "`Attributes` LONG, "
670 "`Property` CHAR(50), "
671 "`Text` CHAR(0) LOCALIZABLE, "
672 "`Control_Next` CHAR(50), "
673 "`Help` CHAR(255) LOCALIZABLE "
674 "PRIMARY KEY `Dialog_`, `Control`)");
677 static UINT create_controlevent_table( MSIHANDLE hdb )
679 return run_query(hdb,
680 "CREATE TABLE `ControlEvent` ("
681 "`Dialog_` CHAR(72) NOT NULL, "
682 "`Control_` CHAR(50) NOT NULL, "
683 "`Event` CHAR(50) NOT NULL, "
684 "`Argument` CHAR(255) NOT NULL, "
685 "`Condition` CHAR(255), "
686 "`Ordering` SHORT "
687 "PRIMARY KEY `Dialog_`, `Control_`, `Event`, `Argument`, `Condition`)");
690 #define make_add_entry(type, qtext) \
691 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
693 char insert[] = qtext; \
694 char *query; \
695 UINT sz, r; \
696 sz = strlen(values) + sizeof insert; \
697 query = HeapAlloc(GetProcessHeap(),0,sz); \
698 sprintf(query,insert,values); \
699 r = run_query( hdb, query ); \
700 HeapFree(GetProcessHeap(), 0, query); \
701 return r; \
704 make_add_entry(component,
705 "INSERT INTO `Component` "
706 "(`Component`, `ComponentId`, `Directory_`, "
707 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
709 make_add_entry(directory,
710 "INSERT INTO `Directory` "
711 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
713 make_add_entry(feature,
714 "INSERT INTO `Feature` "
715 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
716 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
718 make_add_entry(feature_components,
719 "INSERT INTO `FeatureComponents` "
720 "(`Feature_`, `Component_`) VALUES( %s )")
722 make_add_entry(file,
723 "INSERT INTO `File` "
724 "(`File`, `Component_`, `FileName`, `FileSize`, "
725 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
727 make_add_entry(appsearch,
728 "INSERT INTO `AppSearch` "
729 "(`Property`, `Signature_`) VALUES( %s )")
731 make_add_entry(signature,
732 "INSERT INTO `Signature` "
733 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
734 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
735 "VALUES( %s )")
737 make_add_entry(launchcondition,
738 "INSERT INTO `LaunchCondition` "
739 "(`Condition`, `Description`) VALUES( %s )")
741 make_add_entry(property,
742 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
744 make_add_entry(install_execute_sequence,
745 "INSERT INTO `InstallExecuteSequence` "
746 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
748 make_add_entry(media,
749 "INSERT INTO `Media` "
750 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
751 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
753 make_add_entry(ccpsearch,
754 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
756 make_add_entry(drlocator,
757 "INSERT INTO `DrLocator` "
758 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
760 make_add_entry(complocator,
761 "INSERT INTO `CompLocator` "
762 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
764 make_add_entry(inilocator,
765 "INSERT INTO `IniLocator` "
766 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
767 "VALUES( %s )")
769 make_add_entry(custom_action,
770 "INSERT INTO `CustomAction` "
771 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
773 make_add_entry(dialog,
774 "INSERT INTO `Dialog` "
775 "(`Dialog`, `HCentering`, `VCentering`, `Width`, `Height`, `Attributes`, `Control_First`) VALUES ( %s )")
777 make_add_entry(control,
778 "INSERT INTO `Control` "
779 "(`Dialog_`, `Control`, `Type`, `X`, `Y`, `Width`, `Height`, `Attributes`, `Text`) VALUES( %s )");
781 make_add_entry(controlevent,
782 "INSERT INTO `ControlEvent` "
783 "(`Dialog_`, `Control_`, `Event`, `Argument`, `Condition`, `Ordering`) VALUES( %s )");
785 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
786 const char *name, UINT type )
788 const char insert[] =
789 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
790 "VALUES( '%s', %u, '%s', '%s', %u )";
791 char *query;
792 UINT sz, r;
794 sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
795 query = HeapAlloc( GetProcessHeap(), 0, sz );
796 sprintf( query, insert, sig, root, path, name, type );
797 r = run_query( hdb, query );
798 HeapFree( GetProcessHeap(), 0, query );
799 return r;
802 static UINT set_summary_info(MSIHANDLE hdb)
804 UINT res;
805 MSIHANDLE suminfo;
807 /* build summary info */
808 res = MsiGetSummaryInformationA(hdb, NULL, 7, &suminfo);
809 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
811 res = MsiSummaryInfoSetPropertyA(suminfo,2, VT_LPSTR, 0,NULL,
812 "Installation Database");
813 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
815 res = MsiSummaryInfoSetPropertyA(suminfo,3, VT_LPSTR, 0,NULL,
816 "Installation Database");
817 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
819 res = MsiSummaryInfoSetPropertyA(suminfo,4, VT_LPSTR, 0,NULL,
820 "Wine Hackers");
821 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
823 res = MsiSummaryInfoSetPropertyA(suminfo,7, VT_LPSTR, 0,NULL,
824 ";1033");
825 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
827 res = MsiSummaryInfoSetPropertyA(suminfo,9, VT_LPSTR, 0,NULL,
828 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
829 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
831 res = MsiSummaryInfoSetPropertyA(suminfo, 14, VT_I4, 100, NULL, NULL);
832 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
834 res = MsiSummaryInfoSetPropertyA(suminfo, 15, VT_I4, 0, NULL, NULL);
835 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
837 res = MsiSummaryInfoPersist(suminfo);
838 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
840 res = MsiCloseHandle( suminfo);
841 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
843 return res;
847 static MSIHANDLE create_package_db(void)
849 MSIHANDLE hdb = 0;
850 UINT res;
852 DeleteFileA(msifile);
854 /* create an empty database */
855 res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb );
856 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
857 if( res != ERROR_SUCCESS )
858 return hdb;
860 res = MsiDatabaseCommit( hdb );
861 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
863 res = set_summary_info(hdb);
864 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
866 res = run_query( hdb,
867 "CREATE TABLE `Directory` ( "
868 "`Directory` CHAR(255) NOT NULL, "
869 "`Directory_Parent` CHAR(255), "
870 "`DefaultDir` CHAR(255) NOT NULL "
871 "PRIMARY KEY `Directory`)" );
872 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
874 return hdb;
877 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
879 UINT res;
880 CHAR szPackage[12];
881 MSIHANDLE hPackage;
883 sprintf(szPackage, "#%u", hdb);
884 res = MsiOpenPackageA(szPackage, &hPackage);
885 if (res != ERROR_SUCCESS)
887 MsiCloseHandle(hdb);
888 return res;
891 res = MsiCloseHandle(hdb);
892 if (res != ERROR_SUCCESS)
894 MsiCloseHandle(hPackage);
895 return res;
898 *handle = hPackage;
899 return ERROR_SUCCESS;
902 static void create_file_data(LPCSTR name, LPCSTR data)
904 HANDLE file;
905 DWORD written;
907 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
908 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
909 if (file == INVALID_HANDLE_VALUE)
910 return;
912 WriteFile(file, data, strlen(data), &written, NULL);
913 WriteFile(file, "\n", strlen("\n"), &written, NULL);
915 CloseHandle(file);
918 static void create_test_file(const CHAR *name)
920 create_file_data(name, name);
923 typedef struct _tagVS_VERSIONINFO
925 WORD wLength;
926 WORD wValueLength;
927 WORD wType;
928 WCHAR szKey[1];
929 WORD wPadding1[1];
930 VS_FIXEDFILEINFO Value;
931 WORD wPadding2[1];
932 WORD wChildren[1];
933 } VS_VERSIONINFO;
935 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
936 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
938 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
940 VS_VERSIONINFO *pVerInfo;
941 VS_FIXEDFILEINFO *pFixedInfo;
942 LPBYTE buffer, ofs;
943 CHAR path[MAX_PATH];
944 DWORD handle, size;
945 HANDLE resource;
946 BOOL ret = FALSE;
948 GetSystemDirectoryA(path, MAX_PATH);
949 /* Some dlls can't be updated on Vista/W2K8 */
950 lstrcatA(path, "\\version.dll");
952 CopyFileA(path, name, FALSE);
954 size = GetFileVersionInfoSizeA(path, &handle);
955 buffer = HeapAlloc(GetProcessHeap(), 0, size);
957 GetFileVersionInfoA(path, 0, size, buffer);
959 pVerInfo = (VS_VERSIONINFO *)buffer;
960 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
961 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
963 pFixedInfo->dwFileVersionMS = ms;
964 pFixedInfo->dwFileVersionLS = ls;
965 pFixedInfo->dwProductVersionMS = ms;
966 pFixedInfo->dwProductVersionLS = ls;
968 resource = BeginUpdateResourceA(name, FALSE);
969 if (!resource)
970 goto done;
972 if (!UpdateResourceA(resource, (LPCSTR)RT_VERSION, (LPCSTR)MAKEINTRESOURCE(VS_VERSION_INFO),
973 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
974 goto done;
976 if (!EndUpdateResourceA(resource, FALSE))
977 goto done;
979 ret = TRUE;
981 done:
982 HeapFree(GetProcessHeap(), 0, buffer);
983 return ret;
986 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
988 RESTOREPOINTINFOA spec;
990 spec.dwEventType = event_type;
991 spec.dwRestorePtType = APPLICATION_INSTALL;
992 spec.llSequenceNumber = status->llSequenceNumber;
993 lstrcpyA(spec.szDescription, "msitest restore point");
995 return pSRSetRestorePointA(&spec, status);
998 static void remove_restore_point(DWORD seq_number)
1000 DWORD res;
1002 res = pSRRemoveRestorePoint(seq_number);
1003 if (res != ERROR_SUCCESS)
1004 trace("Failed to remove the restore point : %08x\n", res);
1007 static BOOL is_root(const char *path)
1009 return (isalpha(path[0]) && path[1] == ':' && path[2] == '\\' && !path[3]);
1012 static void test_createpackage(void)
1014 MSIHANDLE hPackage = 0;
1015 UINT res;
1017 res = package_from_db(create_package_db(), &hPackage);
1018 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
1020 skip("Not enough rights to perform tests\n");
1021 DeleteFileA(msifile);
1022 return;
1024 ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
1026 res = MsiCloseHandle( hPackage);
1027 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
1028 DeleteFileA(msifile);
1031 static void test_doaction( void )
1033 MSIHANDLE hpkg;
1034 UINT r;
1036 r = MsiDoActionA( -1, NULL );
1037 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1039 r = package_from_db(create_package_db(), &hpkg);
1040 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1042 skip("Not enough rights to perform tests\n");
1043 DeleteFileA(msifile);
1044 return;
1046 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1048 r = MsiDoActionA(hpkg, NULL);
1049 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1051 r = MsiDoActionA(0, "boo");
1052 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1054 r = MsiDoActionA(hpkg, "boo");
1055 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
1057 MsiCloseHandle( hpkg );
1058 DeleteFileA(msifile);
1061 static void test_gettargetpath_bad(void)
1063 static const WCHAR boo[] = {'b','o','o',0};
1064 static const WCHAR empty[] = {0};
1065 char buffer[0x80];
1066 WCHAR bufferW[0x80];
1067 MSIHANDLE hpkg;
1068 DWORD sz;
1069 UINT r;
1071 r = package_from_db(create_package_db(), &hpkg);
1072 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1074 skip("Not enough rights to perform tests\n");
1075 DeleteFileA(msifile);
1076 return;
1078 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1080 r = MsiGetTargetPathA( 0, NULL, NULL, NULL );
1081 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1083 r = MsiGetTargetPathA( 0, NULL, NULL, &sz );
1084 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1086 r = MsiGetTargetPathA( 0, "boo", NULL, NULL );
1087 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1089 r = MsiGetTargetPathA( 0, "boo", NULL, NULL );
1090 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1092 r = MsiGetTargetPathA( hpkg, "boo", NULL, NULL );
1093 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1095 r = MsiGetTargetPathA( hpkg, "boo", buffer, NULL );
1096 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1098 sz = 0;
1099 r = MsiGetTargetPathA( hpkg, "", buffer, &sz );
1100 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1102 r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
1103 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1105 r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
1106 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1108 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1109 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1111 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1112 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1114 r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
1115 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1117 r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
1118 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1120 sz = 0;
1121 r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
1122 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1124 MsiCloseHandle( hpkg );
1125 DeleteFileA(msifile);
1128 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1130 UINT r;
1131 DWORD size;
1132 MSIHANDLE rec;
1134 rec = MsiCreateRecord( 1 );
1135 ok(rec, "MsiCreate record failed\n");
1137 r = MsiRecordSetStringA( rec, 0, file );
1138 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1140 size = MAX_PATH;
1141 r = MsiFormatRecordA( hpkg, rec, buff, &size );
1142 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1144 MsiCloseHandle( rec );
1147 static void test_settargetpath(void)
1149 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1150 DWORD sz;
1151 MSIHANDLE hpkg;
1152 UINT r;
1153 MSIHANDLE hdb;
1155 hdb = create_package_db();
1156 ok ( hdb, "failed to create package database\n" );
1158 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1159 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1161 r = create_component_table( hdb );
1162 ok( r == S_OK, "cannot create Component table: %d\n", r );
1164 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1165 ok( r == S_OK, "cannot add dummy component: %d\n", r );
1167 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1168 ok( r == S_OK, "cannot add test component: %d\n", r );
1170 r = create_feature_table( hdb );
1171 ok( r == S_OK, "cannot create Feature table: %d\n", r );
1173 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1174 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1176 r = create_feature_components_table( hdb );
1177 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1179 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1180 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1182 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1183 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1185 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1186 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1188 r = create_file_table( hdb );
1189 ok( r == S_OK, "cannot create File table: %d\n", r );
1191 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1192 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1194 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1195 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1197 r = package_from_db( hdb, &hpkg );
1198 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1200 skip("Not enough rights to perform tests\n");
1201 DeleteFileA(msifile);
1202 return;
1204 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1206 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1208 r = MsiDoActionA( hpkg, "CostInitialize");
1209 ok( r == ERROR_SUCCESS, "cost init failed\n");
1211 r = MsiDoActionA( hpkg, "FileCost");
1212 ok( r == ERROR_SUCCESS, "file cost failed\n");
1214 r = MsiDoActionA( hpkg, "CostFinalize");
1215 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1217 buffer[0] = 0;
1218 sz = sizeof(buffer);
1219 r = MsiGetPropertyA( hpkg, "OutOfNoRbDiskSpace", buffer, &sz );
1220 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1221 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer );
1223 r = MsiSetTargetPathA( 0, NULL, NULL );
1224 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1226 r = MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1227 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1229 r = MsiSetTargetPathA( hpkg, "boo", NULL );
1230 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1232 r = MsiSetTargetPathA( hpkg, "boo", "c:\\bogusx" );
1233 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1235 sz = sizeof tempdir - 1;
1236 r = MsiGetTargetPathA( hpkg, "TARGETDIR", tempdir, &sz );
1237 sprintf( file, "%srootfile.txt", tempdir );
1238 buffer[0] = 0;
1239 query_file_path( hpkg, "[#RootFile]", buffer );
1240 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1241 ok( !lstrcmpA(buffer, file), "Expected %s, got %s\n", file, buffer );
1243 GetTempFileNameA( tempdir, "_wt", 0, buffer );
1244 sprintf( tempdir, "%s\\subdir", buffer );
1246 r = MsiSetTargetPathA( hpkg, "TARGETDIR", buffer );
1247 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1248 "MsiSetTargetPath on file returned %d\n", r );
1250 r = MsiSetTargetPathA( hpkg, "TARGETDIR", tempdir );
1251 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1252 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1254 DeleteFileA( buffer );
1256 r = MsiSetTargetPathA( hpkg, "TARGETDIR", buffer );
1257 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1259 r = GetFileAttributesA( buffer );
1260 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1262 r = MsiSetTargetPathA( hpkg, "TARGETDIR", tempdir );
1263 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1265 buffer[0] = 0;
1266 sz = sizeof buffer - 1;
1267 lstrcatA( tempdir, "\\" );
1268 r = MsiGetTargetPathA( hpkg, "TARGETDIR", buffer, &sz );
1269 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1270 ok( !lstrcmpA(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1272 sprintf( file, "%srootfile.txt", tempdir );
1273 query_file_path( hpkg, "[#RootFile]", buffer );
1274 ok( !lstrcmpA(buffer, file), "Expected %s, got %s\n", file, buffer);
1276 buffer[0] = 0;
1277 sz = sizeof(buffer);
1278 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1279 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1280 lstrcatA( tempdir, "TestParent\\" );
1281 ok( !lstrcmpiA(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1283 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\one\\two" );
1284 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1286 buffer[0] = 0;
1287 sz = sizeof(buffer);
1288 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1289 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1290 ok( lstrcmpiA(buffer, "C:\\one\\two\\TestDir\\"),
1291 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1293 buffer[0] = 0;
1294 query_file_path( hpkg, "[#TestFile]", buffer );
1295 ok( !lstrcmpiA(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1296 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1298 buffer[0] = 0;
1299 sz = sizeof buffer - 1;
1300 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1301 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1302 ok( !lstrcmpiA(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1304 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\one\\two\\three" );
1305 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1307 buffer[0] = 0;
1308 sz = sizeof buffer - 1;
1309 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1310 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1311 ok( !lstrcmpiA(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1313 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\\\one\\\\two " );
1314 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1316 buffer[0] = 0;
1317 sz = sizeof buffer - 1;
1318 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1319 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1320 ok( !lstrcmpiA(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1322 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\\\ Program Files \\\\ " );
1323 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1325 buffer[0] = 0;
1326 sz = sizeof buffer - 1;
1327 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1328 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1329 ok( !lstrcmpiA(buffer, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer);
1331 MsiCloseHandle( hpkg );
1334 static void test_condition(void)
1336 static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1337 static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1338 static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1339 static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1340 MSICONDITION r;
1341 MSIHANDLE hpkg;
1343 r = package_from_db(create_package_db(), &hpkg);
1344 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1346 skip("Not enough rights to perform tests\n");
1347 DeleteFileA(msifile);
1348 return;
1350 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1352 r = MsiEvaluateConditionA(0, NULL);
1353 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1355 r = MsiEvaluateConditionA(hpkg, NULL);
1356 ok( r == MSICONDITION_NONE, "wrong return val\n");
1358 r = MsiEvaluateConditionA(hpkg, "");
1359 ok( r == MSICONDITION_NONE, "wrong return val\n");
1361 r = MsiEvaluateConditionA(hpkg, "1");
1362 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1364 r = MsiEvaluateConditionA(hpkg, "0");
1365 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1367 r = MsiEvaluateConditionA(hpkg, "-1");
1368 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1370 r = MsiEvaluateConditionA(hpkg, "0 = 0");
1371 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1373 r = MsiEvaluateConditionA(hpkg, "0 <> 0");
1374 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1376 r = MsiEvaluateConditionA(hpkg, "0 = 1");
1377 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1379 r = MsiEvaluateConditionA(hpkg, "0 > 1");
1380 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1382 r = MsiEvaluateConditionA(hpkg, "0 ~> 1");
1383 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1385 r = MsiEvaluateConditionA(hpkg, "1 > 1");
1386 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1388 r = MsiEvaluateConditionA(hpkg, "1 ~> 1");
1389 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1391 r = MsiEvaluateConditionA(hpkg, "0 >= 1");
1392 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1394 r = MsiEvaluateConditionA(hpkg, "0 ~>= 1");
1395 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1397 r = MsiEvaluateConditionA(hpkg, "1 >= 1");
1398 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1400 r = MsiEvaluateConditionA(hpkg, "1 ~>= 1");
1401 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1403 r = MsiEvaluateConditionA(hpkg, "0 < 1");
1404 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1406 r = MsiEvaluateConditionA(hpkg, "0 ~< 1");
1407 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1409 r = MsiEvaluateConditionA(hpkg, "1 < 1");
1410 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1412 r = MsiEvaluateConditionA(hpkg, "1 ~< 1");
1413 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1415 r = MsiEvaluateConditionA(hpkg, "0 <= 1");
1416 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1418 r = MsiEvaluateConditionA(hpkg, "0 ~<= 1");
1419 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1421 r = MsiEvaluateConditionA(hpkg, "1 <= 1");
1422 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1424 r = MsiEvaluateConditionA(hpkg, "1 ~<= 1");
1425 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1427 r = MsiEvaluateConditionA(hpkg, "0 >=");
1428 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1430 r = MsiEvaluateConditionA(hpkg, " ");
1431 ok( r == MSICONDITION_NONE, "wrong return val\n");
1433 r = MsiEvaluateConditionA(hpkg, "LicView <> \"1\"");
1434 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1436 r = MsiEvaluateConditionA(hpkg, "LicView <> \"0\"");
1437 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1439 r = MsiEvaluateConditionA(hpkg, "LicView <> LicView");
1440 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1442 r = MsiEvaluateConditionA(hpkg, "not 0");
1443 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1445 r = MsiEvaluateConditionA(hpkg, "not LicView");
1446 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1448 r = MsiEvaluateConditionA(hpkg, "\"Testing\" ~<< \"Testing\"");
1449 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1451 r = MsiEvaluateConditionA(hpkg, "LicView ~<< \"Testing\"");
1452 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1454 r = MsiEvaluateConditionA(hpkg, "Not LicView ~<< \"Testing\"");
1455 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1457 r = MsiEvaluateConditionA(hpkg, "not \"A\"");
1458 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1460 r = MsiEvaluateConditionA(hpkg, "~not \"A\"");
1461 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1463 r = MsiEvaluateConditionA(hpkg, "\"0\"");
1464 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1466 r = MsiEvaluateConditionA(hpkg, "1 and 2");
1467 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1469 r = MsiEvaluateConditionA(hpkg, "not 0 and 3");
1470 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1472 r = MsiEvaluateConditionA(hpkg, "not 0 and 0");
1473 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1475 r = MsiEvaluateConditionA(hpkg, "not 0 or 1");
1476 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1478 r = MsiEvaluateConditionA(hpkg, "(0)");
1479 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1481 r = MsiEvaluateConditionA(hpkg, "(((((1))))))");
1482 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1484 r = MsiEvaluateConditionA(hpkg, "(((((1)))))");
1485 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1487 r = MsiEvaluateConditionA(hpkg, " \"A\" < \"B\" ");
1488 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1490 r = MsiEvaluateConditionA(hpkg, " \"A\" > \"B\" ");
1491 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1493 r = MsiEvaluateConditionA(hpkg, " \"1\" > \"12\" ");
1494 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1496 r = MsiEvaluateConditionA(hpkg, " \"100\" < \"21\" ");
1497 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1499 r = MsiEvaluateConditionA(hpkg, "0 < > 0");
1500 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1502 r = MsiEvaluateConditionA(hpkg, "(1<<1) == 2");
1503 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1505 r = MsiEvaluateConditionA(hpkg, " \"A\" = \"a\" ");
1506 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1508 r = MsiEvaluateConditionA(hpkg, " \"A\" ~ = \"a\" ");
1509 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1511 r = MsiEvaluateConditionA(hpkg, " \"A\" ~= \"a\" ");
1512 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1514 r = MsiEvaluateConditionA(hpkg, " \"A\" ~= 1 ");
1515 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1517 r = MsiEvaluateConditionA(hpkg, " \"A\" = 1 ");
1518 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1520 r = MsiEvaluateConditionA(hpkg, " 1 ~= 1 ");
1521 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1523 r = MsiEvaluateConditionA(hpkg, " 1 ~= \"1\" ");
1524 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1526 r = MsiEvaluateConditionA(hpkg, " 1 = \"1\" ");
1527 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1529 r = MsiEvaluateConditionA(hpkg, " 0 = \"1\" ");
1530 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1532 r = MsiEvaluateConditionA(hpkg, " 0 < \"100\" ");
1533 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1535 r = MsiEvaluateConditionA(hpkg, " 100 > \"0\" ");
1536 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1538 r = MsiEvaluateConditionA(hpkg, "1 XOR 1");
1539 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1541 r = MsiEvaluateConditionA(hpkg, "1 IMP 1");
1542 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1544 r = MsiEvaluateConditionA(hpkg, "1 IMP 0");
1545 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1547 r = MsiEvaluateConditionA(hpkg, "0 IMP 0");
1548 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1550 r = MsiEvaluateConditionA(hpkg, "0 EQV 0");
1551 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1553 r = MsiEvaluateConditionA(hpkg, "0 EQV 1");
1554 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1556 r = MsiEvaluateConditionA(hpkg, "1 IMP 1 OR 0");
1557 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1559 r = MsiEvaluateConditionA(hpkg, "1 IMPL 1");
1560 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1562 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" >< \"S\" ");
1563 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1565 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"s\" ");
1566 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1568 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"\" ");
1569 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1571 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"sss\" ");
1572 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1574 MsiSetPropertyA(hpkg, "mm", "5" );
1576 r = MsiEvaluateConditionA(hpkg, "mm = 5");
1577 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1579 r = MsiEvaluateConditionA(hpkg, "mm < 6");
1580 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1582 r = MsiEvaluateConditionA(hpkg, "mm <= 5");
1583 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1585 r = MsiEvaluateConditionA(hpkg, "mm > 4");
1586 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1588 r = MsiEvaluateConditionA(hpkg, "mm < 12");
1589 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1591 r = MsiEvaluateConditionA(hpkg, "mm = \"5\"");
1592 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1594 r = MsiEvaluateConditionA(hpkg, "0 = \"\"");
1595 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1597 r = MsiEvaluateConditionA(hpkg, "0 AND \"\"");
1598 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1600 r = MsiEvaluateConditionA(hpkg, "1 AND \"\"");
1601 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1603 r = MsiEvaluateConditionA(hpkg, "1 AND \"1\"");
1604 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1606 r = MsiEvaluateConditionA(hpkg, "3 >< 1");
1607 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1609 r = MsiEvaluateConditionA(hpkg, "3 >< 4");
1610 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1612 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 0");
1613 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1615 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 1");
1616 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1618 r = MsiEvaluateConditionA(hpkg, "NOT 1 OR 0");
1619 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1621 r = MsiEvaluateConditionA(hpkg, "0 AND 1 OR 1");
1622 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1624 r = MsiEvaluateConditionA(hpkg, "0 AND 0 OR 1");
1625 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1627 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 1 OR 0");
1628 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1630 r = MsiEvaluateConditionA(hpkg, "_1 = _1");
1631 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1633 r = MsiEvaluateConditionA(hpkg, "( 1 AND 1 ) = 2");
1634 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1636 r = MsiEvaluateConditionA(hpkg, "NOT ( 1 AND 1 )");
1637 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1639 r = MsiEvaluateConditionA(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1640 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1642 r = MsiEvaluateConditionA(hpkg, "Installed<>\"\"");
1643 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1645 r = MsiEvaluateConditionA(hpkg, "NOT 1 AND 0");
1646 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1648 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1649 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1651 r = MsiEvaluateConditionA(hpkg, "bandalmael<>0");
1652 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1654 r = MsiEvaluateConditionA(hpkg, "bandalmael<0");
1655 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1657 r = MsiEvaluateConditionA(hpkg, "bandalmael>0");
1658 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1660 r = MsiEvaluateConditionA(hpkg, "bandalmael>=0");
1661 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1663 r = MsiEvaluateConditionA(hpkg, "bandalmael<=0");
1664 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1666 r = MsiEvaluateConditionA(hpkg, "bandalmael~<>0");
1667 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1669 MsiSetPropertyA(hpkg, "bandalmael", "0" );
1670 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1671 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1673 MsiSetPropertyA(hpkg, "bandalmael", "" );
1674 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1675 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1677 MsiSetPropertyA(hpkg, "bandalmael", "asdf" );
1678 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1679 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1681 MsiSetPropertyA(hpkg, "bandalmael", "0asdf" );
1682 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1683 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1685 MsiSetPropertyA(hpkg, "bandalmael", "0 " );
1686 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1687 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1689 MsiSetPropertyA(hpkg, "bandalmael", "-0" );
1690 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1691 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1693 MsiSetPropertyA(hpkg, "bandalmael", "0000000000000" );
1694 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1695 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1697 MsiSetPropertyA(hpkg, "bandalmael", "--0" );
1698 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1699 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1701 MsiSetPropertyA(hpkg, "bandalmael", "0x00" );
1702 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1703 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1705 MsiSetPropertyA(hpkg, "bandalmael", "-" );
1706 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1707 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1709 MsiSetPropertyA(hpkg, "bandalmael", "+0" );
1710 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1711 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1713 MsiSetPropertyA(hpkg, "bandalmael", "0.0" );
1714 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1715 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1716 r = MsiEvaluateConditionA(hpkg, "bandalmael<>0");
1717 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1719 MsiSetPropertyA(hpkg, "one", "hi");
1720 MsiSetPropertyA(hpkg, "two", "hithere");
1721 r = MsiEvaluateConditionA(hpkg, "one >< two");
1722 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1724 MsiSetPropertyA(hpkg, "one", "hithere");
1725 MsiSetPropertyA(hpkg, "two", "hi");
1726 r = MsiEvaluateConditionA(hpkg, "one >< two");
1727 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1729 MsiSetPropertyA(hpkg, "one", "hello");
1730 MsiSetPropertyA(hpkg, "two", "hi");
1731 r = MsiEvaluateConditionA(hpkg, "one >< two");
1732 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1734 MsiSetPropertyA(hpkg, "one", "hellohithere");
1735 MsiSetPropertyA(hpkg, "two", "hi");
1736 r = MsiEvaluateConditionA(hpkg, "one >< two");
1737 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1739 MsiSetPropertyA(hpkg, "one", "");
1740 MsiSetPropertyA(hpkg, "two", "hi");
1741 r = MsiEvaluateConditionA(hpkg, "one >< two");
1742 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1744 MsiSetPropertyA(hpkg, "one", "hi");
1745 MsiSetPropertyA(hpkg, "two", "");
1746 r = MsiEvaluateConditionA(hpkg, "one >< two");
1747 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1749 MsiSetPropertyA(hpkg, "one", "");
1750 MsiSetPropertyA(hpkg, "two", "");
1751 r = MsiEvaluateConditionA(hpkg, "one >< two");
1752 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1754 MsiSetPropertyA(hpkg, "one", "1234");
1755 MsiSetPropertyA(hpkg, "two", "1");
1756 r = MsiEvaluateConditionA(hpkg, "one >< two");
1757 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1759 MsiSetPropertyA(hpkg, "one", "one 1234");
1760 MsiSetPropertyA(hpkg, "two", "1");
1761 r = MsiEvaluateConditionA(hpkg, "one >< two");
1762 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1764 MsiSetPropertyA(hpkg, "one", "hithere");
1765 MsiSetPropertyA(hpkg, "two", "hi");
1766 r = MsiEvaluateConditionA(hpkg, "one << two");
1767 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1769 MsiSetPropertyA(hpkg, "one", "hi");
1770 MsiSetPropertyA(hpkg, "two", "hithere");
1771 r = MsiEvaluateConditionA(hpkg, "one << two");
1772 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1774 MsiSetPropertyA(hpkg, "one", "hi");
1775 MsiSetPropertyA(hpkg, "two", "hi");
1776 r = MsiEvaluateConditionA(hpkg, "one << two");
1777 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1779 MsiSetPropertyA(hpkg, "one", "abcdhithere");
1780 MsiSetPropertyA(hpkg, "two", "hi");
1781 r = MsiEvaluateConditionA(hpkg, "one << two");
1782 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1784 MsiSetPropertyA(hpkg, "one", "");
1785 MsiSetPropertyA(hpkg, "two", "hi");
1786 r = MsiEvaluateConditionA(hpkg, "one << two");
1787 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1789 MsiSetPropertyA(hpkg, "one", "hithere");
1790 MsiSetPropertyA(hpkg, "two", "");
1791 r = MsiEvaluateConditionA(hpkg, "one << two");
1792 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1794 MsiSetPropertyA(hpkg, "one", "");
1795 MsiSetPropertyA(hpkg, "two", "");
1796 r = MsiEvaluateConditionA(hpkg, "one << two");
1797 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1799 MsiSetPropertyA(hpkg, "one", "1234");
1800 MsiSetPropertyA(hpkg, "two", "1");
1801 r = MsiEvaluateConditionA(hpkg, "one << two");
1802 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1804 MsiSetPropertyA(hpkg, "one", "1234 one");
1805 MsiSetPropertyA(hpkg, "two", "1");
1806 r = MsiEvaluateConditionA(hpkg, "one << two");
1807 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1809 MsiSetPropertyA(hpkg, "one", "hithere");
1810 MsiSetPropertyA(hpkg, "two", "there");
1811 r = MsiEvaluateConditionA(hpkg, "one >> two");
1812 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1814 MsiSetPropertyA(hpkg, "one", "hithere");
1815 MsiSetPropertyA(hpkg, "two", "hi");
1816 r = MsiEvaluateConditionA(hpkg, "one >> two");
1817 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1819 MsiSetPropertyA(hpkg, "one", "there");
1820 MsiSetPropertyA(hpkg, "two", "hithere");
1821 r = MsiEvaluateConditionA(hpkg, "one >> two");
1822 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1824 MsiSetPropertyA(hpkg, "one", "there");
1825 MsiSetPropertyA(hpkg, "two", "there");
1826 r = MsiEvaluateConditionA(hpkg, "one >> two");
1827 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1829 MsiSetPropertyA(hpkg, "one", "abcdhithere");
1830 MsiSetPropertyA(hpkg, "two", "hi");
1831 r = MsiEvaluateConditionA(hpkg, "one >> two");
1832 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1834 MsiSetPropertyA(hpkg, "one", "");
1835 MsiSetPropertyA(hpkg, "two", "there");
1836 r = MsiEvaluateConditionA(hpkg, "one >> two");
1837 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1839 MsiSetPropertyA(hpkg, "one", "there");
1840 MsiSetPropertyA(hpkg, "two", "");
1841 r = MsiEvaluateConditionA(hpkg, "one >> two");
1842 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1844 MsiSetPropertyA(hpkg, "one", "");
1845 MsiSetPropertyA(hpkg, "two", "");
1846 r = MsiEvaluateConditionA(hpkg, "one >> two");
1847 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1849 MsiSetPropertyA(hpkg, "one", "1234");
1850 MsiSetPropertyA(hpkg, "two", "4");
1851 r = MsiEvaluateConditionA(hpkg, "one >> two");
1852 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1854 MsiSetPropertyA(hpkg, "one", "one 1234");
1855 MsiSetPropertyA(hpkg, "two", "4");
1856 r = MsiEvaluateConditionA(hpkg, "one >> two");
1857 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1859 MsiSetPropertyA(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1861 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1862 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1864 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1865 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1867 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1868 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1870 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1871 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1873 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1874 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1876 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1877 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1879 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1880 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1882 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1883 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1885 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1886 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1888 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1889 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1891 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1892 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1894 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1895 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1897 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"1.1");
1898 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1900 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"1.1\"");
1901 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1903 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"12.1\"");
1904 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1906 r = MsiEvaluateConditionA(hpkg, "\"02.1\" < \"2.11\"");
1907 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1909 r = MsiEvaluateConditionA(hpkg, "\"02.1.1\" < \"2.1\"");
1910 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1912 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1913 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1915 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1\"");
1916 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1918 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"0\"");
1919 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1921 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"-1\"");
1922 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1924 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a\"");
1925 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1927 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"!\"");
1928 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1930 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"!\"");
1931 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1933 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"/\"");
1934 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1936 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \" \"");
1937 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1939 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1940 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1942 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1943 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1945 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1946 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1948 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1949 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1951 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1952 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1954 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1955 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1957 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"{a\"");
1958 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1960 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a\"");
1961 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1963 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a{\"");
1964 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1966 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a]\"");
1967 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1969 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"A\"");
1970 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1972 MsiSetPropertyA(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1973 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1974 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1976 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1977 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1979 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1980 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1982 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1983 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1985 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1\"");
1986 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1988 MsiSetPropertyA(hpkg, "one", "1");
1989 r = MsiEvaluateConditionA(hpkg, "one < \"1\"");
1990 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1992 MsiSetPropertyA(hpkg, "X", "5.0");
1994 r = MsiEvaluateConditionA(hpkg, "X != \"\"");
1995 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1997 r = MsiEvaluateConditionA(hpkg, "X =\"5.0\"");
1998 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2000 r = MsiEvaluateConditionA(hpkg, "X =\"5.1\"");
2001 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2003 r = MsiEvaluateConditionA(hpkg, "X =\"6.0\"");
2004 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2006 r = MsiEvaluateConditionA(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
2007 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2009 r = MsiEvaluateConditionA(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2010 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2012 r = MsiEvaluateConditionA(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
2013 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
2015 /* feature doesn't exist */
2016 r = MsiEvaluateConditionA(hpkg, "&nofeature");
2017 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2019 MsiSetPropertyA(hpkg, "A", "2");
2020 MsiSetPropertyA(hpkg, "X", "50");
2022 r = MsiEvaluateConditionA(hpkg, "2 <= X");
2023 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2025 r = MsiEvaluateConditionA(hpkg, "A <= X");
2026 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2028 r = MsiEvaluateConditionA(hpkg, "A <= 50");
2029 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2031 MsiSetPropertyA(hpkg, "X", "50val");
2033 r = MsiEvaluateConditionA(hpkg, "2 <= X");
2034 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2036 r = MsiEvaluateConditionA(hpkg, "A <= X");
2037 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2039 MsiSetPropertyA(hpkg, "A", "7");
2040 MsiSetPropertyA(hpkg, "X", "50");
2042 r = MsiEvaluateConditionA(hpkg, "7 <= X");
2043 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2045 r = MsiEvaluateConditionA(hpkg, "A <= X");
2046 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2048 r = MsiEvaluateConditionA(hpkg, "A <= 50");
2049 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
2051 MsiSetPropertyA(hpkg, "X", "50val");
2053 r = MsiEvaluateConditionA(hpkg, "2 <= X");
2054 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2056 r = MsiEvaluateConditionA(hpkg, "A <= X");
2057 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
2059 r = MsiEvaluateConditionW(hpkg, cond1);
2060 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
2061 "wrong return val (%d)\n", r);
2063 r = MsiEvaluateConditionW(hpkg, cond2);
2064 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
2065 "wrong return val (%d)\n", r);
2067 r = MsiEvaluateConditionW(hpkg, cond3);
2068 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
2069 "wrong return val (%d)\n", r);
2071 r = MsiEvaluateConditionW(hpkg, cond4);
2072 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
2073 "wrong return val (%d)\n", r);
2075 MsiCloseHandle( hpkg );
2076 DeleteFileA(msifile);
2079 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
2081 UINT r;
2082 DWORD sz;
2083 char buffer[2];
2085 sz = sizeof buffer;
2086 strcpy(buffer,"x");
2087 r = MsiGetPropertyA( hpkg, prop, buffer, &sz );
2088 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
2091 static void test_props(void)
2093 MSIHANDLE hpkg, hdb;
2094 UINT r;
2095 DWORD sz;
2096 char buffer[0x100];
2098 hdb = create_package_db();
2099 r = run_query( hdb,
2100 "CREATE TABLE `Property` ( "
2101 "`Property` CHAR(255) NOT NULL, "
2102 "`Value` CHAR(255) "
2103 "PRIMARY KEY `Property`)" );
2104 ok( r == ERROR_SUCCESS , "Failed\n" );
2106 r = run_query(hdb,
2107 "INSERT INTO `Property` "
2108 "(`Property`, `Value`) "
2109 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
2110 ok( r == ERROR_SUCCESS , "Failed\n" );
2112 r = package_from_db( hdb, &hpkg );
2113 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2115 skip("Not enough rights to perform tests\n");
2116 DeleteFileA(msifile);
2117 return;
2119 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2121 /* test invalid values */
2122 r = MsiGetPropertyA( 0, NULL, NULL, NULL );
2123 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2125 r = MsiGetPropertyA( hpkg, NULL, NULL, NULL );
2126 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2128 r = MsiGetPropertyA( hpkg, "boo", NULL, NULL );
2129 ok( r == ERROR_SUCCESS, "wrong return val\n");
2131 r = MsiGetPropertyA( hpkg, "boo", buffer, NULL );
2132 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2134 /* test retrieving an empty/nonexistent property */
2135 sz = sizeof buffer;
2136 r = MsiGetPropertyA( hpkg, "boo", NULL, &sz );
2137 ok( r == ERROR_SUCCESS, "wrong return val\n");
2138 ok( sz == 0, "wrong size returned\n");
2140 check_prop_empty( hpkg, "boo");
2141 sz = 0;
2142 strcpy(buffer,"x");
2143 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2144 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2145 ok( !strcmp(buffer,"x"), "buffer was changed\n");
2146 ok( sz == 0, "wrong size returned\n");
2148 sz = 1;
2149 strcpy(buffer,"x");
2150 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2151 ok( r == ERROR_SUCCESS, "wrong return val\n");
2152 ok( buffer[0] == 0, "buffer was not changed\n");
2153 ok( sz == 0, "wrong size returned\n");
2155 /* set the property to something */
2156 r = MsiSetPropertyA( 0, NULL, NULL );
2157 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
2159 r = MsiSetPropertyA( hpkg, NULL, NULL );
2160 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2162 r = MsiSetPropertyA( hpkg, "", NULL );
2163 ok( r == ERROR_SUCCESS, "wrong return val\n");
2165 /* try set and get some illegal property identifiers */
2166 r = MsiSetPropertyA( hpkg, "", "asdf" );
2167 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2169 r = MsiSetPropertyA( hpkg, "=", "asdf" );
2170 ok( r == ERROR_SUCCESS, "wrong return val\n");
2172 r = MsiSetPropertyA( hpkg, " ", "asdf" );
2173 ok( r == ERROR_SUCCESS, "wrong return val\n");
2175 r = MsiSetPropertyA( hpkg, "'", "asdf" );
2176 ok( r == ERROR_SUCCESS, "wrong return val\n");
2178 sz = sizeof buffer;
2179 buffer[0]=0;
2180 r = MsiGetPropertyA( hpkg, "'", buffer, &sz );
2181 ok( r == ERROR_SUCCESS, "wrong return val\n");
2182 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2184 /* set empty values */
2185 r = MsiSetPropertyA( hpkg, "boo", NULL );
2186 ok( r == ERROR_SUCCESS, "wrong return val\n");
2187 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2189 r = MsiSetPropertyA( hpkg, "boo", "" );
2190 ok( r == ERROR_SUCCESS, "wrong return val\n");
2191 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2193 /* set a non-empty value */
2194 r = MsiSetPropertyA( hpkg, "boo", "xyz" );
2195 ok( r == ERROR_SUCCESS, "wrong return val\n");
2197 sz = 1;
2198 strcpy(buffer,"x");
2199 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2200 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2201 ok( buffer[0] == 0, "buffer was not changed\n");
2202 ok( sz == 3, "wrong size returned\n");
2204 sz = 4;
2205 strcpy(buffer,"x");
2206 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2207 ok( r == ERROR_SUCCESS, "wrong return val\n");
2208 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2209 ok( sz == 3, "wrong size returned\n");
2211 sz = 3;
2212 strcpy(buffer,"x");
2213 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2214 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2215 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2216 ok( sz == 3, "wrong size returned\n");
2218 r = MsiSetPropertyA(hpkg, "SourceDir", "foo");
2219 ok( r == ERROR_SUCCESS, "wrong return val\n");
2221 sz = 4;
2222 r = MsiGetPropertyA(hpkg, "SOURCEDIR", buffer, &sz);
2223 ok( r == ERROR_SUCCESS, "wrong return val\n");
2224 ok( !strcmp(buffer,""), "buffer wrong\n");
2225 ok( sz == 0, "wrong size returned\n");
2227 sz = 4;
2228 r = MsiGetPropertyA(hpkg, "SOMERANDOMNAME", buffer, &sz);
2229 ok( r == ERROR_SUCCESS, "wrong return val\n");
2230 ok( !strcmp(buffer,""), "buffer wrong\n");
2231 ok( sz == 0, "wrong size returned\n");
2233 sz = 4;
2234 r = MsiGetPropertyA(hpkg, "SourceDir", buffer, &sz);
2235 ok( r == ERROR_SUCCESS, "wrong return val\n");
2236 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2237 ok( sz == 3, "wrong size returned\n");
2239 r = MsiSetPropertyA(hpkg, "MetadataCompName", "Photoshop.dll");
2240 ok( r == ERROR_SUCCESS, "wrong return val\n");
2242 sz = 0;
2243 r = MsiGetPropertyA(hpkg, "MetadataCompName", NULL, &sz );
2244 ok( r == ERROR_SUCCESS, "return wrong\n");
2245 ok( sz == 13, "size wrong (%d)\n", sz);
2247 sz = 13;
2248 r = MsiGetPropertyA(hpkg, "MetadataCompName", buffer, &sz );
2249 ok( r == ERROR_MORE_DATA, "return wrong\n");
2250 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2252 r = MsiSetPropertyA(hpkg, "property", "value");
2253 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2255 sz = 6;
2256 r = MsiGetPropertyA(hpkg, "property", buffer, &sz);
2257 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2258 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2260 r = MsiSetPropertyA(hpkg, "property", NULL);
2261 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2263 sz = 6;
2264 r = MsiGetPropertyA(hpkg, "property", buffer, &sz);
2265 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2266 ok(!buffer[0], "Expected empty string, got %s\n", buffer);
2268 MsiCloseHandle( hpkg );
2269 DeleteFileA(msifile);
2272 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val, int len)
2274 MSIHANDLE hview, hrec;
2275 BOOL found = FALSE;
2276 CHAR buffer[MAX_PATH];
2277 DWORD sz;
2278 UINT r;
2280 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Property`", &hview);
2281 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2282 r = MsiViewExecute(hview, 0);
2283 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2285 if (len < 0) len = lstrlenA(val);
2287 while (r == ERROR_SUCCESS && !found)
2289 r = MsiViewFetch(hview, &hrec);
2290 if (r != ERROR_SUCCESS) break;
2292 sz = MAX_PATH;
2293 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
2294 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2296 sz = MAX_PATH;
2297 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
2298 if (r == ERROR_SUCCESS && !memcmp(buffer, val, len) && !buffer[len])
2300 ok(sz == len, "wrong size %u\n", sz);
2301 found = TRUE;
2305 MsiCloseHandle(hrec);
2307 MsiViewClose(hview);
2308 MsiCloseHandle(hview);
2309 return found;
2312 static void test_property_table(void)
2314 const char *query;
2315 UINT r;
2316 MSIHANDLE hpkg, hdb, hrec;
2317 char buffer[MAX_PATH], package[10];
2318 DWORD sz;
2319 BOOL found;
2321 hdb = create_package_db();
2322 ok( hdb, "failed to create package\n");
2324 r = package_from_db(hdb, &hpkg);
2325 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2327 skip("Not enough rights to perform tests\n");
2328 DeleteFileA(msifile);
2329 return;
2331 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2333 MsiCloseHandle(hdb);
2335 hdb = MsiGetActiveDatabase(hpkg);
2337 query = "CREATE TABLE `_Property` ( "
2338 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2339 r = run_query(hdb, query);
2340 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2342 MsiCloseHandle(hdb);
2343 MsiCloseHandle(hpkg);
2344 DeleteFileA(msifile);
2346 hdb = create_package_db();
2347 ok( hdb, "failed to create package\n");
2349 query = "CREATE TABLE `_Property` ( "
2350 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2351 r = run_query(hdb, query);
2352 ok(r == ERROR_SUCCESS, "failed to create table\n");
2354 query = "ALTER `_Property` ADD `foo` INTEGER";
2355 r = run_query(hdb, query);
2356 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2358 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2359 r = run_query(hdb, query);
2360 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2362 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2363 r = run_query(hdb, query);
2364 ok(r == ERROR_SUCCESS, "failed to add column\n");
2366 sprintf(package, "#%i", hdb);
2367 r = MsiOpenPackageA(package, &hpkg);
2368 ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2369 if (r == ERROR_SUCCESS)
2370 MsiCloseHandle(hpkg);
2372 r = MsiCloseHandle(hdb);
2373 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2375 hdb = create_package_db();
2376 ok (hdb, "failed to create package database\n");
2378 r = create_property_table(hdb);
2379 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2381 r = add_property_entry(hdb, "'prop', 'val'");
2382 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2384 r = create_custom_action_table(hdb);
2385 ok(r == ERROR_SUCCESS, "cannot create CustomAction table: %d\n", r);
2387 r = add_custom_action_entry( hdb, "'EmbedNull', 51, 'prop2', '[~]np'" );
2388 ok( r == ERROR_SUCCESS, "cannot add custom action: %d\n", r);
2390 r = package_from_db(hdb, &hpkg);
2391 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2393 MsiCloseHandle(hdb);
2395 sz = MAX_PATH;
2396 r = MsiGetPropertyA(hpkg, "prop", buffer, &sz);
2397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2398 ok(!lstrcmpA(buffer, "val"), "Expected val, got %s\n", buffer);
2400 hdb = MsiGetActiveDatabase(hpkg);
2402 found = find_prop_in_property(hdb, "prop", "val", -1);
2403 ok(found, "prop should be in the _Property table\n");
2405 r = add_property_entry(hdb, "'dantes', 'mercedes'");
2406 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2408 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2409 r = do_query(hdb, query, &hrec);
2410 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2412 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2413 ok(found == FALSE, "dantes should not be in the _Property table\n");
2415 sz = MAX_PATH;
2416 lstrcpyA(buffer, "aaa");
2417 r = MsiGetPropertyA(hpkg, "dantes", buffer, &sz);
2418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2419 ok(!buffer[0], "Expected empty string, got %s\n", buffer);
2421 r = MsiSetPropertyA(hpkg, "dantes", "mercedes");
2422 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2424 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2425 ok(found == TRUE, "dantes should be in the _Property table\n");
2427 r = MsiDoActionA( hpkg, "EmbedNull" );
2428 ok( r == ERROR_SUCCESS, "EmbedNull failed: %d\n", r);
2430 sz = MAX_PATH;
2431 memset( buffer, 'a', sizeof(buffer) );
2432 r = MsiGetPropertyA( hpkg, "prop2", buffer, &sz );
2433 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2434 ok( !memcmp( buffer, "\0np", sizeof("\0np") ), "wrong value\n");
2435 ok( sz == sizeof("\0np") - 1, "got %u\n", sz );
2437 found = find_prop_in_property(hdb, "prop2", "\0np", 3);
2438 ok(found == TRUE, "prop2 should be in the _Property table\n");
2440 MsiCloseHandle(hdb);
2441 MsiCloseHandle(hpkg);
2442 DeleteFileA(msifile);
2445 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2447 MSIHANDLE htab = 0;
2448 UINT res;
2450 res = MsiDatabaseOpenViewA( hdb, szQuery, &htab );
2451 if( res == ERROR_SUCCESS )
2453 UINT r;
2455 r = MsiViewExecute( htab, hrec );
2456 if( r != ERROR_SUCCESS )
2458 res = r;
2459 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2462 r = MsiViewClose( htab );
2463 if( r != ERROR_SUCCESS )
2464 res = r;
2466 r = MsiCloseHandle( htab );
2467 if( r != ERROR_SUCCESS )
2468 res = r;
2470 return res;
2473 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2475 return try_query_param( hdb, szQuery, 0 );
2478 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2480 MSIHANDLE summary;
2481 UINT r;
2483 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2484 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2486 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2487 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2489 r = MsiSummaryInfoPersist(summary);
2490 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2492 MsiCloseHandle(summary);
2495 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2497 MSIHANDLE summary;
2498 UINT r;
2500 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2501 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2503 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2504 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2506 r = MsiSummaryInfoPersist(summary);
2507 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2509 MsiCloseHandle(summary);
2512 static void test_msipackage(void)
2514 MSIHANDLE hdb = 0, hpack = 100;
2515 UINT r;
2516 const char *query;
2517 char name[10];
2519 /* NULL szPackagePath */
2520 r = MsiOpenPackageA(NULL, &hpack);
2521 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2523 /* empty szPackagePath */
2524 r = MsiOpenPackageA("", &hpack);
2525 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2527 skip("Not enough rights to perform tests\n");
2528 return;
2530 todo_wine
2532 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2535 if (r == ERROR_SUCCESS)
2536 MsiCloseHandle(hpack);
2538 /* nonexistent szPackagePath */
2539 r = MsiOpenPackageA("nonexistent", &hpack);
2540 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2542 /* NULL hProduct */
2543 r = MsiOpenPackageA(msifile, NULL);
2544 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2546 name[0]='#';
2547 name[1]=0;
2548 r = MsiOpenPackageA(name, &hpack);
2549 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2551 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
2552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2554 /* database exists, but is empty */
2555 sprintf(name, "#%d", hdb);
2556 r = MsiOpenPackageA(name, &hpack);
2557 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2558 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2560 query = "CREATE TABLE `Property` ( "
2561 "`Property` CHAR(72), `Value` CHAR(0) "
2562 "PRIMARY KEY `Property`)";
2563 r = try_query(hdb, query);
2564 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2566 query = "CREATE TABLE `InstallExecuteSequence` ("
2567 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2568 "PRIMARY KEY `Action`)";
2569 r = try_query(hdb, query);
2570 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2572 /* a few key tables exist */
2573 sprintf(name, "#%d", hdb);
2574 r = MsiOpenPackageA(name, &hpack);
2575 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2576 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2578 MsiCloseHandle(hdb);
2579 DeleteFileA(msifile);
2581 /* start with a clean database to show what constitutes a valid package */
2582 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
2583 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2585 sprintf(name, "#%d", hdb);
2587 /* The following summary information props must exist:
2588 * - PID_REVNUMBER
2589 * - PID_PAGECOUNT
2592 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2593 r = MsiOpenPackageA(name, &hpack);
2594 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2595 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2597 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2598 r = MsiOpenPackageA(name, &hpack);
2599 ok(r == ERROR_SUCCESS,
2600 "Expected ERROR_SUCCESS, got %d\n", r);
2602 MsiCloseHandle(hpack);
2603 MsiCloseHandle(hdb);
2604 DeleteFileA(msifile);
2607 static void test_formatrecord2(void)
2609 MSIHANDLE hpkg, hrec ;
2610 char buffer[0x100];
2611 DWORD sz;
2612 UINT r;
2614 r = package_from_db(create_package_db(), &hpkg);
2615 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2617 skip("Not enough rights to perform tests\n");
2618 DeleteFileA(msifile);
2619 return;
2621 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2623 r = MsiSetPropertyA(hpkg, "Manufacturer", " " );
2624 ok( r == ERROR_SUCCESS, "set property failed\n");
2626 hrec = MsiCreateRecord(2);
2627 ok(hrec, "create record failed\n");
2629 r = MsiRecordSetStringA( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2630 ok( r == ERROR_SUCCESS, "format record failed\n");
2632 buffer[0] = 0;
2633 sz = sizeof buffer;
2634 r = MsiFormatRecordA( hpkg, hrec, buffer, &sz );
2635 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2637 r = MsiRecordSetStringA(hrec, 0, "[foo][1]");
2638 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2639 r = MsiRecordSetStringA(hrec, 1, "hoo");
2640 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2641 sz = sizeof buffer;
2642 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2643 ok( sz == 3, "size wrong\n");
2644 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2645 ok( r == ERROR_SUCCESS, "format failed\n");
2647 r = MsiRecordSetStringA(hrec, 0, "x[~]x");
2648 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2649 sz = sizeof buffer;
2650 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2651 ok( sz == 3, "size wrong\n");
2652 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2653 ok( r == ERROR_SUCCESS, "format failed\n");
2655 r = MsiRecordSetStringA(hrec, 0, "[foo.$%}][1]");
2656 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2657 r = MsiRecordSetStringA(hrec, 1, "hoo");
2658 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2659 sz = sizeof buffer;
2660 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2661 ok( sz == 3, "size wrong\n");
2662 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2663 ok( r == ERROR_SUCCESS, "format failed\n");
2665 r = MsiRecordSetStringA(hrec, 0, "[\\[]");
2666 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2667 sz = sizeof buffer;
2668 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2669 ok( sz == 1, "size wrong\n");
2670 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2671 ok( r == ERROR_SUCCESS, "format failed\n");
2673 SetEnvironmentVariableA("FOO", "BAR");
2674 r = MsiRecordSetStringA(hrec, 0, "[%FOO]");
2675 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2676 sz = sizeof buffer;
2677 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2678 ok( sz == 3, "size wrong\n");
2679 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2680 ok( r == ERROR_SUCCESS, "format failed\n");
2682 r = MsiRecordSetStringA(hrec, 0, "[[1]]");
2683 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2684 r = MsiRecordSetStringA(hrec, 1, "%FOO");
2685 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2686 sz = sizeof buffer;
2687 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2688 ok( sz == 3, "size wrong\n");
2689 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2690 ok( r == ERROR_SUCCESS, "format failed\n");
2692 MsiCloseHandle( hrec );
2693 MsiCloseHandle( hpkg );
2694 DeleteFileA(msifile);
2697 static void test_feature_states( UINT line, MSIHANDLE package, const char *feature, UINT error,
2698 INSTALLSTATE expected_state, INSTALLSTATE expected_action, BOOL todo )
2700 UINT r;
2701 INSTALLSTATE state = 0xdeadbee;
2702 INSTALLSTATE action = 0xdeadbee;
2704 r = MsiGetFeatureStateA( package, feature, &state, &action );
2705 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2706 if (r == ERROR_SUCCESS)
2708 ok( state == expected_state, "%u: expected state %d got %d\n",
2709 line, expected_state, state );
2710 todo_wine_if (todo)
2711 ok( action == expected_action, "%u: expected action %d got %d\n",
2712 line, expected_action, action );
2714 else
2716 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line, state );
2717 todo_wine_if (todo)
2718 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2723 static void test_component_states( UINT line, MSIHANDLE package, const char *component, UINT error,
2724 INSTALLSTATE expected_state, INSTALLSTATE expected_action, BOOL todo )
2726 UINT r;
2727 INSTALLSTATE state = 0xdeadbee;
2728 INSTALLSTATE action = 0xdeadbee;
2730 r = MsiGetComponentStateA( package, component, &state, &action );
2731 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2732 if (r == ERROR_SUCCESS)
2734 ok( state == expected_state, "%u: expected state %d got %d\n",
2735 line, expected_state, state );
2736 todo_wine_if (todo)
2737 ok( action == expected_action, "%u: expected action %d got %d\n",
2738 line, expected_action, action );
2740 else
2742 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2743 line, state );
2744 todo_wine_if (todo)
2745 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2746 line, action );
2750 static void test_states(void)
2752 static const char msifile2[] = "winetest2-package.msi";
2753 static const char msifile3[] = "winetest3-package.msi";
2754 static const char msifile4[] = "winetest4-package.msi";
2755 static const WCHAR msifile2W[] =
2756 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
2757 static const WCHAR msifile3W[] =
2758 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
2759 static const WCHAR msifile4W[] =
2760 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
2761 INSTALLSTATE state;
2762 MSIHANDLE hpkg;
2763 UINT r;
2764 MSIHANDLE hdb;
2766 if (is_process_limited())
2768 skip("process is limited\n");
2769 return;
2772 hdb = create_package_db();
2773 ok ( hdb, "failed to create package database\n" );
2775 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2776 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2778 r = create_property_table( hdb );
2779 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2781 r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2782 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2784 r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2785 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2787 r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2788 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2790 r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2791 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2793 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2794 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2796 r = create_install_execute_sequence_table( hdb );
2797 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2799 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2800 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2802 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2803 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2805 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2806 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2808 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2809 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2811 r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2812 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2814 r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2815 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2817 r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2818 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2820 r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2821 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2823 r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2824 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2826 r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2827 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2829 r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2830 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2832 r = create_media_table( hdb );
2833 ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2835 r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2836 ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2838 r = create_feature_table( hdb );
2839 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2841 r = create_component_table( hdb );
2842 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2844 /* msidbFeatureAttributesFavorLocal */
2845 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2846 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2848 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2849 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2850 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2852 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2853 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2854 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2856 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2857 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2858 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2860 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2861 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2862 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2864 /* msidbFeatureAttributesFavorSource */
2865 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2866 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2868 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2869 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2870 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2872 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2873 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2874 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2876 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2877 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2878 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2880 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2881 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2882 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2884 /* msidbFeatureAttributesFavorSource */
2885 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2886 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2888 /* msidbFeatureAttributesFavorLocal */
2889 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2890 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2892 /* disabled */
2893 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2894 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2896 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2897 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2898 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2900 /* no feature parent:msidbComponentAttributesLocalOnly */
2901 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2902 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2904 /* msidbFeatureAttributesFavorLocal:removed */
2905 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2906 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2908 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2909 r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2910 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2912 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2913 r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2914 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2916 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2917 r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2918 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2920 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2921 r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2922 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2924 /* msidbFeatureAttributesFavorSource:removed */
2925 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2926 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2928 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2929 r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2930 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2932 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2933 r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2934 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2936 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2937 r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2938 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2940 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2941 r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2942 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2944 /* msidbFeatureAttributesFavorLocal */
2945 r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2946 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2948 r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2949 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2951 /* msidbFeatureAttributesFavorSource */
2952 r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2953 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2955 r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2956 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2958 /* msidbFeatureAttributesFavorAdvertise */
2959 r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2960 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2962 r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2963 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2965 /* msidbFeatureAttributesUIDisallowAbsent */
2966 r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2967 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2969 r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2970 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2972 /* high install level */
2973 r = add_feature_entry( hdb, "'twelve', '', '', '', 2, 2, '', 0" );
2974 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2976 r = add_component_entry( hdb, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
2977 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2979 /* msidbFeatureAttributesFollowParent */
2980 r = add_feature_entry( hdb, "'thirteen', '', '', '', 2, 2, '', 2" );
2981 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2983 r = create_feature_components_table( hdb );
2984 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2986 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2987 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2989 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2990 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2992 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2993 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2995 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2996 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2998 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2999 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3001 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
3002 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3004 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
3005 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3007 r = add_feature_components_entry( hdb, "'two', 'iota'" );
3008 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3010 r = add_feature_components_entry( hdb, "'three', 'eta'" );
3011 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3013 r = add_feature_components_entry( hdb, "'four', 'eta'" );
3014 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3016 r = add_feature_components_entry( hdb, "'five', 'eta'" );
3017 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3019 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
3020 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3022 r = add_feature_components_entry( hdb, "'six', 'mu'" );
3023 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3025 r = add_feature_components_entry( hdb, "'six', 'nu'" );
3026 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3028 r = add_feature_components_entry( hdb, "'six', 'xi'" );
3029 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3031 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
3032 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3034 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
3035 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3037 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
3038 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3040 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
3041 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3043 r = add_feature_components_entry( hdb, "'eight', 'tau'" );
3044 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3046 r = add_feature_components_entry( hdb, "'nine', 'phi'" );
3047 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3049 r = add_feature_components_entry( hdb, "'ten', 'chi'" );
3050 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3052 r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
3053 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3055 r = add_feature_components_entry( hdb, "'twelve', 'upsilon'" );
3056 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3058 r = add_feature_components_entry( hdb, "'thirteen', 'upsilon'" );
3059 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3061 r = create_file_table( hdb );
3062 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3064 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
3065 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3067 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
3068 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3070 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3071 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3073 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3074 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3076 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3077 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3079 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3080 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3082 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3083 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3085 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3086 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3088 /* compressed file */
3089 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3090 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3092 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3093 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3095 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3096 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3098 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3099 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3101 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3102 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3104 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3105 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3107 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3108 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3110 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3111 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3113 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3114 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3116 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3117 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3119 r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3120 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3122 r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3123 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3125 r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3126 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3128 r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3129 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3131 r = add_file_entry( hdb, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3132 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3134 MsiDatabaseCommit(hdb);
3136 /* these properties must not be in the saved msi file */
3137 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3138 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3140 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3141 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3143 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3144 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3146 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3147 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3149 r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
3150 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3152 r = package_from_db( hdb, &hpkg );
3153 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3155 skip("Not enough rights to perform tests\n");
3156 DeleteFileA(msifile);
3157 return;
3159 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3161 MsiCloseHandle(hdb);
3163 CopyFileA(msifile, msifile2, FALSE);
3164 CopyFileA(msifile, msifile3, FALSE);
3165 CopyFileA(msifile, msifile4, FALSE);
3167 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3168 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3170 r = MsiDoActionA( hpkg, "CostInitialize");
3171 ok( r == ERROR_SUCCESS, "cost init failed\n");
3173 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3174 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3176 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3178 r = MsiDoActionA( hpkg, "FileCost");
3179 ok( r == ERROR_SUCCESS, "file cost failed\n");
3181 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3182 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3184 r = MsiDoActionA( hpkg, "CostFinalize");
3185 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3187 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3188 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3189 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3190 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3191 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3192 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3193 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3194 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3195 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3196 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3197 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3198 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3199 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3201 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3202 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3203 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3204 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3205 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3206 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3207 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3208 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3209 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3210 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3211 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3212 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3213 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3214 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3215 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3216 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3217 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3218 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3219 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3220 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3221 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3222 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3223 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3225 MsiCloseHandle( hpkg );
3227 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3229 /* publish the features and components */
3230 r = MsiInstallProductA(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3231 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3233 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
3234 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3236 /* these properties must not be in the saved msi file */
3237 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3238 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3240 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3241 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3243 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3244 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3246 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3247 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3249 r = package_from_db( hdb, &hpkg );
3250 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3252 MsiCloseHandle(hdb);
3254 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3255 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3257 r = MsiDoActionA( hpkg, "CostInitialize");
3258 ok( r == ERROR_SUCCESS, "cost init failed\n");
3260 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3261 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3263 r = MsiDoActionA( hpkg, "FileCost");
3264 ok( r == ERROR_SUCCESS, "file cost failed\n");
3266 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3267 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3269 r = MsiDoActionA( hpkg, "CostFinalize");
3270 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3272 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3273 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3274 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3275 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3276 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3277 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3278 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3279 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3280 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3281 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3282 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3283 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3284 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3286 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3287 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3288 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3289 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3290 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3291 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3292 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3293 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3294 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3295 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3296 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3297 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3298 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3299 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3300 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3301 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3302 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3303 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3304 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3305 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3306 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3307 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3308 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3310 MsiCloseHandle(hpkg);
3312 /* uninstall the product */
3313 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3314 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3316 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3317 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3318 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3319 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3321 /* all features installed locally */
3322 r = MsiInstallProductA(msifile2, "ADDLOCAL=ALL");
3323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3325 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3326 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3327 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3328 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3330 r = MsiOpenDatabaseW(msifile2W, MSIDBOPEN_DIRECT, &hdb);
3331 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3333 /* these properties must not be in the saved msi file */
3334 r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3335 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3337 r = package_from_db( hdb, &hpkg );
3338 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3340 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3341 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3343 r = MsiDoActionA( hpkg, "CostInitialize");
3344 ok( r == ERROR_SUCCESS, "cost init failed\n");
3346 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3347 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3349 r = MsiDoActionA( hpkg, "CostFinalize");
3350 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3352 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3353 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3354 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3355 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3356 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3357 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3358 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3359 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3360 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3361 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3362 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3363 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3364 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3366 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3367 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3368 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3369 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3370 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3371 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3372 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3373 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3374 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3375 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3376 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3377 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3378 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3379 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3380 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3381 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3382 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3383 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3384 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3385 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3386 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3387 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3388 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3390 MsiCloseHandle(hpkg);
3392 /* uninstall the product */
3393 r = MsiInstallProductA(msifile2, "REMOVE=ALL");
3394 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3396 /* all features installed from source */
3397 r = MsiInstallProductA(msifile3, "ADDSOURCE=ALL");
3398 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3400 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3401 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3402 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3403 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3405 r = MsiOpenDatabaseW(msifile3W, MSIDBOPEN_DIRECT, &hdb);
3406 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3408 /* this property must not be in the saved msi file */
3409 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3410 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3412 r = package_from_db( hdb, &hpkg );
3413 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3415 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3416 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3418 r = MsiDoActionA( hpkg, "CostInitialize");
3419 ok( r == ERROR_SUCCESS, "cost init failed\n");
3421 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3422 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3424 r = MsiDoActionA( hpkg, "FileCost");
3425 ok( r == ERROR_SUCCESS, "file cost failed\n");
3427 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3428 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3430 r = MsiDoActionA( hpkg, "CostFinalize");
3431 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3433 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3434 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3435 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3436 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3437 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3438 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3439 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3440 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3441 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3442 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3443 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3444 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3445 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3447 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3448 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3449 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3450 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3451 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3452 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3453 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3454 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3455 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3456 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3457 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3458 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3459 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3460 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3461 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3462 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3463 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3464 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3465 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3466 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3467 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3468 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3469 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, TRUE );
3471 MsiCloseHandle(hpkg);
3473 /* reinstall the product */
3474 r = MsiInstallProductA(msifile3, "REINSTALL=ALL");
3475 ok(r == ERROR_SUCCESS || broken(r == ERROR_INSTALL_FAILURE) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r);
3477 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3478 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3479 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3480 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3482 r = MsiOpenDatabaseW(msifile4W, MSIDBOPEN_DIRECT, &hdb);
3483 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3485 /* this property must not be in the saved msi file */
3486 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3487 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3489 r = package_from_db( hdb, &hpkg );
3490 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3492 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3493 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3495 r = MsiDoActionA( hpkg, "CostInitialize");
3496 ok( r == ERROR_SUCCESS, "cost init failed\n");
3498 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3499 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3501 r = MsiDoActionA( hpkg, "FileCost");
3502 ok( r == ERROR_SUCCESS, "file cost failed\n");
3504 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3505 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3507 r = MsiDoActionA( hpkg, "CostFinalize");
3508 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3510 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3511 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3512 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3513 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3514 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3515 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3516 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3517 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3518 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3519 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3520 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3521 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3522 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3524 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3525 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3526 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3527 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3528 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3529 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3530 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3531 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3532 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3533 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3534 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3535 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3536 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3537 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3538 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3539 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3540 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3541 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3542 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3543 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3544 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3545 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3546 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, TRUE );
3548 MsiCloseHandle(hpkg);
3550 /* uninstall the product */
3551 r = MsiInstallProductA(msifile4, "REMOVE=ALL");
3552 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3554 DeleteFileA(msifile);
3555 DeleteFileA(msifile2);
3556 DeleteFileA(msifile3);
3557 DeleteFileA(msifile4);
3560 static void test_getproperty(void)
3562 MSIHANDLE hPackage = 0;
3563 char prop[100];
3564 static CHAR empty[] = "";
3565 DWORD size;
3566 UINT r;
3568 r = package_from_db(create_package_db(), &hPackage);
3569 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3571 skip("Not enough rights to perform tests\n");
3572 DeleteFileA(msifile);
3573 return;
3575 ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
3577 /* set the property */
3578 r = MsiSetPropertyA(hPackage, "Name", "Value");
3579 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3581 /* retrieve the size, NULL pointer */
3582 size = 0;
3583 r = MsiGetPropertyA(hPackage, "Name", NULL, &size);
3584 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3585 ok( size == 5, "Expected 5, got %d\n", size);
3587 /* retrieve the size, empty string */
3588 size = 0;
3589 r = MsiGetPropertyA(hPackage, "Name", empty, &size);
3590 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3591 ok( size == 5, "Expected 5, got %d\n", size);
3593 /* don't change size */
3594 r = MsiGetPropertyA(hPackage, "Name", prop, &size);
3595 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3596 ok( size == 5, "Expected 5, got %d\n", size);
3597 ok( !lstrcmpA(prop, "Valu"), "Expected Valu, got %s\n", prop);
3599 /* increase the size by 1 */
3600 size++;
3601 r = MsiGetPropertyA(hPackage, "Name", prop, &size);
3602 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3603 ok( size == 5, "Expected 5, got %d\n", size);
3604 ok( !lstrcmpA(prop, "Value"), "Expected Value, got %s\n", prop);
3606 r = MsiCloseHandle( hPackage);
3607 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
3608 DeleteFileA(msifile);
3611 static void test_removefiles(void)
3613 MSIHANDLE hpkg;
3614 UINT r;
3615 MSIHANDLE hdb;
3616 INSTALLSTATE installed, action;
3618 hdb = create_package_db();
3619 ok ( hdb, "failed to create package database\n" );
3621 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3622 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3624 r = create_feature_table( hdb );
3625 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3627 r = create_component_table( hdb );
3628 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3630 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3631 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3633 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3634 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3636 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3637 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3639 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3640 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3642 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3643 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3645 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3646 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3648 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3649 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3651 r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3652 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3654 r = create_feature_components_table( hdb );
3655 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3657 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3658 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3660 r = add_feature_components_entry( hdb, "'one', 'helium'" );
3661 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3663 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
3664 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3666 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
3667 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3669 r = add_feature_components_entry( hdb, "'one', 'boron'" );
3670 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3672 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
3673 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3675 r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
3676 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3678 r = create_file_table( hdb );
3679 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3681 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3682 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3684 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3685 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3687 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3688 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3690 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3691 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3693 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3694 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3696 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3697 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3699 r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3700 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3702 r = create_remove_file_table( hdb );
3703 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
3705 r = package_from_db( hdb, &hpkg );
3706 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3708 skip("Not enough rights to perform tests\n");
3709 DeleteFileA(msifile);
3710 return;
3712 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3714 MsiCloseHandle( hdb );
3716 create_test_file( "hydrogen.txt" );
3717 create_test_file( "helium.txt" );
3718 create_test_file( "lithium.txt" );
3719 create_test_file( "beryllium.txt" );
3720 create_test_file( "boron.txt" );
3721 create_test_file( "carbon.txt" );
3722 create_test_file( "oxygen.txt" );
3724 r = MsiSetPropertyA( hpkg, "TARGETDIR", CURR_DIR );
3725 ok( r == ERROR_SUCCESS, "set property failed\n");
3727 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3729 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3730 ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
3732 r = MsiDoActionA( hpkg, "CostInitialize");
3733 ok( r == ERROR_SUCCESS, "cost init failed\n");
3735 r = MsiDoActionA( hpkg, "FileCost");
3736 ok( r == ERROR_SUCCESS, "file cost failed\n");
3738 installed = action = 0xdeadbeef;
3739 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3740 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3741 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3742 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3744 r = MsiDoActionA( hpkg, "CostFinalize");
3745 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3747 r = MsiDoActionA( hpkg, "InstallValidate");
3748 ok( r == ERROR_SUCCESS, "install validate failed\n");
3750 r = MsiSetComponentStateA( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3751 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3753 installed = action = 0xdeadbeef;
3754 r = MsiGetComponentStateA( hpkg, "hydrogen", &installed, &action );
3755 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3756 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3757 todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3759 r = MsiSetComponentStateA( hpkg, "helium", INSTALLSTATE_LOCAL );
3760 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3762 r = MsiSetComponentStateA( hpkg, "lithium", INSTALLSTATE_SOURCE );
3763 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3765 r = MsiSetComponentStateA( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3766 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3768 r = MsiSetComponentStateA( hpkg, "boron", INSTALLSTATE_LOCAL );
3769 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3771 r = MsiSetComponentStateA( hpkg, "carbon", INSTALLSTATE_SOURCE );
3772 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3774 installed = action = 0xdeadbeef;
3775 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3776 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3777 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3778 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3780 r = MsiSetComponentStateA( hpkg, "oxygen", INSTALLSTATE_ABSENT );
3781 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3783 installed = action = 0xdeadbeef;
3784 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3785 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3786 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3787 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3789 r = MsiDoActionA( hpkg, "RemoveFiles");
3790 ok( r == ERROR_SUCCESS, "remove files failed\n");
3792 installed = action = 0xdeadbeef;
3793 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3794 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3795 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3796 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3798 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3799 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3800 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3801 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3802 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3803 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3804 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3806 MsiCloseHandle( hpkg );
3807 DeleteFileA(msifile);
3810 static void test_appsearch(void)
3812 MSIHANDLE hpkg;
3813 UINT r;
3814 MSIHANDLE hdb;
3815 CHAR prop[MAX_PATH];
3816 DWORD size;
3817 HKEY hkey;
3818 const char reg_expand_value[] = "%systemroot%\\system32\\notepad.exe";
3820 hdb = create_package_db();
3821 ok ( hdb, "failed to create package database\n" );
3823 r = create_appsearch_table( hdb );
3824 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
3826 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3827 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3829 r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
3830 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3832 r = add_appsearch_entry( hdb, "'REGEXPANDVAL', 'NewSignature3'" );
3833 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3835 r = create_reglocator_table( hdb );
3836 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3838 r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3839 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3841 r = RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Winetest_msi", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
3842 ok( r == ERROR_SUCCESS, "Could not create key: %d.\n", r );
3843 r = RegSetValueExA(hkey, NULL, 0, REG_EXPAND_SZ, (const BYTE*)reg_expand_value, strlen(reg_expand_value) + 1);
3844 ok( r == ERROR_SUCCESS, "Could not set key value: %d.\n", r);
3845 RegCloseKey(hkey);
3846 r = add_reglocator_entry( hdb, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
3847 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3849 r = create_drlocator_table( hdb );
3850 ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
3852 r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3853 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3855 r = create_signature_table( hdb );
3856 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3858 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3859 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3861 r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3862 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3864 r = add_signature_entry( hdb, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3865 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3867 r = package_from_db( hdb, &hpkg );
3868 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3870 skip("Not enough rights to perform tests\n");
3871 DeleteFileA(msifile);
3872 return;
3874 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3875 MsiCloseHandle( hdb );
3876 if (r != ERROR_SUCCESS)
3877 goto done;
3879 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3881 r = MsiDoActionA( hpkg, "AppSearch" );
3882 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3884 size = sizeof(prop);
3885 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3886 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3887 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3889 size = sizeof(prop);
3890 r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
3891 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3893 size = sizeof(prop);
3894 r = MsiGetPropertyA( hpkg, "REGEXPANDVAL", prop, &size );
3895 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3896 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3898 done:
3899 MsiCloseHandle( hpkg );
3900 DeleteFileA(msifile);
3901 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Winetest_msi");
3904 static void test_appsearch_complocator(void)
3906 MSIHANDLE hpkg, hdb;
3907 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
3908 LPSTR usersid;
3909 DWORD size;
3910 UINT r;
3912 if (!(usersid = get_user_sid()))
3913 return;
3915 if (is_process_limited())
3917 skip("process is limited\n");
3918 return;
3921 create_test_file("FileName1");
3922 create_test_file("FileName4");
3923 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
3924 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
3926 create_test_file("FileName2");
3927 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
3928 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
3930 create_test_file("FileName3");
3931 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
3932 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
3934 create_test_file("FileName5");
3935 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
3936 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
3938 create_test_file("FileName6");
3939 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
3940 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
3942 create_test_file("FileName7");
3943 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
3944 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
3946 /* dir is FALSE, but we're pretending it's a directory */
3947 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
3948 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
3950 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3951 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
3952 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
3954 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3955 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
3956 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
3958 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3959 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
3960 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
3962 hdb = create_package_db();
3963 ok(hdb, "Expected a valid database handle\n");
3965 r = create_appsearch_table(hdb);
3966 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3968 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
3969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3971 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
3972 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3974 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
3975 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3977 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
3978 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3980 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
3981 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3983 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
3984 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3986 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
3987 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3989 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
3990 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3992 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
3993 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3995 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
3996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3998 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
3999 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4001 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4004 r = create_complocator_table(hdb);
4005 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4007 /* published component, machine, file, signature, misdbLocatorTypeFile */
4008 r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
4009 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4011 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
4012 r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
4013 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4015 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
4016 r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
4017 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4019 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
4020 r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
4021 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4023 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
4024 r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
4025 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4027 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
4028 r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
4029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4031 /* published component, machine, file, no signature, misdbLocatorTypeFile */
4032 r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
4033 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4035 /* unpublished component, no signature, misdbLocatorTypeDir */
4036 r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
4037 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4039 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
4040 r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
4041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4043 /* published component, signature w/ ver, misdbLocatorTypeFile */
4044 r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
4045 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4047 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
4048 r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
4049 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4051 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
4052 r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
4053 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4055 r = create_signature_table(hdb);
4056 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4058 r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
4059 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4061 r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
4062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4064 r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
4065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4067 r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
4068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4070 r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4073 r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4076 r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4077 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4079 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4080 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4082 r = package_from_db(hdb, &hpkg);
4083 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4085 skip("Not enough rights to perform tests\n");
4086 goto error;
4088 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4090 r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
4091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4093 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4095 r = MsiDoActionA(hpkg, "AppSearch");
4096 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4098 strcpy(expected, CURR_DIR);
4099 if (is_root(CURR_DIR)) expected[2] = 0;
4101 size = MAX_PATH;
4102 sprintf(path, "%s\\FileName1", expected);
4103 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4105 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4107 size = MAX_PATH;
4108 sprintf(path, "%s\\FileName2", expected);
4109 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4111 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4113 size = MAX_PATH;
4114 sprintf(path, "%s\\FileName3", expected);
4115 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4116 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4117 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4119 size = MAX_PATH;
4120 sprintf(path, "%s\\FileName4", expected);
4121 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4123 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4125 size = MAX_PATH;
4126 sprintf(path, "%s\\FileName5", expected);
4127 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4128 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4129 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4131 size = MAX_PATH;
4132 sprintf(path, "%s\\", expected);
4133 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4134 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4135 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4137 size = MAX_PATH;
4138 sprintf(path, "%s\\", expected);
4139 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4141 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4143 size = MAX_PATH;
4144 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4145 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4146 ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
4148 size = MAX_PATH;
4149 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4150 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4151 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4153 size = MAX_PATH;
4154 sprintf(path, "%s\\FileName8.dll", expected);
4155 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4156 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4157 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4159 size = MAX_PATH;
4160 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4161 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4162 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4164 size = MAX_PATH;
4165 sprintf(path, "%s\\FileName10.dll", expected);
4166 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4167 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4168 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4170 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4171 MSIINSTALLCONTEXT_MACHINE, NULL);
4172 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4173 MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
4174 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4175 MSIINSTALLCONTEXT_USERMANAGED, usersid);
4176 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4177 MSIINSTALLCONTEXT_MACHINE, NULL);
4178 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4179 MSIINSTALLCONTEXT_MACHINE, NULL);
4180 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4181 MSIINSTALLCONTEXT_MACHINE, NULL);
4182 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4183 MSIINSTALLCONTEXT_MACHINE, NULL);
4184 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4185 MSIINSTALLCONTEXT_MACHINE, NULL);
4186 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4187 MSIINSTALLCONTEXT_MACHINE, NULL);
4188 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4189 MSIINSTALLCONTEXT_MACHINE, NULL);
4191 MsiCloseHandle(hpkg);
4193 error:
4194 DeleteFileA("FileName1");
4195 DeleteFileA("FileName2");
4196 DeleteFileA("FileName3");
4197 DeleteFileA("FileName4");
4198 DeleteFileA("FileName5");
4199 DeleteFileA("FileName6");
4200 DeleteFileA("FileName7");
4201 DeleteFileA("FileName8.dll");
4202 DeleteFileA("FileName9.dll");
4203 DeleteFileA("FileName10.dll");
4204 DeleteFileA(msifile);
4205 LocalFree(usersid);
4208 static void test_appsearch_reglocator(void)
4210 MSIHANDLE hpkg, hdb;
4211 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4212 DWORD binary[2], size, val;
4213 BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
4214 HKEY hklm, classes, hkcu, users;
4215 LPSTR pathdata, pathvar, ptr;
4216 LPCSTR str;
4217 LONG res;
4218 UINT r, type = 0;
4219 SYSTEM_INFO si;
4221 version = TRUE;
4222 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4223 version = FALSE;
4225 DeleteFileA("test.dll");
4227 res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
4228 if (res == ERROR_ACCESS_DENIED)
4230 skip("Not enough rights to perform tests\n");
4231 return;
4233 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4235 res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
4236 (const BYTE *)"regszdata", 10);
4237 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4239 res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
4240 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4242 res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
4243 (const BYTE *)"regszdata", 10);
4244 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4246 users = 0;
4247 res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
4248 ok(res == ERROR_SUCCESS ||
4249 broken(res == ERROR_INVALID_PARAMETER),
4250 "Expected ERROR_SUCCESS, got %d\n", res);
4252 if (res == ERROR_SUCCESS)
4254 res = RegSetValueExA(users, "Value1", 0, REG_SZ,
4255 (const BYTE *)"regszdata", 10);
4256 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4259 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
4260 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4262 res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
4263 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4265 res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
4266 (const BYTE *)"regszdata", 10);
4267 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4269 val = 42;
4270 res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
4271 (const BYTE *)&val, sizeof(DWORD));
4272 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4274 val = -42;
4275 res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
4276 (const BYTE *)&val, sizeof(DWORD));
4277 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4279 res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
4280 (const BYTE *)"%PATH%", 7);
4281 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4283 res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
4284 (const BYTE *)"my%NOVAR%", 10);
4285 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4287 res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
4288 (const BYTE *)"one\0two\0", 9);
4289 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4291 binary[0] = 0x1234abcd;
4292 binary[1] = 0x567890ef;
4293 res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
4294 (const BYTE *)binary, sizeof(binary));
4295 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4297 res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
4298 (const BYTE *)"#regszdata", 11);
4299 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4301 strcpy(expected, CURR_DIR);
4302 if (is_root(CURR_DIR)) expected[2] = 0;
4304 create_test_file("FileName1");
4305 sprintf(path, "%s\\FileName1", expected);
4306 res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
4307 (const BYTE *)path, lstrlenA(path) + 1);
4308 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4310 sprintf(path, "%s\\FileName2", expected);
4311 res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
4312 (const BYTE *)path, lstrlenA(path) + 1);
4313 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4315 lstrcpyA(path, expected);
4316 res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
4317 (const BYTE *)path, lstrlenA(path) + 1);
4318 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4320 res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
4321 (const BYTE *)"", 1);
4322 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4324 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4325 sprintf(path, "%s\\FileName3.dll", expected);
4326 res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
4327 (const BYTE *)path, lstrlenA(path) + 1);
4328 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4330 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4331 sprintf(path, "%s\\FileName4.dll", expected);
4332 res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
4333 (const BYTE *)path, lstrlenA(path) + 1);
4334 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4336 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4337 sprintf(path, "%s\\FileName5.dll", expected);
4338 res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
4339 (const BYTE *)path, lstrlenA(path) + 1);
4340 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4342 sprintf(path, "\"%s\\FileName1\" -option", expected);
4343 res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
4344 (const BYTE *)path, lstrlenA(path) + 1);
4345 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4347 space = strchr(expected, ' ') != NULL;
4348 sprintf(path, "%s\\FileName1 -option", expected);
4349 res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
4350 (const BYTE *)path, lstrlenA(path) + 1);
4351 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4353 hdb = create_package_db();
4354 ok(hdb, "Expected a valid database handle\n");
4356 r = create_appsearch_table(hdb);
4357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4359 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4360 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4362 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4365 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4366 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4368 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4369 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4371 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4372 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4374 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4375 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4377 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4378 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4380 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4381 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4383 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4384 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4386 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4387 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4389 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4390 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4392 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4395 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
4396 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4398 r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
4399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4401 r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
4402 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4404 r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
4405 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4407 r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
4408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4410 r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
4411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4413 r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
4414 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4416 r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
4417 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4419 r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
4420 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4422 r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
4423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4425 r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
4426 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4428 r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
4429 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4431 r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
4432 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4434 r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
4435 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4437 r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
4438 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4440 r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
4441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4443 r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
4444 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4446 r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
4447 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4449 r = create_reglocator_table(hdb);
4450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4452 type = msidbLocatorTypeRawValue;
4453 if (is_64bit)
4454 type |= msidbLocatorType64bit;
4456 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4457 r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
4458 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4460 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4461 r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
4462 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4464 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4465 r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
4466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4468 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4469 r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
4470 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4472 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4473 r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
4474 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4476 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4477 r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
4478 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4480 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4481 r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
4482 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4484 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4485 r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
4486 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4488 type = msidbLocatorTypeFileName;
4489 if (is_64bit)
4490 type |= msidbLocatorType64bit;
4492 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4493 r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
4494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4496 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4497 r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
4498 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4500 /* HKLM, msidbLocatorTypeFileName, no signature */
4501 r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
4502 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4504 type = msidbLocatorTypeDirectory;
4505 if (is_64bit)
4506 type |= msidbLocatorType64bit;
4508 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4509 r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
4510 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4512 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4513 r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
4514 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4516 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4517 r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
4518 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4520 type = msidbLocatorTypeRawValue;
4521 if (is_64bit)
4522 type |= msidbLocatorType64bit;
4524 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4525 r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
4526 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4528 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4529 r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
4530 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4532 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4533 r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
4534 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4536 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4537 r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
4538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4540 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4541 r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
4542 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4544 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4545 r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
4546 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4548 type = msidbLocatorTypeFileName;
4549 if (is_64bit)
4550 type |= msidbLocatorType64bit;
4552 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4553 r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
4554 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4556 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4557 r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
4558 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4560 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4561 r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
4562 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4564 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4565 r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
4566 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4568 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4569 r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
4570 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4572 type = msidbLocatorTypeDirectory;
4573 if (is_64bit)
4574 type |= msidbLocatorType64bit;
4576 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4577 r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
4578 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4580 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4581 r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
4582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4584 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4585 r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
4586 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4588 type = msidbLocatorTypeFileName;
4589 if (is_64bit)
4590 type |= msidbLocatorType64bit;
4592 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4593 r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
4594 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4596 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4597 r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
4598 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4600 r = create_signature_table(hdb);
4601 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4603 str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4604 r = add_signature_entry(hdb, str);
4605 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4607 str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4608 r = add_signature_entry(hdb, str);
4609 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4611 str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4612 r = add_signature_entry(hdb, str);
4613 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4615 str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4616 r = add_signature_entry(hdb, str);
4617 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4619 str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4620 r = add_signature_entry(hdb, str);
4621 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4623 str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4624 r = add_signature_entry(hdb, str);
4625 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4627 if (!is_root(CURR_DIR))
4629 ptr = strrchr(expected, '\\') + 1;
4630 sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
4631 r = add_signature_entry(hdb, path);
4632 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4634 str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4635 r = add_signature_entry(hdb, str);
4636 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4638 str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4639 r = add_signature_entry(hdb, str);
4640 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4642 str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4643 r = add_signature_entry(hdb, str);
4644 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4646 r = package_from_db(hdb, &hpkg);
4647 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4649 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4651 r = MsiDoActionA(hpkg, "AppSearch");
4652 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4654 size = MAX_PATH;
4655 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4656 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4657 ok(!lstrcmpA(prop, "regszdata"),
4658 "Expected \"regszdata\", got \"%s\"\n", prop);
4660 size = MAX_PATH;
4661 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4662 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4663 ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
4665 size = MAX_PATH;
4666 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4667 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4668 ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
4670 memset(&si, 0, sizeof(si));
4671 if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
4673 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
4675 size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
4676 pathvar = HeapAlloc(GetProcessHeap(), 0, size);
4677 ExpandEnvironmentStringsA("%PATH%", pathvar, size);
4679 size = 0;
4680 r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
4681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4683 pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
4684 r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
4685 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4686 ok(!lstrcmpA(pathdata, pathvar),
4687 "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
4689 HeapFree(GetProcessHeap(), 0, pathvar);
4690 HeapFree(GetProcessHeap(), 0, pathdata);
4693 size = MAX_PATH;
4694 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4695 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4696 ok(!lstrcmpA(prop,
4697 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
4699 size = MAX_PATH;
4700 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4702 todo_wine
4704 ok(!memcmp(prop, "\0one\0two\0\0", 10),
4705 "Expected \"\\0one\\0two\\0\\0\"\n");
4708 size = MAX_PATH;
4709 lstrcpyA(path, "#xCDAB3412EF907856");
4710 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4711 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4712 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4714 size = MAX_PATH;
4715 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4716 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4717 ok(!lstrcmpA(prop, "##regszdata"),
4718 "Expected \"##regszdata\", got \"%s\"\n", prop);
4720 size = MAX_PATH;
4721 sprintf(path, "%s\\FileName1", expected);
4722 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4723 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4724 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4726 size = MAX_PATH;
4727 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4729 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4731 size = MAX_PATH;
4732 sprintf(path, "%s\\", expected);
4733 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4734 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4735 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4737 size = MAX_PATH;
4738 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4739 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4740 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4742 size = MAX_PATH;
4743 sprintf(path, "%s\\", expected);
4744 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
4745 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4746 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4748 size = MAX_PATH;
4749 r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
4750 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4751 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4753 size = MAX_PATH;
4754 r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
4755 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4756 ok(!lstrcmpA(prop, "regszdata"),
4757 "Expected \"regszdata\", got \"%s\"\n", prop);
4759 size = MAX_PATH;
4760 r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
4761 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4762 ok(!lstrcmpA(prop, "regszdata"),
4763 "Expected \"regszdata\", got \"%s\"\n", prop);
4765 if (users)
4767 size = MAX_PATH;
4768 r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
4769 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4770 ok(!lstrcmpA(prop, "regszdata"),
4771 "Expected \"regszdata\", got \"%s\"\n", prop);
4774 size = MAX_PATH;
4775 r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
4776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4777 ok(!lstrcmpA(prop, "defvalue"),
4778 "Expected \"defvalue\", got \"%s\"\n", prop);
4780 size = MAX_PATH;
4781 r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
4782 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4783 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4785 size = MAX_PATH;
4786 r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
4787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4788 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4790 if (version)
4792 size = MAX_PATH;
4793 sprintf(path, "%s\\FileName3.dll", expected);
4794 r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
4795 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4796 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4798 size = MAX_PATH;
4799 r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
4800 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4801 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4803 size = MAX_PATH;
4804 sprintf(path, "%s\\FileName5.dll", expected);
4805 r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
4806 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4807 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4810 if (!is_root(CURR_DIR))
4812 size = MAX_PATH;
4813 lstrcpyA(path, expected);
4814 ptr = strrchr(path, '\\') + 1;
4815 *ptr = '\0';
4816 r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
4817 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4818 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4820 size = MAX_PATH;
4821 sprintf(path, "%s\\", expected);
4822 r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
4823 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4824 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4826 size = MAX_PATH;
4827 r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
4828 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4829 if (is_root(CURR_DIR))
4830 ok(!lstrcmpA(prop, CURR_DIR), "Expected \"%s\", got \"%s\"\n", CURR_DIR, prop);
4831 else
4832 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4834 size = MAX_PATH;
4835 r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
4836 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4837 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4839 size = MAX_PATH;
4840 r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
4841 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4842 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4844 size = MAX_PATH;
4845 sprintf(path, "%s\\FileName1", expected);
4846 r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
4847 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4848 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4850 size = MAX_PATH;
4851 sprintf(path, "%s\\FileName1", expected);
4852 r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
4853 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4854 if (space)
4855 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4856 else
4857 todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4859 RegSetValueA(hklm, NULL, REG_SZ, "", 0);
4860 RegDeleteValueA(hklm, "Value1");
4861 RegDeleteValueA(hklm, "Value2");
4862 RegDeleteValueA(hklm, "Value3");
4863 RegDeleteValueA(hklm, "Value4");
4864 RegDeleteValueA(hklm, "Value5");
4865 RegDeleteValueA(hklm, "Value6");
4866 RegDeleteValueA(hklm, "Value7");
4867 RegDeleteValueA(hklm, "Value8");
4868 RegDeleteValueA(hklm, "Value9");
4869 RegDeleteValueA(hklm, "Value10");
4870 RegDeleteValueA(hklm, "Value11");
4871 RegDeleteValueA(hklm, "Value12");
4872 RegDeleteValueA(hklm, "Value13");
4873 RegDeleteValueA(hklm, "Value14");
4874 RegDeleteValueA(hklm, "Value15");
4875 RegDeleteValueA(hklm, "Value16");
4876 RegDeleteValueA(hklm, "Value17");
4877 RegDeleteKeyA(hklm, "");
4878 RegCloseKey(hklm);
4880 RegDeleteValueA(classes, "Value1");
4881 RegDeleteKeyA(classes, "");
4882 RegCloseKey(classes);
4884 RegDeleteValueA(hkcu, "Value1");
4885 RegDeleteKeyA(hkcu, "");
4886 RegCloseKey(hkcu);
4888 RegDeleteValueA(users, "Value1");
4889 RegDeleteKeyA(users, "");
4890 RegCloseKey(users);
4892 DeleteFileA("FileName1");
4893 DeleteFileA("FileName3.dll");
4894 DeleteFileA("FileName4.dll");
4895 DeleteFileA("FileName5.dll");
4896 MsiCloseHandle(hpkg);
4897 DeleteFileA(msifile);
4900 static void delete_win_ini(LPCSTR file)
4902 CHAR path[MAX_PATH];
4904 GetWindowsDirectoryA(path, MAX_PATH);
4905 lstrcatA(path, "\\");
4906 lstrcatA(path, file);
4908 DeleteFileA(path);
4911 static void test_appsearch_inilocator(void)
4913 MSIHANDLE hpkg, hdb;
4914 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4915 BOOL version;
4916 LPCSTR str;
4917 LPSTR ptr;
4918 DWORD size;
4919 UINT r;
4921 version = TRUE;
4922 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4923 version = FALSE;
4925 DeleteFileA("test.dll");
4927 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4929 strcpy(expected, CURR_DIR);
4930 if (is_root(CURR_DIR)) expected[2] = 0;
4932 create_test_file("FileName1");
4933 sprintf(path, "%s\\FileName1", expected);
4934 WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
4936 WritePrivateProfileStringA("Section", "Key3", expected, "IniFile.ini");
4938 sprintf(path, "%s\\IDontExist", expected);
4939 WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
4941 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4942 sprintf(path, "%s\\FileName2.dll", expected);
4943 WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
4945 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4946 sprintf(path, "%s\\FileName3.dll", expected);
4947 WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
4949 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4950 sprintf(path, "%s\\FileName4.dll", expected);
4951 WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
4953 hdb = create_package_db();
4954 ok(hdb, "Expected a valid database handle\n");
4956 r = create_appsearch_table(hdb);
4957 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4959 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4960 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4962 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4963 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4965 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4966 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4968 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4971 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4972 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4974 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4975 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4977 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4978 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4980 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4981 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4983 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4984 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4986 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4987 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4989 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4990 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4992 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4993 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4995 r = create_inilocator_table(hdb);
4996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4998 /* msidbLocatorTypeRawValue, field 1 */
4999 str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
5000 r = add_inilocator_entry(hdb, str);
5001 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5003 /* msidbLocatorTypeRawValue, field 2 */
5004 str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
5005 r = add_inilocator_entry(hdb, str);
5006 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5008 /* msidbLocatorTypeRawValue, entire field */
5009 str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
5010 r = add_inilocator_entry(hdb, str);
5011 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5013 /* msidbLocatorTypeFile */
5014 str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
5015 r = add_inilocator_entry(hdb, str);
5016 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5018 /* msidbLocatorTypeDirectory, file */
5019 str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
5020 r = add_inilocator_entry(hdb, str);
5021 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5023 /* msidbLocatorTypeDirectory, directory */
5024 str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
5025 r = add_inilocator_entry(hdb, str);
5026 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5028 /* msidbLocatorTypeFile, file, no signature */
5029 str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
5030 r = add_inilocator_entry(hdb, str);
5031 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5033 /* msidbLocatorTypeFile, dir, no signature */
5034 str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
5035 r = add_inilocator_entry(hdb, str);
5036 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5038 /* msidbLocatorTypeFile, file does not exist */
5039 str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
5040 r = add_inilocator_entry(hdb, str);
5041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5043 /* msidbLocatorTypeFile, signature with version */
5044 str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
5045 r = add_inilocator_entry(hdb, str);
5046 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5048 /* msidbLocatorTypeFile, signature with version, ver > max */
5049 str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
5050 r = add_inilocator_entry(hdb, str);
5051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5053 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
5054 str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
5055 r = add_inilocator_entry(hdb, str);
5056 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5058 r = create_signature_table(hdb);
5059 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5061 r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
5062 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5064 r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
5065 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5067 r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5070 r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5071 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5073 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5076 r = package_from_db(hdb, &hpkg);
5077 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5079 skip("Not enough rights to perform tests\n");
5080 goto error;
5082 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5084 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5086 r = MsiDoActionA(hpkg, "AppSearch");
5087 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5089 size = MAX_PATH;
5090 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5091 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5092 ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
5094 size = MAX_PATH;
5095 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5096 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5097 ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
5099 size = MAX_PATH;
5100 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5101 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5102 ok(!lstrcmpA(prop, "keydata,field2"),
5103 "Expected \"keydata,field2\", got \"%s\"\n", prop);
5105 size = MAX_PATH;
5106 sprintf(path, "%s\\FileName1", expected);
5107 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5109 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5111 size = MAX_PATH;
5112 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5113 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5114 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5116 size = MAX_PATH;
5117 sprintf(path, "%s\\", expected);
5118 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5120 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5122 size = MAX_PATH;
5123 sprintf(path, "%s\\", expected);
5124 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5125 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5126 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5128 if (!is_root(CURR_DIR))
5130 size = MAX_PATH;
5131 lstrcpyA(path, expected);
5132 ptr = strrchr(path, '\\');
5133 *(ptr + 1) = 0;
5134 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5135 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5136 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5138 size = MAX_PATH;
5139 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5140 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5141 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5143 if (version)
5145 size = MAX_PATH;
5146 sprintf(path, "%s\\FileName2.dll", expected);
5147 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5149 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5151 size = MAX_PATH;
5152 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5153 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5154 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5156 size = MAX_PATH;
5157 sprintf(path, "%s\\FileName4.dll", expected);
5158 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
5159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5160 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5163 MsiCloseHandle(hpkg);
5165 error:
5166 delete_win_ini("IniFile.ini");
5167 DeleteFileA("FileName1");
5168 DeleteFileA("FileName2.dll");
5169 DeleteFileA("FileName3.dll");
5170 DeleteFileA("FileName4.dll");
5171 DeleteFileA(msifile);
5175 * MSI AppSearch action on DrLocator table always returns absolute paths.
5176 * If a relative path was set, it returns the first absolute path that
5177 * matches or an empty string if it didn't find anything.
5178 * This helper function replicates this behaviour.
5180 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
5182 int i, size;
5183 DWORD attr, drives;
5185 size = lstrlenA(relative);
5186 drives = GetLogicalDrives();
5187 lstrcpyA(absolute, "A:\\");
5188 for (i = 0; i < 26; absolute[0] = '\0', i++)
5190 if (!(drives & (1 << i)))
5191 continue;
5193 absolute[0] = 'A' + i;
5194 if (GetDriveTypeA(absolute) != DRIVE_FIXED)
5195 continue;
5197 lstrcpynA(absolute + 3, relative, size + 1);
5198 attr = GetFileAttributesA(absolute);
5199 if (attr != INVALID_FILE_ATTRIBUTES &&
5200 (attr & FILE_ATTRIBUTE_DIRECTORY))
5202 if (absolute[3 + size - 1] != '\\')
5203 lstrcatA(absolute, "\\");
5204 break;
5206 absolute[3] = '\0';
5210 static void test_appsearch_drlocator(void)
5212 MSIHANDLE hpkg, hdb;
5213 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
5214 BOOL version;
5215 LPCSTR str;
5216 DWORD size;
5217 UINT r;
5219 version = TRUE;
5220 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5221 version = FALSE;
5223 DeleteFileA("test.dll");
5225 create_test_file("FileName1");
5226 CreateDirectoryA("one", NULL);
5227 CreateDirectoryA("one\\two", NULL);
5228 CreateDirectoryA("one\\two\\three", NULL);
5229 create_test_file("one\\two\\three\\FileName2");
5230 CreateDirectoryA("another", NULL);
5231 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5232 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5233 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5235 hdb = create_package_db();
5236 ok(hdb, "Expected a valid database handle\n");
5238 r = create_appsearch_table(hdb);
5239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5241 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5244 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5245 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5247 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5250 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5253 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5256 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5257 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5259 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5260 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5262 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5263 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5265 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5266 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5268 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5271 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5272 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5274 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
5275 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5277 r = create_drlocator_table(hdb);
5278 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5280 strcpy(expected, CURR_DIR);
5281 if (is_root(CURR_DIR)) expected[2] = 0;
5283 /* no parent, full path, depth 0, signature */
5284 sprintf(path, "'NewSignature1', '', '%s', 0", expected);
5285 r = add_drlocator_entry(hdb, path);
5286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5288 /* no parent, full path, depth 0, no signature */
5289 sprintf(path, "'NewSignature2', '', '%s', 0", expected);
5290 r = add_drlocator_entry(hdb, path);
5291 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5293 /* no parent, relative path, depth 0, no signature */
5294 sprintf(path, "'NewSignature3', '', '%s', 0", expected + 3);
5295 r = add_drlocator_entry(hdb, path);
5296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5298 /* no parent, full path, depth 2, signature */
5299 sprintf(path, "'NewSignature4', '', '%s', 2", expected);
5300 r = add_drlocator_entry(hdb, path);
5301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5303 /* no parent, full path, depth 3, signature */
5304 sprintf(path, "'NewSignature5', '', '%s', 3", expected);
5305 r = add_drlocator_entry(hdb, path);
5306 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5308 /* no parent, full path, depth 1, signature is dir */
5309 sprintf(path, "'NewSignature6', '', '%s', 1", expected);
5310 r = add_drlocator_entry(hdb, path);
5311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5313 /* parent is in DrLocator, relative path, depth 0, signature */
5314 sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5315 r = add_drlocator_entry(hdb, path);
5316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5318 /* no parent, full path, depth 0, signature w/ version */
5319 sprintf(path, "'NewSignature8', '', '%s', 0", expected);
5320 r = add_drlocator_entry(hdb, path);
5321 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5323 /* no parent, full path, depth 0, signature w/ version, ver > max */
5324 sprintf(path, "'NewSignature9', '', '%s', 0", expected);
5325 r = add_drlocator_entry(hdb, path);
5326 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5328 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5329 sprintf(path, "'NewSignature10', '', '%s', 0", expected);
5330 r = add_drlocator_entry(hdb, path);
5331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5333 /* no parent, relative empty path, depth 0, no signature */
5334 sprintf(path, "'NewSignature11', '', '', 0");
5335 r = add_drlocator_entry(hdb, path);
5336 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5338 r = create_reglocator_table(hdb);
5339 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5341 /* parent */
5342 r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5345 /* parent is in RegLocator, no path, depth 0, no signature */
5346 sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
5347 r = add_drlocator_entry(hdb, path);
5348 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5350 r = create_signature_table(hdb);
5351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5353 str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5354 r = add_signature_entry(hdb, str);
5355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5357 str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5358 r = add_signature_entry(hdb, str);
5359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5361 str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5362 r = add_signature_entry(hdb, str);
5363 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5365 str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5366 r = add_signature_entry(hdb, str);
5367 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5369 str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5370 r = add_signature_entry(hdb, str);
5371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5373 str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5374 r = add_signature_entry(hdb, str);
5375 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5377 str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5378 r = add_signature_entry(hdb, str);
5379 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5381 str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5382 r = add_signature_entry(hdb, str);
5383 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5385 r = package_from_db(hdb, &hpkg);
5386 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5388 skip("Not enough rights to perform tests\n");
5389 goto error;
5391 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5393 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5395 r = MsiDoActionA(hpkg, "AppSearch");
5396 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5398 size = MAX_PATH;
5399 sprintf(path, "%s\\FileName1", expected);
5400 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5401 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5402 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5404 size = MAX_PATH;
5405 sprintf(path, "%s\\", expected);
5406 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5407 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5408 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5410 size = MAX_PATH;
5411 search_absolute_directory(path, expected + 3);
5412 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5413 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5414 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5416 size = MAX_PATH;
5417 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5419 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5421 size = MAX_PATH;
5422 sprintf(path, "%s\\one\\two\\three\\FileName2", expected);
5423 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5424 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5425 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5427 size = MAX_PATH;
5428 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5429 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5430 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5432 size = MAX_PATH;
5433 sprintf(path, "%s\\one\\two\\three\\FileName2", expected);
5434 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5435 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5436 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5438 if (version)
5440 size = MAX_PATH;
5441 sprintf(path, "%s\\FileName3.dll", expected);
5442 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5443 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5444 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5446 size = MAX_PATH;
5447 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5448 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5449 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5451 size = MAX_PATH;
5452 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5453 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5454 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5457 size = MAX_PATH;
5458 search_absolute_directory(path, "");
5459 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5460 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5461 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5463 size = MAX_PATH;
5464 strcpy(path, "c:\\");
5465 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
5466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5467 ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
5469 MsiCloseHandle(hpkg);
5471 error:
5472 DeleteFileA("FileName1");
5473 DeleteFileA("FileName3.dll");
5474 DeleteFileA("FileName4.dll");
5475 DeleteFileA("FileName5.dll");
5476 DeleteFileA("one\\two\\three\\FileName2");
5477 RemoveDirectoryA("one\\two\\three");
5478 RemoveDirectoryA("one\\two");
5479 RemoveDirectoryA("one");
5480 RemoveDirectoryA("another");
5481 DeleteFileA(msifile);
5484 static void test_featureparents(void)
5486 MSIHANDLE hpkg;
5487 UINT r;
5488 MSIHANDLE hdb;
5490 hdb = create_package_db();
5491 ok ( hdb, "failed to create package database\n" );
5493 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5494 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5496 r = create_feature_table( hdb );
5497 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5499 r = create_component_table( hdb );
5500 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5502 r = create_feature_components_table( hdb );
5503 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5505 r = create_file_table( hdb );
5506 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5508 /* msidbFeatureAttributesFavorLocal */
5509 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
5510 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5512 /* msidbFeatureAttributesFavorSource */
5513 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
5514 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5516 /* msidbFeatureAttributesFavorLocal */
5517 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
5518 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5520 /* msidbFeatureAttributesUIDisallowAbsent */
5521 r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
5522 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5524 /* disabled because of install level */
5525 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
5526 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5528 /* child feature of disabled feature */
5529 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5530 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5532 /* component of disabled feature (install level) */
5533 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5534 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5536 /* component of disabled child feature (install level) */
5537 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5538 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5540 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5541 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5542 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5544 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5545 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5546 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5548 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5549 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5550 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5552 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5553 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5554 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5556 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5557 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5558 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5560 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5561 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5562 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5564 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5565 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5566 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5568 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5569 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5570 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5572 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5573 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5574 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5576 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
5577 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5579 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
5580 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5582 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
5583 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5585 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
5586 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5588 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
5589 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5591 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
5592 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5594 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
5595 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5597 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
5598 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5600 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
5601 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5603 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
5604 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5606 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
5607 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5609 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
5610 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5612 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
5613 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5615 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
5616 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5618 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
5619 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5621 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
5622 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5624 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
5625 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5627 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5628 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5630 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5631 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5633 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5634 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5636 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5637 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5639 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5640 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5642 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5643 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5645 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5646 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5648 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5649 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5651 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5652 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5654 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5655 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5657 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5658 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5660 r = package_from_db( hdb, &hpkg );
5661 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5663 skip("Not enough rights to perform tests\n");
5664 DeleteFileA(msifile);
5665 return;
5667 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5669 MsiCloseHandle( hdb );
5671 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5673 r = MsiDoActionA( hpkg, "CostInitialize");
5674 ok( r == ERROR_SUCCESS, "cost init failed\n");
5676 r = MsiDoActionA( hpkg, "FileCost");
5677 ok( r == ERROR_SUCCESS, "file cost failed\n");
5679 r = MsiDoActionA( hpkg, "CostFinalize");
5680 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5682 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5683 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
5684 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5685 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5686 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5687 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5689 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5690 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5691 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5692 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5693 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5694 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5695 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5696 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5697 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5698 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5699 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5701 r = MsiSetFeatureStateA(hpkg, "orion", INSTALLSTATE_ABSENT);
5702 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5704 r = MsiSetFeatureStateA(hpkg, "lyra", INSTALLSTATE_ABSENT);
5705 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5707 r = MsiSetFeatureStateA(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
5708 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
5710 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5711 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
5712 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, FALSE );
5713 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, FALSE );
5714 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5715 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5717 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5718 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5719 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5720 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5721 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5722 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5723 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5724 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5725 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5726 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5727 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5729 MsiCloseHandle(hpkg);
5730 DeleteFileA(msifile);
5733 static void test_installprops(void)
5735 MSIHANDLE hpkg, hdb;
5736 CHAR path[MAX_PATH], buf[MAX_PATH];
5737 DWORD size, type;
5738 LANGID langid;
5739 HKEY hkey1, hkey2;
5740 int res;
5741 UINT r;
5742 REGSAM access = KEY_ALL_ACCESS;
5743 SYSTEM_INFO si;
5744 INSTALLUILEVEL uilevel;
5746 if (is_wow64)
5747 access |= KEY_WOW64_64KEY;
5749 lstrcpyA(path, CURR_DIR);
5750 if (!is_root(CURR_DIR)) lstrcatA(path, "\\");
5751 lstrcatA(path, msifile);
5753 uilevel = MsiSetInternalUI(INSTALLUILEVEL_BASIC|INSTALLUILEVEL_SOURCERESONLY, NULL);
5755 hdb = create_package_db();
5756 ok( hdb, "failed to create database\n");
5758 r = package_from_db(hdb, &hpkg);
5759 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5761 skip("Not enough rights to perform tests\n");
5762 MsiSetInternalUI(uilevel, NULL);
5763 DeleteFileA(msifile);
5764 return;
5766 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5768 MsiCloseHandle(hdb);
5770 buf[0] = 0;
5771 size = MAX_PATH;
5772 r = MsiGetPropertyA(hpkg, "UILevel", buf, &size);
5773 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5774 ok( !lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5776 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5778 buf[0] = 0;
5779 size = MAX_PATH;
5780 r = MsiGetPropertyA(hpkg, "UILevel", buf, &size);
5781 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5782 ok( !lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5784 buf[0] = 0;
5785 size = MAX_PATH;
5786 r = MsiGetPropertyA(hpkg, "DATABASE", buf, &size);
5787 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5788 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5790 RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
5791 RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
5793 size = MAX_PATH;
5794 type = REG_SZ;
5795 *path = '\0';
5796 if (RegQueryValueExA(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5798 size = MAX_PATH;
5799 type = REG_SZ;
5800 RegQueryValueExA(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
5803 buf[0] = 0;
5804 size = MAX_PATH;
5805 r = MsiGetPropertyA(hpkg, "USERNAME", buf, &size);
5806 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5807 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5809 size = MAX_PATH;
5810 type = REG_SZ;
5811 *path = '\0';
5812 if (RegQueryValueExA(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5814 size = MAX_PATH;
5815 type = REG_SZ;
5816 RegQueryValueExA(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
5819 if (*path)
5821 buf[0] = 0;
5822 size = MAX_PATH;
5823 r = MsiGetPropertyA(hpkg, "COMPANYNAME", buf, &size);
5824 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5825 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5828 buf[0] = 0;
5829 size = MAX_PATH;
5830 r = MsiGetPropertyA(hpkg, "VersionDatabase", buf, &size);
5831 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5832 trace("VersionDatabase = %s\n", buf);
5834 buf[0] = 0;
5835 size = MAX_PATH;
5836 r = MsiGetPropertyA(hpkg, "VersionMsi", buf, &size);
5837 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5838 trace("VersionMsi = %s\n", buf);
5840 buf[0] = 0;
5841 size = MAX_PATH;
5842 r = MsiGetPropertyA(hpkg, "Date", buf, &size);
5843 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5844 trace("Date = %s\n", buf);
5846 buf[0] = 0;
5847 size = MAX_PATH;
5848 r = MsiGetPropertyA(hpkg, "Time", buf, &size);
5849 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5850 trace("Time = %s\n", buf);
5852 buf[0] = 0;
5853 size = MAX_PATH;
5854 r = MsiGetPropertyA(hpkg, "PackageCode", buf, &size);
5855 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5856 trace("PackageCode = %s\n", buf);
5858 buf[0] = 0;
5859 size = MAX_PATH;
5860 r = MsiGetPropertyA(hpkg, "ComputerName", buf, &size);
5861 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5862 trace("ComputerName = %s\n", buf);
5864 langid = GetUserDefaultLangID();
5865 sprintf(path, "%d", langid);
5867 buf[0] = 0;
5868 size = MAX_PATH;
5869 r = MsiGetPropertyA(hpkg, "UserLanguageID", buf, &size);
5870 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5871 ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
5873 res = GetSystemMetrics(SM_CXSCREEN);
5874 buf[0] = 0;
5875 size = MAX_PATH;
5876 r = MsiGetPropertyA(hpkg, "ScreenX", buf, &size);
5877 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5878 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5880 res = GetSystemMetrics(SM_CYSCREEN);
5881 buf[0] = 0;
5882 size = MAX_PATH;
5883 r = MsiGetPropertyA(hpkg, "ScreenY", buf, &size);
5884 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5885 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5887 if (pGetSystemInfo && pSHGetFolderPathA)
5889 pGetSystemInfo(&si);
5890 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
5892 buf[0] = 0;
5893 size = MAX_PATH;
5894 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5895 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5896 ok(buf[0], "property not set\n");
5898 buf[0] = 0;
5899 size = MAX_PATH;
5900 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5901 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5902 ok(buf[0], "property not set\n");
5904 buf[0] = 0;
5905 size = MAX_PATH;
5906 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5907 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5908 ok(buf[0], "property not set\n");
5910 buf[0] = 0;
5911 size = MAX_PATH;
5912 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5913 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5914 GetSystemDirectoryA(path, MAX_PATH);
5915 if (size) buf[size - 1] = 0;
5916 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5918 buf[0] = 0;
5919 size = MAX_PATH;
5920 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5921 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5922 pGetSystemWow64DirectoryA(path, MAX_PATH);
5923 if (size) buf[size - 1] = 0;
5924 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5926 buf[0] = 0;
5927 size = MAX_PATH;
5928 r = MsiGetPropertyA(hpkg, "ProgramFiles64Folder", buf, &size);
5929 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5930 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5931 if (size) buf[size - 1] = 0;
5932 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5934 buf[0] = 0;
5935 size = MAX_PATH;
5936 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
5937 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5938 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5939 if (size) buf[size - 1] = 0;
5940 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5942 buf[0] = 0;
5943 size = MAX_PATH;
5944 r = MsiGetPropertyA(hpkg, "CommonFiles64Folder", buf, &size);
5945 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5946 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5947 if (size) buf[size - 1] = 0;
5948 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5950 buf[0] = 0;
5951 size = MAX_PATH;
5952 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
5953 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5954 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5955 if (size) buf[size - 1] = 0;
5956 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5958 buf[0] = 0;
5959 size = MAX_PATH;
5960 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
5961 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5962 ok(buf[0], "property not set\n");
5964 else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
5966 if (!is_wow64)
5968 buf[0] = 0;
5969 size = MAX_PATH;
5970 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5971 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5972 ok(buf[0], "property not set\n");
5974 buf[0] = 0;
5975 size = MAX_PATH;
5976 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5977 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5978 ok(!buf[0], "property set\n");
5980 buf[0] = 0;
5981 size = MAX_PATH;
5982 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5983 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5984 ok(!buf[0], "property set\n");
5986 buf[0] = 0;
5987 size = MAX_PATH;
5988 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5989 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5990 ok(!buf[0], "property set\n");
5992 buf[0] = 0;
5993 size = MAX_PATH;
5994 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5995 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5996 GetSystemDirectoryA(path, MAX_PATH);
5997 if (size) buf[size - 1] = 0;
5998 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6000 buf[0] = 0;
6001 size = MAX_PATH;
6002 r = MsiGetPropertyA(hpkg, "ProgramFiles64Folder", buf, &size);
6003 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6004 ok(!buf[0], "property set\n");
6006 buf[0] = 0;
6007 size = MAX_PATH;
6008 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
6009 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6010 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
6011 if (size) buf[size - 1] = 0;
6012 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6014 buf[0] = 0;
6015 size = MAX_PATH;
6016 r = MsiGetPropertyA(hpkg, "CommonFiles64Folder", buf, &size);
6017 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6018 ok(!buf[0], "property set\n");
6020 buf[0] = 0;
6021 size = MAX_PATH;
6022 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
6023 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6024 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
6025 if (size) buf[size - 1] = 0;
6026 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6028 buf[0] = 0;
6029 size = MAX_PATH;
6030 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
6031 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6032 ok(!buf[0], "property set\n");
6034 else
6036 buf[0] = 0;
6037 size = MAX_PATH;
6038 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
6039 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6040 ok(buf[0], "property not set\n");
6042 buf[0] = 0;
6043 size = MAX_PATH;
6044 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
6045 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6046 ok(buf[0], "property not set\n");
6048 buf[0] = 0;
6049 size = MAX_PATH;
6050 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
6051 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6052 ok(buf[0], "property not set\n");
6054 buf[0] = 0;
6055 size = MAX_PATH;
6056 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
6057 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6058 GetSystemDirectoryA(path, MAX_PATH);
6059 if (size) buf[size - 1] = 0;
6060 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6062 buf[0] = 0;
6063 size = MAX_PATH;
6064 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
6065 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6066 pGetSystemWow64DirectoryA(path, MAX_PATH);
6067 if (size) buf[size - 1] = 0;
6068 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6070 buf[0] = 0;
6071 size = MAX_PATH;
6072 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder64", buf, &size);
6073 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6074 ok(!buf[0], "property set\n");
6076 buf[0] = 0;
6077 size = MAX_PATH;
6078 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
6079 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6080 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
6081 if (size) buf[size - 1] = 0;
6082 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6084 buf[0] = 0;
6085 size = MAX_PATH;
6086 r = MsiGetPropertyA(hpkg, "CommonFilesFolder64", buf, &size);
6087 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6088 ok(!buf[0], "property set\n");
6090 buf[0] = 0;
6091 size = MAX_PATH;
6092 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
6093 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6094 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
6095 if (size) buf[size - 1] = 0;
6096 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6098 buf[0] = 0;
6099 size = MAX_PATH;
6100 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
6101 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6102 ok(buf[0], "property not set\n");
6107 CloseHandle(hkey1);
6108 CloseHandle(hkey2);
6109 MsiCloseHandle(hpkg);
6110 DeleteFileA(msifile);
6111 MsiSetInternalUI(uilevel, NULL);
6114 static void test_launchconditions(void)
6116 MSIHANDLE hpkg;
6117 MSIHANDLE hdb;
6118 UINT r;
6120 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6122 hdb = create_package_db();
6123 ok( hdb, "failed to create package database\n" );
6125 r = create_launchcondition_table( hdb );
6126 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
6128 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
6129 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
6131 /* invalid condition */
6132 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
6133 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
6135 r = package_from_db( hdb, &hpkg );
6136 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6138 skip("Not enough rights to perform tests\n");
6139 DeleteFileA(msifile);
6140 return;
6142 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6144 MsiCloseHandle( hdb );
6146 r = MsiSetPropertyA( hpkg, "X", "1" );
6147 ok( r == ERROR_SUCCESS, "failed to set property\n" );
6149 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6151 /* invalid conditions are ignored */
6152 r = MsiDoActionA( hpkg, "LaunchConditions" );
6153 ok( r == ERROR_SUCCESS, "cost init failed\n" );
6155 /* verify LaunchConditions still does some verification */
6156 r = MsiSetPropertyA( hpkg, "X", "2" );
6157 ok( r == ERROR_SUCCESS, "failed to set property\n" );
6159 r = MsiDoActionA( hpkg, "LaunchConditions" );
6160 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
6162 MsiCloseHandle( hpkg );
6163 DeleteFileA( msifile );
6166 static void test_ccpsearch(void)
6168 MSIHANDLE hdb, hpkg;
6169 CHAR prop[MAX_PATH];
6170 DWORD size = MAX_PATH;
6171 UINT r;
6173 hdb = create_package_db();
6174 ok(hdb, "failed to create package database\n");
6176 r = create_ccpsearch_table(hdb);
6177 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6179 r = add_ccpsearch_entry(hdb, "'CCP_random'");
6180 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6182 r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
6183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6185 r = create_reglocator_table(hdb);
6186 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6188 r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
6189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6191 r = create_drlocator_table(hdb);
6192 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6194 r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
6195 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6197 r = create_signature_table(hdb);
6198 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6200 r = package_from_db(hdb, &hpkg);
6201 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6203 skip("Not enough rights to perform tests\n");
6204 DeleteFileA(msifile);
6205 return;
6207 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6209 MsiCloseHandle(hdb);
6211 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6213 r = MsiDoActionA(hpkg, "CCPSearch");
6214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6216 r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
6217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6218 ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
6220 MsiCloseHandle(hpkg);
6221 DeleteFileA(msifile);
6224 static void test_complocator(void)
6226 MSIHANDLE hdb, hpkg;
6227 UINT r;
6228 CHAR prop[MAX_PATH];
6229 CHAR expected[MAX_PATH];
6230 DWORD size = MAX_PATH;
6232 hdb = create_package_db();
6233 ok(hdb, "failed to create package database\n");
6235 r = create_appsearch_table(hdb);
6236 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6238 r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
6239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6241 r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
6242 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6244 r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
6245 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6247 r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
6248 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6250 r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
6251 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6253 r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
6254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6256 r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
6257 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6259 r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
6260 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6262 r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
6263 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6265 r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
6266 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6268 r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
6269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6271 r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
6272 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6274 r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
6275 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6277 r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
6278 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6280 r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
6281 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6283 r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
6284 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6286 r = create_complocator_table(hdb);
6287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6289 r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6290 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6292 r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6295 r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6298 r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6301 r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6302 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6304 r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6305 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6307 r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6310 r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6313 r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6314 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6316 r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6319 r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6322 r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6325 r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6326 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6328 r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6331 r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6332 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6334 r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6337 r = create_signature_table(hdb);
6338 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6340 r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6343 r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6346 r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6349 r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6350 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6352 r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6355 r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6358 r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6361 r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6364 r = package_from_db(hdb, &hpkg);
6365 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6367 skip("Not enough rights to perform tests\n");
6368 DeleteFileA(msifile);
6369 return;
6371 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6373 MsiCloseHandle(hdb);
6375 create_test_file("abelisaurus");
6376 create_test_file("bactrosaurus");
6377 create_test_file("camelotia");
6378 create_test_file("diclonius");
6379 create_test_file("echinodon");
6380 create_test_file("falcarius");
6381 create_test_file("gallimimus");
6382 create_test_file("hagryphus");
6383 CreateDirectoryA("iguanodon", NULL);
6384 CreateDirectoryA("jobaria", NULL);
6385 CreateDirectoryA("kakuru", NULL);
6386 CreateDirectoryA("labocania", NULL);
6387 CreateDirectoryA("megaraptor", NULL);
6388 CreateDirectoryA("neosodon", NULL);
6389 CreateDirectoryA("olorotitan", NULL);
6390 CreateDirectoryA("pantydraco", NULL);
6392 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
6393 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
6394 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
6395 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
6396 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
6397 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
6398 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
6399 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
6400 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
6401 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
6402 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
6403 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
6404 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
6405 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
6406 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
6407 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
6409 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6411 r = MsiDoActionA(hpkg, "AppSearch");
6412 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6414 size = MAX_PATH;
6415 r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
6416 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6418 lstrcpyA(expected, CURR_DIR);
6419 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6420 lstrcatA(expected, "abelisaurus");
6421 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6422 "Expected %s or empty string, got %s\n", expected, prop);
6424 size = MAX_PATH;
6425 r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
6426 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6427 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6429 size = MAX_PATH;
6430 r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
6431 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6432 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6434 size = MAX_PATH;
6435 r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
6436 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6437 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6439 size = MAX_PATH;
6440 r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
6441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6443 lstrcpyA(expected, CURR_DIR);
6444 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6445 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6446 "Expected %s or empty string, got %s\n", expected, prop);
6448 size = MAX_PATH;
6449 r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
6450 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6451 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6453 size = MAX_PATH;
6454 r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
6455 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6456 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6458 size = MAX_PATH;
6459 r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
6460 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6461 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6463 size = MAX_PATH;
6464 r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
6465 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6466 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6468 size = MAX_PATH;
6469 r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
6470 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6471 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6473 size = MAX_PATH;
6474 r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
6475 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6476 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6478 size = MAX_PATH;
6479 r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
6480 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6481 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6483 size = MAX_PATH;
6484 r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
6485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6487 lstrcpyA(expected, CURR_DIR);
6488 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6489 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6490 "Expected %s or empty string, got %s\n", expected, prop);
6492 size = MAX_PATH;
6493 r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
6494 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6496 lstrcpyA(expected, CURR_DIR);
6497 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6498 lstrcatA(expected, "neosodon\\");
6499 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6500 "Expected %s or empty string, got %s\n", expected, prop);
6502 size = MAX_PATH;
6503 r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
6504 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6505 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6507 size = MAX_PATH;
6508 r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
6509 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6510 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6512 MsiCloseHandle(hpkg);
6513 DeleteFileA("abelisaurus");
6514 DeleteFileA("bactrosaurus");
6515 DeleteFileA("camelotia");
6516 DeleteFileA("diclonius");
6517 DeleteFileA("echinodon");
6518 DeleteFileA("falcarius");
6519 DeleteFileA("gallimimus");
6520 DeleteFileA("hagryphus");
6521 RemoveDirectoryA("iguanodon");
6522 RemoveDirectoryA("jobaria");
6523 RemoveDirectoryA("kakuru");
6524 RemoveDirectoryA("labocania");
6525 RemoveDirectoryA("megaraptor");
6526 RemoveDirectoryA("neosodon");
6527 RemoveDirectoryA("olorotitan");
6528 RemoveDirectoryA("pantydraco");
6529 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6530 MSIINSTALLCONTEXT_MACHINE, NULL);
6531 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6532 MSIINSTALLCONTEXT_MACHINE, NULL);
6533 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6534 MSIINSTALLCONTEXT_MACHINE, NULL);
6535 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6536 MSIINSTALLCONTEXT_MACHINE, NULL);
6537 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6538 MSIINSTALLCONTEXT_MACHINE, NULL);
6539 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6540 MSIINSTALLCONTEXT_MACHINE, NULL);
6541 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6542 MSIINSTALLCONTEXT_MACHINE, NULL);
6543 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6544 MSIINSTALLCONTEXT_MACHINE, NULL);
6545 DeleteFileA(msifile);
6548 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
6550 MSIHANDLE summary;
6551 UINT r;
6553 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6554 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6556 r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
6557 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6559 r = MsiSummaryInfoPersist(summary);
6560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6562 MsiCloseHandle(summary);
6565 static void test_MsiGetSourcePath(void)
6567 MSIHANDLE hdb, hpkg;
6568 CHAR path[MAX_PATH];
6569 CHAR cwd[MAX_PATH];
6570 CHAR subsrc[MAX_PATH];
6571 CHAR sub2[MAX_PATH];
6572 DWORD size;
6573 UINT r;
6575 lstrcpyA(cwd, CURR_DIR);
6576 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
6578 lstrcpyA(subsrc, cwd);
6579 lstrcatA(subsrc, "subsource");
6580 lstrcatA(subsrc, "\\");
6582 lstrcpyA(sub2, subsrc);
6583 lstrcatA(sub2, "sub2");
6584 lstrcatA(sub2, "\\");
6586 /* uncompressed source */
6588 hdb = create_package_db();
6589 ok( hdb, "failed to create database\n");
6591 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
6593 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
6594 ok(r == S_OK, "failed\n");
6596 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6597 ok(r == S_OK, "failed\n");
6599 r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
6600 ok(r == S_OK, "failed\n");
6602 r = MsiDatabaseCommit(hdb);
6603 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6605 r = package_from_db(hdb, &hpkg);
6606 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6608 skip("Not enough rights to perform tests\n");
6609 DeleteFileA(msifile);
6610 return;
6612 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6614 MsiCloseHandle(hdb);
6616 /* invalid database handle */
6617 size = MAX_PATH;
6618 lstrcpyA(path, "kiwi");
6619 r = MsiGetSourcePathA(-1, "TARGETDIR", path, &size);
6620 ok(r == ERROR_INVALID_HANDLE,
6621 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
6622 ok(!lstrcmpA(path, "kiwi"),
6623 "Expected path to be unchanged, got \"%s\"\n", path);
6624 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6626 /* NULL szFolder */
6627 size = MAX_PATH;
6628 lstrcpyA(path, "kiwi");
6629 r = MsiGetSourcePathA(hpkg, NULL, path, &size);
6630 ok(r == ERROR_INVALID_PARAMETER,
6631 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6632 ok(!lstrcmpA(path, "kiwi"),
6633 "Expected path to be unchanged, got \"%s\"\n", path);
6634 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6636 /* empty szFolder */
6637 size = MAX_PATH;
6638 lstrcpyA(path, "kiwi");
6639 r = MsiGetSourcePathA(hpkg, "", path, &size);
6640 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6641 ok(!lstrcmpA(path, "kiwi"),
6642 "Expected path to be unchanged, got \"%s\"\n", path);
6643 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6645 /* try TARGETDIR */
6646 size = MAX_PATH;
6647 lstrcpyA(path, "kiwi");
6648 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6649 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6650 ok(!lstrcmpA(path, "kiwi"),
6651 "Expected path to be unchanged, got \"%s\"\n", path);
6652 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6654 size = MAX_PATH;
6655 lstrcpyA(path, "kiwi");
6656 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6657 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6658 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6659 ok(size == 0, "Expected 0, got %d\n", size);
6661 size = MAX_PATH;
6662 lstrcpyA(path, "kiwi");
6663 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6664 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6665 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6666 ok(size == 0, "Expected 0, got %d\n", size);
6668 /* try SourceDir */
6669 size = MAX_PATH;
6670 lstrcpyA(path, "kiwi");
6671 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6672 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6673 ok(!lstrcmpA(path, "kiwi"),
6674 "Expected path to be unchanged, got \"%s\"\n", path);
6675 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6677 /* try SOURCEDIR */
6678 size = MAX_PATH;
6679 lstrcpyA(path, "kiwi");
6680 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6681 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6682 ok(!lstrcmpA(path, "kiwi"),
6683 "Expected path to be unchanged, got \"%s\"\n", path);
6684 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6686 /* source path does not exist, but the property exists */
6687 size = MAX_PATH;
6688 lstrcpyA(path, "kiwi");
6689 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6690 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6691 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6692 ok(size == 0, "Expected 0, got %d\n", size);
6694 size = MAX_PATH;
6695 lstrcpyA(path, "kiwi");
6696 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6697 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6698 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6699 ok(size == 0, "Expected 0, got %d\n", size);
6701 /* try SubDir */
6702 size = MAX_PATH;
6703 lstrcpyA(path, "kiwi");
6704 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6705 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6706 ok(!lstrcmpA(path, "kiwi"),
6707 "Expected path to be unchanged, got \"%s\"\n", path);
6708 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6710 /* try SubDir2 */
6711 size = MAX_PATH;
6712 lstrcpyA(path, "kiwi");
6713 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6714 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6715 ok(!lstrcmpA(path, "kiwi"),
6716 "Expected path to be unchanged, got \"%s\"\n", path);
6717 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6719 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6721 r = MsiDoActionA(hpkg, "CostInitialize");
6722 ok(r == ERROR_SUCCESS, "cost init failed\n");
6724 /* try TARGETDIR after CostInitialize */
6725 size = MAX_PATH;
6726 lstrcpyA(path, "kiwi");
6727 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6729 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6730 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6732 /* try SourceDir after CostInitialize */
6733 size = MAX_PATH;
6734 lstrcpyA(path, "kiwi");
6735 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6736 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6737 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6738 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6740 /* try SOURCEDIR after CostInitialize */
6741 size = MAX_PATH;
6742 lstrcpyA(path, "kiwi");
6743 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6744 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6745 ok(!lstrcmpA(path, "kiwi"),
6746 "Expected path to be unchanged, got \"%s\"\n", path);
6747 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6749 /* source path does not exist, but the property exists */
6750 size = MAX_PATH;
6751 lstrcpyA(path, "kiwi");
6752 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6754 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6755 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6757 size = MAX_PATH;
6758 lstrcpyA(path, "kiwi");
6759 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6761 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6762 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6764 /* try SubDir after CostInitialize */
6765 size = MAX_PATH;
6766 lstrcpyA(path, "kiwi");
6767 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6768 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6769 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6770 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6772 /* try SubDir2 after CostInitialize */
6773 size = MAX_PATH;
6774 lstrcpyA(path, "kiwi");
6775 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6776 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6777 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6778 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6780 r = MsiDoActionA(hpkg, "ResolveSource");
6781 ok(r == ERROR_SUCCESS, "file cost failed\n");
6783 /* try TARGETDIR after ResolveSource */
6784 size = MAX_PATH;
6785 lstrcpyA(path, "kiwi");
6786 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6788 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6789 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6791 /* try SourceDir after ResolveSource */
6792 size = MAX_PATH;
6793 lstrcpyA(path, "kiwi");
6794 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6795 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6796 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6797 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6799 /* try SOURCEDIR after ResolveSource */
6800 size = MAX_PATH;
6801 lstrcpyA(path, "kiwi");
6802 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6803 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6804 ok(!lstrcmpA(path, "kiwi"),
6805 "Expected path to be unchanged, got \"%s\"\n", path);
6806 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6808 /* source path does not exist, but the property exists */
6809 size = MAX_PATH;
6810 lstrcpyA(path, "kiwi");
6811 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6812 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6813 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6814 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6816 size = MAX_PATH;
6817 lstrcpyA(path, "kiwi");
6818 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6819 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6820 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6821 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6823 /* try SubDir after ResolveSource */
6824 size = MAX_PATH;
6825 lstrcpyA(path, "kiwi");
6826 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6827 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6828 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6829 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6831 /* try SubDir2 after ResolveSource */
6832 size = MAX_PATH;
6833 lstrcpyA(path, "kiwi");
6834 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6835 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6836 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6837 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6839 r = MsiDoActionA(hpkg, "FileCost");
6840 ok(r == ERROR_SUCCESS, "file cost failed\n");
6842 /* try TARGETDIR after FileCost */
6843 size = MAX_PATH;
6844 lstrcpyA(path, "kiwi");
6845 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6846 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6847 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6848 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6850 /* try SourceDir after FileCost */
6851 size = MAX_PATH;
6852 lstrcpyA(path, "kiwi");
6853 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6854 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6855 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6856 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6858 /* try SOURCEDIR after FileCost */
6859 size = MAX_PATH;
6860 lstrcpyA(path, "kiwi");
6861 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6862 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6863 ok(!lstrcmpA(path, "kiwi"),
6864 "Expected path to be unchanged, got \"%s\"\n", path);
6865 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6867 /* source path does not exist, but the property exists */
6868 size = MAX_PATH;
6869 lstrcpyA(path, "kiwi");
6870 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6871 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6872 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6873 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6875 size = MAX_PATH;
6876 lstrcpyA(path, "kiwi");
6877 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6879 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6880 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6882 /* try SubDir after FileCost */
6883 size = MAX_PATH;
6884 lstrcpyA(path, "kiwi");
6885 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6887 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6888 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6890 /* try SubDir2 after FileCost */
6891 size = MAX_PATH;
6892 lstrcpyA(path, "kiwi");
6893 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6894 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6895 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6896 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6898 r = MsiDoActionA(hpkg, "CostFinalize");
6899 ok(r == ERROR_SUCCESS, "file cost failed\n");
6901 /* try TARGETDIR after CostFinalize */
6902 size = MAX_PATH;
6903 lstrcpyA(path, "kiwi");
6904 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6905 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6906 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6907 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6909 /* try SourceDir after CostFinalize */
6910 size = MAX_PATH;
6911 lstrcpyA(path, "kiwi");
6912 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6913 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6914 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6915 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6917 /* try SOURCEDIR after CostFinalize */
6918 size = MAX_PATH;
6919 lstrcpyA(path, "kiwi");
6920 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6921 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6922 ok(!lstrcmpA(path, "kiwi"),
6923 "Expected path to be unchanged, got \"%s\"\n", path);
6924 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6926 /* source path does not exist, but the property exists */
6927 size = MAX_PATH;
6928 lstrcpyA(path, "kiwi");
6929 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6930 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6931 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6932 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6934 size = MAX_PATH;
6935 lstrcpyA(path, "kiwi");
6936 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6938 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6939 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6941 /* try SubDir after CostFinalize */
6942 size = MAX_PATH;
6943 lstrcpyA(path, "kiwi");
6944 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6945 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6946 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6947 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6949 /* try SubDir2 after CostFinalize */
6950 size = MAX_PATH;
6951 lstrcpyA(path, "kiwi");
6952 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6953 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6954 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6955 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6957 /* nonexistent directory */
6958 size = MAX_PATH;
6959 lstrcpyA(path, "kiwi");
6960 r = MsiGetSourcePathA(hpkg, "IDontExist", path, &size);
6961 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6962 ok(!lstrcmpA(path, "kiwi"),
6963 "Expected path to be unchanged, got \"%s\"\n", path);
6964 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6966 /* NULL szPathBuf */
6967 size = MAX_PATH;
6968 r = MsiGetSourcePathA(hpkg, "SourceDir", NULL, &size);
6969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6970 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6972 /* NULL pcchPathBuf */
6973 lstrcpyA(path, "kiwi");
6974 r = MsiGetSourcePathA(hpkg, "SourceDir", path, NULL);
6975 ok(r == ERROR_INVALID_PARAMETER,
6976 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6977 ok(!lstrcmpA(path, "kiwi"),
6978 "Expected path to be unchanged, got \"%s\"\n", path);
6980 /* pcchPathBuf is 0 */
6981 size = 0;
6982 lstrcpyA(path, "kiwi");
6983 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6984 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6985 ok(!lstrcmpA(path, "kiwi"),
6986 "Expected path to be unchanged, got \"%s\"\n", path);
6987 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6989 /* pcchPathBuf does not have room for NULL terminator */
6990 size = lstrlenA(cwd);
6991 lstrcpyA(path, "kiwi");
6992 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6993 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6994 ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
6995 "Expected path with no backslash, got \"%s\"\n", path);
6996 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6998 /* pcchPathBuf has room for NULL terminator */
6999 size = lstrlenA(cwd) + 1;
7000 lstrcpyA(path, "kiwi");
7001 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7002 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7003 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7004 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7006 /* remove property */
7007 r = MsiSetPropertyA(hpkg, "SourceDir", NULL);
7008 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7010 /* try SourceDir again */
7011 size = MAX_PATH;
7012 lstrcpyA(path, "kiwi");
7013 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7015 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7016 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7018 /* set property to a valid directory */
7019 r = MsiSetPropertyA(hpkg, "SOURCEDIR", cwd);
7020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7022 /* try SOURCEDIR again */
7023 size = MAX_PATH;
7024 lstrcpyA(path, "kiwi");
7025 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7026 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7027 ok(!lstrcmpA(path, "kiwi"),
7028 "Expected path to be unchanged, got \"%s\"\n", path);
7029 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7031 MsiCloseHandle(hpkg);
7033 /* compressed source */
7035 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
7036 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7038 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
7040 r = package_from_db(hdb, &hpkg);
7041 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7043 /* try TARGETDIR */
7044 size = MAX_PATH;
7045 lstrcpyA(path, "kiwi");
7046 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7047 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7048 ok(!lstrcmpA(path, "kiwi"),
7049 "Expected path to be unchanged, got \"%s\"\n", path);
7050 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7052 /* try SourceDir */
7053 size = MAX_PATH;
7054 lstrcpyA(path, "kiwi");
7055 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7056 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7057 ok(!lstrcmpA(path, "kiwi"),
7058 "Expected path to be unchanged, got \"%s\"\n", path);
7059 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7061 /* try SOURCEDIR */
7062 size = MAX_PATH;
7063 lstrcpyA(path, "kiwi");
7064 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7065 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7066 ok(!lstrcmpA(path, "kiwi"),
7067 "Expected path to be unchanged, got \"%s\"\n", path);
7068 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7070 /* source path nor the property exist */
7071 size = MAX_PATH;
7072 lstrcpyA(path, "kiwi");
7073 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7074 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7075 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7076 ok(size == 0, "Expected 0, got %d\n", size);
7078 size = MAX_PATH;
7079 lstrcpyA(path, "kiwi");
7080 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7082 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7083 ok(size == 0, "Expected 0, got %d\n", size);
7085 /* try SubDir */
7086 size = MAX_PATH;
7087 lstrcpyA(path, "kiwi");
7088 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7089 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7090 ok(!lstrcmpA(path, "kiwi"),
7091 "Expected path to be unchanged, got \"%s\"\n", path);
7092 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7094 /* try SubDir2 */
7095 size = MAX_PATH;
7096 lstrcpyA(path, "kiwi");
7097 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7098 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7099 ok(!lstrcmpA(path, "kiwi"),
7100 "Expected path to be unchanged, got \"%s\"\n", path);
7101 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7103 r = MsiDoActionA(hpkg, "CostInitialize");
7104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7106 /* try TARGETDIR after CostInitialize */
7107 size = MAX_PATH;
7108 lstrcpyA(path, "kiwi");
7109 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7111 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7112 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7114 /* try SourceDir after CostInitialize */
7115 size = MAX_PATH;
7116 lstrcpyA(path, "kiwi");
7117 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7118 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7119 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7120 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7122 /* try SOURCEDIR after CostInitialize */
7123 size = MAX_PATH;
7124 lstrcpyA(path, "kiwi");
7125 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7126 todo_wine
7128 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7129 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7130 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7133 /* source path does not exist, but the property exists */
7134 size = MAX_PATH;
7135 lstrcpyA(path, "kiwi");
7136 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7137 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7138 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7139 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7141 size = MAX_PATH;
7142 lstrcpyA(path, "kiwi");
7143 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7144 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7145 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7146 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7148 /* try SubDir after CostInitialize */
7149 size = MAX_PATH;
7150 lstrcpyA(path, "kiwi");
7151 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7152 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7153 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7154 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7156 /* try SubDir2 after CostInitialize */
7157 size = MAX_PATH;
7158 lstrcpyA(path, "kiwi");
7159 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7160 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7161 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7162 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7164 r = MsiDoActionA(hpkg, "ResolveSource");
7165 ok(r == ERROR_SUCCESS, "file cost failed\n");
7167 /* try TARGETDIR after ResolveSource */
7168 size = MAX_PATH;
7169 lstrcpyA(path, "kiwi");
7170 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7171 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7172 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7173 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7175 /* try SourceDir after ResolveSource */
7176 size = MAX_PATH;
7177 lstrcpyA(path, "kiwi");
7178 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7180 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7181 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7183 /* try SOURCEDIR after ResolveSource */
7184 size = MAX_PATH;
7185 lstrcpyA(path, "kiwi");
7186 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7187 todo_wine
7189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7190 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7191 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7194 /* source path and the property exist */
7195 size = MAX_PATH;
7196 lstrcpyA(path, "kiwi");
7197 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7198 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7199 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7200 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7202 size = MAX_PATH;
7203 lstrcpyA(path, "kiwi");
7204 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7205 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7206 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7207 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7209 /* try SubDir after ResolveSource */
7210 size = MAX_PATH;
7211 lstrcpyA(path, "kiwi");
7212 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7213 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7214 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7215 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7217 /* try SubDir2 after ResolveSource */
7218 size = MAX_PATH;
7219 lstrcpyA(path, "kiwi");
7220 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7221 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7222 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7223 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7225 r = MsiDoActionA(hpkg, "FileCost");
7226 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7228 /* try TARGETDIR after CostFinalize */
7229 size = MAX_PATH;
7230 lstrcpyA(path, "kiwi");
7231 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7233 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7234 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7236 /* try SourceDir after CostFinalize */
7237 size = MAX_PATH;
7238 lstrcpyA(path, "kiwi");
7239 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7240 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7241 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7242 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7244 /* try SOURCEDIR after CostFinalize */
7245 size = MAX_PATH;
7246 lstrcpyA(path, "kiwi");
7247 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7248 todo_wine
7250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7251 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7252 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7255 /* source path and the property exist */
7256 size = MAX_PATH;
7257 lstrcpyA(path, "kiwi");
7258 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7260 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7261 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7263 size = MAX_PATH;
7264 lstrcpyA(path, "kiwi");
7265 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7266 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7267 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7268 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7270 /* try SubDir after CostFinalize */
7271 size = MAX_PATH;
7272 lstrcpyA(path, "kiwi");
7273 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7275 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7276 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7278 /* try SubDir2 after CostFinalize */
7279 size = MAX_PATH;
7280 lstrcpyA(path, "kiwi");
7281 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7282 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7283 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7284 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7286 r = MsiDoActionA(hpkg, "CostFinalize");
7287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7289 /* try TARGETDIR after CostFinalize */
7290 size = MAX_PATH;
7291 lstrcpyA(path, "kiwi");
7292 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7294 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7295 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7297 /* try SourceDir after CostFinalize */
7298 size = MAX_PATH;
7299 lstrcpyA(path, "kiwi");
7300 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7301 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7302 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7303 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7305 /* try SOURCEDIR after CostFinalize */
7306 size = MAX_PATH;
7307 lstrcpyA(path, "kiwi");
7308 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7309 todo_wine
7311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7312 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7313 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7316 /* source path and the property exist */
7317 size = MAX_PATH;
7318 lstrcpyA(path, "kiwi");
7319 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7321 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7322 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7324 size = MAX_PATH;
7325 lstrcpyA(path, "kiwi");
7326 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7327 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7328 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7329 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7331 /* try SubDir after CostFinalize */
7332 size = MAX_PATH;
7333 lstrcpyA(path, "kiwi");
7334 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7336 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7337 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7339 /* try SubDir2 after CostFinalize */
7340 size = MAX_PATH;
7341 lstrcpyA(path, "kiwi");
7342 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7343 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7344 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7345 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7347 MsiCloseHandle(hpkg);
7348 DeleteFileA(msifile);
7351 static void test_shortlongsource(void)
7353 MSIHANDLE hdb, hpkg;
7354 CHAR path[MAX_PATH];
7355 CHAR cwd[MAX_PATH];
7356 CHAR subsrc[MAX_PATH];
7357 DWORD size;
7358 UINT r;
7360 lstrcpyA(cwd, CURR_DIR);
7361 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
7363 lstrcpyA(subsrc, cwd);
7364 lstrcatA(subsrc, "long");
7365 lstrcatA(subsrc, "\\");
7367 /* long file names */
7369 hdb = create_package_db();
7370 ok( hdb, "failed to create database\n");
7372 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7374 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7375 ok(r == S_OK, "failed\n");
7377 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
7378 ok(r == S_OK, "failed\n");
7380 /* CostInitialize:short */
7381 r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
7382 ok(r == S_OK, "failed\n");
7384 /* CostInitialize:long */
7385 r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
7386 ok(r == S_OK, "failed\n");
7388 /* FileCost:short */
7389 r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
7390 ok(r == S_OK, "failed\n");
7392 /* FileCost:long */
7393 r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7394 ok(r == S_OK, "failed\n");
7396 /* CostFinalize:short */
7397 r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7398 ok(r == S_OK, "failed\n");
7400 /* CostFinalize:long */
7401 r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7402 ok(r == S_OK, "failed\n");
7404 MsiDatabaseCommit(hdb);
7406 r = package_from_db(hdb, &hpkg);
7407 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7409 skip("Not enough rights to perform tests\n");
7410 DeleteFileA(msifile);
7411 return;
7413 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7415 MsiCloseHandle(hdb);
7417 CreateDirectoryA("one", NULL);
7418 CreateDirectoryA("four", NULL);
7420 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7422 r = MsiDoActionA(hpkg, "CostInitialize");
7423 ok(r == ERROR_SUCCESS, "file cost failed\n");
7425 CreateDirectoryA("five", NULL);
7426 CreateDirectoryA("eight", NULL);
7428 r = MsiDoActionA(hpkg, "FileCost");
7429 ok(r == ERROR_SUCCESS, "file cost failed\n");
7431 CreateDirectoryA("nine", NULL);
7432 CreateDirectoryA("twelve", NULL);
7434 r = MsiDoActionA(hpkg, "CostFinalize");
7435 ok(r == ERROR_SUCCESS, "file cost failed\n");
7437 /* neither short nor long source directories exist */
7438 size = MAX_PATH;
7439 lstrcpyA(path, "kiwi");
7440 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7441 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7442 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7443 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7445 CreateDirectoryA("short", NULL);
7447 /* short source directory exists */
7448 size = MAX_PATH;
7449 lstrcpyA(path, "kiwi");
7450 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7451 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7452 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7453 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7455 CreateDirectoryA("long", NULL);
7457 /* both short and long source directories exist */
7458 size = MAX_PATH;
7459 lstrcpyA(path, "kiwi");
7460 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7461 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7462 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7463 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7465 lstrcpyA(subsrc, cwd);
7466 lstrcatA(subsrc, "two");
7467 lstrcatA(subsrc, "\\");
7469 /* short dir exists before CostInitialize */
7470 size = MAX_PATH;
7471 lstrcpyA(path, "kiwi");
7472 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7473 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7474 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7475 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7477 lstrcpyA(subsrc, cwd);
7478 lstrcatA(subsrc, "four");
7479 lstrcatA(subsrc, "\\");
7481 /* long dir exists before CostInitialize */
7482 size = MAX_PATH;
7483 lstrcpyA(path, "kiwi");
7484 r = MsiGetSourcePathA(hpkg, "SubDir3", path, &size);
7485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7486 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7487 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7489 lstrcpyA(subsrc, cwd);
7490 lstrcatA(subsrc, "six");
7491 lstrcatA(subsrc, "\\");
7493 /* short dir exists before FileCost */
7494 size = MAX_PATH;
7495 lstrcpyA(path, "kiwi");
7496 r = MsiGetSourcePathA(hpkg, "SubDir4", path, &size);
7497 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7498 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7499 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7501 lstrcpyA(subsrc, cwd);
7502 lstrcatA(subsrc, "eight");
7503 lstrcatA(subsrc, "\\");
7505 /* long dir exists before FileCost */
7506 size = MAX_PATH;
7507 lstrcpyA(path, "kiwi");
7508 r = MsiGetSourcePathA(hpkg, "SubDir5", path, &size);
7509 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7510 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7511 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7513 lstrcpyA(subsrc, cwd);
7514 lstrcatA(subsrc, "ten");
7515 lstrcatA(subsrc, "\\");
7517 /* short dir exists before CostFinalize */
7518 size = MAX_PATH;
7519 lstrcpyA(path, "kiwi");
7520 r = MsiGetSourcePathA(hpkg, "SubDir6", path, &size);
7521 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7522 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7523 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7525 lstrcpyA(subsrc, cwd);
7526 lstrcatA(subsrc, "twelve");
7527 lstrcatA(subsrc, "\\");
7529 /* long dir exists before CostFinalize */
7530 size = MAX_PATH;
7531 lstrcpyA(path, "kiwi");
7532 r = MsiGetSourcePathA(hpkg, "SubDir7", path, &size);
7533 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7534 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7535 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7537 MsiCloseHandle(hpkg);
7538 RemoveDirectoryA("short");
7539 RemoveDirectoryA("long");
7540 RemoveDirectoryA("one");
7541 RemoveDirectoryA("four");
7542 RemoveDirectoryA("five");
7543 RemoveDirectoryA("eight");
7544 RemoveDirectoryA("nine");
7545 RemoveDirectoryA("twelve");
7547 /* short file names */
7549 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
7550 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7552 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
7554 r = package_from_db(hdb, &hpkg);
7555 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7557 MsiCloseHandle(hdb);
7559 CreateDirectoryA("one", NULL);
7560 CreateDirectoryA("four", NULL);
7562 r = MsiDoActionA(hpkg, "CostInitialize");
7563 ok(r == ERROR_SUCCESS, "file cost failed\n");
7565 CreateDirectoryA("five", NULL);
7566 CreateDirectoryA("eight", NULL);
7568 r = MsiDoActionA(hpkg, "FileCost");
7569 ok(r == ERROR_SUCCESS, "file cost failed\n");
7571 CreateDirectoryA("nine", NULL);
7572 CreateDirectoryA("twelve", NULL);
7574 r = MsiDoActionA(hpkg, "CostFinalize");
7575 ok(r == ERROR_SUCCESS, "file cost failed\n");
7577 lstrcpyA(subsrc, cwd);
7578 lstrcatA(subsrc, "short");
7579 lstrcatA(subsrc, "\\");
7581 /* neither short nor long source directories exist */
7582 size = MAX_PATH;
7583 lstrcpyA(path, "kiwi");
7584 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7585 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7586 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7587 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7589 CreateDirectoryA("short", NULL);
7591 /* short source directory exists */
7592 size = MAX_PATH;
7593 lstrcpyA(path, "kiwi");
7594 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7596 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7597 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7599 CreateDirectoryA("long", NULL);
7601 /* both short and long source directories exist */
7602 size = MAX_PATH;
7603 lstrcpyA(path, "kiwi");
7604 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7605 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7606 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7607 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7609 lstrcpyA(subsrc, cwd);
7610 lstrcatA(subsrc, "one");
7611 lstrcatA(subsrc, "\\");
7613 /* short dir exists before CostInitialize */
7614 size = MAX_PATH;
7615 lstrcpyA(path, "kiwi");
7616 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7617 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7618 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7619 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7621 lstrcpyA(subsrc, cwd);
7622 lstrcatA(subsrc, "three");
7623 lstrcatA(subsrc, "\\");
7625 /* long dir exists before CostInitialize */
7626 size = MAX_PATH;
7627 lstrcpyA(path, "kiwi");
7628 r = MsiGetSourcePathA(hpkg, "SubDir3", path, &size);
7629 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7630 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7631 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7633 lstrcpyA(subsrc, cwd);
7634 lstrcatA(subsrc, "five");
7635 lstrcatA(subsrc, "\\");
7637 /* short dir exists before FileCost */
7638 size = MAX_PATH;
7639 lstrcpyA(path, "kiwi");
7640 r = MsiGetSourcePathA(hpkg, "SubDir4", path, &size);
7641 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7642 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7643 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7645 lstrcpyA(subsrc, cwd);
7646 lstrcatA(subsrc, "seven");
7647 lstrcatA(subsrc, "\\");
7649 /* long dir exists before FileCost */
7650 size = MAX_PATH;
7651 lstrcpyA(path, "kiwi");
7652 r = MsiGetSourcePathA(hpkg, "SubDir5", path, &size);
7653 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7654 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7655 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7657 lstrcpyA(subsrc, cwd);
7658 lstrcatA(subsrc, "nine");
7659 lstrcatA(subsrc, "\\");
7661 /* short dir exists before CostFinalize */
7662 size = MAX_PATH;
7663 lstrcpyA(path, "kiwi");
7664 r = MsiGetSourcePathA(hpkg, "SubDir6", path, &size);
7665 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7666 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7667 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7669 lstrcpyA(subsrc, cwd);
7670 lstrcatA(subsrc, "eleven");
7671 lstrcatA(subsrc, "\\");
7673 /* long dir exists before CostFinalize */
7674 size = MAX_PATH;
7675 lstrcpyA(path, "kiwi");
7676 r = MsiGetSourcePathA(hpkg, "SubDir7", path, &size);
7677 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7678 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7679 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7681 MsiCloseHandle(hpkg);
7682 RemoveDirectoryA("short");
7683 RemoveDirectoryA("long");
7684 RemoveDirectoryA("one");
7685 RemoveDirectoryA("four");
7686 RemoveDirectoryA("five");
7687 RemoveDirectoryA("eight");
7688 RemoveDirectoryA("nine");
7689 RemoveDirectoryA("twelve");
7690 DeleteFileA(msifile);
7693 static void test_sourcedir(void)
7695 MSIHANDLE hdb, hpkg;
7696 CHAR package[12];
7697 CHAR path[MAX_PATH];
7698 CHAR cwd[MAX_PATH];
7699 CHAR subsrc[MAX_PATH];
7700 DWORD size;
7701 UINT r;
7703 lstrcpyA(cwd, CURR_DIR);
7704 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
7706 lstrcpyA(subsrc, cwd);
7707 lstrcatA(subsrc, "long");
7708 lstrcatA(subsrc, "\\");
7710 hdb = create_package_db();
7711 ok( hdb, "failed to create database\n");
7713 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7714 ok(r == S_OK, "failed\n");
7716 sprintf(package, "#%u", hdb);
7717 r = MsiOpenPackageA(package, &hpkg);
7718 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7720 skip("Not enough rights to perform tests\n");
7721 goto error;
7723 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7725 /* properties only */
7727 /* SourceDir prop */
7728 size = MAX_PATH;
7729 lstrcpyA(path, "kiwi");
7730 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7731 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7732 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7733 ok(size == 0, "Expected 0, got %d\n", size);
7735 /* SOURCEDIR prop */
7736 size = MAX_PATH;
7737 lstrcpyA(path, "kiwi");
7738 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7739 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7740 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7741 ok(size == 0, "Expected 0, got %d\n", size);
7743 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7745 r = MsiDoActionA(hpkg, "CostInitialize");
7746 ok(r == ERROR_SUCCESS, "file cost failed\n");
7748 /* SourceDir after CostInitialize */
7749 size = MAX_PATH;
7750 lstrcpyA(path, "kiwi");
7751 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7752 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7753 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7754 ok(size == 0, "Expected 0, got %d\n", size);
7756 /* SOURCEDIR after CostInitialize */
7757 size = MAX_PATH;
7758 lstrcpyA(path, "kiwi");
7759 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7761 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7762 ok(size == 0, "Expected 0, got %d\n", size);
7764 r = MsiDoActionA(hpkg, "FileCost");
7765 ok(r == ERROR_SUCCESS, "file cost failed\n");
7767 /* SourceDir after FileCost */
7768 size = MAX_PATH;
7769 lstrcpyA(path, "kiwi");
7770 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7771 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7772 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7773 ok(size == 0, "Expected 0, got %d\n", size);
7775 /* SOURCEDIR after FileCost */
7776 size = MAX_PATH;
7777 lstrcpyA(path, "kiwi");
7778 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7780 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7781 ok(size == 0, "Expected 0, got %d\n", size);
7783 r = MsiDoActionA(hpkg, "CostFinalize");
7784 ok(r == ERROR_SUCCESS, "file cost failed\n");
7786 /* SourceDir after CostFinalize */
7787 size = MAX_PATH;
7788 lstrcpyA(path, "kiwi");
7789 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7790 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7791 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7792 ok(size == 0, "Expected 0, got %d\n", size);
7794 /* SOURCEDIR after CostFinalize */
7795 size = MAX_PATH;
7796 lstrcpyA(path, "kiwi");
7797 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7798 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7799 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7800 ok(size == 0, "Expected 0, got %d\n", size);
7802 size = MAX_PATH;
7803 lstrcpyA(path, "kiwi");
7804 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7805 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7806 ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
7807 ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
7809 /* SOURCEDIR after calling MsiGetSourcePath */
7810 size = MAX_PATH;
7811 lstrcpyA(path, "kiwi");
7812 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7813 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7814 todo_wine {
7815 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7816 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7819 r = MsiDoActionA(hpkg, "ResolveSource");
7820 ok(r == ERROR_SUCCESS, "file cost failed\n");
7822 /* SourceDir after ResolveSource */
7823 size = MAX_PATH;
7824 lstrcpyA(path, "kiwi");
7825 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7826 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7827 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7828 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7830 /* SOURCEDIR after ResolveSource */
7831 size = MAX_PATH;
7832 lstrcpyA(path, "kiwi");
7833 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7834 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7835 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7836 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7838 /* random casing */
7839 size = MAX_PATH;
7840 lstrcpyA(path, "kiwi");
7841 r = MsiGetPropertyA(hpkg, "SoUrCeDiR", path, &size);
7842 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7843 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7844 ok(size == 0, "Expected 0, got %d\n", size);
7846 MsiCloseHandle(hpkg);
7848 /* reset the package state */
7849 sprintf(package, "#%i", hdb);
7850 r = MsiOpenPackageA(package, &hpkg);
7851 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7853 /* test how MsiGetSourcePath affects the properties */
7855 /* SourceDir prop */
7856 size = MAX_PATH;
7857 lstrcpyA(path, "kiwi");
7858 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7859 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7860 todo_wine
7862 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7863 ok(size == 0, "Expected 0, got %d\n", size);
7866 size = MAX_PATH;
7867 lstrcpyA(path, "kiwi");
7868 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7869 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7870 ok(!lstrcmpA(path, "kiwi"),
7871 "Expected path to be unchanged, got \"%s\"\n", path);
7872 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7874 /* SourceDir after MsiGetSourcePath */
7875 size = MAX_PATH;
7876 lstrcpyA(path, "kiwi");
7877 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7879 todo_wine
7881 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7882 ok(size == 0, "Expected 0, got %d\n", size);
7885 /* SOURCEDIR prop */
7886 size = MAX_PATH;
7887 lstrcpyA(path, "kiwi");
7888 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7889 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7890 todo_wine
7892 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7893 ok(size == 0, "Expected 0, got %d\n", size);
7896 size = MAX_PATH;
7897 lstrcpyA(path, "kiwi");
7898 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7899 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7900 ok(!lstrcmpA(path, "kiwi"),
7901 "Expected path to be unchanged, got \"%s\"\n", path);
7902 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7904 /* SOURCEDIR prop after MsiGetSourcePath */
7905 size = MAX_PATH;
7906 lstrcpyA(path, "kiwi");
7907 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7909 todo_wine
7911 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7912 ok(size == 0, "Expected 0, got %d\n", size);
7915 r = MsiDoActionA(hpkg, "CostInitialize");
7916 ok(r == ERROR_SUCCESS, "file cost failed\n");
7918 /* SourceDir after CostInitialize */
7919 size = MAX_PATH;
7920 lstrcpyA(path, "kiwi");
7921 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7922 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7923 todo_wine
7925 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7926 ok(size == 0, "Expected 0, got %d\n", size);
7929 size = MAX_PATH;
7930 lstrcpyA(path, "kiwi");
7931 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7932 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7933 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7934 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7936 /* SourceDir after MsiGetSourcePath */
7937 size = MAX_PATH;
7938 lstrcpyA(path, "kiwi");
7939 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7940 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7941 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7942 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7944 /* SOURCEDIR after CostInitialize */
7945 size = MAX_PATH;
7946 lstrcpyA(path, "kiwi");
7947 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7948 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7949 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7950 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7952 /* SOURCEDIR source path still does not exist */
7953 size = MAX_PATH;
7954 lstrcpyA(path, "kiwi");
7955 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7956 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7957 ok(!lstrcmpA(path, "kiwi"),
7958 "Expected path to be unchanged, got \"%s\"\n", path);
7959 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7961 r = MsiDoActionA(hpkg, "FileCost");
7962 ok(r == ERROR_SUCCESS, "file cost failed\n");
7964 /* SourceDir after FileCost */
7965 size = MAX_PATH;
7966 lstrcpyA(path, "kiwi");
7967 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7968 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7969 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7970 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7972 /* SOURCEDIR after FileCost */
7973 size = MAX_PATH;
7974 lstrcpyA(path, "kiwi");
7975 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7976 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7977 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7978 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7980 /* SOURCEDIR source path still does not exist */
7981 size = MAX_PATH;
7982 lstrcpyA(path, "kiwi");
7983 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7984 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7985 ok(!lstrcmpA(path, "kiwi"),
7986 "Expected path to be unchanged, got \"%s\"\n", path);
7987 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7989 r = MsiDoActionA(hpkg, "CostFinalize");
7990 ok(r == ERROR_SUCCESS, "file cost failed\n");
7992 /* SourceDir after CostFinalize */
7993 size = MAX_PATH;
7994 lstrcpyA(path, "kiwi");
7995 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7996 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7997 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7998 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8000 /* SOURCEDIR after CostFinalize */
8001 size = MAX_PATH;
8002 lstrcpyA(path, "kiwi");
8003 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
8004 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8005 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8006 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8008 /* SOURCEDIR source path still does not exist */
8009 size = MAX_PATH;
8010 lstrcpyA(path, "kiwi");
8011 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
8012 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8013 ok(!lstrcmpA(path, "kiwi"),
8014 "Expected path to be unchanged, got \"%s\"\n", path);
8015 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8017 r = MsiDoActionA(hpkg, "ResolveSource");
8018 ok(r == ERROR_SUCCESS, "file cost failed\n");
8020 /* SourceDir after ResolveSource */
8021 size = MAX_PATH;
8022 lstrcpyA(path, "kiwi");
8023 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
8024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8025 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8026 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8028 /* SOURCEDIR after ResolveSource */
8029 size = MAX_PATH;
8030 lstrcpyA(path, "kiwi");
8031 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
8032 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8033 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
8034 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
8036 /* SOURCEDIR source path still does not exist */
8037 size = MAX_PATH;
8038 lstrcpyA(path, "kiwi");
8039 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
8040 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
8041 ok(!lstrcmpA(path, "kiwi"),
8042 "Expected path to be unchanged, got \"%s\"\n", path);
8043 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8045 MsiCloseHandle(hpkg);
8047 error:
8048 MsiCloseHandle(hdb);
8049 DeleteFileA(msifile);
8052 struct access_res
8054 BOOL gothandle;
8055 DWORD lasterr;
8056 BOOL ignore;
8059 static const struct access_res create[16] =
8061 { TRUE, ERROR_SUCCESS, TRUE },
8062 { TRUE, ERROR_SUCCESS, TRUE },
8063 { TRUE, ERROR_SUCCESS, FALSE },
8064 { TRUE, ERROR_SUCCESS, FALSE },
8065 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8066 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8067 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8068 { TRUE, ERROR_SUCCESS, FALSE },
8069 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8070 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8071 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8072 { TRUE, ERROR_SUCCESS, TRUE },
8073 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8074 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8075 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8076 { TRUE, ERROR_SUCCESS, TRUE }
8079 static const struct access_res create_commit[16] =
8081 { TRUE, ERROR_SUCCESS, TRUE },
8082 { TRUE, ERROR_SUCCESS, TRUE },
8083 { TRUE, ERROR_SUCCESS, FALSE },
8084 { TRUE, ERROR_SUCCESS, FALSE },
8085 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8086 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8087 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8088 { TRUE, ERROR_SUCCESS, FALSE },
8089 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8090 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8091 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8092 { TRUE, ERROR_SUCCESS, TRUE },
8093 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8094 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8095 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8096 { TRUE, ERROR_SUCCESS, TRUE }
8099 static const struct access_res create_close[16] =
8101 { TRUE, ERROR_SUCCESS, FALSE },
8102 { TRUE, ERROR_SUCCESS, FALSE },
8103 { TRUE, ERROR_SUCCESS, FALSE },
8104 { TRUE, ERROR_SUCCESS, FALSE },
8105 { TRUE, ERROR_SUCCESS, FALSE },
8106 { TRUE, ERROR_SUCCESS, FALSE },
8107 { TRUE, ERROR_SUCCESS, FALSE },
8108 { TRUE, ERROR_SUCCESS, FALSE },
8109 { TRUE, ERROR_SUCCESS, FALSE },
8110 { TRUE, ERROR_SUCCESS, FALSE },
8111 { TRUE, ERROR_SUCCESS, FALSE },
8112 { TRUE, ERROR_SUCCESS, FALSE },
8113 { TRUE, ERROR_SUCCESS, FALSE },
8114 { TRUE, ERROR_SUCCESS, FALSE },
8115 { TRUE, ERROR_SUCCESS, FALSE },
8116 { TRUE, ERROR_SUCCESS }
8119 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
8121 DWORD access = 0, share = 0;
8122 DWORD lasterr;
8123 HANDLE hfile;
8124 int i, j, idx = 0;
8126 for (i = 0; i < 4; i++)
8128 if (i == 0) access = 0;
8129 if (i == 1) access = GENERIC_READ;
8130 if (i == 2) access = GENERIC_WRITE;
8131 if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
8133 for (j = 0; j < 4; j++)
8135 if (ares[idx].ignore)
8136 continue;
8138 if (j == 0) share = 0;
8139 if (j == 1) share = FILE_SHARE_READ;
8140 if (j == 2) share = FILE_SHARE_WRITE;
8141 if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
8143 SetLastError(0xdeadbeef);
8144 hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
8145 FILE_ATTRIBUTE_NORMAL, 0);
8146 lasterr = GetLastError();
8148 ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
8149 "(%d, handle, %d): Expected %d, got %d\n",
8150 line, idx, ares[idx].gothandle,
8151 (hfile != INVALID_HANDLE_VALUE));
8153 ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
8154 line, idx, ares[idx].lasterr, lasterr);
8156 CloseHandle(hfile);
8157 idx++;
8162 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
8164 static void test_access(void)
8166 MSIHANDLE hdb;
8167 UINT r;
8169 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
8170 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8172 test_file_access(msifile, create);
8174 r = MsiDatabaseCommit(hdb);
8175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8177 test_file_access(msifile, create_commit);
8178 MsiCloseHandle(hdb);
8180 test_file_access(msifile, create_close);
8181 DeleteFileA(msifile);
8183 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATEDIRECT, &hdb);
8184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8186 test_file_access(msifile, create);
8188 r = MsiDatabaseCommit(hdb);
8189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8191 test_file_access(msifile, create_commit);
8192 MsiCloseHandle(hdb);
8194 test_file_access(msifile, create_close);
8195 DeleteFileA(msifile);
8198 static void test_emptypackage(void)
8200 MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
8201 MSIHANDLE hview = 0, hrec = 0;
8202 MSICONDITION condition;
8203 CHAR buffer[MAX_PATH];
8204 DWORD size;
8205 UINT r;
8207 r = MsiOpenPackageA("", &hpkg);
8208 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8210 skip("Not enough rights to perform tests\n");
8211 return;
8213 todo_wine
8215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8218 hdb = MsiGetActiveDatabase(hpkg);
8219 todo_wine
8221 ok(hdb != 0, "Expected a valid database handle\n");
8224 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Tables`", &hview);
8225 todo_wine
8227 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8229 r = MsiViewExecute(hview, 0);
8230 todo_wine
8232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8235 r = MsiViewFetch(hview, &hrec);
8236 todo_wine
8238 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8241 buffer[0] = 0;
8242 size = MAX_PATH;
8243 r = MsiRecordGetStringA(hrec, 1, buffer, &size);
8244 todo_wine
8246 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8247 ok(!lstrcmpA(buffer, "_Property"),
8248 "Expected \"_Property\", got \"%s\"\n", buffer);
8251 MsiCloseHandle(hrec);
8253 r = MsiViewFetch(hview, &hrec);
8254 todo_wine
8256 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8259 size = MAX_PATH;
8260 r = MsiRecordGetStringA(hrec, 1, buffer, &size);
8261 todo_wine
8263 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8264 ok(!lstrcmpA(buffer, "#_FolderCache"),
8265 "Expected \"_Property\", got \"%s\"\n", buffer);
8268 MsiCloseHandle(hrec);
8269 MsiViewClose(hview);
8270 MsiCloseHandle(hview);
8272 condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
8273 todo_wine
8275 ok(condition == MSICONDITION_FALSE,
8276 "Expected MSICONDITION_FALSE, got %d\n", condition);
8279 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Property`", &hview);
8280 todo_wine
8282 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8284 r = MsiViewExecute(hview, 0);
8285 todo_wine
8287 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8290 /* _Property table is not empty */
8291 r = MsiViewFetch(hview, &hrec);
8292 todo_wine
8294 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8297 MsiCloseHandle(hrec);
8298 MsiViewClose(hview);
8299 MsiCloseHandle(hview);
8301 condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
8302 todo_wine
8304 ok(condition == MSICONDITION_FALSE,
8305 "Expected MSICONDITION_FALSE, got %d\n", condition);
8308 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `#_FolderCache`", &hview);
8309 todo_wine
8311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8313 r = MsiViewExecute(hview, 0);
8314 todo_wine
8316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8319 /* #_FolderCache is not empty */
8320 r = MsiViewFetch(hview, &hrec);
8321 todo_wine
8323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8326 MsiCloseHandle(hrec);
8327 MsiViewClose(hview);
8328 MsiCloseHandle(hview);
8330 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Streams`", &hview);
8331 todo_wine
8333 ok(r == ERROR_BAD_QUERY_SYNTAX,
8334 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8337 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Storages`", &hview);
8338 todo_wine
8340 ok(r == ERROR_BAD_QUERY_SYNTAX,
8341 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8344 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
8345 todo_wine
8347 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
8348 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
8351 MsiCloseHandle(hsuminfo);
8353 r = MsiDatabaseCommit(hdb);
8354 todo_wine
8356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8359 MsiCloseHandle(hdb);
8360 MsiCloseHandle(hpkg);
8363 static void test_MsiGetProductProperty(void)
8365 static const WCHAR prodcode_propW[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
8366 static const WCHAR nonexistentW[] = {'I','D','o','n','t','E','x','i','s','t',0};
8367 static const WCHAR newpropW[] = {'N','e','w','P','r','o','p','e','r','t','y',0};
8368 static const WCHAR appleW[] = {'a','p','p','l','e',0};
8369 static const WCHAR emptyW[] = {0};
8370 WCHAR valW[MAX_PATH];
8371 MSIHANDLE hprod, hdb;
8372 CHAR val[MAX_PATH];
8373 CHAR path[MAX_PATH];
8374 CHAR query[MAX_PATH];
8375 CHAR keypath[MAX_PATH*2];
8376 CHAR prodcode[MAX_PATH];
8377 WCHAR prodcodeW[MAX_PATH];
8378 CHAR prod_squashed[MAX_PATH];
8379 WCHAR prod_squashedW[MAX_PATH];
8380 HKEY prodkey, userkey, props;
8381 DWORD size;
8382 LONG res;
8383 UINT r;
8384 REGSAM access = KEY_ALL_ACCESS;
8386 GetCurrentDirectoryA(MAX_PATH, path);
8387 lstrcatA(path, "\\");
8389 create_test_guid(prodcode, prod_squashed);
8390 MultiByteToWideChar(CP_ACP, 0, prodcode, -1, prodcodeW, MAX_PATH);
8391 squash_guid(prodcodeW, prod_squashedW);
8393 if (is_wow64)
8394 access |= KEY_WOW64_64KEY;
8396 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
8397 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8399 r = MsiDatabaseCommit(hdb);
8400 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8402 r = set_summary_info(hdb);
8403 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8405 r = run_query(hdb,
8406 "CREATE TABLE `Directory` ( "
8407 "`Directory` CHAR(255) NOT NULL, "
8408 "`Directory_Parent` CHAR(255), "
8409 "`DefaultDir` CHAR(255) NOT NULL "
8410 "PRIMARY KEY `Directory`)");
8411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8413 r = run_query(hdb,
8414 "CREATE TABLE `Property` ( "
8415 "`Property` CHAR(72) NOT NULL, "
8416 "`Value` CHAR(255) "
8417 "PRIMARY KEY `Property`)");
8418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8420 sprintf(query, "INSERT INTO `Property` "
8421 "(`Property`, `Value`) "
8422 "VALUES( 'ProductCode', '%s' )", prodcode);
8423 r = run_query(hdb, query);
8424 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8426 r = MsiDatabaseCommit(hdb);
8427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8429 MsiCloseHandle(hdb);
8431 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8432 lstrcatA(keypath, prod_squashed);
8434 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8435 if (res == ERROR_ACCESS_DENIED)
8437 skip("Not enough rights to perform tests\n");
8438 DeleteFileA(msifile);
8439 return;
8441 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8443 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8444 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8445 lstrcatA(keypath, prod_squashed);
8447 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
8448 if (res == ERROR_ACCESS_DENIED)
8450 skip("Not enough rights to perform tests\n");
8451 RegDeleteKeyA(prodkey, "");
8452 RegCloseKey(prodkey);
8453 return;
8455 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8457 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8458 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8460 lstrcpyA(val, path);
8461 lstrcatA(val, "\\");
8462 lstrcatA(val, msifile);
8463 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8464 (const BYTE *)val, lstrlenA(val) + 1);
8465 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8467 hprod = 0xdeadbeef;
8468 r = MsiOpenProductA(prodcode, &hprod);
8469 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8470 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
8472 /* hProduct is invalid */
8473 size = MAX_PATH;
8474 lstrcpyA(val, "apple");
8475 r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
8476 ok(r == ERROR_INVALID_HANDLE,
8477 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8478 ok(!lstrcmpA(val, "apple"),
8479 "Expected val to be unchanged, got \"%s\"\n", val);
8480 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8482 size = MAX_PATH;
8483 lstrcpyW(valW, appleW);
8484 r = MsiGetProductPropertyW(0xdeadbeef, prodcode_propW, valW, &size);
8485 ok(r == ERROR_INVALID_HANDLE,
8486 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8487 ok(!lstrcmpW(valW, appleW),
8488 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8489 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8491 /* szProperty is NULL */
8492 size = MAX_PATH;
8493 lstrcpyA(val, "apple");
8494 r = MsiGetProductPropertyA(hprod, NULL, val, &size);
8495 ok(r == ERROR_INVALID_PARAMETER,
8496 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8497 ok(!lstrcmpA(val, "apple"),
8498 "Expected val to be unchanged, got \"%s\"\n", val);
8499 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8501 size = MAX_PATH;
8502 lstrcpyW(valW, appleW);
8503 r = MsiGetProductPropertyW(hprod, NULL, valW, &size);
8504 ok(r == ERROR_INVALID_PARAMETER,
8505 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8506 ok(!lstrcmpW(valW, appleW),
8507 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8508 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8510 /* szProperty is empty */
8511 size = MAX_PATH;
8512 lstrcpyA(val, "apple");
8513 r = MsiGetProductPropertyA(hprod, "", val, &size);
8514 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8515 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8516 ok(size == 0, "Expected 0, got %d\n", size);
8518 size = MAX_PATH;
8519 lstrcpyW(valW, appleW);
8520 r = MsiGetProductPropertyW(hprod, emptyW, valW, &size);
8521 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8522 ok(*valW == 0, "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8523 ok(size == 0, "Expected 0, got %d\n", size);
8525 /* get the property */
8526 size = MAX_PATH;
8527 lstrcpyA(val, "apple");
8528 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8529 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8530 ok(!lstrcmpA(val, prodcode),
8531 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8532 ok(size == lstrlenA(prodcode),
8533 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8535 size = MAX_PATH;
8536 lstrcpyW(valW, appleW);
8537 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8539 ok(!lstrcmpW(valW, prodcodeW),
8540 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8541 ok(size == lstrlenW(prodcodeW),
8542 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8544 /* lpValueBuf is NULL */
8545 size = MAX_PATH;
8546 r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
8547 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8548 ok(size == lstrlenA(prodcode),
8549 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8551 size = MAX_PATH;
8552 r = MsiGetProductPropertyW(hprod, prodcode_propW, NULL, &size);
8553 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8554 ok(size == lstrlenW(prodcodeW),
8555 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8557 /* pcchValueBuf is NULL */
8558 lstrcpyA(val, "apple");
8559 r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
8560 ok(r == ERROR_INVALID_PARAMETER,
8561 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8562 ok(!lstrcmpA(val, "apple"),
8563 "Expected val to be unchanged, got \"%s\"\n", val);
8564 ok(size == lstrlenA(prodcode),
8565 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8567 lstrcpyW(valW, appleW);
8568 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, NULL);
8569 ok(r == ERROR_INVALID_PARAMETER,
8570 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8571 ok(!lstrcmpW(valW, appleW),
8572 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8573 ok(size == lstrlenW(prodcodeW),
8574 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8576 /* pcchValueBuf is too small */
8577 size = 4;
8578 lstrcpyA(val, "apple");
8579 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8580 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8581 ok(!strncmp(val, prodcode, 3),
8582 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
8583 ok(size == lstrlenA(prodcode),
8584 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8586 size = 4;
8587 lstrcpyW(valW, appleW);
8588 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8589 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8590 ok(!memcmp(valW, prodcodeW, 3 * sizeof(WCHAR)),
8591 "Expected first 3 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8592 ok(size == lstrlenW(prodcodeW),
8593 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8595 /* pcchValueBuf does not leave room for NULL terminator */
8596 size = lstrlenA(prodcode);
8597 lstrcpyA(val, "apple");
8598 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8599 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8600 ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
8601 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
8602 ok(size == lstrlenA(prodcode),
8603 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8605 size = lstrlenW(prodcodeW);
8606 lstrcpyW(valW, appleW);
8607 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8608 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8609 ok(!memcmp(valW, prodcodeW, lstrlenW(prodcodeW) - 1),
8610 "Expected first 37 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8611 ok(size == lstrlenW(prodcodeW),
8612 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8614 /* pcchValueBuf has enough room for NULL terminator */
8615 size = lstrlenA(prodcode) + 1;
8616 lstrcpyA(val, "apple");
8617 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8618 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8619 ok(!lstrcmpA(val, prodcode),
8620 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8621 ok(size == lstrlenA(prodcode),
8622 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8624 size = lstrlenW(prodcodeW) + 1;
8625 lstrcpyW(valW, appleW);
8626 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8628 ok(!lstrcmpW(valW, prodcodeW),
8629 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8630 ok(size == lstrlenW(prodcodeW),
8631 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8633 /* nonexistent property */
8634 size = MAX_PATH;
8635 lstrcpyA(val, "apple");
8636 r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
8637 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8638 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8639 ok(size == 0, "Expected 0, got %d\n", size);
8641 size = MAX_PATH;
8642 lstrcpyW(valW, appleW);
8643 r = MsiGetProductPropertyW(hprod, nonexistentW, valW, &size);
8644 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8645 ok(!lstrcmpW(valW, emptyW), "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8646 ok(size == 0, "Expected 0, got %d\n", size);
8648 r = MsiSetPropertyA(hprod, "NewProperty", "value");
8649 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8651 /* non-product property set */
8652 size = MAX_PATH;
8653 lstrcpyA(val, "apple");
8654 r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
8655 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8656 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8657 ok(size == 0, "Expected 0, got %d\n", size);
8659 size = MAX_PATH;
8660 lstrcpyW(valW, appleW);
8661 r = MsiGetProductPropertyW(hprod, newpropW, valW, &size);
8662 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8663 ok(!lstrcmpW(valW, emptyW), "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8664 ok(size == 0, "Expected 0, got %d\n", size);
8666 r = MsiSetPropertyA(hprod, "ProductCode", "value");
8667 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8669 /* non-product property that is also a product property set */
8670 size = MAX_PATH;
8671 lstrcpyA(val, "apple");
8672 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8673 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8674 ok(!lstrcmpA(val, prodcode),
8675 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8676 ok(size == lstrlenA(prodcode),
8677 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8679 size = MAX_PATH;
8680 lstrcpyW(valW, appleW);
8681 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8682 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8683 ok(!lstrcmpW(valW, prodcodeW),
8684 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8685 ok(size == lstrlenW(prodcodeW),
8686 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8688 MsiCloseHandle(hprod);
8690 RegDeleteValueA(props, "LocalPackage");
8691 delete_key(props, "", access);
8692 RegCloseKey(props);
8693 delete_key(userkey, "", access);
8694 RegCloseKey(userkey);
8695 delete_key(prodkey, "", access);
8696 RegCloseKey(prodkey);
8697 DeleteFileA(msifile);
8700 static void test_MsiSetProperty(void)
8702 MSIHANDLE hpkg, hdb, hrec;
8703 CHAR buf[MAX_PATH];
8704 LPCSTR query;
8705 DWORD size;
8706 UINT r;
8708 r = package_from_db(create_package_db(), &hpkg);
8709 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8711 skip("Not enough rights to perform tests\n");
8712 DeleteFileA(msifile);
8713 return;
8715 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8717 /* invalid hInstall */
8718 r = MsiSetPropertyA(0, "Prop", "Val");
8719 ok(r == ERROR_INVALID_HANDLE,
8720 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8722 /* invalid hInstall */
8723 r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8724 ok(r == ERROR_INVALID_HANDLE,
8725 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8727 /* szName is NULL */
8728 r = MsiSetPropertyA(hpkg, NULL, "Val");
8729 ok(r == ERROR_INVALID_PARAMETER,
8730 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8732 /* both szName and szValue are NULL */
8733 r = MsiSetPropertyA(hpkg, NULL, NULL);
8734 ok(r == ERROR_INVALID_PARAMETER,
8735 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8737 /* szName is empty */
8738 r = MsiSetPropertyA(hpkg, "", "Val");
8739 ok(r == ERROR_FUNCTION_FAILED,
8740 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8742 /* szName is empty and szValue is NULL */
8743 r = MsiSetPropertyA(hpkg, "", NULL);
8744 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8746 /* set a property */
8747 r = MsiSetPropertyA(hpkg, "Prop", "Val");
8748 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8750 /* get the property */
8751 size = MAX_PATH;
8752 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8753 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8754 ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
8755 ok(size == 3, "Expected 3, got %d\n", size);
8757 /* update the property */
8758 r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
8759 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8761 /* get the property */
8762 size = MAX_PATH;
8763 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8764 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8765 ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
8766 ok(size == 4, "Expected 4, got %d\n", size);
8768 hdb = MsiGetActiveDatabase(hpkg);
8769 ok(hdb != 0, "Expected a valid database handle\n");
8771 /* set prop is not in the _Property table */
8772 query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8773 r = do_query(hdb, query, &hrec);
8774 ok(r == ERROR_BAD_QUERY_SYNTAX,
8775 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8777 /* set prop is not in the Property table */
8778 query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8779 r = do_query(hdb, query, &hrec);
8780 ok(r == ERROR_BAD_QUERY_SYNTAX,
8781 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8783 MsiCloseHandle(hdb);
8785 /* szValue is an empty string */
8786 r = MsiSetPropertyA(hpkg, "Prop", "");
8787 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8789 /* try to get the property */
8790 size = MAX_PATH;
8791 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8792 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8793 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8794 ok(size == 0, "Expected 0, got %d\n", size);
8796 /* reset the property */
8797 r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
8798 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8800 /* delete the property */
8801 r = MsiSetPropertyA(hpkg, "Prop", NULL);
8802 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8804 /* try to get the property */
8805 size = MAX_PATH;
8806 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8807 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8808 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8809 ok(size == 0, "Expected 0, got %d\n", size);
8811 MsiCloseHandle(hpkg);
8812 DeleteFileA(msifile);
8815 static void test_MsiApplyMultiplePatches(void)
8817 UINT r, type = GetDriveTypeW(NULL);
8819 r = MsiApplyMultiplePatchesA(NULL, NULL, NULL);
8820 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8822 r = MsiApplyMultiplePatchesA("", NULL, NULL);
8823 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8825 r = MsiApplyMultiplePatchesA(";", NULL, NULL);
8826 if (type == DRIVE_FIXED)
8827 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8828 else
8829 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8831 r = MsiApplyMultiplePatchesA(" ;", NULL, NULL);
8832 if (type == DRIVE_FIXED)
8833 todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
8834 else
8835 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8837 r = MsiApplyMultiplePatchesA(";;", NULL, NULL);
8838 if (type == DRIVE_FIXED)
8839 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8840 else
8841 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8843 r = MsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
8844 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8846 r = MsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
8847 if (type == DRIVE_FIXED)
8848 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8849 else
8850 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8852 r = MsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
8853 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8855 r = MsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL, NULL);
8856 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8859 static void test_MsiApplyPatch(void)
8861 UINT r;
8863 r = MsiApplyPatchA(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
8864 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8866 r = MsiApplyPatchA("", NULL, INSTALLTYPE_DEFAULT, NULL);
8867 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8870 static void test_MsiEnumComponentCosts(void)
8872 MSIHANDLE hdb, hpkg;
8873 char package[12], drive[3];
8874 DWORD len;
8875 UINT r;
8876 int cost, temp;
8878 hdb = create_package_db();
8879 ok( hdb, "failed to create database\n" );
8881 r = create_property_table( hdb );
8882 ok( r == ERROR_SUCCESS, "cannot create Property table %u\n", r );
8884 r = add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8885 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8887 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
8888 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8890 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
8891 ok( r == ERROR_SUCCESS, "failed to add directory entry %u\n" , r );
8893 r = create_media_table( hdb );
8894 ok( r == ERROR_SUCCESS, "cannot create Media table %u\n", r );
8896 r = add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
8897 ok( r == ERROR_SUCCESS, "cannot add media entry %u\n", r );
8899 r = create_file_table( hdb );
8900 ok( r == ERROR_SUCCESS, "cannot create File table %u\n", r );
8902 r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8903 ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
8905 r = create_component_table( hdb );
8906 ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
8908 r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8909 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8911 r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8912 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8914 r = create_feature_table( hdb );
8915 ok( r == ERROR_SUCCESS, "cannot create Feature table %u\n", r );
8917 r = add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
8918 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8920 r = add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
8921 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8923 r = create_feature_components_table( hdb );
8924 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table %u\n", r );
8926 r = add_feature_components_entry( hdb, "'one', 'one'" );
8927 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8929 r = add_feature_components_entry( hdb, "'two', 'two'" );
8930 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8932 r = create_install_execute_sequence_table( hdb );
8933 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table %u\n", r );
8935 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
8936 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8938 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
8939 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8941 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
8942 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8944 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
8945 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8947 MsiDatabaseCommit( hdb );
8949 sprintf( package, "#%u", hdb );
8950 r = MsiOpenPackageA( package, &hpkg );
8951 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8953 skip("Not enough rights to perform tests\n");
8954 goto error;
8956 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8958 r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8959 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8961 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8962 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8964 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8965 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8967 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8968 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8970 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8971 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8973 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
8974 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8976 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
8977 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8979 len = sizeof(drive);
8980 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
8981 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8983 len = sizeof(drive);
8984 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
8985 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8987 len = sizeof(drive);
8988 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8989 todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
8991 len = sizeof(drive);
8992 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
8993 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8995 MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
8997 r = MsiDoActionA( hpkg, "CostInitialize" );
8998 ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
9000 r = MsiDoActionA( hpkg, "FileCost" );
9001 ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
9003 len = sizeof(drive);
9004 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9005 ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
9007 r = MsiDoActionA( hpkg, "CostFinalize" );
9008 ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
9010 /* contrary to what msdn says InstallValidate must be called too */
9011 len = sizeof(drive);
9012 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9013 todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
9015 r = MsiDoActionA( hpkg, "InstallValidate" );
9016 ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
9018 len = 0;
9019 r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9020 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
9022 len = 0;
9023 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9024 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
9025 ok( len == 2, "expected len == 2, got %u\n", len );
9027 len = 2;
9028 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9029 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
9030 ok( len == 2, "expected len == 2, got %u\n", len );
9032 len = 2;
9033 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
9034 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
9035 ok( len == 2, "expected len == 2, got %u\n", len );
9037 /* install state doesn't seem to matter */
9038 len = sizeof(drive);
9039 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
9040 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9042 len = sizeof(drive);
9043 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
9044 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9046 len = sizeof(drive);
9047 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
9048 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9050 len = sizeof(drive);
9051 drive[0] = 0;
9052 cost = temp = 0xdead;
9053 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9054 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9055 ok( len == 2, "expected len == 2, got %u\n", len );
9056 ok( drive[0], "expected a drive\n" );
9057 ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
9058 ok( !temp, "expected temp == 0, got %d\n", temp );
9060 len = sizeof(drive);
9061 drive[0] = 0;
9062 cost = temp = 0xdead;
9063 r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9064 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9065 ok( len == 2, "expected len == 2, got %u\n", len );
9066 ok( drive[0], "expected a drive\n" );
9067 ok( !cost, "expected cost == 0, got %d\n", cost );
9068 ok( !temp, "expected temp == 0, got %d\n", temp );
9070 len = sizeof(drive);
9071 drive[0] = 0;
9072 cost = temp = 0xdead;
9073 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
9074 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9075 ok( len == 2, "expected len == 2, got %u\n", len );
9076 ok( drive[0], "expected a drive\n" );
9077 ok( !cost, "expected cost == 0, got %d\n", cost );
9078 ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
9080 /* increased index */
9081 len = sizeof(drive);
9082 r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9083 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
9085 len = sizeof(drive);
9086 r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
9087 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
9089 MsiCloseHandle( hpkg );
9090 error:
9091 MsiCloseHandle( hdb );
9092 DeleteFileA( msifile );
9095 static void test_MsiDatabaseCommit(void)
9097 UINT r;
9098 MSIHANDLE hdb, hpkg = 0;
9099 char buf[32], package[12];
9100 DWORD sz;
9102 hdb = create_package_db();
9103 ok( hdb, "failed to create database\n" );
9105 r = create_property_table( hdb );
9106 ok( r == ERROR_SUCCESS, "can't create Property table %u\n", r );
9108 sprintf( package, "#%u", hdb );
9109 r = MsiOpenPackageA( package, &hpkg );
9110 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9112 skip("Not enough rights to perform tests\n");
9113 goto error;
9115 ok( r == ERROR_SUCCESS, "got %u\n", r );
9117 r = MsiSetPropertyA( hpkg, "PROP", "value" );
9118 ok( r == ERROR_SUCCESS, "got %u\n", r );
9120 buf[0] = 0;
9121 sz = sizeof(buf);
9122 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
9123 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
9124 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
9126 r = MsiDatabaseCommit( hdb );
9127 ok( r == ERROR_SUCCESS, "MsiDatabaseCommit returned %u\n", r );
9129 buf[0] = 0;
9130 sz = sizeof(buf);
9131 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
9132 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
9133 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
9135 MsiCloseHandle( hpkg );
9136 error:
9137 MsiCloseHandle( hdb );
9138 DeleteFileA( msifile );
9141 static int externalui_ran;
9143 static INT CALLBACK externalui_callback(void *context, UINT message_type, LPCSTR message)
9145 externalui_ran = 1;
9146 ok(message_type == INSTALLMESSAGE_USER, "expected INSTALLMESSAGE_USER, got %08x\n", message_type);
9147 return 0;
9150 static int externalui_record_ran;
9152 static INT CALLBACK externalui_record_callback(void *context, UINT message_type, MSIHANDLE hrecord)
9154 INT retval = context ? *((INT *)context) : 0;
9155 UINT r;
9156 externalui_record_ran = 1;
9157 ok(message_type == INSTALLMESSAGE_USER, "expected INSTALLMESSAGE_USER, got %08x\n", message_type);
9158 r = MsiRecordGetFieldCount(hrecord);
9159 ok(r == 1, "expected 1, got %u\n", r);
9160 r = MsiRecordGetInteger(hrecord, 1);
9161 ok(r == 12345, "expected 12345, got %u\n", r);
9162 return retval;
9165 static void test_externalui(void)
9167 /* test that external UI handlers work correctly */
9169 INSTALLUI_HANDLERA prev;
9170 INSTALLUI_HANDLER_RECORD prev_record;
9171 MSIHANDLE hpkg, hrecord;
9172 UINT r;
9173 INT retval = 0;
9175 prev = MsiSetExternalUIA(externalui_callback, INSTALLLOGMODE_USER, NULL);
9177 r = package_from_db(create_package_db(), &hpkg);
9178 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9180 skip("Not enough rights to perform tests\n");
9181 DeleteFileA(msifile);
9182 return;
9184 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
9186 hrecord = MsiCreateRecord(1);
9187 ok(hrecord, "Expected a valid record\n");
9188 r = MsiRecordSetStringA(hrecord, 0, "test message [1]");
9189 ok(r == ERROR_SUCCESS, "MsiSetString failed %u\n", r);
9190 r = MsiRecordSetInteger(hrecord, 1, 12345);
9191 ok(r == ERROR_SUCCESS, "MsiSetInteger failed %u\n", r);
9193 externalui_ran = 0;
9194 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9195 ok(r == 0, "expected 0, got %u\n", r);
9196 ok(externalui_ran == 1, "external UI callback did not run\n");
9198 prev = MsiSetExternalUIA(prev, 0, NULL);
9199 ok(prev == externalui_callback, "wrong callback function %p\n", prev);
9200 r = MsiSetExternalUIRecord(externalui_record_callback, INSTALLLOGMODE_USER, &retval, &prev_record);
9201 ok(r == ERROR_SUCCESS, "MsiSetExternalUIRecord failed %u\n", r);
9203 externalui_ran = externalui_record_ran = 0;
9204 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9205 ok(r == 0, "expected 0, got %u\n", r);
9206 ok(externalui_ran == 0, "external UI callback should not have run\n");
9207 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
9209 MsiSetExternalUIA(externalui_callback, INSTALLLOGMODE_USER, NULL);
9211 externalui_ran = externalui_record_ran = 0;
9212 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9213 ok(r == 0, "expected 0, got %u\n", r);
9214 ok(externalui_ran == 1, "external UI callback did not run\n");
9215 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
9217 retval = 1;
9218 externalui_ran = externalui_record_ran = 0;
9219 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9220 ok(r == 1, "expected 1, got %u\n", r);
9221 ok(externalui_ran == 0, "external UI callback should not have run\n");
9222 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
9224 /* filter and context should be kept separately */
9225 r = MsiSetExternalUIRecord(externalui_record_callback, INSTALLLOGMODE_ERROR, &retval, &prev_record);
9226 ok(r == ERROR_SUCCESS, "MsiSetExternalUIRecord failed %u\n", r);
9228 externalui_ran = externalui_record_ran = 0;
9229 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9230 ok(r == 0, "expected 0, got %u\n", r);
9231 ok(externalui_ran == 1, "external UI callback did not run\n");
9232 ok(externalui_record_ran == 0, "external UI record callback should not have run\n");
9234 MsiCloseHandle(hpkg);
9235 DeleteFileA(msifile);
9238 struct externalui_message {
9239 UINT message;
9240 int field_count;
9241 char field[4][100];
9242 int match[4]; /* should we test for a match */
9243 int optional;
9246 static struct externalui_message *sequence;
9247 static int sequence_count, sequence_size;
9249 static void add_message(const struct externalui_message *msg)
9251 if (!sequence)
9253 sequence_size = 10;
9254 sequence = HeapAlloc(GetProcessHeap(), 0, sequence_size * sizeof(*sequence));
9256 if (sequence_count == sequence_size)
9258 sequence_size *= 2;
9259 sequence = HeapReAlloc(GetProcessHeap(), 0, sequence, sequence_size * sizeof(*sequence));
9262 assert(sequence);
9264 sequence[sequence_count++] = *msg;
9267 static void flush_sequence(void)
9269 HeapFree(GetProcessHeap(), 0, sequence);
9270 sequence = NULL;
9271 sequence_count = sequence_size = 0;
9274 static void ok_sequence_(const struct externalui_message *expected, const char *context, BOOL todo,
9275 const char *file, int line)
9277 static const struct externalui_message end_of_sequence = {0};
9278 const struct externalui_message *actual;
9279 int failcount = 0;
9280 int i;
9282 add_message(&end_of_sequence);
9284 actual = sequence;
9286 while (expected->message && actual->message)
9288 if (expected->message == actual->message)
9290 if (expected->field_count != actual->field_count)
9292 todo_wine_if (todo)
9293 ok_(file, line) (FALSE, "%s: in msg 0x%08x expecting field count %d got %d\n",
9294 context, expected->message, expected->field_count, actual->field_count);
9295 failcount++;
9298 for (i = 0; i <= actual->field_count; i++)
9300 if (expected->match[i] && strcmp(expected->field[i], actual->field[i]))
9302 todo_wine_if (todo)
9303 ok_(file, line) (FALSE, "%s: in msg 0x%08x field %d: expected \"%s\", got \"%s\"\n",
9304 context, expected->message, i, expected->field[i], actual->field[i]);
9305 failcount++;
9309 expected++;
9310 actual++;
9312 else
9314 todo_wine_if (todo)
9315 ok_(file, line) (FALSE, "%s: the msg 0x%08x was expected, but got msg 0x%08x instead\n",
9316 context, expected->message, actual->message);
9317 failcount++;
9318 if (todo)
9319 goto done;
9320 expected++;
9321 actual++;
9325 if (expected->message || actual->message)
9327 todo_wine_if (todo)
9328 ok_(file, line) (FALSE, "%s: the msg sequence is not complete: expected %08x - actual %08x\n",
9329 context, expected->message, actual->message);
9330 failcount++;
9333 if(todo && !failcount) /* succeeded yet marked todo */
9335 todo_wine
9336 ok_(file, line)(TRUE, "%s: marked \"todo_wine\" but succeeds\n", context);
9339 done:
9340 flush_sequence();
9343 #define ok_sequence(exp, contx, todo) \
9344 ok_sequence_((exp), (contx), (todo), __FILE__, __LINE__)
9346 static const struct externalui_message empty_sequence[] = {
9350 static const struct externalui_message openpackage_nonexistent_sequence[] = {
9351 {INSTALLMESSAGE_INITIALIZE, -1},
9352 {INSTALLMESSAGE_TERMINATE, -1},
9356 static const struct externalui_message openpackage_sequence[] = {
9357 {INSTALLMESSAGE_INITIALIZE, -1},
9358 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {1, 1, 1, 1}},
9359 {INSTALLMESSAGE_INFO|MB_ICONHAND, 0, {""}, {0}},
9360 {INSTALLMESSAGE_COMMONDATA, 3, {"", "0", "1033", "1252"}, {0, 1, 1, 1}},
9361 {INSTALLMESSAGE_COMMONDATA, 3, {"", "1", "", ""}, {0, 1, 0, 0}},
9365 static const struct externalui_message processmessage_info_sequence[] = {
9366 {INSTALLMESSAGE_INFO, 3, {"zero", "one", "two", "three"}, {1, 1, 1, 1}},
9370 static const struct externalui_message processmessage_actionstart_sequence[] = {
9371 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "name", "description", "template"}, {0, 1, 1, 1}},
9375 static const struct externalui_message processmessage_actiondata_sequence[] = {
9376 {INSTALLMESSAGE_ACTIONDATA, 3, {"{{name: }}template", "cherry", "banana", "guava"}, {1, 1, 1, 1}},
9380 static const struct externalui_message doaction_costinitialize_sequence[] = {
9381 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "CostInitialize", "", ""}, {0, 1, 0, 1}},
9382 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", ""}, {0, 1, 1}},
9383 {INSTALLMESSAGE_INFO, 2, {"", "CostInitialize", "1"}, {0, 1, 1}},
9387 static const struct externalui_message doaction_custom_sequence[] = {
9388 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9389 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9390 {INSTALLMESSAGE_INFO, 2, {"", "custom", "0"}, {0, 1, 1}},
9394 static const struct externalui_message doaction_custom_fullui_sequence[] = {
9395 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9396 {INSTALLMESSAGE_INFO, 2, {"", "custom", ""}, {0, 1, 1}},
9397 {INSTALLMESSAGE_SHOWDIALOG, 0, {"custom"}, {1}},
9398 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9402 static const struct externalui_message doaction_custom_cancel_sequence[] = {
9403 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9407 static const struct externalui_message doaction_dialog_nonexistent_sequence[] = {
9408 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9409 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9410 {INSTALLMESSAGE_SHOWDIALOG, 0, {"custom"}, {1}},
9411 {INSTALLMESSAGE_INFO, 2, {"DEBUG: Error [1]: Action not found: [2]", "2726", "custom"}, {1, 1, 1}},
9412 {INSTALLMESSAGE_INFO, 2, {"", "2726", "custom"}, {0, 1, 1}},
9413 {INSTALLMESSAGE_INFO, 2, {"", "custom", "0"}, {0, 1, 1}},
9417 static const struct externalui_message doaction_dialog_sequence[] = {
9418 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9419 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "0"}, {0, 1, 1}},
9420 {INSTALLMESSAGE_SHOWDIALOG, 0, {"dialog"}, {1}},
9421 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "dialog", "Dialog created"}, {0, 1, 1}},
9422 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "1"}, {0, 1, 1}},
9426 static const struct externalui_message doaction_dialog_error_sequence[] = {
9427 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "error", "", ""}, {0, 1, 1, 1}},
9428 {INSTALLMESSAGE_INFO, 2, {"", "error", "1"}, {0, 1, 1}},
9429 {INSTALLMESSAGE_SHOWDIALOG, 0, {"error"}, {1}},
9433 static const struct externalui_message doaction_dialog_3_sequence[] = {
9434 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9435 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "0"}, {0, 1, 1}},
9436 {INSTALLMESSAGE_SHOWDIALOG, 0, {"dialog"}, {1}},
9437 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "3"}, {0, 1, 1}},
9441 static const struct externalui_message doaction_dialog_12345_sequence[] = {
9442 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "dialog", "", ""}, {0, 1, 1, 1}},
9443 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "3"}, {0, 1, 1}},
9444 {INSTALLMESSAGE_SHOWDIALOG, 0, {"dialog"}, {1}},
9445 {INSTALLMESSAGE_INFO, 2, {"", "dialog", "12345"}, {0, 1, 1}},
9449 static const struct externalui_message closehandle_sequence[] = {
9450 {INSTALLMESSAGE_TERMINATE, -1},
9454 static INT CALLBACK externalui_message_string_callback(void *context, UINT message, LPCSTR string)
9456 INT retval = context ? *((INT *)context) : 0;
9457 struct externalui_message msg;
9459 msg.message = message;
9460 msg.field_count = 0;
9461 strcpy(msg.field[0], string);
9462 add_message(&msg);
9464 return retval;
9467 static INT CALLBACK externalui_message_callback(void *context, UINT message, MSIHANDLE hrecord)
9469 INT retval = context ? *((INT *)context) : 0;
9470 struct externalui_message msg;
9471 char buffer[100];
9472 DWORD length = 100;
9473 int i;
9475 msg.message = message;
9476 if (message == INSTALLMESSAGE_TERMINATE)
9478 /* trying to access the record seems to hang on some versions of Windows */
9479 msg.field_count = -1;
9480 add_message(&msg);
9481 return 1;
9483 msg.field_count = MsiRecordGetFieldCount(hrecord);
9484 for (i = 0; i <= msg.field_count; i++)
9486 length = 100;
9487 MsiRecordGetStringA(hrecord, i, buffer, &length);
9488 memcpy(msg.field[i], buffer, min(100, length+1));
9491 add_message(&msg);
9493 return retval;
9496 static void test_externalui_message(void)
9498 /* test that events trigger the correct sequence of messages */
9500 INSTALLUI_HANDLER_RECORD prev;
9501 MSIHANDLE hdb, hpkg, hrecord;
9502 INT retval = 1;
9503 UINT r;
9505 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
9507 /* processing SHOWDIALOG with a record handler causes a crash on XP */
9508 MsiSetExternalUIA(externalui_message_string_callback, INSTALLLOGMODE_SHOWDIALOG, &retval);
9509 r = MsiSetExternalUIRecord(externalui_message_callback, 0xffffffff ^ INSTALLLOGMODE_PROGRESS ^ INSTALLLOGMODE_SHOWDIALOG, &retval, &prev);
9511 flush_sequence();
9513 CoInitialize(NULL);
9515 hdb = create_package_db();
9516 ok(hdb, "failed to create database\n");
9518 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9519 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9520 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9522 r = MsiOpenPackageA(NULL, &hpkg);
9523 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
9524 ok_sequence(empty_sequence, "MsiOpenPackage with NULL db", FALSE);
9526 r = MsiOpenPackageA("nonexistent", &hpkg);
9527 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
9528 ok_sequence(openpackage_nonexistent_sequence, "MsiOpenPackage with nonexistent db", FALSE);
9530 r = package_from_db(hdb, &hpkg);
9531 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9533 skip("Not enough rights to perform tests\n");
9534 DeleteFileA(msifile);
9535 return;
9537 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9538 ok_sequence(openpackage_sequence, "MsiOpenPackage with valid db", FALSE);
9540 /* Test MsiProcessMessage */
9541 hrecord = MsiCreateRecord(3);
9542 ok(hrecord, "failed to create record\n");
9544 MsiRecordSetStringA(hrecord, 0, "zero");
9545 MsiRecordSetStringA(hrecord, 1, "one");
9546 MsiRecordSetStringA(hrecord, 2, "two");
9547 MsiRecordSetStringA(hrecord, 3, "three");
9548 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_INFO, hrecord);
9549 ok(r == 1, "Expected 1, got %d\n", r);
9550 ok_sequence(processmessage_info_sequence, "MsiProcessMessage(INSTALLMESSAGE_INFO)", FALSE);
9552 MsiRecordSetStringA(hrecord, 1, "name");
9553 MsiRecordSetStringA(hrecord, 2, "description");
9554 MsiRecordSetStringA(hrecord, 3, "template");
9555 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_ACTIONSTART, hrecord);
9556 ok(r == 1, "Expected 1, got %d\n", r);
9557 ok_sequence(processmessage_actionstart_sequence, "MsiProcessMessage(INSTALLMESSAGE_ACTIONSTART)", FALSE);
9559 MsiRecordSetStringA(hrecord, 0, "apple");
9560 MsiRecordSetStringA(hrecord, 1, "cherry");
9561 MsiRecordSetStringA(hrecord, 2, "banana");
9562 MsiRecordSetStringA(hrecord, 3, "guava");
9563 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_ACTIONDATA, hrecord);
9564 ok(r == 1, "Expected 1, got %d\n", r);
9565 ok_sequence(processmessage_actiondata_sequence, "MsiProcessMessage(INSTALLMESSAGE_ACTIONDATA)", FALSE);
9567 /* Test a standard action */
9568 r = MsiDoActionA(hpkg, "CostInitialize");
9569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9570 ok_sequence(doaction_costinitialize_sequence, "MsiDoAction(\"CostInitialize\")", FALSE);
9572 /* Test a custom action */
9573 r = MsiDoActionA(hpkg, "custom");
9574 ok(r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r);
9575 ok_sequence(doaction_custom_sequence, "MsiDoAction(\"custom\")", FALSE);
9577 /* close the package */
9578 MsiCloseHandle(hpkg);
9579 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9581 /* Test dialogs */
9582 hdb = create_package_db();
9583 ok(hdb, "failed to create database\n");
9585 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9586 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9588 r = create_dialog_table(hdb);
9589 ok(r == ERROR_SUCCESS, "failed to create dialog table %u\n", r);
9590 r = add_dialog_entry(hdb, "'dialog', 50, 50, 100, 100, 0, 'dummy'");
9591 ok(r == ERROR_SUCCESS, "failed to insert into dialog table %u\n", r);
9593 r = create_control_table(hdb);
9594 ok(r == ERROR_SUCCESS, "failed to create control table %u\n", r);
9595 r = add_control_entry(hdb, "'dialog', 'dummy', 'Text', 5, 5, 5, 5, 3, 'dummy'");
9596 ok(r == ERROR_SUCCESS, "failed to insert into control table %u\n", r);
9598 r = package_from_db(hdb, &hpkg);
9599 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
9600 ok_sequence(openpackage_sequence, "MsiOpenPackage with valid db", FALSE);
9602 /* Test a custom action */
9603 r = MsiDoActionA(hpkg, "custom");
9604 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9605 ok_sequence(doaction_custom_fullui_sequence, "MsiDoAction(\"custom\")", FALSE);
9607 retval = 2;
9608 r = MsiDoActionA(hpkg, "custom");
9609 ok(r == ERROR_INSTALL_USEREXIT, "Expected ERROR_INSTALL_USEREXIT, got %d\n", r);
9610 ok_sequence(doaction_custom_cancel_sequence, "MsiDoAction(\"custom\")", FALSE);
9612 retval = 0;
9613 r = MsiDoActionA(hpkg, "custom");
9614 ok(r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r);
9615 ok_sequence(doaction_dialog_nonexistent_sequence, "MsiDoAction(\"custom\")", FALSE);
9617 r = MsiDoActionA(hpkg, "dialog");
9618 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9619 ok_sequence(doaction_dialog_sequence, "MsiDoAction(\"dialog\")", FALSE);
9621 retval = -1;
9622 r = MsiDoActionA(hpkg, "error");
9623 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9624 ok_sequence(doaction_dialog_error_sequence, "MsiDoAction(\"error\")", FALSE);
9626 r = MsiDoActionA(hpkg, "error");
9627 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9628 ok_sequence(doaction_dialog_error_sequence, "MsiDoAction(\"error\")", FALSE);
9630 retval = -2;
9631 r = MsiDoActionA(hpkg, "custom");
9632 ok(r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %d\n", r);
9633 ok_sequence(doaction_dialog_nonexistent_sequence, "MsiDoAction(\"custom\")", FALSE);
9635 retval = 3;
9636 r = MsiDoActionA(hpkg, "dialog");
9637 ok(r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r);
9638 ok_sequence(doaction_dialog_3_sequence, "MsiDoAction(\"dialog\")", FALSE);
9640 retval = 12345;
9641 r = MsiDoActionA(hpkg, "dialog");
9642 ok(r == ERROR_FUNCTION_FAILED, "Expected ERROR_INSTALL_FAILURE, got %d\n", r);
9643 ok_sequence(doaction_dialog_12345_sequence, "MsiDoAction(\"dialog\")", FALSE);
9645 MsiCloseHandle(hpkg);
9646 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9648 MsiCloseHandle(hrecord);
9649 CoUninitialize();
9650 DeleteFileA(msifile);
9651 DeleteFileA("forcecodepage.idt");
9654 static const struct externalui_message controlevent_spawn_sequence[] = {
9655 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "spawn", "", ""}, {0, 1, 1, 1}},
9656 {INSTALLMESSAGE_INFO, 2, {"", "spawn", ""}, {0, 1, 1}},
9657 {INSTALLMESSAGE_SHOWDIALOG, 0, {"spawn"}, {1}},
9658 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "spawn", "Dialog created"}, {0, 1, 1}},
9660 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9661 {INSTALLMESSAGE_INFO, 2, {"", "custom", ""}, {0, 1, 1}},
9662 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9664 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "child1", "Dialog created"}, {0, 1, 1}},
9666 {INSTALLMESSAGE_INFO, 2, {"", "spawn", "2"}, {0, 1, 1}},
9670 static const struct externalui_message controlevent_spawn2_sequence[] = {
9671 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "spawn2", "", ""}, {0, 1, 1, 1}},
9672 {INSTALLMESSAGE_INFO, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9673 {INSTALLMESSAGE_SHOWDIALOG, 0, {"spawn2"}, {1}},
9674 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "spawn2", "Dialog created"}, {0, 1, 1}},
9676 {INSTALLMESSAGE_ACTIONSTART, 3, {"", "custom", "", ""}, {0, 1, 1, 1}},
9677 {INSTALLMESSAGE_INFO, 2, {"", "custom", "2"}, {0, 1, 1}},
9678 {INSTALLMESSAGE_INFO, 2, {"", "custom", "1"}, {0, 1, 1}},
9680 {INSTALLMESSAGE_ACTIONSTART, 2, {"", "child2", "Dialog created"}, {0, 1, 1}},
9682 {INSTALLMESSAGE_INFO, 2, {"", "spawn2", "2"}, {0, 1, 1}},
9686 static void test_controlevent(void)
9688 INSTALLUI_HANDLER_RECORD prev;
9689 MSIHANDLE hdb, hpkg;
9690 UINT r;
9692 if (!winetest_interactive)
9694 skip("interactive ControlEvent tests\n");
9695 return;
9698 MsiSetInternalUI(INSTALLUILEVEL_FULL, NULL);
9700 /* processing SHOWDIALOG with a record handler causes a crash on XP */
9701 MsiSetExternalUIA(externalui_message_string_callback, INSTALLLOGMODE_SHOWDIALOG, NULL);
9702 r = MsiSetExternalUIRecord(externalui_message_callback, 0xffffffff ^ INSTALLLOGMODE_PROGRESS ^ INSTALLLOGMODE_SHOWDIALOG, NULL, &prev);
9704 flush_sequence();
9706 CoInitialize(NULL);
9708 hdb = create_package_db();
9709 ok(hdb, "failed to create database\n");
9711 create_file_data("forcecodepage.idt", "\r\n\r\n1252\t_ForceCodepage\r\n");
9712 r = MsiDatabaseImportA(hdb, CURR_DIR, "forcecodepage.idt");
9713 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
9715 r = create_dialog_table(hdb);
9716 ok(r == ERROR_SUCCESS, "failed to create Dialog table: %u\n", r);
9717 r = add_dialog_entry(hdb, "'spawn', 50, 50, 100, 100, 3, 'button'");
9718 ok(r == ERROR_SUCCESS, "failed to insert into Dialog table: %u\n", r);
9719 r = add_dialog_entry(hdb, "'spawn2', 50, 50, 100, 100, 3, 'button'");
9720 ok(r == ERROR_SUCCESS, "failed to insert into Dialog table: %u\n", r);
9721 r = add_dialog_entry(hdb, "'child1', 50, 50, 80, 40, 3, 'exit'");
9722 ok(r == ERROR_SUCCESS, "failed to insert into Dialog table: %u\n", r);
9723 r = add_dialog_entry(hdb, "'child2', 50, 50, 80, 40, 3, 'exit'");
9724 ok(r == ERROR_SUCCESS, "failed to insert into Dialog table: %u\n", r);
9726 r = create_control_table(hdb);
9727 ok(r == ERROR_SUCCESS, "failed to create Control table: %u\n", r);
9728 r = add_control_entry(hdb, "'spawn', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9729 ok(r == ERROR_SUCCESS, "failed to insert into Control table: %u\n", r);
9730 r = add_control_entry(hdb, "'spawn2', 'button', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9731 ok(r == ERROR_SUCCESS, "failed to insert into Control table: %u\n", r);
9732 r = add_control_entry(hdb, "'child1', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9733 ok(r == ERROR_SUCCESS, "failed to insert into Control table: %u\n", r);
9734 r = add_control_entry(hdb, "'child2', 'exit', 'PushButton', 10, 10, 66, 17, 3, 'Click me'");
9735 ok(r == ERROR_SUCCESS, "failed to insert into Control table: %u\n", r);
9737 r = create_controlevent_table(hdb);
9738 ok(r == ERROR_SUCCESS, "failed to create ControlEvent table: %u\n", r);
9739 r = add_controlevent_entry(hdb, "'child1', 'exit', 'EndDialog', 'Exit', 1, 1");
9740 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9741 r = add_controlevent_entry(hdb, "'child2', 'exit', 'EndDialog', 'Exit', 1, 1");
9742 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9744 r = create_custom_action_table(hdb);
9745 ok(r == ERROR_SUCCESS, "failed to create CustomAction table: %u\n", r);
9746 r = add_custom_action_entry(hdb, "'custom', 51, 'dummy', 'dummy value'");
9747 ok(r == ERROR_SUCCESS, "failed to insert into CustomAction table: %u\n", r);
9749 /* SpawnDialog and EndDialog should trigger after all other events */
9750 r = add_controlevent_entry(hdb, "'spawn', 'button', 'SpawnDialog', 'child1', 1, 1");
9751 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9752 r = add_controlevent_entry(hdb, "'spawn', 'button', 'DoAction', 'custom', 1, 2");
9753 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9755 /* Multiple dialog events cause only the last one to be triggered */
9756 r = add_controlevent_entry(hdb, "'spawn2', 'button', 'SpawnDialog', 'child1', 1, 1");
9757 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9758 r = add_controlevent_entry(hdb, "'spawn2', 'button', 'SpawnDialog', 'child2', 1, 2");
9759 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9760 r = add_controlevent_entry(hdb, "'spawn2', 'button', 'DoAction', 'custom', 1, 3");
9761 ok(r == ERROR_SUCCESS, "failed to insert into ControlEvent table: %u\n", r);
9763 r = package_from_db(hdb, &hpkg);
9764 ok(r == ERROR_SUCCESS, "failed to create package: %u\n", r);
9765 ok_sequence(openpackage_sequence, "MsiOpenPackage()", FALSE);
9767 r = MsiDoActionA(hpkg, "spawn");
9768 todo_wine
9769 ok(r == ERROR_INSTALL_USEREXIT, "expected ERROR_INSTALL_USEREXIT, got %u\n", r);
9770 ok_sequence(controlevent_spawn_sequence, "control event: spawn", TRUE);
9772 r = MsiDoActionA(hpkg, "spawn2");
9773 todo_wine
9774 ok(r == ERROR_INSTALL_USEREXIT, "expected ERROR_INSTALL_USEREXIT, got %u\n", r);
9775 ok_sequence(controlevent_spawn2_sequence, "control event: spawn2", TRUE);
9777 MsiCloseHandle(hpkg);
9778 ok_sequence(closehandle_sequence, "MsiCloseHandle()", FALSE);
9780 CoUninitialize();
9781 DeleteFileA(msifile);
9782 DeleteFileA("forcecodepage.idt");
9785 START_TEST(package)
9787 STATEMGRSTATUS status;
9788 BOOL ret = FALSE;
9790 init_functionpointers();
9792 if (pIsWow64Process)
9793 pIsWow64Process(GetCurrentProcess(), &is_wow64);
9795 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
9797 /* Create a restore point ourselves so we circumvent the multitude of restore points
9798 * that would have been created by all the installation and removal tests.
9800 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
9801 * creation of restore points.
9803 if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
9805 memset(&status, 0, sizeof(status));
9806 ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
9809 test_createpackage();
9810 test_doaction();
9811 test_gettargetpath_bad();
9812 test_settargetpath();
9813 test_props();
9814 test_property_table();
9815 test_condition();
9816 test_msipackage();
9817 test_formatrecord2();
9818 test_states();
9819 test_getproperty();
9820 test_removefiles();
9821 test_appsearch();
9822 test_appsearch_complocator();
9823 test_appsearch_reglocator();
9824 test_appsearch_inilocator();
9825 test_appsearch_drlocator();
9826 test_featureparents();
9827 test_installprops();
9828 test_launchconditions();
9829 test_ccpsearch();
9830 test_complocator();
9831 test_MsiGetSourcePath();
9832 test_shortlongsource();
9833 test_sourcedir();
9834 test_access();
9835 test_emptypackage();
9836 test_MsiGetProductProperty();
9837 test_MsiSetProperty();
9838 test_MsiApplyMultiplePatches();
9839 test_MsiApplyPatch();
9840 test_MsiEnumComponentCosts();
9841 test_MsiDatabaseCommit();
9842 test_externalui();
9843 test_externalui_message();
9844 test_controlevent();
9846 if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
9848 ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
9849 if (ret)
9850 remove_restore_point(status.llSequenceNumber);