msi: Use an external UI record handler before a string handler.
[wine.git] / dlls / msi / tests / package.c
blobe18f0f0abe66932a781fb84ad725f071f98366cd
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 <stdio.h>
25 #include <windows.h>
26 #include <msidefs.h>
27 #include <msi.h>
28 #include <msiquery.h>
29 #include <srrestoreptapi.h>
30 #include <shlobj.h>
32 #include "wine/test.h"
34 static BOOL is_wow64;
35 static const char msifile[] = "winetest-package.msi";
36 static const WCHAR msifileW[] =
37 {'w','i','n','e','t','e','s','t','-','p','a','c','k','a','g','e','.','m','s','i',0};
38 static char CURR_DIR[MAX_PATH];
40 static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
41 static INSTALLSTATE (WINAPI *pMsiGetComponentPathExA)(LPCSTR, LPCSTR, LPCSTR, MSIINSTALLCONTEXT, LPSTR, LPDWORD);
42 static UINT (WINAPI *pMsiSetExternalUIRecord)(INSTALLUI_HANDLER_RECORD, DWORD, LPVOID, PINSTALLUI_HANDLER_RECORD);
43 static HRESULT (WINAPI *pSHGetFolderPathA)(HWND, int, HANDLE, DWORD, LPSTR);
45 static BOOL (WINAPI *pCheckTokenMembership)(HANDLE,PSID,PBOOL);
46 static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
47 static BOOL (WINAPI *pOpenProcessToken)( HANDLE, DWORD, PHANDLE );
48 static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
49 static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
50 static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
51 static void (WINAPI *pGetSystemInfo)(LPSYSTEM_INFO);
52 static void (WINAPI *pGetNativeSystemInfo)(LPSYSTEM_INFO);
53 static UINT (WINAPI *pGetSystemWow64DirectoryA)(LPSTR, UINT);
55 static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
56 static BOOL (WINAPI *pSRSetRestorePointA)(RESTOREPOINTINFOA*, STATEMGRSTATUS*);
58 static void init_functionpointers(void)
60 HMODULE hmsi = GetModuleHandleA("msi.dll");
61 HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
62 HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
63 HMODULE hshell32 = GetModuleHandleA("shell32.dll");
64 HMODULE hsrclient;
66 #define GET_PROC(mod, func) \
67 p ## func = (void*)GetProcAddress(mod, #func);
69 GET_PROC(hmsi, MsiApplyMultiplePatchesA);
70 GET_PROC(hmsi, MsiGetComponentPathExA);
71 GET_PROC(hmsi, MsiSetExternalUIRecord);
72 GET_PROC(hshell32, SHGetFolderPathA);
74 GET_PROC(hadvapi32, CheckTokenMembership);
75 GET_PROC(hadvapi32, ConvertSidToStringSidA);
76 GET_PROC(hadvapi32, OpenProcessToken);
77 GET_PROC(hadvapi32, RegDeleteKeyExA)
78 GET_PROC(hadvapi32, RegDeleteKeyExW)
79 GET_PROC(hkernel32, IsWow64Process)
80 GET_PROC(hkernel32, GetNativeSystemInfo)
81 GET_PROC(hkernel32, GetSystemInfo)
82 GET_PROC(hkernel32, GetSystemWow64DirectoryA)
84 hsrclient = LoadLibraryA("srclient.dll");
85 GET_PROC(hsrclient, SRRemoveRestorePoint);
86 GET_PROC(hsrclient, SRSetRestorePointA);
87 #undef GET_PROC
90 static BOOL is_process_limited(void)
92 SID_IDENTIFIER_AUTHORITY NtAuthority = {SECURITY_NT_AUTHORITY};
93 PSID Group = NULL;
94 BOOL IsInGroup;
95 HANDLE token;
97 if (!pCheckTokenMembership || !pOpenProcessToken) return FALSE;
99 if (!AllocateAndInitializeSid(&NtAuthority, 2, SECURITY_BUILTIN_DOMAIN_RID,
100 DOMAIN_ALIAS_RID_ADMINS, 0, 0, 0, 0, 0, 0, &Group) ||
101 !pCheckTokenMembership(NULL, Group, &IsInGroup))
103 trace("Could not check if the current user is an administrator\n");
104 FreeSid(Group);
105 return FALSE;
107 FreeSid(Group);
109 if (!IsInGroup)
111 if (!AllocateAndInitializeSid(&NtAuthority, 2,
112 SECURITY_BUILTIN_DOMAIN_RID,
113 DOMAIN_ALIAS_RID_POWER_USERS,
114 0, 0, 0, 0, 0, 0, &Group) ||
115 !pCheckTokenMembership(NULL, Group, &IsInGroup))
117 trace("Could not check if the current user is a power user\n");
118 return FALSE;
120 if (!IsInGroup)
122 /* Only administrators and power users can be powerful */
123 return TRUE;
127 if (pOpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token))
129 BOOL ret;
130 TOKEN_ELEVATION_TYPE type = TokenElevationTypeDefault;
131 DWORD size;
133 ret = GetTokenInformation(token, TokenElevationType, &type, sizeof(type), &size);
134 CloseHandle(token);
135 return (ret && type == TokenElevationTypeLimited);
137 return FALSE;
140 static LONG delete_key( HKEY key, LPCSTR subkey, REGSAM access )
142 if (pRegDeleteKeyExA)
143 return pRegDeleteKeyExA( key, subkey, access, 0 );
144 return RegDeleteKeyA( key, subkey );
147 static char *get_user_sid(void)
149 HANDLE token;
150 DWORD size = 0;
151 TOKEN_USER *user;
152 char *usersid = NULL;
154 if (!pConvertSidToStringSidA)
156 win_skip("ConvertSidToStringSidA is not available\n");
157 return NULL;
159 OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token);
160 GetTokenInformation(token, TokenUser, NULL, size, &size);
162 user = HeapAlloc(GetProcessHeap(), 0, size);
163 GetTokenInformation(token, TokenUser, user, size, &size);
164 pConvertSidToStringSidA(user->User.Sid, &usersid);
165 HeapFree(GetProcessHeap(), 0, user);
167 CloseHandle(token);
168 return usersid;
171 /* RegDeleteTreeW from dlls/advapi32/registry.c */
172 static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
174 LONG ret;
175 DWORD dwMaxSubkeyLen, dwMaxValueLen;
176 DWORD dwMaxLen, dwSize;
177 WCHAR szNameBuf[MAX_PATH], *lpszName = szNameBuf;
178 HKEY hSubKey = hKey;
180 if(lpszSubKey)
182 ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
183 if (ret) return ret;
186 ret = RegQueryInfoKeyW(hSubKey, NULL, NULL, NULL, NULL,
187 &dwMaxSubkeyLen, NULL, NULL, &dwMaxValueLen, NULL, NULL, NULL);
188 if (ret) goto cleanup;
190 dwMaxSubkeyLen++;
191 dwMaxValueLen++;
192 dwMaxLen = max(dwMaxSubkeyLen, dwMaxValueLen);
193 if (dwMaxLen > sizeof(szNameBuf)/sizeof(WCHAR))
195 /* Name too big: alloc a buffer for it */
196 if (!(lpszName = HeapAlloc( GetProcessHeap(), 0, dwMaxLen*sizeof(WCHAR))))
198 ret = ERROR_NOT_ENOUGH_MEMORY;
199 goto cleanup;
203 /* Recursively delete all the subkeys */
204 while (TRUE)
206 dwSize = dwMaxLen;
207 if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
208 NULL, NULL, NULL)) break;
210 ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
211 if (ret) goto cleanup;
214 if (lpszSubKey)
216 if (pRegDeleteKeyExW)
217 ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
218 else
219 ret = RegDeleteKeyW(hKey, lpszSubKey);
221 else
222 while (TRUE)
224 dwSize = dwMaxLen;
225 if (RegEnumValueW(hKey, 0, lpszName, &dwSize,
226 NULL, NULL, NULL, NULL)) break;
228 ret = RegDeleteValueW(hKey, lpszName);
229 if (ret) goto cleanup;
232 cleanup:
233 if (lpszName != szNameBuf)
234 HeapFree(GetProcessHeap(), 0, lpszName);
235 if(lpszSubKey)
236 RegCloseKey(hSubKey);
237 return ret;
240 static BOOL squash_guid(LPCWSTR in, LPWSTR out)
242 DWORD i,n=1;
243 GUID guid;
245 if (FAILED(CLSIDFromString((LPCOLESTR)in, &guid)))
246 return FALSE;
248 for(i=0; i<8; i++)
249 out[7-i] = in[n++];
250 n++;
251 for(i=0; i<4; i++)
252 out[11-i] = in[n++];
253 n++;
254 for(i=0; i<4; i++)
255 out[15-i] = in[n++];
256 n++;
257 for(i=0; i<2; i++)
259 out[17+i*2] = in[n++];
260 out[16+i*2] = in[n++];
262 n++;
263 for( ; i<8; i++)
265 out[17+i*2] = in[n++];
266 out[16+i*2] = in[n++];
268 out[32]=0;
269 return TRUE;
272 static void create_test_guid(LPSTR prodcode, LPSTR squashed)
274 WCHAR guidW[MAX_PATH];
275 WCHAR squashedW[MAX_PATH];
276 GUID guid;
277 HRESULT hr;
278 int size;
280 hr = CoCreateGuid(&guid);
281 ok(hr == S_OK, "Expected S_OK, got %d\n", hr);
283 size = StringFromGUID2(&guid, guidW, MAX_PATH);
284 ok(size == 39, "Expected 39, got %d\n", hr);
286 WideCharToMultiByte(CP_ACP, 0, guidW, size, prodcode, MAX_PATH, NULL, NULL);
287 squash_guid(guidW, squashedW);
288 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
291 static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
292 LPCSTR guid, LPSTR usersid, BOOL dir)
294 WCHAR guidW[MAX_PATH];
295 WCHAR squashedW[MAX_PATH];
296 CHAR squashed[MAX_PATH];
297 CHAR comppath[MAX_PATH];
298 CHAR prodpath[MAX_PATH];
299 CHAR path[MAX_PATH];
300 LPCSTR prod = NULL;
301 HKEY hkey;
302 REGSAM access = KEY_ALL_ACCESS;
304 if (is_wow64)
305 access |= KEY_WOW64_64KEY;
307 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
308 squash_guid(guidW, squashedW);
309 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
311 if (context == MSIINSTALLCONTEXT_MACHINE)
313 prod = "3D0DAE300FACA1300AD792060BCDAA92";
314 sprintf(comppath,
315 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
316 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
317 lstrcpyA(prodpath,
318 "SOFTWARE\\Classes\\Installer\\"
319 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
321 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
323 prod = "7D2F387510109040002000060BECB6AB";
324 sprintf(comppath,
325 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
326 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
327 sprintf(prodpath,
328 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
329 "Installer\\%s\\Installer\\Products\\"
330 "7D2F387510109040002000060BECB6AB", usersid);
332 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
334 prod = "7D2F387510109040002000060BECB6AB";
335 sprintf(comppath,
336 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
337 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
338 sprintf(prodpath,
339 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
340 "Installer\\Managed\\%s\\Installer\\Products\\"
341 "7D2F387510109040002000060BECB6AB", usersid);
344 RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
346 lstrcpyA(path, CURR_DIR);
347 lstrcatA(path, "\\");
348 if (!dir) lstrcatA(path, filename);
350 RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
351 RegCloseKey(hkey);
353 RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
354 RegCloseKey(hkey);
357 static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR usersid)
359 WCHAR guidW[MAX_PATH];
360 WCHAR squashedW[MAX_PATH];
361 WCHAR substrW[MAX_PATH];
362 CHAR squashed[MAX_PATH];
363 CHAR comppath[MAX_PATH];
364 CHAR prodpath[MAX_PATH];
365 REGSAM access = KEY_ALL_ACCESS;
367 if (is_wow64)
368 access |= KEY_WOW64_64KEY;
370 MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
371 squash_guid(guidW, squashedW);
372 WideCharToMultiByte(CP_ACP, 0, squashedW, -1, squashed, MAX_PATH, NULL, NULL);
374 if (context == MSIINSTALLCONTEXT_MACHINE)
376 sprintf(comppath,
377 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
378 "Installer\\UserData\\S-1-5-18\\Components\\%s", squashed);
379 lstrcpyA(prodpath,
380 "SOFTWARE\\Classes\\Installer\\"
381 "Products\\3D0DAE300FACA1300AD792060BCDAA92");
383 else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
385 sprintf(comppath,
386 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
387 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
388 sprintf(prodpath,
389 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
390 "Installer\\%s\\Installer\\Products\\"
391 "7D2F387510109040002000060BECB6AB", usersid);
393 else if (context == MSIINSTALLCONTEXT_USERMANAGED)
395 sprintf(comppath,
396 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
397 "Installer\\UserData\\%s\\Components\\%s", usersid, squashed);
398 sprintf(prodpath,
399 "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\"
400 "Installer\\Managed\\%s\\Installer\\Products\\"
401 "7D2F387510109040002000060BECB6AB", usersid);
404 MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
405 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
407 MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
408 package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
411 static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
413 MSIHANDLE hview = 0;
414 UINT r, ret;
416 /* open a select query */
417 r = MsiDatabaseOpenViewA(hdb, query, &hview);
418 if (r != ERROR_SUCCESS)
419 return r;
420 r = MsiViewExecute(hview, 0);
421 if (r != ERROR_SUCCESS)
422 return r;
423 ret = MsiViewFetch(hview, phrec);
424 r = MsiViewClose(hview);
425 if (r != ERROR_SUCCESS)
426 return r;
427 r = MsiCloseHandle(hview);
428 if (r != ERROR_SUCCESS)
429 return r;
430 return ret;
433 static UINT run_query( MSIHANDLE hdb, const char *query )
435 MSIHANDLE hview = 0;
436 UINT r;
438 r = MsiDatabaseOpenViewA(hdb, query, &hview);
439 if( r != ERROR_SUCCESS )
440 return r;
442 r = MsiViewExecute(hview, 0);
443 if( r == ERROR_SUCCESS )
444 r = MsiViewClose(hview);
445 MsiCloseHandle(hview);
446 return r;
449 static UINT create_component_table( MSIHANDLE hdb )
451 return run_query( hdb,
452 "CREATE TABLE `Component` ( "
453 "`Component` CHAR(72) NOT NULL, "
454 "`ComponentId` CHAR(38), "
455 "`Directory_` CHAR(72) NOT NULL, "
456 "`Attributes` SHORT NOT NULL, "
457 "`Condition` CHAR(255), "
458 "`KeyPath` CHAR(72) "
459 "PRIMARY KEY `Component`)" );
462 static UINT create_feature_table( MSIHANDLE hdb )
464 return run_query( hdb,
465 "CREATE TABLE `Feature` ( "
466 "`Feature` CHAR(38) NOT NULL, "
467 "`Feature_Parent` CHAR(38), "
468 "`Title` CHAR(64), "
469 "`Description` CHAR(255), "
470 "`Display` SHORT NOT NULL, "
471 "`Level` SHORT NOT NULL, "
472 "`Directory_` CHAR(72), "
473 "`Attributes` SHORT NOT NULL "
474 "PRIMARY KEY `Feature`)" );
477 static UINT create_feature_components_table( MSIHANDLE hdb )
479 return run_query( hdb,
480 "CREATE TABLE `FeatureComponents` ( "
481 "`Feature_` CHAR(38) NOT NULL, "
482 "`Component_` CHAR(72) NOT NULL "
483 "PRIMARY KEY `Feature_`, `Component_` )" );
486 static UINT create_file_table( MSIHANDLE hdb )
488 return run_query( hdb,
489 "CREATE TABLE `File` ("
490 "`File` CHAR(72) NOT NULL, "
491 "`Component_` CHAR(72) NOT NULL, "
492 "`FileName` CHAR(255) NOT NULL, "
493 "`FileSize` LONG NOT NULL, "
494 "`Version` CHAR(72), "
495 "`Language` CHAR(20), "
496 "`Attributes` SHORT, "
497 "`Sequence` SHORT NOT NULL "
498 "PRIMARY KEY `File`)" );
501 static UINT create_remove_file_table( MSIHANDLE hdb )
503 return run_query( hdb,
504 "CREATE TABLE `RemoveFile` ("
505 "`FileKey` CHAR(72) NOT NULL, "
506 "`Component_` CHAR(72) NOT NULL, "
507 "`FileName` CHAR(255) LOCALIZABLE, "
508 "`DirProperty` CHAR(72) NOT NULL, "
509 "`InstallMode` SHORT NOT NULL "
510 "PRIMARY KEY `FileKey`)" );
513 static UINT create_appsearch_table( MSIHANDLE hdb )
515 return run_query( hdb,
516 "CREATE TABLE `AppSearch` ("
517 "`Property` CHAR(72) NOT NULL, "
518 "`Signature_` CHAR(72) NOT NULL "
519 "PRIMARY KEY `Property`, `Signature_`)" );
522 static UINT create_reglocator_table( MSIHANDLE hdb )
524 return run_query( hdb,
525 "CREATE TABLE `RegLocator` ("
526 "`Signature_` CHAR(72) NOT NULL, "
527 "`Root` SHORT NOT NULL, "
528 "`Key` CHAR(255) NOT NULL, "
529 "`Name` CHAR(255), "
530 "`Type` SHORT "
531 "PRIMARY KEY `Signature_`)" );
534 static UINT create_signature_table( MSIHANDLE hdb )
536 return run_query( hdb,
537 "CREATE TABLE `Signature` ("
538 "`Signature` CHAR(72) NOT NULL, "
539 "`FileName` CHAR(255) NOT NULL, "
540 "`MinVersion` CHAR(20), "
541 "`MaxVersion` CHAR(20), "
542 "`MinSize` LONG, "
543 "`MaxSize` LONG, "
544 "`MinDate` LONG, "
545 "`MaxDate` LONG, "
546 "`Languages` CHAR(255) "
547 "PRIMARY KEY `Signature`)" );
550 static UINT create_launchcondition_table( MSIHANDLE hdb )
552 return run_query( hdb,
553 "CREATE TABLE `LaunchCondition` ("
554 "`Condition` CHAR(255) NOT NULL, "
555 "`Description` CHAR(255) NOT NULL "
556 "PRIMARY KEY `Condition`)" );
559 static UINT create_property_table( MSIHANDLE hdb )
561 return run_query( hdb,
562 "CREATE TABLE `Property` ("
563 "`Property` CHAR(72) NOT NULL, "
564 "`Value` CHAR(0) "
565 "PRIMARY KEY `Property`)" );
568 static UINT create_install_execute_sequence_table( MSIHANDLE hdb )
570 return run_query( hdb,
571 "CREATE TABLE `InstallExecuteSequence` ("
572 "`Action` CHAR(72) NOT NULL, "
573 "`Condition` CHAR(255), "
574 "`Sequence` SHORT "
575 "PRIMARY KEY `Action`)" );
578 static UINT create_media_table( MSIHANDLE hdb )
580 return run_query( hdb,
581 "CREATE TABLE `Media` ("
582 "`DiskId` SHORT NOT NULL, "
583 "`LastSequence` SHORT NOT NULL, "
584 "`DiskPrompt` CHAR(64), "
585 "`Cabinet` CHAR(255), "
586 "`VolumeLabel` CHAR(32), "
587 "`Source` CHAR(72) "
588 "PRIMARY KEY `DiskId`)" );
591 static UINT create_ccpsearch_table( MSIHANDLE hdb )
593 return run_query( hdb,
594 "CREATE TABLE `CCPSearch` ("
595 "`Signature_` CHAR(72) NOT NULL "
596 "PRIMARY KEY `Signature_`)" );
599 static UINT create_drlocator_table( MSIHANDLE hdb )
601 return run_query( hdb,
602 "CREATE TABLE `DrLocator` ("
603 "`Signature_` CHAR(72) NOT NULL, "
604 "`Parent` CHAR(72), "
605 "`Path` CHAR(255), "
606 "`Depth` SHORT "
607 "PRIMARY KEY `Signature_`, `Parent`, `Path`)" );
610 static UINT create_complocator_table( MSIHANDLE hdb )
612 return run_query( hdb,
613 "CREATE TABLE `CompLocator` ("
614 "`Signature_` CHAR(72) NOT NULL, "
615 "`ComponentId` CHAR(38) NOT NULL, "
616 "`Type` SHORT "
617 "PRIMARY KEY `Signature_`)" );
620 static UINT create_inilocator_table( MSIHANDLE hdb )
622 return run_query( hdb,
623 "CREATE TABLE `IniLocator` ("
624 "`Signature_` CHAR(72) NOT NULL, "
625 "`FileName` CHAR(255) NOT NULL, "
626 "`Section` CHAR(96)NOT NULL, "
627 "`Key` CHAR(128)NOT NULL, "
628 "`Field` SHORT, "
629 "`Type` SHORT "
630 "PRIMARY KEY `Signature_`)" );
633 static UINT create_custom_action_table( MSIHANDLE hdb )
635 return run_query( hdb,
636 "CREATE TABLE `CustomAction` ("
637 "`Action` CHAR(72) NOT NULL, "
638 "`Type` SHORT NOT NULL, "
639 "`Source` CHAR(75), "
640 "`Target` CHAR(255) "
641 "PRIMARY KEY `Action`)" );
644 #define make_add_entry(type, qtext) \
645 static UINT add##_##type##_##entry( MSIHANDLE hdb, const char *values ) \
647 char insert[] = qtext; \
648 char *query; \
649 UINT sz, r; \
650 sz = strlen(values) + sizeof insert; \
651 query = HeapAlloc(GetProcessHeap(),0,sz); \
652 sprintf(query,insert,values); \
653 r = run_query( hdb, query ); \
654 HeapFree(GetProcessHeap(), 0, query); \
655 return r; \
658 make_add_entry(component,
659 "INSERT INTO `Component` "
660 "(`Component`, `ComponentId`, `Directory_`, "
661 "`Attributes`, `Condition`, `KeyPath`) VALUES( %s )")
663 make_add_entry(directory,
664 "INSERT INTO `Directory` "
665 "(`Directory`,`Directory_Parent`,`DefaultDir`) VALUES( %s )")
667 make_add_entry(feature,
668 "INSERT INTO `Feature` "
669 "(`Feature`, `Feature_Parent`, `Title`, `Description`, "
670 "`Display`, `Level`, `Directory_`, `Attributes`) VALUES( %s )")
672 make_add_entry(feature_components,
673 "INSERT INTO `FeatureComponents` "
674 "(`Feature_`, `Component_`) VALUES( %s )")
676 make_add_entry(file,
677 "INSERT INTO `File` "
678 "(`File`, `Component_`, `FileName`, `FileSize`, "
679 "`Version`, `Language`, `Attributes`, `Sequence`) VALUES( %s )")
681 make_add_entry(appsearch,
682 "INSERT INTO `AppSearch` "
683 "(`Property`, `Signature_`) VALUES( %s )")
685 make_add_entry(signature,
686 "INSERT INTO `Signature` "
687 "(`Signature`, `FileName`, `MinVersion`, `MaxVersion`,"
688 " `MinSize`, `MaxSize`, `MinDate`, `MaxDate`, `Languages`) "
689 "VALUES( %s )")
691 make_add_entry(launchcondition,
692 "INSERT INTO `LaunchCondition` "
693 "(`Condition`, `Description`) VALUES( %s )")
695 make_add_entry(property,
696 "INSERT INTO `Property` (`Property`, `Value`) VALUES( %s )")
698 make_add_entry(install_execute_sequence,
699 "INSERT INTO `InstallExecuteSequence` "
700 "(`Action`, `Condition`, `Sequence`) VALUES( %s )")
702 make_add_entry(media,
703 "INSERT INTO `Media` "
704 "(`DiskId`, `LastSequence`, `DiskPrompt`, "
705 "`Cabinet`, `VolumeLabel`, `Source`) VALUES( %s )")
707 make_add_entry(ccpsearch,
708 "INSERT INTO `CCPSearch` (`Signature_`) VALUES( %s )")
710 make_add_entry(drlocator,
711 "INSERT INTO `DrLocator` "
712 "(`Signature_`, `Parent`, `Path`, `Depth`) VALUES( %s )")
714 make_add_entry(complocator,
715 "INSERT INTO `CompLocator` "
716 "(`Signature_`, `ComponentId`, `Type`) VALUES( %s )")
718 make_add_entry(inilocator,
719 "INSERT INTO `IniLocator` "
720 "(`Signature_`, `FileName`, `Section`, `Key`, `Field`, `Type`) "
721 "VALUES( %s )")
723 make_add_entry(custom_action,
724 "INSERT INTO `CustomAction` "
725 "(`Action`, `Type`, `Source`, `Target`) VALUES( %s )")
727 static UINT add_reglocator_entry( MSIHANDLE hdb, const char *sig, UINT root, const char *path,
728 const char *name, UINT type )
730 const char insert[] =
731 "INSERT INTO `RegLocator` (`Signature_`, `Root`, `Key`, `Name`, `Type`) "
732 "VALUES( '%s', %u, '%s', '%s', %u )";
733 char *query;
734 UINT sz, r;
736 sz = strlen( sig ) + 10 + strlen( path ) + strlen( name ) + 10 + sizeof( insert );
737 query = HeapAlloc( GetProcessHeap(), 0, sz );
738 sprintf( query, insert, sig, root, path, name, type );
739 r = run_query( hdb, query );
740 HeapFree( GetProcessHeap(), 0, query );
741 return r;
744 static UINT set_summary_info(MSIHANDLE hdb)
746 UINT res;
747 MSIHANDLE suminfo;
749 /* build summary info */
750 res = MsiGetSummaryInformationA(hdb, NULL, 7, &suminfo);
751 ok( res == ERROR_SUCCESS , "Failed to open summaryinfo\n" );
753 res = MsiSummaryInfoSetPropertyA(suminfo,2, VT_LPSTR, 0,NULL,
754 "Installation Database");
755 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
757 res = MsiSummaryInfoSetPropertyA(suminfo,3, VT_LPSTR, 0,NULL,
758 "Installation Database");
759 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
761 res = MsiSummaryInfoSetPropertyA(suminfo,4, VT_LPSTR, 0,NULL,
762 "Wine Hackers");
763 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
765 res = MsiSummaryInfoSetPropertyA(suminfo,7, VT_LPSTR, 0,NULL,
766 ";1033");
767 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
769 res = MsiSummaryInfoSetPropertyA(suminfo,9, VT_LPSTR, 0,NULL,
770 "{913B8D18-FBB6-4CAC-A239-C74C11E3FA74}");
771 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
773 res = MsiSummaryInfoSetPropertyA(suminfo, 14, VT_I4, 100, NULL, NULL);
774 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
776 res = MsiSummaryInfoSetPropertyA(suminfo, 15, VT_I4, 0, NULL, NULL);
777 ok( res == ERROR_SUCCESS , "Failed to set summary info\n" );
779 res = MsiSummaryInfoPersist(suminfo);
780 ok( res == ERROR_SUCCESS , "Failed to make summary info persist\n" );
782 res = MsiCloseHandle( suminfo);
783 ok( res == ERROR_SUCCESS , "Failed to close suminfo\n" );
785 return res;
789 static MSIHANDLE create_package_db(void)
791 MSIHANDLE hdb = 0;
792 UINT res;
794 DeleteFileA(msifile);
796 /* create an empty database */
797 res = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb );
798 ok( res == ERROR_SUCCESS , "Failed to create database %u\n", res );
799 if( res != ERROR_SUCCESS )
800 return hdb;
802 res = MsiDatabaseCommit( hdb );
803 ok( res == ERROR_SUCCESS , "Failed to commit database\n" );
805 res = set_summary_info(hdb);
806 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
808 res = run_query( hdb,
809 "CREATE TABLE `Directory` ( "
810 "`Directory` CHAR(255) NOT NULL, "
811 "`Directory_Parent` CHAR(255), "
812 "`DefaultDir` CHAR(255) NOT NULL "
813 "PRIMARY KEY `Directory`)" );
814 ok( res == ERROR_SUCCESS , "Failed to create directory table\n" );
816 return hdb;
819 static UINT package_from_db(MSIHANDLE hdb, MSIHANDLE *handle)
821 UINT res;
822 CHAR szPackage[12];
823 MSIHANDLE hPackage;
825 sprintf(szPackage, "#%u", hdb);
826 res = MsiOpenPackageA(szPackage, &hPackage);
827 if (res != ERROR_SUCCESS)
829 MsiCloseHandle(hdb);
830 return res;
833 res = MsiCloseHandle(hdb);
834 if (res != ERROR_SUCCESS)
836 MsiCloseHandle(hPackage);
837 return res;
840 *handle = hPackage;
841 return ERROR_SUCCESS;
844 static void create_test_file(const CHAR *name)
846 HANDLE file;
847 DWORD written;
849 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
850 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
851 WriteFile(file, name, strlen(name), &written, NULL);
852 WriteFile(file, "\n", strlen("\n"), &written, NULL);
853 CloseHandle(file);
856 typedef struct _tagVS_VERSIONINFO
858 WORD wLength;
859 WORD wValueLength;
860 WORD wType;
861 WCHAR szKey[1];
862 WORD wPadding1[1];
863 VS_FIXEDFILEINFO Value;
864 WORD wPadding2[1];
865 WORD wChildren[1];
866 } VS_VERSIONINFO;
868 #define roundoffs(a, b, r) (((BYTE *)(b) - (BYTE *)(a) + ((r) - 1)) & ~((r) - 1))
869 #define roundpos(a, b, r) (((BYTE *)(a)) + roundoffs(a, b, r))
871 static BOOL create_file_with_version(const CHAR *name, LONG ms, LONG ls)
873 VS_VERSIONINFO *pVerInfo;
874 VS_FIXEDFILEINFO *pFixedInfo;
875 LPBYTE buffer, ofs;
876 CHAR path[MAX_PATH];
877 DWORD handle, size;
878 HANDLE resource;
879 BOOL ret = FALSE;
881 GetSystemDirectoryA(path, MAX_PATH);
882 /* Some dlls can't be updated on Vista/W2K8 */
883 lstrcatA(path, "\\version.dll");
885 CopyFileA(path, name, FALSE);
887 size = GetFileVersionInfoSizeA(path, &handle);
888 buffer = HeapAlloc(GetProcessHeap(), 0, size);
890 GetFileVersionInfoA(path, 0, size, buffer);
892 pVerInfo = (VS_VERSIONINFO *)buffer;
893 ofs = (BYTE *)&pVerInfo->szKey[lstrlenW(pVerInfo->szKey) + 1];
894 pFixedInfo = (VS_FIXEDFILEINFO *)roundpos(pVerInfo, ofs, 4);
896 pFixedInfo->dwFileVersionMS = ms;
897 pFixedInfo->dwFileVersionLS = ls;
898 pFixedInfo->dwProductVersionMS = ms;
899 pFixedInfo->dwProductVersionLS = ls;
901 resource = BeginUpdateResourceA(name, FALSE);
902 if (!resource)
903 goto done;
905 if (!UpdateResourceA(resource, (LPCSTR)RT_VERSION, (LPCSTR)MAKEINTRESOURCE(VS_VERSION_INFO),
906 MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL), buffer, size))
907 goto done;
909 if (!EndUpdateResourceA(resource, FALSE))
910 goto done;
912 ret = TRUE;
914 done:
915 HeapFree(GetProcessHeap(), 0, buffer);
916 return ret;
919 static BOOL notify_system_change(DWORD event_type, STATEMGRSTATUS *status)
921 RESTOREPOINTINFOA spec;
923 spec.dwEventType = event_type;
924 spec.dwRestorePtType = APPLICATION_INSTALL;
925 spec.llSequenceNumber = status->llSequenceNumber;
926 lstrcpyA(spec.szDescription, "msitest restore point");
928 return pSRSetRestorePointA(&spec, status);
931 static void remove_restore_point(DWORD seq_number)
933 DWORD res;
935 res = pSRRemoveRestorePoint(seq_number);
936 if (res != ERROR_SUCCESS)
937 trace("Failed to remove the restore point : %08x\n", res);
940 static BOOL is_root(const char *path)
942 return (isalpha(path[0]) && path[1] == ':' && path[2] == '\\' && !path[3]);
945 static void test_createpackage(void)
947 MSIHANDLE hPackage = 0;
948 UINT res;
950 res = package_from_db(create_package_db(), &hPackage);
951 if (res == ERROR_INSTALL_PACKAGE_REJECTED)
953 skip("Not enough rights to perform tests\n");
954 DeleteFileA(msifile);
955 return;
957 ok( res == ERROR_SUCCESS, " Failed to create package %u\n", res );
959 res = MsiCloseHandle( hPackage);
960 ok( res == ERROR_SUCCESS , "Failed to close package\n" );
961 DeleteFileA(msifile);
964 static void test_doaction( void )
966 MSIHANDLE hpkg;
967 UINT r;
969 r = MsiDoActionA( -1, NULL );
970 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
972 r = package_from_db(create_package_db(), &hpkg);
973 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
975 skip("Not enough rights to perform tests\n");
976 DeleteFileA(msifile);
977 return;
979 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
981 r = MsiDoActionA(hpkg, NULL);
982 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
984 r = MsiDoActionA(0, "boo");
985 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
987 r = MsiDoActionA(hpkg, "boo");
988 ok( r == ERROR_FUNCTION_NOT_CALLED, "wrong return val\n");
990 MsiCloseHandle( hpkg );
991 DeleteFileA(msifile);
994 static void test_gettargetpath_bad(void)
996 static const WCHAR boo[] = {'b','o','o',0};
997 static const WCHAR empty[] = {0};
998 char buffer[0x80];
999 WCHAR bufferW[0x80];
1000 MSIHANDLE hpkg;
1001 DWORD sz;
1002 UINT r;
1004 r = package_from_db(create_package_db(), &hpkg);
1005 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1007 skip("Not enough rights to perform tests\n");
1008 DeleteFileA(msifile);
1009 return;
1011 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1013 r = MsiGetTargetPathA( 0, NULL, NULL, NULL );
1014 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1016 r = MsiGetTargetPathA( 0, NULL, NULL, &sz );
1017 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1019 r = MsiGetTargetPathA( 0, "boo", NULL, NULL );
1020 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1022 r = MsiGetTargetPathA( 0, "boo", NULL, NULL );
1023 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1025 r = MsiGetTargetPathA( hpkg, "boo", NULL, NULL );
1026 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1028 r = MsiGetTargetPathA( hpkg, "boo", buffer, NULL );
1029 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1031 sz = 0;
1032 r = MsiGetTargetPathA( hpkg, "", buffer, &sz );
1033 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1035 r = MsiGetTargetPathW( 0, NULL, NULL, NULL );
1036 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1038 r = MsiGetTargetPathW( 0, NULL, NULL, &sz );
1039 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1041 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1042 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1044 r = MsiGetTargetPathW( 0, boo, NULL, NULL );
1045 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1047 r = MsiGetTargetPathW( hpkg, boo, NULL, NULL );
1048 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1050 r = MsiGetTargetPathW( hpkg, boo, bufferW, NULL );
1051 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1053 sz = 0;
1054 r = MsiGetTargetPathW( hpkg, empty, bufferW, &sz );
1055 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1057 MsiCloseHandle( hpkg );
1058 DeleteFileA(msifile);
1061 static void query_file_path(MSIHANDLE hpkg, LPCSTR file, LPSTR buff)
1063 UINT r;
1064 DWORD size;
1065 MSIHANDLE rec;
1067 rec = MsiCreateRecord( 1 );
1068 ok(rec, "MsiCreate record failed\n");
1070 r = MsiRecordSetStringA( rec, 0, file );
1071 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1073 size = MAX_PATH;
1074 r = MsiFormatRecordA( hpkg, rec, buff, &size );
1075 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
1077 MsiCloseHandle( rec );
1080 static void test_settargetpath(void)
1082 char tempdir[MAX_PATH+8], buffer[MAX_PATH], file[MAX_PATH];
1083 DWORD sz;
1084 MSIHANDLE hpkg;
1085 UINT r;
1086 MSIHANDLE hdb;
1088 hdb = create_package_db();
1089 ok ( hdb, "failed to create package database\n" );
1091 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
1092 ok( r == S_OK, "failed to add directory entry: %d\n" , r );
1094 r = create_component_table( hdb );
1095 ok( r == S_OK, "cannot create Component table: %d\n", r );
1097 r = add_component_entry( hdb, "'RootComp', '{83e2694d-0864-4124-9323-6d37630912a1}', 'TARGETDIR', 8, '', 'RootFile'" );
1098 ok( r == S_OK, "cannot add dummy component: %d\n", r );
1100 r = add_component_entry( hdb, "'TestComp', '{A3FB59C8-C293-4F7E-B8C5-F0E1D8EEE4E5}', 'TestDir', 0, '', 'TestFile'" );
1101 ok( r == S_OK, "cannot add test component: %d\n", r );
1103 r = create_feature_table( hdb );
1104 ok( r == S_OK, "cannot create Feature table: %d\n", r );
1106 r = add_feature_entry( hdb, "'TestFeature', '', '', '', 0, 1, '', 0" );
1107 ok( r == ERROR_SUCCESS, "cannot add TestFeature to Feature table: %d\n", r );
1109 r = create_feature_components_table( hdb );
1110 ok( r == S_OK, "cannot create FeatureComponents table: %d\n", r );
1112 r = add_feature_components_entry( hdb, "'TestFeature', 'RootComp'" );
1113 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1115 r = add_feature_components_entry( hdb, "'TestFeature', 'TestComp'" );
1116 ok( r == S_OK, "cannot insert component into FeatureComponents table: %d\n", r );
1118 add_directory_entry( hdb, "'TestParent', 'TARGETDIR', 'TestParent'" );
1119 add_directory_entry( hdb, "'TestDir', 'TestParent', 'TestDir'" );
1121 r = create_file_table( hdb );
1122 ok( r == S_OK, "cannot create File table: %d\n", r );
1124 r = add_file_entry( hdb, "'RootFile', 'RootComp', 'rootfile.txt', 0, '', '1033', 8192, 1" );
1125 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1127 r = add_file_entry( hdb, "'TestFile', 'TestComp', 'testfile.txt', 0, '', '1033', 8192, 1" );
1128 ok( r == S_OK, "cannot add file to the File table: %d\n", r );
1130 r = package_from_db( hdb, &hpkg );
1131 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1133 skip("Not enough rights to perform tests\n");
1134 DeleteFileA(msifile);
1135 return;
1137 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1139 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
1141 r = MsiDoActionA( hpkg, "CostInitialize");
1142 ok( r == ERROR_SUCCESS, "cost init failed\n");
1144 r = MsiDoActionA( hpkg, "FileCost");
1145 ok( r == ERROR_SUCCESS, "file cost failed\n");
1147 r = MsiDoActionA( hpkg, "CostFinalize");
1148 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
1150 buffer[0] = 0;
1151 sz = sizeof(buffer);
1152 r = MsiGetPropertyA( hpkg, "OutOfNoRbDiskSpace", buffer, &sz );
1153 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1154 trace( "OutOfNoRbDiskSpace = \"%s\"\n", buffer );
1156 r = MsiSetTargetPathA( 0, NULL, NULL );
1157 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1159 r = MsiSetTargetPathA( 0, "boo", "C:\\bogusx" );
1160 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
1162 r = MsiSetTargetPathA( hpkg, "boo", NULL );
1163 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
1165 r = MsiSetTargetPathA( hpkg, "boo", "c:\\bogusx" );
1166 ok( r == ERROR_DIRECTORY, "wrong return val\n");
1168 sz = sizeof tempdir - 1;
1169 r = MsiGetTargetPathA( hpkg, "TARGETDIR", tempdir, &sz );
1170 sprintf( file, "%srootfile.txt", tempdir );
1171 buffer[0] = 0;
1172 query_file_path( hpkg, "[#RootFile]", buffer );
1173 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1174 ok( !lstrcmpA(buffer, file), "Expected %s, got %s\n", file, buffer );
1176 GetTempFileNameA( tempdir, "_wt", 0, buffer );
1177 sprintf( tempdir, "%s\\subdir", buffer );
1179 r = MsiSetTargetPathA( hpkg, "TARGETDIR", buffer );
1180 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1181 "MsiSetTargetPath on file returned %d\n", r );
1183 r = MsiSetTargetPathA( hpkg, "TARGETDIR", tempdir );
1184 ok( r == ERROR_SUCCESS || r == ERROR_DIRECTORY,
1185 "MsiSetTargetPath on 'subdir' of file returned %d\n", r );
1187 DeleteFileA( buffer );
1189 r = MsiSetTargetPathA( hpkg, "TARGETDIR", buffer );
1190 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1192 r = GetFileAttributesA( buffer );
1193 ok ( r == INVALID_FILE_ATTRIBUTES, "file/directory exists after MsiSetTargetPath. Attributes: %08X\n", r );
1195 r = MsiSetTargetPathA( hpkg, "TARGETDIR", tempdir );
1196 ok( r == ERROR_SUCCESS, "MsiSetTargetPath on subsubdir returned %d\n", r );
1198 buffer[0] = 0;
1199 sz = sizeof buffer - 1;
1200 lstrcatA( tempdir, "\\" );
1201 r = MsiGetTargetPathA( hpkg, "TARGETDIR", buffer, &sz );
1202 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1203 ok( !lstrcmpA(buffer, tempdir), "Expected %s, got %s\n", tempdir, buffer);
1205 sprintf( file, "%srootfile.txt", tempdir );
1206 query_file_path( hpkg, "[#RootFile]", buffer );
1207 ok( !lstrcmpA(buffer, file), "Expected %s, got %s\n", file, buffer);
1209 buffer[0] = 0;
1210 sz = sizeof(buffer);
1211 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1212 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1213 lstrcatA( tempdir, "TestParent\\" );
1214 ok( !lstrcmpiA(buffer, tempdir), "Expected \"%s\", got \"%s\"\n", tempdir, buffer );
1216 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\one\\two" );
1217 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1219 buffer[0] = 0;
1220 sz = sizeof(buffer);
1221 r = MsiGetPropertyA( hpkg, "TestParent", buffer, &sz );
1222 ok( r == ERROR_SUCCESS, "MsiGetProperty returned %u\n", r );
1223 ok( lstrcmpiA(buffer, "C:\\one\\two\\TestDir\\"),
1224 "Expected \"C:\\one\\two\\TestDir\\\", got \"%s\"\n", buffer );
1226 buffer[0] = 0;
1227 query_file_path( hpkg, "[#TestFile]", buffer );
1228 ok( !lstrcmpiA(buffer, "C:\\one\\two\\TestDir\\testfile.txt"),
1229 "Expected C:\\one\\two\\TestDir\\testfile.txt, got %s\n", buffer );
1231 buffer[0] = 0;
1232 sz = sizeof buffer - 1;
1233 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1234 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1235 ok( !lstrcmpiA(buffer, "C:\\one\\two\\"), "Expected C:\\one\\two\\, got %s\n", buffer);
1237 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\one\\two\\three" );
1238 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1240 buffer[0] = 0;
1241 sz = sizeof buffer - 1;
1242 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1243 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1244 ok( !lstrcmpiA(buffer, "C:\\one\\two\\three\\"), "Expected C:\\one\\two\\three\\, got %s\n", buffer);
1246 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\\\one\\\\two " );
1247 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1249 buffer[0] = 0;
1250 sz = sizeof buffer - 1;
1251 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1252 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1253 ok( !lstrcmpiA(buffer, "C:\\one\\two\\"), "Expected \"C:\\one\\two\\\", got %s\n", buffer);
1255 r = MsiSetTargetPathA( hpkg, "TestParent", "C:\\\\ Program Files \\\\ " );
1256 ok( r == ERROR_SUCCESS, "MsiSetTargetPath returned %d\n", r );
1258 buffer[0] = 0;
1259 sz = sizeof buffer - 1;
1260 r = MsiGetTargetPathA( hpkg, "TestParent", buffer, &sz );
1261 ok( r == ERROR_SUCCESS, "failed to get target path: %d\n", r);
1262 ok( !lstrcmpiA(buffer, "C:\\Program Files\\"), "Expected \"C:\\Program Files\\\", got %s\n", buffer);
1264 MsiCloseHandle( hpkg );
1267 static void test_condition(void)
1269 static const WCHAR cond1[] = {'\"','a',0x30a,'\"','<','\"',0xe5,'\"',0};
1270 static const WCHAR cond2[] = {'\"','a',0x30a,'\"','>','\"',0xe5,'\"',0};
1271 static const WCHAR cond3[] = {'\"','a',0x30a,'\"','<','>','\"',0xe5,'\"',0};
1272 static const WCHAR cond4[] = {'\"','a',0x30a,'\"','=','\"',0xe5,'\"',0};
1273 MSICONDITION r;
1274 MSIHANDLE hpkg;
1276 r = package_from_db(create_package_db(), &hpkg);
1277 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
1279 skip("Not enough rights to perform tests\n");
1280 DeleteFileA(msifile);
1281 return;
1283 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
1285 r = MsiEvaluateConditionA(0, NULL);
1286 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1288 r = MsiEvaluateConditionA(hpkg, NULL);
1289 ok( r == MSICONDITION_NONE, "wrong return val\n");
1291 r = MsiEvaluateConditionA(hpkg, "");
1292 ok( r == MSICONDITION_NONE, "wrong return val\n");
1294 r = MsiEvaluateConditionA(hpkg, "1");
1295 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1297 r = MsiEvaluateConditionA(hpkg, "0");
1298 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1300 r = MsiEvaluateConditionA(hpkg, "-1");
1301 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1303 r = MsiEvaluateConditionA(hpkg, "0 = 0");
1304 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1306 r = MsiEvaluateConditionA(hpkg, "0 <> 0");
1307 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1309 r = MsiEvaluateConditionA(hpkg, "0 = 1");
1310 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1312 r = MsiEvaluateConditionA(hpkg, "0 > 1");
1313 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1315 r = MsiEvaluateConditionA(hpkg, "0 ~> 1");
1316 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1318 r = MsiEvaluateConditionA(hpkg, "1 > 1");
1319 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1321 r = MsiEvaluateConditionA(hpkg, "1 ~> 1");
1322 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1324 r = MsiEvaluateConditionA(hpkg, "0 >= 1");
1325 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1327 r = MsiEvaluateConditionA(hpkg, "0 ~>= 1");
1328 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1330 r = MsiEvaluateConditionA(hpkg, "1 >= 1");
1331 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1333 r = MsiEvaluateConditionA(hpkg, "1 ~>= 1");
1334 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1336 r = MsiEvaluateConditionA(hpkg, "0 < 1");
1337 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1339 r = MsiEvaluateConditionA(hpkg, "0 ~< 1");
1340 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1342 r = MsiEvaluateConditionA(hpkg, "1 < 1");
1343 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1345 r = MsiEvaluateConditionA(hpkg, "1 ~< 1");
1346 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1348 r = MsiEvaluateConditionA(hpkg, "0 <= 1");
1349 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1351 r = MsiEvaluateConditionA(hpkg, "0 ~<= 1");
1352 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1354 r = MsiEvaluateConditionA(hpkg, "1 <= 1");
1355 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1357 r = MsiEvaluateConditionA(hpkg, "1 ~<= 1");
1358 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1360 r = MsiEvaluateConditionA(hpkg, "0 >=");
1361 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1363 r = MsiEvaluateConditionA(hpkg, " ");
1364 ok( r == MSICONDITION_NONE, "wrong return val\n");
1366 r = MsiEvaluateConditionA(hpkg, "LicView <> \"1\"");
1367 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1369 r = MsiEvaluateConditionA(hpkg, "LicView <> \"0\"");
1370 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1372 r = MsiEvaluateConditionA(hpkg, "LicView <> LicView");
1373 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1375 r = MsiEvaluateConditionA(hpkg, "not 0");
1376 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1378 r = MsiEvaluateConditionA(hpkg, "not LicView");
1379 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1381 r = MsiEvaluateConditionA(hpkg, "\"Testing\" ~<< \"Testing\"");
1382 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1384 r = MsiEvaluateConditionA(hpkg, "LicView ~<< \"Testing\"");
1385 ok (r == MSICONDITION_FALSE, "wrong return val\n");
1387 r = MsiEvaluateConditionA(hpkg, "Not LicView ~<< \"Testing\"");
1388 ok (r == MSICONDITION_TRUE, "wrong return val\n");
1390 r = MsiEvaluateConditionA(hpkg, "not \"A\"");
1391 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1393 r = MsiEvaluateConditionA(hpkg, "~not \"A\"");
1394 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1396 r = MsiEvaluateConditionA(hpkg, "\"0\"");
1397 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1399 r = MsiEvaluateConditionA(hpkg, "1 and 2");
1400 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1402 r = MsiEvaluateConditionA(hpkg, "not 0 and 3");
1403 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1405 r = MsiEvaluateConditionA(hpkg, "not 0 and 0");
1406 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1408 r = MsiEvaluateConditionA(hpkg, "not 0 or 1");
1409 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1411 r = MsiEvaluateConditionA(hpkg, "(0)");
1412 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1414 r = MsiEvaluateConditionA(hpkg, "(((((1))))))");
1415 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1417 r = MsiEvaluateConditionA(hpkg, "(((((1)))))");
1418 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1420 r = MsiEvaluateConditionA(hpkg, " \"A\" < \"B\" ");
1421 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1423 r = MsiEvaluateConditionA(hpkg, " \"A\" > \"B\" ");
1424 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1426 r = MsiEvaluateConditionA(hpkg, " \"1\" > \"12\" ");
1427 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1429 r = MsiEvaluateConditionA(hpkg, " \"100\" < \"21\" ");
1430 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1432 r = MsiEvaluateConditionA(hpkg, "0 < > 0");
1433 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1435 r = MsiEvaluateConditionA(hpkg, "(1<<1) == 2");
1436 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1438 r = MsiEvaluateConditionA(hpkg, " \"A\" = \"a\" ");
1439 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1441 r = MsiEvaluateConditionA(hpkg, " \"A\" ~ = \"a\" ");
1442 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1444 r = MsiEvaluateConditionA(hpkg, " \"A\" ~= \"a\" ");
1445 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1447 r = MsiEvaluateConditionA(hpkg, " \"A\" ~= 1 ");
1448 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1450 r = MsiEvaluateConditionA(hpkg, " \"A\" = 1 ");
1451 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1453 r = MsiEvaluateConditionA(hpkg, " 1 ~= 1 ");
1454 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1456 r = MsiEvaluateConditionA(hpkg, " 1 ~= \"1\" ");
1457 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1459 r = MsiEvaluateConditionA(hpkg, " 1 = \"1\" ");
1460 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1462 r = MsiEvaluateConditionA(hpkg, " 0 = \"1\" ");
1463 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1465 r = MsiEvaluateConditionA(hpkg, " 0 < \"100\" ");
1466 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1468 r = MsiEvaluateConditionA(hpkg, " 100 > \"0\" ");
1469 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1471 r = MsiEvaluateConditionA(hpkg, "1 XOR 1");
1472 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1474 r = MsiEvaluateConditionA(hpkg, "1 IMP 1");
1475 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1477 r = MsiEvaluateConditionA(hpkg, "1 IMP 0");
1478 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1480 r = MsiEvaluateConditionA(hpkg, "0 IMP 0");
1481 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1483 r = MsiEvaluateConditionA(hpkg, "0 EQV 0");
1484 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1486 r = MsiEvaluateConditionA(hpkg, "0 EQV 1");
1487 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1489 r = MsiEvaluateConditionA(hpkg, "1 IMP 1 OR 0");
1490 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1492 r = MsiEvaluateConditionA(hpkg, "1 IMPL 1");
1493 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1495 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" >< \"S\" ");
1496 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1498 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"s\" ");
1499 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1501 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"\" ");
1502 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1504 r = MsiEvaluateConditionA(hpkg, "\"ASFD\" ~>< \"sss\" ");
1505 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1507 MsiSetPropertyA(hpkg, "mm", "5" );
1509 r = MsiEvaluateConditionA(hpkg, "mm = 5");
1510 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1512 r = MsiEvaluateConditionA(hpkg, "mm < 6");
1513 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1515 r = MsiEvaluateConditionA(hpkg, "mm <= 5");
1516 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1518 r = MsiEvaluateConditionA(hpkg, "mm > 4");
1519 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1521 r = MsiEvaluateConditionA(hpkg, "mm < 12");
1522 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1524 r = MsiEvaluateConditionA(hpkg, "mm = \"5\"");
1525 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1527 r = MsiEvaluateConditionA(hpkg, "0 = \"\"");
1528 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1530 r = MsiEvaluateConditionA(hpkg, "0 AND \"\"");
1531 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1533 r = MsiEvaluateConditionA(hpkg, "1 AND \"\"");
1534 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1536 r = MsiEvaluateConditionA(hpkg, "1 AND \"1\"");
1537 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1539 r = MsiEvaluateConditionA(hpkg, "3 >< 1");
1540 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1542 r = MsiEvaluateConditionA(hpkg, "3 >< 4");
1543 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1545 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 0");
1546 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1548 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 1");
1549 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1551 r = MsiEvaluateConditionA(hpkg, "NOT 1 OR 0");
1552 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1554 r = MsiEvaluateConditionA(hpkg, "0 AND 1 OR 1");
1555 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1557 r = MsiEvaluateConditionA(hpkg, "0 AND 0 OR 1");
1558 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1560 r = MsiEvaluateConditionA(hpkg, "NOT 0 AND 1 OR 0");
1561 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1563 r = MsiEvaluateConditionA(hpkg, "_1 = _1");
1564 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1566 r = MsiEvaluateConditionA(hpkg, "( 1 AND 1 ) = 2");
1567 ok( r == MSICONDITION_ERROR, "wrong return val\n");
1569 r = MsiEvaluateConditionA(hpkg, "NOT ( 1 AND 1 )");
1570 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1572 r = MsiEvaluateConditionA(hpkg, "NOT A AND (BBBBBBBBBB=2 OR CCC=1) AND Ddddddddd");
1573 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1575 r = MsiEvaluateConditionA(hpkg, "Installed<>\"\"");
1576 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1578 r = MsiEvaluateConditionA(hpkg, "NOT 1 AND 0");
1579 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1581 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1582 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1584 r = MsiEvaluateConditionA(hpkg, "bandalmael<>0");
1585 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1587 r = MsiEvaluateConditionA(hpkg, "bandalmael<0");
1588 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1590 r = MsiEvaluateConditionA(hpkg, "bandalmael>0");
1591 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1593 r = MsiEvaluateConditionA(hpkg, "bandalmael>=0");
1594 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1596 r = MsiEvaluateConditionA(hpkg, "bandalmael<=0");
1597 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1599 r = MsiEvaluateConditionA(hpkg, "bandalmael~<>0");
1600 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1602 MsiSetPropertyA(hpkg, "bandalmael", "0" );
1603 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1604 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1606 MsiSetPropertyA(hpkg, "bandalmael", "" );
1607 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1608 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1610 MsiSetPropertyA(hpkg, "bandalmael", "asdf" );
1611 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1612 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1614 MsiSetPropertyA(hpkg, "bandalmael", "0asdf" );
1615 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1616 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1618 MsiSetPropertyA(hpkg, "bandalmael", "0 " );
1619 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1620 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1622 MsiSetPropertyA(hpkg, "bandalmael", "-0" );
1623 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1624 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1626 MsiSetPropertyA(hpkg, "bandalmael", "0000000000000" );
1627 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1628 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1630 MsiSetPropertyA(hpkg, "bandalmael", "--0" );
1631 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1632 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1634 MsiSetPropertyA(hpkg, "bandalmael", "0x00" );
1635 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1636 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1638 MsiSetPropertyA(hpkg, "bandalmael", "-" );
1639 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1640 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1642 MsiSetPropertyA(hpkg, "bandalmael", "+0" );
1643 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1644 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1646 MsiSetPropertyA(hpkg, "bandalmael", "0.0" );
1647 r = MsiEvaluateConditionA(hpkg, "bandalmael=0");
1648 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1649 r = MsiEvaluateConditionA(hpkg, "bandalmael<>0");
1650 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1652 MsiSetPropertyA(hpkg, "one", "hi");
1653 MsiSetPropertyA(hpkg, "two", "hithere");
1654 r = MsiEvaluateConditionA(hpkg, "one >< two");
1655 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1657 MsiSetPropertyA(hpkg, "one", "hithere");
1658 MsiSetPropertyA(hpkg, "two", "hi");
1659 r = MsiEvaluateConditionA(hpkg, "one >< two");
1660 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1662 MsiSetPropertyA(hpkg, "one", "hello");
1663 MsiSetPropertyA(hpkg, "two", "hi");
1664 r = MsiEvaluateConditionA(hpkg, "one >< two");
1665 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1667 MsiSetPropertyA(hpkg, "one", "hellohithere");
1668 MsiSetPropertyA(hpkg, "two", "hi");
1669 r = MsiEvaluateConditionA(hpkg, "one >< two");
1670 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1672 MsiSetPropertyA(hpkg, "one", "");
1673 MsiSetPropertyA(hpkg, "two", "hi");
1674 r = MsiEvaluateConditionA(hpkg, "one >< two");
1675 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1677 MsiSetPropertyA(hpkg, "one", "hi");
1678 MsiSetPropertyA(hpkg, "two", "");
1679 r = MsiEvaluateConditionA(hpkg, "one >< two");
1680 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1682 MsiSetPropertyA(hpkg, "one", "");
1683 MsiSetPropertyA(hpkg, "two", "");
1684 r = MsiEvaluateConditionA(hpkg, "one >< two");
1685 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1687 MsiSetPropertyA(hpkg, "one", "1234");
1688 MsiSetPropertyA(hpkg, "two", "1");
1689 r = MsiEvaluateConditionA(hpkg, "one >< two");
1690 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1692 MsiSetPropertyA(hpkg, "one", "one 1234");
1693 MsiSetPropertyA(hpkg, "two", "1");
1694 r = MsiEvaluateConditionA(hpkg, "one >< two");
1695 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1697 MsiSetPropertyA(hpkg, "one", "hithere");
1698 MsiSetPropertyA(hpkg, "two", "hi");
1699 r = MsiEvaluateConditionA(hpkg, "one << two");
1700 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1702 MsiSetPropertyA(hpkg, "one", "hi");
1703 MsiSetPropertyA(hpkg, "two", "hithere");
1704 r = MsiEvaluateConditionA(hpkg, "one << two");
1705 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1707 MsiSetPropertyA(hpkg, "one", "hi");
1708 MsiSetPropertyA(hpkg, "two", "hi");
1709 r = MsiEvaluateConditionA(hpkg, "one << two");
1710 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1712 MsiSetPropertyA(hpkg, "one", "abcdhithere");
1713 MsiSetPropertyA(hpkg, "two", "hi");
1714 r = MsiEvaluateConditionA(hpkg, "one << two");
1715 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1717 MsiSetPropertyA(hpkg, "one", "");
1718 MsiSetPropertyA(hpkg, "two", "hi");
1719 r = MsiEvaluateConditionA(hpkg, "one << two");
1720 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1722 MsiSetPropertyA(hpkg, "one", "hithere");
1723 MsiSetPropertyA(hpkg, "two", "");
1724 r = MsiEvaluateConditionA(hpkg, "one << two");
1725 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1727 MsiSetPropertyA(hpkg, "one", "");
1728 MsiSetPropertyA(hpkg, "two", "");
1729 r = MsiEvaluateConditionA(hpkg, "one << two");
1730 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1732 MsiSetPropertyA(hpkg, "one", "1234");
1733 MsiSetPropertyA(hpkg, "two", "1");
1734 r = MsiEvaluateConditionA(hpkg, "one << two");
1735 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1737 MsiSetPropertyA(hpkg, "one", "1234 one");
1738 MsiSetPropertyA(hpkg, "two", "1");
1739 r = MsiEvaluateConditionA(hpkg, "one << two");
1740 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1742 MsiSetPropertyA(hpkg, "one", "hithere");
1743 MsiSetPropertyA(hpkg, "two", "there");
1744 r = MsiEvaluateConditionA(hpkg, "one >> two");
1745 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1747 MsiSetPropertyA(hpkg, "one", "hithere");
1748 MsiSetPropertyA(hpkg, "two", "hi");
1749 r = MsiEvaluateConditionA(hpkg, "one >> two");
1750 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1752 MsiSetPropertyA(hpkg, "one", "there");
1753 MsiSetPropertyA(hpkg, "two", "hithere");
1754 r = MsiEvaluateConditionA(hpkg, "one >> two");
1755 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1757 MsiSetPropertyA(hpkg, "one", "there");
1758 MsiSetPropertyA(hpkg, "two", "there");
1759 r = MsiEvaluateConditionA(hpkg, "one >> two");
1760 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1762 MsiSetPropertyA(hpkg, "one", "abcdhithere");
1763 MsiSetPropertyA(hpkg, "two", "hi");
1764 r = MsiEvaluateConditionA(hpkg, "one >> two");
1765 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1767 MsiSetPropertyA(hpkg, "one", "");
1768 MsiSetPropertyA(hpkg, "two", "there");
1769 r = MsiEvaluateConditionA(hpkg, "one >> two");
1770 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1772 MsiSetPropertyA(hpkg, "one", "there");
1773 MsiSetPropertyA(hpkg, "two", "");
1774 r = MsiEvaluateConditionA(hpkg, "one >> two");
1775 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1777 MsiSetPropertyA(hpkg, "one", "");
1778 MsiSetPropertyA(hpkg, "two", "");
1779 r = MsiEvaluateConditionA(hpkg, "one >> two");
1780 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1782 MsiSetPropertyA(hpkg, "one", "1234");
1783 MsiSetPropertyA(hpkg, "two", "4");
1784 r = MsiEvaluateConditionA(hpkg, "one >> two");
1785 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1787 MsiSetPropertyA(hpkg, "one", "one 1234");
1788 MsiSetPropertyA(hpkg, "two", "4");
1789 r = MsiEvaluateConditionA(hpkg, "one >> two");
1790 ok( r == MSICONDITION_TRUE, "wrong return val\n");
1792 MsiSetPropertyA(hpkg, "MsiNetAssemblySupport", NULL); /* make sure it's empty */
1794 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1795 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1797 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport > \"1.1.4322\"");
1798 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1800 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport >= \"1.1.4322\"");
1801 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1803 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport <= \"1.1.4322\"");
1804 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1806 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport <> \"1.1.4322\"");
1807 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1809 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport ~< \"1.1.4322\"");
1810 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1812 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"abcd\"");
1813 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1815 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a1.1.4322\"");
1816 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1818 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322a\"");
1819 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1821 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"0000001.1.4322\"");
1822 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1824 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1\"");
1825 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1827 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322.1.1\"");
1828 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1830 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"1.1");
1831 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1833 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"1.1\"");
1834 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1836 r = MsiEvaluateConditionA(hpkg, "\"2\" < \"12.1\"");
1837 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1839 r = MsiEvaluateConditionA(hpkg, "\"02.1\" < \"2.11\"");
1840 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1842 r = MsiEvaluateConditionA(hpkg, "\"02.1.1\" < \"2.1\"");
1843 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1845 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1846 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1848 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1\"");
1849 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1851 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"0\"");
1852 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1854 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"-1\"");
1855 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1857 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a\"");
1858 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1860 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"!\"");
1861 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1863 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"!\"");
1864 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1866 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"/\"");
1867 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1869 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \" \"");
1870 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1872 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"azAZ_\"");
1873 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1875 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a[a]\"");
1876 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1878 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a[a]a\"");
1879 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1881 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a]\"");
1882 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1884 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a]a\"");
1885 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1887 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"{a}\"");
1888 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1890 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"{a\"");
1891 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1893 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"[a\"");
1894 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1896 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a{\"");
1897 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1899 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"a]\"");
1900 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1902 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"A\"");
1903 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1905 MsiSetPropertyA(hpkg, "MsiNetAssemblySupport", "1.1.4322");
1906 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.4322\"");
1907 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1909 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.14322\"");
1910 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1912 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1.5\"");
1913 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1915 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1.1\"");
1916 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1918 r = MsiEvaluateConditionA(hpkg, "MsiNetAssemblySupport < \"1\"");
1919 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1921 MsiSetPropertyA(hpkg, "one", "1");
1922 r = MsiEvaluateConditionA(hpkg, "one < \"1\"");
1923 ok( r == MSICONDITION_FALSE, "wrong return val\n");
1925 MsiSetPropertyA(hpkg, "X", "5.0");
1927 r = MsiEvaluateConditionA(hpkg, "X != \"\"");
1928 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1930 r = MsiEvaluateConditionA(hpkg, "X =\"5.0\"");
1931 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1933 r = MsiEvaluateConditionA(hpkg, "X =\"5.1\"");
1934 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1936 r = MsiEvaluateConditionA(hpkg, "X =\"6.0\"");
1937 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1939 r = MsiEvaluateConditionA(hpkg, "X =\"5.0\" or X =\"5.1\" or X =\"6.0\"");
1940 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1942 r = MsiEvaluateConditionA(hpkg, "(X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1943 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1945 r = MsiEvaluateConditionA(hpkg, "X !=\"\" and (X =\"5.0\" or X =\"5.1\" or X =\"6.0\")");
1946 ok( r == MSICONDITION_ERROR, "wrong return val (%d)\n", r);
1948 /* feature doesn't exist */
1949 r = MsiEvaluateConditionA(hpkg, "&nofeature");
1950 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1952 MsiSetPropertyA(hpkg, "A", "2");
1953 MsiSetPropertyA(hpkg, "X", "50");
1955 r = MsiEvaluateConditionA(hpkg, "2 <= X");
1956 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1958 r = MsiEvaluateConditionA(hpkg, "A <= X");
1959 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1961 r = MsiEvaluateConditionA(hpkg, "A <= 50");
1962 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1964 MsiSetPropertyA(hpkg, "X", "50val");
1966 r = MsiEvaluateConditionA(hpkg, "2 <= X");
1967 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1969 r = MsiEvaluateConditionA(hpkg, "A <= X");
1970 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1972 MsiSetPropertyA(hpkg, "A", "7");
1973 MsiSetPropertyA(hpkg, "X", "50");
1975 r = MsiEvaluateConditionA(hpkg, "7 <= X");
1976 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1978 r = MsiEvaluateConditionA(hpkg, "A <= X");
1979 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1981 r = MsiEvaluateConditionA(hpkg, "A <= 50");
1982 ok( r == MSICONDITION_TRUE, "wrong return val (%d)\n", r);
1984 MsiSetPropertyA(hpkg, "X", "50val");
1986 r = MsiEvaluateConditionA(hpkg, "2 <= X");
1987 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1989 r = MsiEvaluateConditionA(hpkg, "A <= X");
1990 ok( r == MSICONDITION_FALSE, "wrong return val (%d)\n", r);
1992 r = MsiEvaluateConditionW(hpkg, cond1);
1993 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
1994 "wrong return val (%d)\n", r);
1996 r = MsiEvaluateConditionW(hpkg, cond2);
1997 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
1998 "wrong return val (%d)\n", r);
2000 r = MsiEvaluateConditionW(hpkg, cond3);
2001 ok( r == MSICONDITION_TRUE || broken(r == MSICONDITION_FALSE),
2002 "wrong return val (%d)\n", r);
2004 r = MsiEvaluateConditionW(hpkg, cond4);
2005 ok( r == MSICONDITION_FALSE || broken(r == MSICONDITION_TRUE),
2006 "wrong return val (%d)\n", r);
2008 MsiCloseHandle( hpkg );
2009 DeleteFileA(msifile);
2012 static BOOL check_prop_empty( MSIHANDLE hpkg, const char * prop)
2014 UINT r;
2015 DWORD sz;
2016 char buffer[2];
2018 sz = sizeof buffer;
2019 strcpy(buffer,"x");
2020 r = MsiGetPropertyA( hpkg, prop, buffer, &sz );
2021 return r == ERROR_SUCCESS && buffer[0] == 0 && sz == 0;
2024 static void test_props(void)
2026 MSIHANDLE hpkg, hdb;
2027 UINT r;
2028 DWORD sz;
2029 char buffer[0x100];
2031 hdb = create_package_db();
2032 r = run_query( hdb,
2033 "CREATE TABLE `Property` ( "
2034 "`Property` CHAR(255) NOT NULL, "
2035 "`Value` CHAR(255) "
2036 "PRIMARY KEY `Property`)" );
2037 ok( r == ERROR_SUCCESS , "Failed\n" );
2039 r = run_query(hdb,
2040 "INSERT INTO `Property` "
2041 "(`Property`, `Value`) "
2042 "VALUES( 'MetadataCompName', 'Photoshop.dll' )");
2043 ok( r == ERROR_SUCCESS , "Failed\n" );
2045 r = package_from_db( hdb, &hpkg );
2046 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2048 skip("Not enough rights to perform tests\n");
2049 DeleteFileA(msifile);
2050 return;
2052 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2054 /* test invalid values */
2055 r = MsiGetPropertyA( 0, NULL, NULL, NULL );
2056 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2058 r = MsiGetPropertyA( hpkg, NULL, NULL, NULL );
2059 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2061 r = MsiGetPropertyA( hpkg, "boo", NULL, NULL );
2062 ok( r == ERROR_SUCCESS, "wrong return val\n");
2064 r = MsiGetPropertyA( hpkg, "boo", buffer, NULL );
2065 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2067 /* test retrieving an empty/nonexistent property */
2068 sz = sizeof buffer;
2069 r = MsiGetPropertyA( hpkg, "boo", NULL, &sz );
2070 ok( r == ERROR_SUCCESS, "wrong return val\n");
2071 ok( sz == 0, "wrong size returned\n");
2073 check_prop_empty( hpkg, "boo");
2074 sz = 0;
2075 strcpy(buffer,"x");
2076 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2077 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2078 ok( !strcmp(buffer,"x"), "buffer was changed\n");
2079 ok( sz == 0, "wrong size returned\n");
2081 sz = 1;
2082 strcpy(buffer,"x");
2083 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2084 ok( r == ERROR_SUCCESS, "wrong return val\n");
2085 ok( buffer[0] == 0, "buffer was not changed\n");
2086 ok( sz == 0, "wrong size returned\n");
2088 /* set the property to something */
2089 r = MsiSetPropertyA( 0, NULL, NULL );
2090 ok( r == ERROR_INVALID_HANDLE, "wrong return val\n");
2092 r = MsiSetPropertyA( hpkg, NULL, NULL );
2093 ok( r == ERROR_INVALID_PARAMETER, "wrong return val\n");
2095 r = MsiSetPropertyA( hpkg, "", NULL );
2096 ok( r == ERROR_SUCCESS, "wrong return val\n");
2098 /* try set and get some illegal property identifiers */
2099 r = MsiSetPropertyA( hpkg, "", "asdf" );
2100 ok( r == ERROR_FUNCTION_FAILED, "wrong return val\n");
2102 r = MsiSetPropertyA( hpkg, "=", "asdf" );
2103 ok( r == ERROR_SUCCESS, "wrong return val\n");
2105 r = MsiSetPropertyA( hpkg, " ", "asdf" );
2106 ok( r == ERROR_SUCCESS, "wrong return val\n");
2108 r = MsiSetPropertyA( hpkg, "'", "asdf" );
2109 ok( r == ERROR_SUCCESS, "wrong return val\n");
2111 sz = sizeof buffer;
2112 buffer[0]=0;
2113 r = MsiGetPropertyA( hpkg, "'", buffer, &sz );
2114 ok( r == ERROR_SUCCESS, "wrong return val\n");
2115 ok( !strcmp(buffer,"asdf"), "buffer was not changed\n");
2117 /* set empty values */
2118 r = MsiSetPropertyA( hpkg, "boo", NULL );
2119 ok( r == ERROR_SUCCESS, "wrong return val\n");
2120 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2122 r = MsiSetPropertyA( hpkg, "boo", "" );
2123 ok( r == ERROR_SUCCESS, "wrong return val\n");
2124 ok( check_prop_empty( hpkg, "boo"), "prop wasn't empty\n");
2126 /* set a non-empty value */
2127 r = MsiSetPropertyA( hpkg, "boo", "xyz" );
2128 ok( r == ERROR_SUCCESS, "wrong return val\n");
2130 sz = 1;
2131 strcpy(buffer,"x");
2132 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2133 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2134 ok( buffer[0] == 0, "buffer was not changed\n");
2135 ok( sz == 3, "wrong size returned\n");
2137 sz = 4;
2138 strcpy(buffer,"x");
2139 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2140 ok( r == ERROR_SUCCESS, "wrong return val\n");
2141 ok( !strcmp(buffer,"xyz"), "buffer was not changed\n");
2142 ok( sz == 3, "wrong size returned\n");
2144 sz = 3;
2145 strcpy(buffer,"x");
2146 r = MsiGetPropertyA( hpkg, "boo", buffer, &sz );
2147 ok( r == ERROR_MORE_DATA, "wrong return val\n");
2148 ok( !strcmp(buffer,"xy"), "buffer was not changed\n");
2149 ok( sz == 3, "wrong size returned\n");
2151 r = MsiSetPropertyA(hpkg, "SourceDir", "foo");
2152 ok( r == ERROR_SUCCESS, "wrong return val\n");
2154 sz = 4;
2155 r = MsiGetPropertyA(hpkg, "SOURCEDIR", buffer, &sz);
2156 ok( r == ERROR_SUCCESS, "wrong return val\n");
2157 ok( !strcmp(buffer,""), "buffer wrong\n");
2158 ok( sz == 0, "wrong size returned\n");
2160 sz = 4;
2161 r = MsiGetPropertyA(hpkg, "SOMERANDOMNAME", buffer, &sz);
2162 ok( r == ERROR_SUCCESS, "wrong return val\n");
2163 ok( !strcmp(buffer,""), "buffer wrong\n");
2164 ok( sz == 0, "wrong size returned\n");
2166 sz = 4;
2167 r = MsiGetPropertyA(hpkg, "SourceDir", buffer, &sz);
2168 ok( r == ERROR_SUCCESS, "wrong return val\n");
2169 ok( !strcmp(buffer,"foo"), "buffer wrong\n");
2170 ok( sz == 3, "wrong size returned\n");
2172 r = MsiSetPropertyA(hpkg, "MetadataCompName", "Photoshop.dll");
2173 ok( r == ERROR_SUCCESS, "wrong return val\n");
2175 sz = 0;
2176 r = MsiGetPropertyA(hpkg, "MetadataCompName", NULL, &sz );
2177 ok( r == ERROR_SUCCESS, "return wrong\n");
2178 ok( sz == 13, "size wrong (%d)\n", sz);
2180 sz = 13;
2181 r = MsiGetPropertyA(hpkg, "MetadataCompName", buffer, &sz );
2182 ok( r == ERROR_MORE_DATA, "return wrong\n");
2183 ok( !strcmp(buffer,"Photoshop.dl"), "buffer wrong\n");
2185 r = MsiSetPropertyA(hpkg, "property", "value");
2186 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2188 sz = 6;
2189 r = MsiGetPropertyA(hpkg, "property", buffer, &sz);
2190 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2191 ok( !strcmp(buffer, "value"), "Expected value, got %s\n", buffer);
2193 r = MsiSetPropertyA(hpkg, "property", NULL);
2194 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2196 sz = 6;
2197 r = MsiGetPropertyA(hpkg, "property", buffer, &sz);
2198 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2199 ok(!buffer[0], "Expected empty string, got %s\n", buffer);
2201 MsiCloseHandle( hpkg );
2202 DeleteFileA(msifile);
2205 static BOOL find_prop_in_property(MSIHANDLE hdb, LPCSTR prop, LPCSTR val, int len)
2207 MSIHANDLE hview, hrec;
2208 BOOL found = FALSE;
2209 CHAR buffer[MAX_PATH];
2210 DWORD sz;
2211 UINT r;
2213 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Property`", &hview);
2214 ok(r == ERROR_SUCCESS, "MsiDatabaseOpenView failed\n");
2215 r = MsiViewExecute(hview, 0);
2216 ok(r == ERROR_SUCCESS, "MsiViewExecute failed\n");
2218 if (len < 0) len = lstrlenA(val);
2220 while (r == ERROR_SUCCESS && !found)
2222 r = MsiViewFetch(hview, &hrec);
2223 if (r != ERROR_SUCCESS) break;
2225 sz = MAX_PATH;
2226 r = MsiRecordGetStringA(hrec, 1, buffer, &sz);
2227 if (r == ERROR_SUCCESS && !lstrcmpA(buffer, prop))
2229 sz = MAX_PATH;
2230 r = MsiRecordGetStringA(hrec, 2, buffer, &sz);
2231 if (r == ERROR_SUCCESS && !memcmp(buffer, val, len) && !buffer[len])
2233 ok(sz == len, "wrong size %u\n", sz);
2234 found = TRUE;
2238 MsiCloseHandle(hrec);
2240 MsiViewClose(hview);
2241 MsiCloseHandle(hview);
2242 return found;
2245 static void test_property_table(void)
2247 const char *query;
2248 UINT r;
2249 MSIHANDLE hpkg, hdb, hrec;
2250 char buffer[MAX_PATH], package[10];
2251 DWORD sz;
2252 BOOL found;
2254 hdb = create_package_db();
2255 ok( hdb, "failed to create package\n");
2257 r = package_from_db(hdb, &hpkg);
2258 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2260 skip("Not enough rights to perform tests\n");
2261 DeleteFileA(msifile);
2262 return;
2264 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2266 MsiCloseHandle(hdb);
2268 hdb = MsiGetActiveDatabase(hpkg);
2270 query = "CREATE TABLE `_Property` ( "
2271 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2272 r = run_query(hdb, query);
2273 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2275 MsiCloseHandle(hdb);
2276 MsiCloseHandle(hpkg);
2277 DeleteFileA(msifile);
2279 hdb = create_package_db();
2280 ok( hdb, "failed to create package\n");
2282 query = "CREATE TABLE `_Property` ( "
2283 "`foo` INT NOT NULL, `bar` INT LOCALIZABLE PRIMARY KEY `foo`)";
2284 r = run_query(hdb, query);
2285 ok(r == ERROR_SUCCESS, "failed to create table\n");
2287 query = "ALTER `_Property` ADD `foo` INTEGER";
2288 r = run_query(hdb, query);
2289 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2291 query = "ALTER TABLE `_Property` ADD `foo` INTEGER";
2292 r = run_query(hdb, query);
2293 ok(r == ERROR_BAD_QUERY_SYNTAX, "failed to add column\n");
2295 query = "ALTER TABLE `_Property` ADD `extra` INTEGER";
2296 r = run_query(hdb, query);
2297 ok(r == ERROR_SUCCESS, "failed to add column\n");
2299 sprintf(package, "#%i", hdb);
2300 r = MsiOpenPackageA(package, &hpkg);
2301 ok(r != ERROR_SUCCESS, "MsiOpenPackage succeeded\n");
2302 if (r == ERROR_SUCCESS)
2303 MsiCloseHandle(hpkg);
2305 r = MsiCloseHandle(hdb);
2306 ok(r == ERROR_SUCCESS, "MsiCloseHandle failed %u\n", r);
2308 hdb = create_package_db();
2309 ok (hdb, "failed to create package database\n");
2311 r = create_property_table(hdb);
2312 ok(r == ERROR_SUCCESS, "cannot create Property table: %d\n", r);
2314 r = add_property_entry(hdb, "'prop', 'val'");
2315 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2317 r = create_custom_action_table(hdb);
2318 ok(r == ERROR_SUCCESS, "cannot create CustomAction table: %d\n", r);
2320 r = add_custom_action_entry( hdb, "'EmbedNull', 51, 'prop2', '[~]np'" );
2321 ok( r == ERROR_SUCCESS, "cannot add custom action: %d\n", r);
2323 r = package_from_db(hdb, &hpkg);
2324 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
2326 MsiCloseHandle(hdb);
2328 sz = MAX_PATH;
2329 r = MsiGetPropertyA(hpkg, "prop", buffer, &sz);
2330 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2331 ok(!lstrcmpA(buffer, "val"), "Expected val, got %s\n", buffer);
2333 hdb = MsiGetActiveDatabase(hpkg);
2335 found = find_prop_in_property(hdb, "prop", "val", -1);
2336 ok(found, "prop should be in the _Property table\n");
2338 r = add_property_entry(hdb, "'dantes', 'mercedes'");
2339 ok(r == ERROR_SUCCESS, "cannot add property: %d\n", r);
2341 query = "SELECT * FROM `_Property` WHERE `Property` = 'dantes'";
2342 r = do_query(hdb, query, &hrec);
2343 ok(r == ERROR_BAD_QUERY_SYNTAX, "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
2345 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2346 ok(found == FALSE, "dantes should not be in the _Property table\n");
2348 sz = MAX_PATH;
2349 lstrcpyA(buffer, "aaa");
2350 r = MsiGetPropertyA(hpkg, "dantes", buffer, &sz);
2351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2352 ok(!buffer[0], "Expected empty string, got %s\n", buffer);
2354 r = MsiSetPropertyA(hpkg, "dantes", "mercedes");
2355 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2357 found = find_prop_in_property(hdb, "dantes", "mercedes", -1);
2358 ok(found == TRUE, "dantes should be in the _Property table\n");
2360 r = MsiDoActionA( hpkg, "EmbedNull" );
2361 ok( r == ERROR_SUCCESS, "EmbedNull failed: %d\n", r);
2363 sz = MAX_PATH;
2364 memset( buffer, 'a', sizeof(buffer) );
2365 r = MsiGetPropertyA( hpkg, "prop2", buffer, &sz );
2366 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
2367 ok( !memcmp( buffer, "\0np", sizeof("\0np") ), "wrong value\n");
2368 ok( sz == sizeof("\0np") - 1, "got %u\n", sz );
2370 found = find_prop_in_property(hdb, "prop2", "\0np", 3);
2371 ok(found == TRUE, "prop2 should be in the _Property table\n");
2373 MsiCloseHandle(hdb);
2374 MsiCloseHandle(hpkg);
2375 DeleteFileA(msifile);
2378 static UINT try_query_param( MSIHANDLE hdb, LPCSTR szQuery, MSIHANDLE hrec )
2380 MSIHANDLE htab = 0;
2381 UINT res;
2383 res = MsiDatabaseOpenViewA( hdb, szQuery, &htab );
2384 if( res == ERROR_SUCCESS )
2386 UINT r;
2388 r = MsiViewExecute( htab, hrec );
2389 if( r != ERROR_SUCCESS )
2391 res = r;
2392 fprintf(stderr,"MsiViewExecute failed %08x\n", res);
2395 r = MsiViewClose( htab );
2396 if( r != ERROR_SUCCESS )
2397 res = r;
2399 r = MsiCloseHandle( htab );
2400 if( r != ERROR_SUCCESS )
2401 res = r;
2403 return res;
2406 static UINT try_query( MSIHANDLE hdb, LPCSTR szQuery )
2408 return try_query_param( hdb, szQuery, 0 );
2411 static void set_summary_str(MSIHANDLE hdb, DWORD pid, LPCSTR value)
2413 MSIHANDLE summary;
2414 UINT r;
2416 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2417 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2419 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_LPSTR, 0, NULL, value);
2420 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2422 r = MsiSummaryInfoPersist(summary);
2423 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2425 MsiCloseHandle(summary);
2428 static void set_summary_dword(MSIHANDLE hdb, DWORD pid, DWORD value)
2430 MSIHANDLE summary;
2431 UINT r;
2433 r = MsiGetSummaryInformationA(hdb, NULL, 1, &summary);
2434 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2436 r = MsiSummaryInfoSetPropertyA(summary, pid, VT_I4, value, NULL, NULL);
2437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2439 r = MsiSummaryInfoPersist(summary);
2440 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
2442 MsiCloseHandle(summary);
2445 static void test_msipackage(void)
2447 MSIHANDLE hdb = 0, hpack = 100;
2448 UINT r;
2449 const char *query;
2450 char name[10];
2452 /* NULL szPackagePath */
2453 r = MsiOpenPackageA(NULL, &hpack);
2454 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2456 /* empty szPackagePath */
2457 r = MsiOpenPackageA("", &hpack);
2458 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2460 skip("Not enough rights to perform tests\n");
2461 return;
2463 todo_wine
2465 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2468 if (r == ERROR_SUCCESS)
2469 MsiCloseHandle(hpack);
2471 /* nonexistent szPackagePath */
2472 r = MsiOpenPackageA("nonexistent", &hpack);
2473 ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", r);
2475 /* NULL hProduct */
2476 r = MsiOpenPackageA(msifile, NULL);
2477 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
2479 name[0]='#';
2480 name[1]=0;
2481 r = MsiOpenPackageA(name, &hpack);
2482 ok(r == ERROR_INVALID_HANDLE, "Expected ERROR_INVALID_HANDLE, got %d\n", r);
2484 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
2485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2487 /* database exists, but is empty */
2488 sprintf(name, "#%d", hdb);
2489 r = MsiOpenPackageA(name, &hpack);
2490 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2491 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2493 query = "CREATE TABLE `Property` ( "
2494 "`Property` CHAR(72), `Value` CHAR(0) "
2495 "PRIMARY KEY `Property`)";
2496 r = try_query(hdb, query);
2497 ok(r == ERROR_SUCCESS, "failed to create Properties table\n");
2499 query = "CREATE TABLE `InstallExecuteSequence` ("
2500 "`Action` CHAR(72), `Condition` CHAR(0), `Sequence` INTEGER "
2501 "PRIMARY KEY `Action`)";
2502 r = try_query(hdb, query);
2503 ok(r == ERROR_SUCCESS, "failed to create InstallExecuteSequence table\n");
2505 /* a few key tables exist */
2506 sprintf(name, "#%d", hdb);
2507 r = MsiOpenPackageA(name, &hpack);
2508 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2509 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2511 MsiCloseHandle(hdb);
2512 DeleteFileA(msifile);
2514 /* start with a clean database to show what constitutes a valid package */
2515 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
2516 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
2518 sprintf(name, "#%d", hdb);
2520 /* The following summary information props must exist:
2521 * - PID_REVNUMBER
2522 * - PID_PAGECOUNT
2525 set_summary_dword(hdb, PID_PAGECOUNT, 100);
2526 r = MsiOpenPackageA(name, &hpack);
2527 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
2528 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
2530 set_summary_str(hdb, PID_REVNUMBER, "{004757CD-5092-49C2-AD20-28E1CE0DF5F2}");
2531 r = MsiOpenPackageA(name, &hpack);
2532 ok(r == ERROR_SUCCESS,
2533 "Expected ERROR_SUCCESS, got %d\n", r);
2535 MsiCloseHandle(hpack);
2536 MsiCloseHandle(hdb);
2537 DeleteFileA(msifile);
2540 static void test_formatrecord2(void)
2542 MSIHANDLE hpkg, hrec ;
2543 char buffer[0x100];
2544 DWORD sz;
2545 UINT r;
2547 r = package_from_db(create_package_db(), &hpkg);
2548 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
2550 skip("Not enough rights to perform tests\n");
2551 DeleteFileA(msifile);
2552 return;
2554 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r);
2556 r = MsiSetPropertyA(hpkg, "Manufacturer", " " );
2557 ok( r == ERROR_SUCCESS, "set property failed\n");
2559 hrec = MsiCreateRecord(2);
2560 ok(hrec, "create record failed\n");
2562 r = MsiRecordSetStringA( hrec, 0, "[ProgramFilesFolder][Manufacturer]\\asdf");
2563 ok( r == ERROR_SUCCESS, "format record failed\n");
2565 buffer[0] = 0;
2566 sz = sizeof buffer;
2567 r = MsiFormatRecordA( hpkg, hrec, buffer, &sz );
2568 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2570 r = MsiRecordSetStringA(hrec, 0, "[foo][1]");
2571 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2572 r = MsiRecordSetStringA(hrec, 1, "hoo");
2573 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2574 sz = sizeof buffer;
2575 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2576 ok( sz == 3, "size wrong\n");
2577 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2578 ok( r == ERROR_SUCCESS, "format failed\n");
2580 r = MsiRecordSetStringA(hrec, 0, "x[~]x");
2581 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2582 sz = sizeof buffer;
2583 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2584 ok( sz == 3, "size wrong\n");
2585 ok( 0 == strcmp(buffer,"x"), "wrong output %s\n",buffer);
2586 ok( r == ERROR_SUCCESS, "format failed\n");
2588 r = MsiRecordSetStringA(hrec, 0, "[foo.$%}][1]");
2589 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2590 r = MsiRecordSetStringA(hrec, 1, "hoo");
2591 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2592 sz = sizeof buffer;
2593 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2594 ok( sz == 3, "size wrong\n");
2595 ok( 0 == strcmp(buffer,"hoo"), "wrong output %s\n",buffer);
2596 ok( r == ERROR_SUCCESS, "format failed\n");
2598 r = MsiRecordSetStringA(hrec, 0, "[\\[]");
2599 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2600 sz = sizeof buffer;
2601 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2602 ok( sz == 1, "size wrong\n");
2603 ok( 0 == strcmp(buffer,"["), "wrong output %s\n",buffer);
2604 ok( r == ERROR_SUCCESS, "format failed\n");
2606 SetEnvironmentVariableA("FOO", "BAR");
2607 r = MsiRecordSetStringA(hrec, 0, "[%FOO]");
2608 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2609 sz = sizeof buffer;
2610 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2611 ok( sz == 3, "size wrong\n");
2612 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2613 ok( r == ERROR_SUCCESS, "format failed\n");
2615 r = MsiRecordSetStringA(hrec, 0, "[[1]]");
2616 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2617 r = MsiRecordSetStringA(hrec, 1, "%FOO");
2618 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
2619 sz = sizeof buffer;
2620 r = MsiFormatRecordA(hpkg, hrec, buffer, &sz);
2621 ok( sz == 3, "size wrong\n");
2622 ok( 0 == strcmp(buffer,"BAR"), "wrong output %s\n",buffer);
2623 ok( r == ERROR_SUCCESS, "format failed\n");
2625 MsiCloseHandle( hrec );
2626 MsiCloseHandle( hpkg );
2627 DeleteFileA(msifile);
2630 static void test_feature_states( UINT line, MSIHANDLE package, const char *feature, UINT error,
2631 INSTALLSTATE expected_state, INSTALLSTATE expected_action, BOOL todo )
2633 UINT r;
2634 INSTALLSTATE state = 0xdeadbee;
2635 INSTALLSTATE action = 0xdeadbee;
2637 r = MsiGetFeatureStateA( package, feature, &state, &action );
2638 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2639 if (r == ERROR_SUCCESS)
2641 ok( state == expected_state, "%u: expected state %d got %d\n",
2642 line, expected_state, state );
2643 todo_wine_if (todo)
2644 ok( action == expected_action, "%u: expected action %d got %d\n",
2645 line, expected_action, action );
2647 else
2649 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n", line, state );
2650 todo_wine_if (todo)
2651 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n", line, action );
2656 static void test_component_states( UINT line, MSIHANDLE package, const char *component, UINT error,
2657 INSTALLSTATE expected_state, INSTALLSTATE expected_action, BOOL todo )
2659 UINT r;
2660 INSTALLSTATE state = 0xdeadbee;
2661 INSTALLSTATE action = 0xdeadbee;
2663 r = MsiGetComponentStateA( package, component, &state, &action );
2664 ok( r == error, "%u: expected %d got %d\n", line, error, r );
2665 if (r == ERROR_SUCCESS)
2667 ok( state == expected_state, "%u: expected state %d got %d\n",
2668 line, expected_state, state );
2669 todo_wine_if (todo)
2670 ok( action == expected_action, "%u: expected action %d got %d\n",
2671 line, expected_action, action );
2673 else
2675 ok( state == 0xdeadbee, "%u: expected state 0xdeadbee got %d\n",
2676 line, state );
2677 todo_wine_if (todo)
2678 ok( action == 0xdeadbee, "%u: expected action 0xdeadbee got %d\n",
2679 line, action );
2683 static void test_states(void)
2685 static const char msifile2[] = "winetest2-package.msi";
2686 static const char msifile3[] = "winetest3-package.msi";
2687 static const char msifile4[] = "winetest4-package.msi";
2688 static const WCHAR msifile2W[] =
2689 {'w','i','n','e','t','e','s','t','2','-','p','a','c','k','a','g','e','.','m','s','i',0};
2690 static const WCHAR msifile3W[] =
2691 {'w','i','n','e','t','e','s','t','3','-','p','a','c','k','a','g','e','.','m','s','i',0};
2692 static const WCHAR msifile4W[] =
2693 {'w','i','n','e','t','e','s','t','4','-','p','a','c','k','a','g','e','.','m','s','i',0};
2694 INSTALLSTATE state;
2695 MSIHANDLE hpkg;
2696 UINT r;
2697 MSIHANDLE hdb;
2699 if (is_process_limited())
2701 skip("process is limited\n");
2702 return;
2705 hdb = create_package_db();
2706 ok ( hdb, "failed to create package database\n" );
2708 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
2709 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
2711 r = create_property_table( hdb );
2712 ok( r == ERROR_SUCCESS, "cannot create Property table: %d\n", r );
2714 r = add_property_entry( hdb, "'ProductCode', '{7262AC98-EEBD-4364-8CE3-D654F6A425B9}'" );
2715 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2717 r = add_property_entry( hdb, "'ProductLanguage', '1033'" );
2718 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2720 r = add_property_entry( hdb, "'ProductName', 'MSITEST'" );
2721 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2723 r = add_property_entry( hdb, "'ProductVersion', '1.1.1'" );
2724 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2726 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
2727 ok( r == ERROR_SUCCESS, "cannot add property entry: %d\n", r );
2729 r = create_install_execute_sequence_table( hdb );
2730 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table: %d\n", r );
2732 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
2733 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2735 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
2736 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2738 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
2739 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2741 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1400'" );
2742 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2744 r = add_install_execute_sequence_entry( hdb, "'InstallInitialize', '', '1500'" );
2745 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2747 r = add_install_execute_sequence_entry( hdb, "'ProcessComponents', '', '1600'" );
2748 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2750 r = add_install_execute_sequence_entry( hdb, "'UnpublishFeatures', '', '1800'" );
2751 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2753 r = add_install_execute_sequence_entry( hdb, "'RegisterProduct', '', '6100'" );
2754 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2756 r = add_install_execute_sequence_entry( hdb, "'PublishFeatures', '', '6300'" );
2757 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2759 r = add_install_execute_sequence_entry( hdb, "'PublishProduct', '', '6400'" );
2760 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2762 r = add_install_execute_sequence_entry( hdb, "'InstallFinalize', '', '6600'" );
2763 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry: %d\n", r );
2765 r = create_media_table( hdb );
2766 ok( r == ERROR_SUCCESS, "cannot create media table: %d\n", r );
2768 r = add_media_entry( hdb, "'1', '3', '', '', 'DISK1', ''");
2769 ok( r == ERROR_SUCCESS, "cannot add media entry: %d\n", r );
2771 r = create_feature_table( hdb );
2772 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
2774 r = create_component_table( hdb );
2775 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
2777 /* msidbFeatureAttributesFavorLocal */
2778 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
2779 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2781 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
2782 r = add_component_entry( hdb, "'alpha', '{467EC132-739D-4784-A37B-677AA43DBC94}', 'TARGETDIR', 0, '', 'alpha_file'" );
2783 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2785 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
2786 r = add_component_entry( hdb, "'beta', '{2C1F189C-24A6-4C34-B26B-994A6C026506}', 'TARGETDIR', 1, '', 'beta_file'" );
2787 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2789 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
2790 r = add_component_entry( hdb, "'gamma', '{C271E2A4-DE2E-4F70-86D1-6984AF7DE2CA}', 'TARGETDIR', 2, '', 'gamma_file'" );
2791 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2793 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSharedDllRefCount */
2794 r = add_component_entry( hdb, "'theta', '{4EB3129D-81A8-48D5-9801-75600FED3DD9}', 'TARGETDIR', 8, '', 'theta_file'" );
2795 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2797 /* msidbFeatureAttributesFavorSource */
2798 r = add_feature_entry( hdb, "'two', '', '', '', 2, 1, '', 1" );
2799 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2801 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
2802 r = add_component_entry( hdb, "'delta', '{938FD4F2-C648-4259-A03C-7AA3B45643F3}', 'TARGETDIR', 0, '', 'delta_file'" );
2803 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2805 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2806 r = add_component_entry( hdb, "'epsilon', '{D59713B6-C11D-47F2-A395-1E5321781190}', 'TARGETDIR', 1, '', 'epsilon_file'" );
2807 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2809 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
2810 r = add_component_entry( hdb, "'zeta', '{377D33AB-2FAA-42B9-A629-0C0DAE9B9C7A}', 'TARGETDIR', 2, '', 'zeta_file'" );
2811 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2813 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSharedDllRefCount */
2814 r = add_component_entry( hdb, "'iota', '{5D36F871-B5ED-4801-9E0F-C46B9E5C9669}', 'TARGETDIR', 8, '', 'iota_file'" );
2815 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2817 /* msidbFeatureAttributesFavorSource */
2818 r = add_feature_entry( hdb, "'three', '', '', '', 2, 1, '', 1" );
2819 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2821 /* msidbFeatureAttributesFavorLocal */
2822 r = add_feature_entry( hdb, "'four', '', '', '', 2, 1, '', 0" );
2823 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2825 /* disabled */
2826 r = add_feature_entry( hdb, "'five', '', '', '', 2, 0, '', 1" );
2827 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2829 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
2830 r = add_component_entry( hdb, "'eta', '{DD89003F-0DD4-41B8-81C0-3411A7DA2695}', 'TARGETDIR', 1, '', 'eta_file'" );
2831 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2833 /* no feature parent:msidbComponentAttributesLocalOnly */
2834 r = add_component_entry( hdb, "'kappa', '{D6B93DC3-8DA5-4769-9888-42BFE156BB8B}', 'TARGETDIR', 1, '', 'kappa_file'" );
2835 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2837 /* msidbFeatureAttributesFavorLocal:removed */
2838 r = add_feature_entry( hdb, "'six', '', '', '', 2, 1, '', 0" );
2839 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2841 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesLocalOnly */
2842 r = add_component_entry( hdb, "'lambda', '{6528C5E4-02A4-4636-A214-7A66A6C35B64}', 'TARGETDIR', 0, '', 'lambda_file'" );
2843 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2845 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSourceOnly */
2846 r = add_component_entry( hdb, "'mu', '{97014BAB-6C56-4013-9A63-2BF913B42519}', 'TARGETDIR', 1, '', 'mu_file'" );
2847 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2849 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesOptional */
2850 r = add_component_entry( hdb, "'nu', '{943DD0D8-5808-4954-8526-3B8493FEDDCD}', 'TARGETDIR', 2, '', 'nu_file'" );
2851 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2853 /* msidbFeatureAttributesFavorLocal:removed:msidbComponentAttributesSharedDllRefCount */
2854 r = add_component_entry( hdb, "'xi', '{D6CF9EF7-6FCF-4930-B34B-F938AEFF9BDB}', 'TARGETDIR', 8, '', 'xi_file'" );
2855 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2857 /* msidbFeatureAttributesFavorSource:removed */
2858 r = add_feature_entry( hdb, "'seven', '', '', '', 2, 1, '', 1" );
2859 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2861 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesLocalOnly */
2862 r = add_component_entry( hdb, "'omicron', '{7B57521D-15DB-4141-9AA6-01D934A4433F}', 'TARGETDIR', 0, '', 'omicron_file'" );
2863 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2865 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSourceOnly */
2866 r = add_component_entry( hdb, "'pi', '{FB85346B-378E-4492-8769-792305471C81}', 'TARGETDIR', 1, '', 'pi_file'" );
2867 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2869 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesOptional */
2870 r = add_component_entry( hdb, "'rho', '{798F2047-7B0C-4783-8BB0-D703E554114B}', 'TARGETDIR', 2, '', 'rho_file'" );
2871 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2873 /* msidbFeatureAttributesFavorSource:removed:msidbComponentAttributesSharedDllRefCount */
2874 r = add_component_entry( hdb, "'sigma', '{5CE9DDA8-B67B-4736-9D93-99D61C5B93E7}', 'TARGETDIR', 8, '', 'sigma_file'" );
2875 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2877 /* msidbFeatureAttributesFavorLocal */
2878 r = add_feature_entry( hdb, "'eight', '', '', '', 2, 1, '', 0" );
2879 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2881 r = add_component_entry( hdb, "'tau', '{07DEB510-677C-4A6F-A0A6-7CD8EFEA77ED}', 'TARGETDIR', 1, '', 'tau_file'" );
2882 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2884 /* msidbFeatureAttributesFavorSource */
2885 r = add_feature_entry( hdb, "'nine', '', '', '', 2, 1, '', 1" );
2886 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2888 r = add_component_entry( hdb, "'phi', '{9F0594C5-35AD-43EA-94DD-8DF73FAA664D}', 'TARGETDIR', 1, '', 'phi_file'" );
2889 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2891 /* msidbFeatureAttributesFavorAdvertise */
2892 r = add_feature_entry( hdb, "'ten', '', '', '', 2, 1, '', 4" );
2893 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2895 r = add_component_entry( hdb, "'chi', '{E6B539AB-5DA9-4236-A2D2-E341A50B4C38}', 'TARGETDIR', 1, '', 'chi_file'" );
2896 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2898 /* msidbFeatureAttributesUIDisallowAbsent */
2899 r = add_feature_entry( hdb, "'eleven', '', '', '', 2, 1, '', 16" );
2900 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2902 r = add_component_entry( hdb, "'psi', '{A06B23B5-746B-427A-8A6E-FD6AC8F46A95}', 'TARGETDIR', 1, '', 'psi_file'" );
2903 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2905 /* high install level */
2906 r = add_feature_entry( hdb, "'twelve', '', '', '', 2, 2, '', 0" );
2907 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2909 r = add_component_entry( hdb, "'upsilon', '{557e0c04-ceba-4c58-86a9-4a73352e8cf6}', 'TARGETDIR', 1, '', 'upsilon_file'" );
2910 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
2912 /* msidbFeatureAttributesFollowParent */
2913 r = add_feature_entry( hdb, "'thirteen', '', '', '', 2, 2, '', 2" );
2914 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
2916 r = create_feature_components_table( hdb );
2917 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
2919 r = add_feature_components_entry( hdb, "'one', 'alpha'" );
2920 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2922 r = add_feature_components_entry( hdb, "'one', 'beta'" );
2923 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2925 r = add_feature_components_entry( hdb, "'one', 'gamma'" );
2926 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2928 r = add_feature_components_entry( hdb, "'one', 'theta'" );
2929 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2931 r = add_feature_components_entry( hdb, "'two', 'delta'" );
2932 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2934 r = add_feature_components_entry( hdb, "'two', 'epsilon'" );
2935 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2937 r = add_feature_components_entry( hdb, "'two', 'zeta'" );
2938 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2940 r = add_feature_components_entry( hdb, "'two', 'iota'" );
2941 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2943 r = add_feature_components_entry( hdb, "'three', 'eta'" );
2944 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2946 r = add_feature_components_entry( hdb, "'four', 'eta'" );
2947 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2949 r = add_feature_components_entry( hdb, "'five', 'eta'" );
2950 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2952 r = add_feature_components_entry( hdb, "'six', 'lambda'" );
2953 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2955 r = add_feature_components_entry( hdb, "'six', 'mu'" );
2956 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2958 r = add_feature_components_entry( hdb, "'six', 'nu'" );
2959 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2961 r = add_feature_components_entry( hdb, "'six', 'xi'" );
2962 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2964 r = add_feature_components_entry( hdb, "'seven', 'omicron'" );
2965 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2967 r = add_feature_components_entry( hdb, "'seven', 'pi'" );
2968 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2970 r = add_feature_components_entry( hdb, "'seven', 'rho'" );
2971 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2973 r = add_feature_components_entry( hdb, "'seven', 'sigma'" );
2974 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2976 r = add_feature_components_entry( hdb, "'eight', 'tau'" );
2977 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2979 r = add_feature_components_entry( hdb, "'nine', 'phi'" );
2980 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2982 r = add_feature_components_entry( hdb, "'ten', 'chi'" );
2983 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2985 r = add_feature_components_entry( hdb, "'eleven', 'psi'" );
2986 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2988 r = add_feature_components_entry( hdb, "'twelve', 'upsilon'" );
2989 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2991 r = add_feature_components_entry( hdb, "'thirteen', 'upsilon'" );
2992 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
2994 r = create_file_table( hdb );
2995 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
2997 r = add_file_entry( hdb, "'alpha_file', 'alpha', 'alpha.txt', 100, '', '1033', 8192, 1" );
2998 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3000 r = add_file_entry( hdb, "'beta_file', 'beta', 'beta.txt', 0, '', '1033', 8192, 1" );
3001 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3003 r = add_file_entry( hdb, "'gamma_file', 'gamma', 'gamma.txt', 0, '', '1033', 8192, 1" );
3004 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3006 r = add_file_entry( hdb, "'theta_file', 'theta', 'theta.txt', 0, '', '1033', 8192, 1" );
3007 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3009 r = add_file_entry( hdb, "'delta_file', 'delta', 'delta.txt', 0, '', '1033', 8192, 1" );
3010 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3012 r = add_file_entry( hdb, "'epsilon_file', 'epsilon', 'epsilon.txt', 0, '', '1033', 8192, 1" );
3013 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3015 r = add_file_entry( hdb, "'zeta_file', 'zeta', 'zeta.txt', 0, '', '1033', 8192, 1" );
3016 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3018 r = add_file_entry( hdb, "'iota_file', 'iota', 'iota.txt', 0, '', '1033', 8192, 1" );
3019 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3021 /* compressed file */
3022 r = add_file_entry( hdb, "'eta_file', 'eta', 'eta.txt', 0, '', '1033', 16384, 1" );
3023 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3025 r = add_file_entry( hdb, "'kappa_file', 'kappa', 'kappa.txt', 0, '', '1033', 8192, 1" );
3026 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3028 r = add_file_entry( hdb, "'lambda_file', 'lambda', 'lambda.txt', 100, '', '1033', 8192, 1" );
3029 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3031 r = add_file_entry( hdb, "'mu_file', 'mu', 'mu.txt', 100, '', '1033', 8192, 1" );
3032 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3034 r = add_file_entry( hdb, "'nu_file', 'nu', 'nu.txt', 100, '', '1033', 8192, 1" );
3035 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3037 r = add_file_entry( hdb, "'xi_file', 'xi', 'xi.txt', 100, '', '1033', 8192, 1" );
3038 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3040 r = add_file_entry( hdb, "'omicron_file', 'omicron', 'omicron.txt', 100, '', '1033', 8192, 1" );
3041 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3043 r = add_file_entry( hdb, "'pi_file', 'pi', 'pi.txt', 100, '', '1033', 8192, 1" );
3044 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3046 r = add_file_entry( hdb, "'rho_file', 'rho', 'rho.txt', 100, '', '1033', 8192, 1" );
3047 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3049 r = add_file_entry( hdb, "'sigma_file', 'sigma', 'sigma.txt', 100, '', '1033', 8192, 1" );
3050 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3052 r = add_file_entry( hdb, "'tau_file', 'tau', 'tau.txt', 100, '', '1033', 8192, 1" );
3053 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3055 r = add_file_entry( hdb, "'phi_file', 'phi', 'phi.txt', 100, '', '1033', 8192, 1" );
3056 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3058 r = add_file_entry( hdb, "'chi_file', 'chi', 'chi.txt', 100, '', '1033', 8192, 1" );
3059 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3061 r = add_file_entry( hdb, "'psi_file', 'psi', 'psi.txt', 100, '', '1033', 8192, 1" );
3062 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3064 r = add_file_entry( hdb, "'upsilon_file', 'upsilon', 'upsilon.txt', 0, '', '1033', 16384, 1" );
3065 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3067 MsiDatabaseCommit(hdb);
3069 /* these properties must not be in the saved msi file */
3070 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3071 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3073 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3074 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3076 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3077 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3079 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3080 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3082 r = add_property_entry( hdb, "'REINSTALLMODE', 'omus'");
3083 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3085 r = package_from_db( hdb, &hpkg );
3086 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3088 skip("Not enough rights to perform tests\n");
3089 DeleteFileA(msifile);
3090 return;
3092 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3094 MsiCloseHandle(hdb);
3096 CopyFileA(msifile, msifile2, FALSE);
3097 CopyFileA(msifile, msifile3, FALSE);
3098 CopyFileA(msifile, msifile4, FALSE);
3100 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3101 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3103 r = MsiDoActionA( hpkg, "CostInitialize");
3104 ok( r == ERROR_SUCCESS, "cost init failed\n");
3106 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3107 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3109 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3111 r = MsiDoActionA( hpkg, "FileCost");
3112 ok( r == ERROR_SUCCESS, "file cost failed\n");
3114 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3115 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3117 r = MsiDoActionA( hpkg, "CostFinalize");
3118 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3120 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3121 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3122 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3123 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3124 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3125 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3126 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3127 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3128 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3129 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3130 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3131 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3132 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3134 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3135 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3136 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3137 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3138 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3139 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3140 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
3141 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3142 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
3143 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3144 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3145 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3146 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3147 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3148 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3149 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3150 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3151 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3152 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3153 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3154 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3155 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3156 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3158 MsiCloseHandle( hpkg );
3160 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3162 /* publish the features and components */
3163 r = MsiInstallProductA(msifile, "ADDLOCAL=one,four ADDSOURCE=two,three REMOVE=six,seven REINSTALL=eight,nine,ten");
3164 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3166 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
3167 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3169 /* these properties must not be in the saved msi file */
3170 r = add_property_entry( hdb, "'ADDLOCAL', 'one,four'");
3171 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3173 r = add_property_entry( hdb, "'ADDSOURCE', 'two,three'");
3174 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3176 r = add_property_entry( hdb, "'REMOVE', 'six,seven'");
3177 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3179 r = add_property_entry( hdb, "'REINSTALL', 'eight,nine,ten'");
3180 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3182 r = package_from_db( hdb, &hpkg );
3183 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3185 MsiCloseHandle(hdb);
3187 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3188 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3190 r = MsiDoActionA( hpkg, "CostInitialize");
3191 ok( r == ERROR_SUCCESS, "cost init failed\n");
3193 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3194 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3196 r = MsiDoActionA( hpkg, "FileCost");
3197 ok( r == ERROR_SUCCESS, "file cost failed\n");
3199 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3200 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3202 r = MsiDoActionA( hpkg, "CostFinalize");
3203 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3205 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3206 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3207 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3208 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3209 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3210 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3211 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3212 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3213 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3214 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3215 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3216 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3217 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3219 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3220 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3221 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3222 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3223 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3224 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3225 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3226 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3227 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3228 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3229 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3230 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3231 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3232 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3233 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3234 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3235 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3236 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3237 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3238 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3239 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3240 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3241 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3243 MsiCloseHandle(hpkg);
3245 /* uninstall the product */
3246 r = MsiInstallProductA(msifile, "REMOVE=ALL");
3247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3249 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3250 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3251 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3252 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3254 /* all features installed locally */
3255 r = MsiInstallProductA(msifile2, "ADDLOCAL=ALL");
3256 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3258 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3259 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3260 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3261 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3263 r = MsiOpenDatabaseW(msifile2W, MSIDBOPEN_DIRECT, &hdb);
3264 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3266 /* these properties must not be in the saved msi file */
3267 r = add_property_entry( hdb, "'ADDLOCAL', 'one,two,three,four,five,six,seven,eight,nine,ten,twelve'");
3268 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3270 r = package_from_db( hdb, &hpkg );
3271 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3273 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3274 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3276 r = MsiDoActionA( hpkg, "CostInitialize");
3277 ok( r == ERROR_SUCCESS, "cost init failed\n");
3279 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3280 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3282 r = MsiDoActionA( hpkg, "CostFinalize");
3283 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3285 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3286 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3287 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3288 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3289 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3290 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3291 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_LOCAL, FALSE );
3292 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3293 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3294 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, TRUE );
3295 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3296 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3297 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3299 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3300 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3301 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3302 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3303 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3304 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3305 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3306 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3307 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3308 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3309 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3310 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3311 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3312 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3313 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3314 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3315 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3316 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3317 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3318 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3319 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3320 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3321 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3323 MsiCloseHandle(hpkg);
3325 /* uninstall the product */
3326 r = MsiInstallProductA(msifile2, "REMOVE=ALL");
3327 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3329 /* all features installed from source */
3330 r = MsiInstallProductA(msifile3, "ADDSOURCE=ALL");
3331 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3333 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3334 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3335 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3336 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3338 r = MsiOpenDatabaseW(msifile3W, MSIDBOPEN_DIRECT, &hdb);
3339 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3341 /* this property must not be in the saved msi file */
3342 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3343 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3345 r = package_from_db( hdb, &hpkg );
3346 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3348 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3349 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3351 r = MsiDoActionA( hpkg, "CostInitialize");
3352 ok( r == ERROR_SUCCESS, "cost init failed\n");
3354 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3355 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3357 r = MsiDoActionA( hpkg, "FileCost");
3358 ok( r == ERROR_SUCCESS, "file cost failed\n");
3360 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3361 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3363 r = MsiDoActionA( hpkg, "CostFinalize");
3364 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3366 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3367 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3368 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3369 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3370 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3371 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3372 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3373 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3374 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3375 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3376 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3377 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3378 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3380 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3381 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3382 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3383 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3384 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3385 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3386 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3387 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3388 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3389 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3390 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3391 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3392 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3393 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3394 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3395 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3396 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3397 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3398 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3399 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3400 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3401 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3402 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, TRUE );
3404 MsiCloseHandle(hpkg);
3406 /* reinstall the product */
3407 r = MsiInstallProductA(msifile3, "REINSTALL=ALL");
3408 ok(r == ERROR_SUCCESS || broken(r == ERROR_INSTALL_FAILURE) /* win2k3 */, "Expected ERROR_SUCCESS, got %d\n", r);
3410 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "five");
3411 ok(state == INSTALLSTATE_UNKNOWN, "state = %d\n", state);
3412 state = MsiQueryFeatureStateA("{7262AC98-EEBD-4364-8CE3-D654F6A425B9}", "twelve");
3413 ok(state == INSTALLSTATE_LOCAL, "state = %d\n", state);
3415 r = MsiOpenDatabaseW(msifile4W, MSIDBOPEN_DIRECT, &hdb);
3416 ok(r == ERROR_SUCCESS, "failed to open database: %d\n", r);
3418 /* this property must not be in the saved msi file */
3419 r = add_property_entry( hdb, "'ADDSOURCE', 'one,two,three,four,five,six,seven,eight,nine,ten'");
3420 ok( r == ERROR_SUCCESS, "cannot add property: %d\n", r );
3422 r = package_from_db( hdb, &hpkg );
3423 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3425 test_feature_states( __LINE__, hpkg, "one", ERROR_UNKNOWN_FEATURE, 0, 0, FALSE );
3426 test_component_states( __LINE__, hpkg, "alpha", ERROR_UNKNOWN_COMPONENT, 0, 0, FALSE );
3428 r = MsiDoActionA( hpkg, "CostInitialize");
3429 ok( r == ERROR_SUCCESS, "cost init failed\n");
3431 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3432 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3434 r = MsiDoActionA( hpkg, "FileCost");
3435 ok( r == ERROR_SUCCESS, "file cost failed\n");
3437 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3438 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
3440 r = MsiDoActionA( hpkg, "CostFinalize");
3441 ok( r == ERROR_SUCCESS, "cost finalize failed: %d\n", r);
3443 test_feature_states( __LINE__, hpkg, "one", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3444 test_feature_states( __LINE__, hpkg, "two", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3445 test_feature_states( __LINE__, hpkg, "three", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3446 test_feature_states( __LINE__, hpkg, "four", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3447 test_feature_states( __LINE__, hpkg, "five", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3448 test_feature_states( __LINE__, hpkg, "six", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3449 test_feature_states( __LINE__, hpkg, "seven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3450 test_feature_states( __LINE__, hpkg, "eight", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3451 test_feature_states( __LINE__, hpkg, "nine", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3452 test_feature_states( __LINE__, hpkg, "ten", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_SOURCE, FALSE );
3453 test_feature_states( __LINE__, hpkg, "eleven", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, TRUE );
3454 test_feature_states( __LINE__, hpkg, "twelve", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3455 test_feature_states( __LINE__, hpkg, "thirteen", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_UNKNOWN, FALSE );
3457 test_component_states( __LINE__, hpkg, "alpha", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3458 test_component_states( __LINE__, hpkg, "beta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3459 test_component_states( __LINE__, hpkg, "gamma", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3460 test_component_states( __LINE__, hpkg, "theta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3461 test_component_states( __LINE__, hpkg, "delta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3462 test_component_states( __LINE__, hpkg, "epsilon", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3463 test_component_states( __LINE__, hpkg, "zeta", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3464 test_component_states( __LINE__, hpkg, "iota", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3465 test_component_states( __LINE__, hpkg, "eta", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3466 test_component_states( __LINE__, hpkg, "kappa", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
3467 test_component_states( __LINE__, hpkg, "lambda", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3468 test_component_states( __LINE__, hpkg, "mu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3469 test_component_states( __LINE__, hpkg, "nu", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3470 test_component_states( __LINE__, hpkg, "xi", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3471 test_component_states( __LINE__, hpkg, "omicron", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3472 test_component_states( __LINE__, hpkg, "pi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3473 test_component_states( __LINE__, hpkg, "rho", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3474 test_component_states( __LINE__, hpkg, "sigma", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, FALSE );
3475 test_component_states( __LINE__, hpkg, "tau", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3476 test_component_states( __LINE__, hpkg, "phi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3477 test_component_states( __LINE__, hpkg, "chi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3478 test_component_states( __LINE__, hpkg, "psi", ERROR_SUCCESS, INSTALLSTATE_SOURCE, INSTALLSTATE_UNKNOWN, FALSE );
3479 test_component_states( __LINE__, hpkg, "upsilon", ERROR_SUCCESS, INSTALLSTATE_LOCAL, INSTALLSTATE_LOCAL, TRUE );
3481 MsiCloseHandle(hpkg);
3483 /* uninstall the product */
3484 r = MsiInstallProductA(msifile4, "REMOVE=ALL");
3485 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3487 DeleteFileA(msifile);
3488 DeleteFileA(msifile2);
3489 DeleteFileA(msifile3);
3490 DeleteFileA(msifile4);
3493 static void test_getproperty(void)
3495 MSIHANDLE hPackage = 0;
3496 char prop[100];
3497 static CHAR empty[] = "";
3498 DWORD size;
3499 UINT r;
3501 r = package_from_db(create_package_db(), &hPackage);
3502 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3504 skip("Not enough rights to perform tests\n");
3505 DeleteFileA(msifile);
3506 return;
3508 ok( r == ERROR_SUCCESS, "Failed to create package %u\n", r );
3510 /* set the property */
3511 r = MsiSetPropertyA(hPackage, "Name", "Value");
3512 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3514 /* retrieve the size, NULL pointer */
3515 size = 0;
3516 r = MsiGetPropertyA(hPackage, "Name", NULL, &size);
3517 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3518 ok( size == 5, "Expected 5, got %d\n", size);
3520 /* retrieve the size, empty string */
3521 size = 0;
3522 r = MsiGetPropertyA(hPackage, "Name", empty, &size);
3523 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3524 ok( size == 5, "Expected 5, got %d\n", size);
3526 /* don't change size */
3527 r = MsiGetPropertyA(hPackage, "Name", prop, &size);
3528 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
3529 ok( size == 5, "Expected 5, got %d\n", size);
3530 ok( !lstrcmpA(prop, "Valu"), "Expected Valu, got %s\n", prop);
3532 /* increase the size by 1 */
3533 size++;
3534 r = MsiGetPropertyA(hPackage, "Name", prop, &size);
3535 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3536 ok( size == 5, "Expected 5, got %d\n", size);
3537 ok( !lstrcmpA(prop, "Value"), "Expected Value, got %s\n", prop);
3539 r = MsiCloseHandle( hPackage);
3540 ok( r == ERROR_SUCCESS , "Failed to close package\n" );
3541 DeleteFileA(msifile);
3544 static void test_removefiles(void)
3546 MSIHANDLE hpkg;
3547 UINT r;
3548 MSIHANDLE hdb;
3549 INSTALLSTATE installed, action;
3551 hdb = create_package_db();
3552 ok ( hdb, "failed to create package database\n" );
3554 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
3555 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
3557 r = create_feature_table( hdb );
3558 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
3560 r = create_component_table( hdb );
3561 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
3563 r = add_feature_entry( hdb, "'one', '', '', '', 2, 1, '', 0" );
3564 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
3566 r = add_component_entry( hdb, "'hydrogen', '', 'TARGETDIR', 0, '', 'hydrogen_file'" );
3567 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3569 r = add_component_entry( hdb, "'helium', '', 'TARGETDIR', 0, '', 'helium_file'" );
3570 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3572 r = add_component_entry( hdb, "'lithium', '', 'TARGETDIR', 0, '', 'lithium_file'" );
3573 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3575 r = add_component_entry( hdb, "'beryllium', '', 'TARGETDIR', 0, '', 'beryllium_file'" );
3576 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3578 r = add_component_entry( hdb, "'boron', '', 'TARGETDIR', 0, '', 'boron_file'" );
3579 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3581 r = add_component_entry( hdb, "'carbon', '', 'TARGETDIR', 0, '', 'carbon_file'" );
3582 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3584 r = add_component_entry( hdb, "'oxygen', '', 'TARGETDIR', 0, '0', 'oxygen_file'" );
3585 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
3587 r = create_feature_components_table( hdb );
3588 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
3590 r = add_feature_components_entry( hdb, "'one', 'hydrogen'" );
3591 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3593 r = add_feature_components_entry( hdb, "'one', 'helium'" );
3594 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3596 r = add_feature_components_entry( hdb, "'one', 'lithium'" );
3597 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3599 r = add_feature_components_entry( hdb, "'one', 'beryllium'" );
3600 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3602 r = add_feature_components_entry( hdb, "'one', 'boron'" );
3603 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3605 r = add_feature_components_entry( hdb, "'one', 'carbon'" );
3606 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3608 r = add_feature_components_entry( hdb, "'one', 'oxygen'" );
3609 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
3611 r = create_file_table( hdb );
3612 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
3614 r = add_file_entry( hdb, "'hydrogen_file', 'hydrogen', 'hydrogen.txt', 0, '', '1033', 8192, 1" );
3615 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3617 r = add_file_entry( hdb, "'helium_file', 'helium', 'helium.txt', 0, '', '1033', 8192, 1" );
3618 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3620 r = add_file_entry( hdb, "'lithium_file', 'lithium', 'lithium.txt', 0, '', '1033', 8192, 1" );
3621 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3623 r = add_file_entry( hdb, "'beryllium_file', 'beryllium', 'beryllium.txt', 0, '', '1033', 16384, 1" );
3624 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3626 r = add_file_entry( hdb, "'boron_file', 'boron', 'boron.txt', 0, '', '1033', 16384, 1" );
3627 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3629 r = add_file_entry( hdb, "'carbon_file', 'carbon', 'carbon.txt', 0, '', '1033', 16384, 1" );
3630 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3632 r = add_file_entry( hdb, "'oxygen_file', 'oxygen', 'oxygen.txt', 0, '', '1033', 16384, 1" );
3633 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
3635 r = create_remove_file_table( hdb );
3636 ok( r == ERROR_SUCCESS, "cannot create Remove File table: %d\n", r);
3638 r = package_from_db( hdb, &hpkg );
3639 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3641 skip("Not enough rights to perform tests\n");
3642 DeleteFileA(msifile);
3643 return;
3645 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3647 MsiCloseHandle( hdb );
3649 create_test_file( "hydrogen.txt" );
3650 create_test_file( "helium.txt" );
3651 create_test_file( "lithium.txt" );
3652 create_test_file( "beryllium.txt" );
3653 create_test_file( "boron.txt" );
3654 create_test_file( "carbon.txt" );
3655 create_test_file( "oxygen.txt" );
3657 r = MsiSetPropertyA( hpkg, "TARGETDIR", CURR_DIR );
3658 ok( r == ERROR_SUCCESS, "set property failed\n");
3660 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3662 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3663 ok( r == ERROR_UNKNOWN_COMPONENT, "expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
3665 r = MsiDoActionA( hpkg, "CostInitialize");
3666 ok( r == ERROR_SUCCESS, "cost init failed\n");
3668 r = MsiDoActionA( hpkg, "FileCost");
3669 ok( r == ERROR_SUCCESS, "file cost failed\n");
3671 installed = action = 0xdeadbeef;
3672 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3673 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3674 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3675 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3677 r = MsiDoActionA( hpkg, "CostFinalize");
3678 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
3680 r = MsiDoActionA( hpkg, "InstallValidate");
3681 ok( r == ERROR_SUCCESS, "install validate failed\n");
3683 r = MsiSetComponentStateA( hpkg, "hydrogen", INSTALLSTATE_ABSENT );
3684 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3686 installed = action = 0xdeadbeef;
3687 r = MsiGetComponentStateA( hpkg, "hydrogen", &installed, &action );
3688 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3689 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3690 todo_wine ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3692 r = MsiSetComponentStateA( hpkg, "helium", INSTALLSTATE_LOCAL );
3693 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3695 r = MsiSetComponentStateA( hpkg, "lithium", INSTALLSTATE_SOURCE );
3696 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3698 r = MsiSetComponentStateA( hpkg, "beryllium", INSTALLSTATE_ABSENT );
3699 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3701 r = MsiSetComponentStateA( hpkg, "boron", INSTALLSTATE_LOCAL );
3702 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3704 r = MsiSetComponentStateA( hpkg, "carbon", INSTALLSTATE_SOURCE );
3705 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3707 installed = action = 0xdeadbeef;
3708 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3709 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3710 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3711 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3713 r = MsiSetComponentStateA( hpkg, "oxygen", INSTALLSTATE_ABSENT );
3714 ok( r == ERROR_SUCCESS, "failed to set component state: %d\n", r);
3716 installed = action = 0xdeadbeef;
3717 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3718 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3719 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3720 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3722 r = MsiDoActionA( hpkg, "RemoveFiles");
3723 ok( r == ERROR_SUCCESS, "remove files failed\n");
3725 installed = action = 0xdeadbeef;
3726 r = MsiGetComponentStateA( hpkg, "oxygen", &installed, &action );
3727 ok( r == ERROR_SUCCESS, "failed to get component state %u\n", r );
3728 ok( installed == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", installed );
3729 ok( action == INSTALLSTATE_UNKNOWN, "expected INSTALLSTATE_UNKNOWN, got %d\n", action );
3731 ok(DeleteFileA("hydrogen.txt"), "Expected hydrogen.txt to exist\n");
3732 ok(DeleteFileA("lithium.txt"), "Expected lithium.txt to exist\n");
3733 ok(DeleteFileA("beryllium.txt"), "Expected beryllium.txt to exist\n");
3734 ok(DeleteFileA("carbon.txt"), "Expected carbon.txt to exist\n");
3735 ok(DeleteFileA("helium.txt"), "Expected helium.txt to exist\n");
3736 ok(DeleteFileA("boron.txt"), "Expected boron.txt to exist\n");
3737 ok(DeleteFileA("oxygen.txt"), "Expected oxygen.txt to exist\n");
3739 MsiCloseHandle( hpkg );
3740 DeleteFileA(msifile);
3743 static void test_appsearch(void)
3745 MSIHANDLE hpkg;
3746 UINT r;
3747 MSIHANDLE hdb;
3748 CHAR prop[MAX_PATH];
3749 DWORD size;
3750 HKEY hkey;
3751 const char reg_expand_value[] = "%systemroot%\\system32\\notepad.exe";
3753 hdb = create_package_db();
3754 ok ( hdb, "failed to create package database\n" );
3756 r = create_appsearch_table( hdb );
3757 ok( r == ERROR_SUCCESS, "cannot create AppSearch table: %d\n", r );
3759 r = add_appsearch_entry( hdb, "'WEBBROWSERPROG', 'NewSignature1'" );
3760 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3762 r = add_appsearch_entry( hdb, "'NOTEPAD', 'NewSignature2'" );
3763 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3765 r = add_appsearch_entry( hdb, "'REGEXPANDVAL', 'NewSignature3'" );
3766 ok( r == ERROR_SUCCESS, "cannot add entry: %d\n", r );
3768 r = create_reglocator_table( hdb );
3769 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3771 r = add_reglocator_entry( hdb, "NewSignature1", 0, "htmlfile\\shell\\open\\command", "", 1 );
3772 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3774 r = RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Winetest_msi", 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL);
3775 ok( r == ERROR_SUCCESS, "Could not create key: %d.\n", r );
3776 r = RegSetValueExA(hkey, NULL, 0, REG_EXPAND_SZ, (const BYTE*)reg_expand_value, strlen(reg_expand_value) + 1);
3777 ok( r == ERROR_SUCCESS, "Could not set key value: %d.\n", r);
3778 RegCloseKey(hkey);
3779 r = add_reglocator_entry( hdb, "NewSignature3", 1, "Software\\Winetest_msi", "", 1 );
3780 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3782 r = create_drlocator_table( hdb );
3783 ok( r == ERROR_SUCCESS, "cannot create DrLocator table: %d\n", r );
3785 r = add_drlocator_entry( hdb, "'NewSignature2', 0, 'c:\\windows\\system32', 0" );
3786 ok( r == ERROR_SUCCESS, "cannot create RegLocator table: %d\n", r );
3788 r = create_signature_table( hdb );
3789 ok( r == ERROR_SUCCESS, "cannot create Signature table: %d\n", r );
3791 r = add_signature_entry( hdb, "'NewSignature1', 'FileName', '', '', '', '', '', '', ''" );
3792 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3794 r = add_signature_entry( hdb, "'NewSignature2', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3795 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3797 r = add_signature_entry( hdb, "'NewSignature3', 'NOTEPAD.EXE|notepad.exe', '', '', '', '', '', '', ''" );
3798 ok( r == ERROR_SUCCESS, "cannot add signature: %d\n", r );
3800 r = package_from_db( hdb, &hpkg );
3801 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
3803 skip("Not enough rights to perform tests\n");
3804 DeleteFileA(msifile);
3805 return;
3807 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
3808 MsiCloseHandle( hdb );
3809 if (r != ERROR_SUCCESS)
3810 goto done;
3812 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
3814 r = MsiDoActionA( hpkg, "AppSearch" );
3815 ok( r == ERROR_SUCCESS, "AppSearch failed: %d\n", r);
3817 size = sizeof(prop);
3818 r = MsiGetPropertyA( hpkg, "WEBBROWSERPROG", prop, &size );
3819 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3820 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3822 size = sizeof(prop);
3823 r = MsiGetPropertyA( hpkg, "NOTEPAD", prop, &size );
3824 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3826 size = sizeof(prop);
3827 r = MsiGetPropertyA( hpkg, "REGEXPANDVAL", prop, &size );
3828 ok( r == ERROR_SUCCESS, "get property failed: %d\n", r);
3829 ok( lstrlenA(prop) != 0, "Expected non-zero length\n");
3831 done:
3832 MsiCloseHandle( hpkg );
3833 DeleteFileA(msifile);
3834 RegDeleteKeyA(HKEY_CURRENT_USER, "Software\\Winetest_msi");
3837 static void test_appsearch_complocator(void)
3839 MSIHANDLE hpkg, hdb;
3840 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
3841 LPSTR usersid;
3842 DWORD size;
3843 UINT r;
3845 if (!(usersid = get_user_sid()))
3846 return;
3848 if (is_process_limited())
3850 skip("process is limited\n");
3851 return;
3854 create_test_file("FileName1");
3855 create_test_file("FileName4");
3856 set_component_path("FileName1", MSIINSTALLCONTEXT_MACHINE,
3857 "{A8AE6692-96BA-4198-8399-145D7D1D0D0E}", NULL, FALSE);
3859 create_test_file("FileName2");
3860 set_component_path("FileName2", MSIINSTALLCONTEXT_USERUNMANAGED,
3861 "{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}", usersid, FALSE);
3863 create_test_file("FileName3");
3864 set_component_path("FileName3", MSIINSTALLCONTEXT_USERMANAGED,
3865 "{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}", usersid, FALSE);
3867 create_test_file("FileName5");
3868 set_component_path("FileName5", MSIINSTALLCONTEXT_MACHINE,
3869 "{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}", NULL, TRUE);
3871 create_test_file("FileName6");
3872 set_component_path("FileName6", MSIINSTALLCONTEXT_MACHINE,
3873 "{C0ECD96F-7898-4410-9667-194BD8C1B648}", NULL, TRUE);
3875 create_test_file("FileName7");
3876 set_component_path("FileName7", MSIINSTALLCONTEXT_MACHINE,
3877 "{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}", NULL, FALSE);
3879 /* dir is FALSE, but we're pretending it's a directory */
3880 set_component_path("IDontExist\\", MSIINSTALLCONTEXT_MACHINE,
3881 "{91B7359B-07F2-4221-AA8D-DE102BB87A5F}", NULL, FALSE);
3883 create_file_with_version("FileName8.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3884 set_component_path("FileName8.dll", MSIINSTALLCONTEXT_MACHINE,
3885 "{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}", NULL, FALSE);
3887 create_file_with_version("FileName9.dll", MAKELONG(1, 2), MAKELONG(3, 4));
3888 set_component_path("FileName9.dll", MSIINSTALLCONTEXT_MACHINE,
3889 "{A204DF48-7346-4635-BA2E-66247DBAC9DF}", NULL, FALSE);
3891 create_file_with_version("FileName10.dll", MAKELONG(2, 1), MAKELONG(4, 3));
3892 set_component_path("FileName10.dll", MSIINSTALLCONTEXT_MACHINE,
3893 "{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}", NULL, FALSE);
3895 hdb = create_package_db();
3896 ok(hdb, "Expected a valid database handle\n");
3898 r = create_appsearch_table(hdb);
3899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3901 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
3902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3904 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
3905 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3907 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
3908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3910 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
3911 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3913 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
3914 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3916 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
3917 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3919 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
3920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3922 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
3923 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3925 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
3926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3928 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
3929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3931 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
3932 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3934 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
3935 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3937 r = create_complocator_table(hdb);
3938 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3940 /* published component, machine, file, signature, misdbLocatorTypeFile */
3941 r = add_complocator_entry(hdb, "'NewSignature1', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 1");
3942 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3944 /* published component, user-unmanaged, file, signature, misdbLocatorTypeFile */
3945 r = add_complocator_entry(hdb, "'NewSignature2', '{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}', 1");
3946 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3948 /* published component, user-managed, file, signature, misdbLocatorTypeFile */
3949 r = add_complocator_entry(hdb, "'NewSignature3', '{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}', 1");
3950 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3952 /* published component, machine, file, signature, misdbLocatorTypeDirectory */
3953 r = add_complocator_entry(hdb, "'NewSignature4', '{A8AE6692-96BA-4198-8399-145D7D1D0D0E}', 0");
3954 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3956 /* published component, machine, dir, signature, misdbLocatorTypeDirectory */
3957 r = add_complocator_entry(hdb, "'NewSignature5', '{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}', 0");
3958 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3960 /* published component, machine, dir, no signature, misdbLocatorTypeDirectory */
3961 r = add_complocator_entry(hdb, "'NewSignature6', '{C0ECD96F-7898-4410-9667-194BD8C1B648}', 0");
3962 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3964 /* published component, machine, file, no signature, misdbLocatorTypeFile */
3965 r = add_complocator_entry(hdb, "'NewSignature7', '{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}', 1");
3966 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3968 /* unpublished component, no signature, misdbLocatorTypeDir */
3969 r = add_complocator_entry(hdb, "'NewSignature8', '{FB671D5B-5083-4048-90E0-481C48D8F3A5}', 0");
3970 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3972 /* published component, no signature, dir does not exist misdbLocatorTypeDir */
3973 r = add_complocator_entry(hdb, "'NewSignature9', '{91B7359B-07F2-4221-AA8D-DE102BB87A5F}', 0");
3974 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3976 /* published component, signature w/ ver, misdbLocatorTypeFile */
3977 r = add_complocator_entry(hdb, "'NewSignature10', '{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}', 1");
3978 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3980 /* published component, signature w/ ver, ver > max, misdbLocatorTypeFile */
3981 r = add_complocator_entry(hdb, "'NewSignature11', '{A204DF48-7346-4635-BA2E-66247DBAC9DF}', 1");
3982 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3984 /* published component, signature w/ ver, sig->name ignored, misdbLocatorTypeFile */
3985 r = add_complocator_entry(hdb, "'NewSignature12', '{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}', 1");
3986 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3988 r = create_signature_table(hdb);
3989 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3991 r = add_signature_entry(hdb, "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''");
3992 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3994 r = add_signature_entry(hdb, "'NewSignature2', 'FileName2', '', '', '', '', '', '', ''");
3995 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
3997 r = add_signature_entry(hdb, "'NewSignature3', 'FileName3', '', '', '', '', '', '', ''");
3998 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4000 r = add_signature_entry(hdb, "'NewSignature4', 'FileName4', '', '', '', '', '', '', ''");
4001 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4003 r = add_signature_entry(hdb, "'NewSignature5', 'FileName5', '', '', '', '', '', '', ''");
4004 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4006 r = add_signature_entry(hdb, "'NewSignature10', 'FileName8.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4007 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4009 r = add_signature_entry(hdb, "'NewSignature11', 'FileName9.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4010 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4012 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
4013 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4015 r = package_from_db(hdb, &hpkg);
4016 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
4018 skip("Not enough rights to perform tests\n");
4019 goto error;
4021 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4023 r = MsiSetPropertyA(hpkg, "SIGPROP8", "october");
4024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4026 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4028 r = MsiDoActionA(hpkg, "AppSearch");
4029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4031 strcpy(expected, CURR_DIR);
4032 if (is_root(CURR_DIR)) expected[2] = 0;
4034 size = MAX_PATH;
4035 sprintf(path, "%s\\FileName1", expected);
4036 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4037 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4038 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4040 size = MAX_PATH;
4041 sprintf(path, "%s\\FileName2", expected);
4042 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4044 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4046 size = MAX_PATH;
4047 sprintf(path, "%s\\FileName3", expected);
4048 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4049 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4050 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4052 size = MAX_PATH;
4053 sprintf(path, "%s\\FileName4", expected);
4054 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
4055 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4056 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4058 size = MAX_PATH;
4059 sprintf(path, "%s\\FileName5", expected);
4060 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4061 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4062 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4064 size = MAX_PATH;
4065 sprintf(path, "%s\\", expected);
4066 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4067 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4068 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4070 size = MAX_PATH;
4071 sprintf(path, "%s\\", expected);
4072 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4073 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4074 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4076 size = MAX_PATH;
4077 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4078 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4079 ok(!lstrcmpA(prop, "october"), "Expected \"october\", got \"%s\"\n", prop);
4081 size = MAX_PATH;
4082 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4083 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4084 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4086 size = MAX_PATH;
4087 sprintf(path, "%s\\FileName8.dll", expected);
4088 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4089 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4090 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4092 size = MAX_PATH;
4093 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4094 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4095 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4097 size = MAX_PATH;
4098 sprintf(path, "%s\\FileName10.dll", expected);
4099 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4100 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4101 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4103 delete_component_path("{A8AE6692-96BA-4198-8399-145D7D1D0D0E}",
4104 MSIINSTALLCONTEXT_MACHINE, NULL);
4105 delete_component_path("{1D2CE6F3-E81C-4949-AB81-78D7DAD2AF2E}",
4106 MSIINSTALLCONTEXT_USERUNMANAGED, usersid);
4107 delete_component_path("{19E0B999-85F5-4973-A61B-DBE4D66ECB1D}",
4108 MSIINSTALLCONTEXT_USERMANAGED, usersid);
4109 delete_component_path("{F0CCA976-27A3-4808-9DDD-1A6FD50A0D5A}",
4110 MSIINSTALLCONTEXT_MACHINE, NULL);
4111 delete_component_path("{C0ECD96F-7898-4410-9667-194BD8C1B648}",
4112 MSIINSTALLCONTEXT_MACHINE, NULL);
4113 delete_component_path("{DB20F535-9C26-4127-9C2B-CC45A8B51DA1}",
4114 MSIINSTALLCONTEXT_MACHINE, NULL);
4115 delete_component_path("{91B7359B-07F2-4221-AA8D-DE102BB87A5F}",
4116 MSIINSTALLCONTEXT_MACHINE, NULL);
4117 delete_component_path("{4A2E1B5B-4034-4177-833B-8CC35F1B3EF1}",
4118 MSIINSTALLCONTEXT_MACHINE, NULL);
4119 delete_component_path("{A204DF48-7346-4635-BA2E-66247DBAC9DF}",
4120 MSIINSTALLCONTEXT_MACHINE, NULL);
4121 delete_component_path("{EC30CE73-4CF9-4908-BABD-1ED82E1515FD}",
4122 MSIINSTALLCONTEXT_MACHINE, NULL);
4124 MsiCloseHandle(hpkg);
4126 error:
4127 DeleteFileA("FileName1");
4128 DeleteFileA("FileName2");
4129 DeleteFileA("FileName3");
4130 DeleteFileA("FileName4");
4131 DeleteFileA("FileName5");
4132 DeleteFileA("FileName6");
4133 DeleteFileA("FileName7");
4134 DeleteFileA("FileName8.dll");
4135 DeleteFileA("FileName9.dll");
4136 DeleteFileA("FileName10.dll");
4137 DeleteFileA(msifile);
4138 LocalFree(usersid);
4141 static void test_appsearch_reglocator(void)
4143 MSIHANDLE hpkg, hdb;
4144 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4145 DWORD binary[2], size, val;
4146 BOOL space, version, is_64bit = sizeof(void *) > sizeof(int);
4147 HKEY hklm, classes, hkcu, users;
4148 LPSTR pathdata, pathvar, ptr;
4149 LPCSTR str;
4150 LONG res;
4151 UINT r, type = 0;
4152 SYSTEM_INFO si;
4154 version = TRUE;
4155 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4156 version = FALSE;
4158 DeleteFileA("test.dll");
4160 res = RegCreateKeyA(HKEY_CLASSES_ROOT, "Software\\Wine", &classes);
4161 if (res == ERROR_ACCESS_DENIED)
4163 skip("Not enough rights to perform tests\n");
4164 return;
4166 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4168 res = RegSetValueExA(classes, "Value1", 0, REG_SZ,
4169 (const BYTE *)"regszdata", 10);
4170 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4172 res = RegCreateKeyA(HKEY_CURRENT_USER, "Software\\Wine", &hkcu);
4173 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4175 res = RegSetValueExA(hkcu, "Value1", 0, REG_SZ,
4176 (const BYTE *)"regszdata", 10);
4177 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4179 users = 0;
4180 res = RegCreateKeyA(HKEY_USERS, "S-1-5-18\\Software\\Wine", &users);
4181 ok(res == ERROR_SUCCESS ||
4182 broken(res == ERROR_INVALID_PARAMETER),
4183 "Expected ERROR_SUCCESS, got %d\n", res);
4185 if (res == ERROR_SUCCESS)
4187 res = RegSetValueExA(users, "Value1", 0, REG_SZ,
4188 (const BYTE *)"regszdata", 10);
4189 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4192 res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
4193 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4195 res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
4196 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4198 res = RegSetValueExA(hklm, "Value1", 0, REG_SZ,
4199 (const BYTE *)"regszdata", 10);
4200 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4202 val = 42;
4203 res = RegSetValueExA(hklm, "Value2", 0, REG_DWORD,
4204 (const BYTE *)&val, sizeof(DWORD));
4205 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4207 val = -42;
4208 res = RegSetValueExA(hklm, "Value3", 0, REG_DWORD,
4209 (const BYTE *)&val, sizeof(DWORD));
4210 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4212 res = RegSetValueExA(hklm, "Value4", 0, REG_EXPAND_SZ,
4213 (const BYTE *)"%PATH%", 7);
4214 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4216 res = RegSetValueExA(hklm, "Value5", 0, REG_EXPAND_SZ,
4217 (const BYTE *)"my%NOVAR%", 10);
4218 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4220 res = RegSetValueExA(hklm, "Value6", 0, REG_MULTI_SZ,
4221 (const BYTE *)"one\0two\0", 9);
4222 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4224 binary[0] = 0x1234abcd;
4225 binary[1] = 0x567890ef;
4226 res = RegSetValueExA(hklm, "Value7", 0, REG_BINARY,
4227 (const BYTE *)binary, sizeof(binary));
4228 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4230 res = RegSetValueExA(hklm, "Value8", 0, REG_SZ,
4231 (const BYTE *)"#regszdata", 11);
4232 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4234 strcpy(expected, CURR_DIR);
4235 if (is_root(CURR_DIR)) expected[2] = 0;
4237 create_test_file("FileName1");
4238 sprintf(path, "%s\\FileName1", expected);
4239 res = RegSetValueExA(hklm, "Value9", 0, REG_SZ,
4240 (const BYTE *)path, lstrlenA(path) + 1);
4241 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4243 sprintf(path, "%s\\FileName2", expected);
4244 res = RegSetValueExA(hklm, "Value10", 0, REG_SZ,
4245 (const BYTE *)path, lstrlenA(path) + 1);
4246 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4248 lstrcpyA(path, expected);
4249 res = RegSetValueExA(hklm, "Value11", 0, REG_SZ,
4250 (const BYTE *)path, lstrlenA(path) + 1);
4251 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4253 res = RegSetValueExA(hklm, "Value12", 0, REG_SZ,
4254 (const BYTE *)"", 1);
4255 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4257 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4258 sprintf(path, "%s\\FileName3.dll", expected);
4259 res = RegSetValueExA(hklm, "Value13", 0, REG_SZ,
4260 (const BYTE *)path, lstrlenA(path) + 1);
4261 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4263 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4264 sprintf(path, "%s\\FileName4.dll", expected);
4265 res = RegSetValueExA(hklm, "Value14", 0, REG_SZ,
4266 (const BYTE *)path, lstrlenA(path) + 1);
4267 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4269 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4270 sprintf(path, "%s\\FileName5.dll", expected);
4271 res = RegSetValueExA(hklm, "Value15", 0, REG_SZ,
4272 (const BYTE *)path, lstrlenA(path) + 1);
4273 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
4275 sprintf(path, "\"%s\\FileName1\" -option", expected);
4276 res = RegSetValueExA(hklm, "value16", 0, REG_SZ,
4277 (const BYTE *)path, lstrlenA(path) + 1);
4278 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4280 space = strchr(expected, ' ') != NULL;
4281 sprintf(path, "%s\\FileName1 -option", expected);
4282 res = RegSetValueExA(hklm, "value17", 0, REG_SZ,
4283 (const BYTE *)path, lstrlenA(path) + 1);
4284 ok( res == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", res);
4286 hdb = create_package_db();
4287 ok(hdb, "Expected a valid database handle\n");
4289 r = create_appsearch_table(hdb);
4290 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4292 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4293 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4295 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4298 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4299 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4301 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4302 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4304 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4305 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4307 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4310 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4311 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4313 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4314 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4316 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4317 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4319 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4320 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4322 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4323 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4325 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4326 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4328 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
4329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4331 r = add_appsearch_entry(hdb, "'SIGPROP14', 'NewSignature14'");
4332 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4334 r = add_appsearch_entry(hdb, "'SIGPROP15', 'NewSignature15'");
4335 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4337 r = add_appsearch_entry(hdb, "'SIGPROP16', 'NewSignature16'");
4338 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4340 r = add_appsearch_entry(hdb, "'SIGPROP17', 'NewSignature17'");
4341 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4343 r = add_appsearch_entry(hdb, "'SIGPROP18', 'NewSignature18'");
4344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4346 r = add_appsearch_entry(hdb, "'SIGPROP19', 'NewSignature19'");
4347 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4349 r = add_appsearch_entry(hdb, "'SIGPROP20', 'NewSignature20'");
4350 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4352 r = add_appsearch_entry(hdb, "'SIGPROP21', 'NewSignature21'");
4353 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4355 r = add_appsearch_entry(hdb, "'SIGPROP22', 'NewSignature22'");
4356 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4358 r = add_appsearch_entry(hdb, "'SIGPROP23', 'NewSignature23'");
4359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4361 r = add_appsearch_entry(hdb, "'SIGPROP24', 'NewSignature24'");
4362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4364 r = add_appsearch_entry(hdb, "'SIGPROP25', 'NewSignature25'");
4365 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4367 r = add_appsearch_entry(hdb, "'SIGPROP26', 'NewSignature26'");
4368 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4370 r = add_appsearch_entry(hdb, "'SIGPROP27', 'NewSignature27'");
4371 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4373 r = add_appsearch_entry(hdb, "'SIGPROP28', 'NewSignature28'");
4374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4376 r = add_appsearch_entry(hdb, "'SIGPROP29', 'NewSignature29'");
4377 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4379 r = add_appsearch_entry(hdb, "'SIGPROP30', 'NewSignature30'");
4380 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4382 r = create_reglocator_table(hdb);
4383 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4385 type = msidbLocatorTypeRawValue;
4386 if (is_64bit)
4387 type |= msidbLocatorType64bit;
4389 /* HKLM, msidbLocatorTypeRawValue, REG_SZ */
4390 r = add_reglocator_entry(hdb, "NewSignature1", 2, "Software\\Wine", "Value1", type);
4391 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4393 /* HKLM, msidbLocatorTypeRawValue, positive DWORD */
4394 r = add_reglocator_entry(hdb, "NewSignature2", 2, "Software\\Wine", "Value2", type);
4395 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4397 /* HKLM, msidbLocatorTypeRawValue, negative DWORD */
4398 r = add_reglocator_entry(hdb, "NewSignature3", 2, "Software\\Wine", "Value3", type);
4399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4401 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4402 r = add_reglocator_entry(hdb, "NewSignature4", 2, "Software\\Wine", "Value4", type);
4403 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4405 /* HKLM, msidbLocatorTypeRawValue, REG_EXPAND_SZ */
4406 r = add_reglocator_entry(hdb, "NewSignature5", 2, "Software\\Wine", "Value5", type);
4407 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4409 /* HKLM, msidbLocatorTypeRawValue, REG_MULTI_SZ */
4410 r = add_reglocator_entry(hdb, "NewSignature6", 2, "Software\\Wine", "Value6", type);
4411 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4413 /* HKLM, msidbLocatorTypeRawValue, REG_BINARY */
4414 r = add_reglocator_entry(hdb, "NewSignature7", 2, "Software\\Wine", "Value7", type);
4415 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4417 /* HKLM, msidbLocatorTypeRawValue, REG_SZ first char is # */
4418 r = add_reglocator_entry(hdb, "NewSignature8", 2, "Software\\Wine", "Value8", type);
4419 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4421 type = msidbLocatorTypeFileName;
4422 if (is_64bit)
4423 type |= msidbLocatorType64bit;
4425 /* HKLM, msidbLocatorTypeFileName, signature, file exists */
4426 r = add_reglocator_entry(hdb, "NewSignature9", 2, "Software\\Wine", "Value9", type);
4427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4429 /* HKLM, msidbLocatorTypeFileName, signature, file does not exist */
4430 r = add_reglocator_entry(hdb, "NewSignature10", 2, "Software\\Wine", "Value10", type);
4431 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4433 /* HKLM, msidbLocatorTypeFileName, no signature */
4434 r = add_reglocator_entry(hdb, "NewSignature11", 2, "Software\\Wine", "Value9", type);
4435 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4437 type = msidbLocatorTypeDirectory;
4438 if (is_64bit)
4439 type |= msidbLocatorType64bit;
4441 /* HKLM, msidbLocatorTypeDirectory, no signature, file exists */
4442 r = add_reglocator_entry(hdb, "NewSignature12", 2, "Software\\Wine", "Value9", type);
4443 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4445 /* HKLM, msidbLocatorTypeDirectory, no signature, directory exists */
4446 r = add_reglocator_entry(hdb, "NewSignature13", 2, "Software\\Wine", "Value11", type);
4447 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4449 /* HKLM, msidbLocatorTypeDirectory, signature, file exists */
4450 r = add_reglocator_entry(hdb, "NewSignature14", 2, "Software\\Wine", "Value9", type);
4451 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4453 type = msidbLocatorTypeRawValue;
4454 if (is_64bit)
4455 type |= msidbLocatorType64bit;
4457 /* HKCR, msidbLocatorTypeRawValue, REG_SZ */
4458 r = add_reglocator_entry(hdb, "NewSignature15", 0, "Software\\Wine", "Value1", type);
4459 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4461 /* HKCU, msidbLocatorTypeRawValue, REG_SZ */
4462 r = add_reglocator_entry(hdb, "NewSignature16", 1, "Software\\Wine", "Value1", type);
4463 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4465 /* HKU, msidbLocatorTypeRawValue, REG_SZ */
4466 r = add_reglocator_entry(hdb, "NewSignature17", 3, "S-1-5-18\\Software\\Wine", "Value1", type);
4467 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4469 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, NULL Name */
4470 r = add_reglocator_entry(hdb, "NewSignature18", 2, "Software\\Wine", "", type);
4471 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4473 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, key does not exist */
4474 r = add_reglocator_entry(hdb, "NewSignature19", 2, "Software\\IDontExist", "", type);
4475 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4477 /* HKLM, msidbLocatorTypeRawValue, REG_SZ, value is empty */
4478 r = add_reglocator_entry(hdb, "NewSignature20", 2, "Software\\Wine", "Value12", type);
4479 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4481 type = msidbLocatorTypeFileName;
4482 if (is_64bit)
4483 type |= msidbLocatorType64bit;
4485 /* HKLM, msidbLocatorTypeFileName, signature, file exists w/ version */
4486 r = add_reglocator_entry(hdb, "NewSignature21", 2, "Software\\Wine", "Value13", type);
4487 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4489 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, version > max */
4490 r = add_reglocator_entry(hdb, "NewSignature22", 2, "Software\\Wine", "Value14", type);
4491 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4493 /* HKLM, msidbLocatorTypeFileName, file exists w/ version, sig->name ignored */
4494 r = add_reglocator_entry(hdb, "NewSignature23", 2, "Software\\Wine", "Value15", type);
4495 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4497 /* HKLM, msidbLocatorTypeFileName, no signature, directory exists */
4498 r = add_reglocator_entry(hdb, "NewSignature24", 2, "Software\\Wine", "Value11", type);
4499 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4501 /* HKLM, msidbLocatorTypeFileName, no signature, file does not exist */
4502 r = add_reglocator_entry(hdb, "NewSignature25", 2, "Software\\Wine", "Value10", type);
4503 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4505 type = msidbLocatorTypeDirectory;
4506 if (is_64bit)
4507 type |= msidbLocatorType64bit;
4509 /* HKLM, msidbLocatorTypeDirectory, signature, directory exists */
4510 r = add_reglocator_entry(hdb, "NewSignature26", 2, "Software\\Wine", "Value11", type);
4511 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4513 /* HKLM, msidbLocatorTypeDirectory, signature, file does not exist */
4514 r = add_reglocator_entry(hdb, "NewSignature27", 2, "Software\\Wine", "Value10", type);
4515 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4517 /* HKLM, msidbLocatorTypeDirectory, no signature, file does not exist */
4518 r = add_reglocator_entry(hdb, "NewSignature28", 2, "Software\\Wine", "Value10", type);
4519 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4521 type = msidbLocatorTypeFileName;
4522 if (is_64bit)
4523 type |= msidbLocatorType64bit;
4525 /* HKLM, msidbLocatorTypeFile, file exists, in quotes */
4526 r = add_reglocator_entry(hdb, "NewSignature29", 2, "Software\\Wine", "Value16", type);
4527 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4529 /* HKLM, msidbLocatorTypeFile, file exists, no quotes */
4530 r = add_reglocator_entry(hdb, "NewSignature30", 2, "Software\\Wine", "Value17", type);
4531 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4533 r = create_signature_table(hdb);
4534 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4536 str = "'NewSignature9', 'FileName1', '', '', '', '', '', '', ''";
4537 r = add_signature_entry(hdb, str);
4538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4540 str = "'NewSignature10', 'FileName2', '', '', '', '', '', '', ''";
4541 r = add_signature_entry(hdb, str);
4542 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4544 str = "'NewSignature14', 'FileName1', '', '', '', '', '', '', ''";
4545 r = add_signature_entry(hdb, str);
4546 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4548 str = "'NewSignature21', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4549 r = add_signature_entry(hdb, str);
4550 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4552 str = "'NewSignature22', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4553 r = add_signature_entry(hdb, str);
4554 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4556 str = "'NewSignature23', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
4557 r = add_signature_entry(hdb, str);
4558 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4560 if (!is_root(CURR_DIR))
4562 ptr = strrchr(expected, '\\') + 1;
4563 sprintf(path, "'NewSignature26', '%s', '', '', '', '', '', '', ''", ptr);
4564 r = add_signature_entry(hdb, path);
4565 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4567 str = "'NewSignature27', 'FileName2', '', '', '', '', '', '', ''";
4568 r = add_signature_entry(hdb, str);
4569 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4571 str = "'NewSignature29', 'FileName1', '', '', '', '', '', '', ''";
4572 r = add_signature_entry(hdb, str);
4573 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4575 str = "'NewSignature30', 'FileName1', '', '', '', '', '', '', ''";
4576 r = add_signature_entry(hdb, str);
4577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4579 r = package_from_db(hdb, &hpkg);
4580 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
4582 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
4584 r = MsiDoActionA(hpkg, "AppSearch");
4585 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4587 size = MAX_PATH;
4588 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
4589 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4590 ok(!lstrcmpA(prop, "regszdata"),
4591 "Expected \"regszdata\", got \"%s\"\n", prop);
4593 size = MAX_PATH;
4594 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
4595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4596 ok(!lstrcmpA(prop, "#42"), "Expected \"#42\", got \"%s\"\n", prop);
4598 size = MAX_PATH;
4599 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
4600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4601 ok(!lstrcmpA(prop, "#-42"), "Expected \"#-42\", got \"%s\"\n", prop);
4603 memset(&si, 0, sizeof(si));
4604 if (pGetNativeSystemInfo) pGetNativeSystemInfo(&si);
4606 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
4608 size = ExpandEnvironmentStringsA("%PATH%", NULL, 0);
4609 pathvar = HeapAlloc(GetProcessHeap(), 0, size);
4610 ExpandEnvironmentStringsA("%PATH%", pathvar, size);
4612 size = 0;
4613 r = MsiGetPropertyA(hpkg, "SIGPROP4", NULL, &size);
4614 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4616 pathdata = HeapAlloc(GetProcessHeap(), 0, ++size);
4617 r = MsiGetPropertyA(hpkg, "SIGPROP4", pathdata, &size);
4618 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4619 ok(!lstrcmpA(pathdata, pathvar),
4620 "Expected \"%s\", got \"%s\"\n", pathvar, pathdata);
4622 HeapFree(GetProcessHeap(), 0, pathvar);
4623 HeapFree(GetProcessHeap(), 0, pathdata);
4626 size = MAX_PATH;
4627 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
4628 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4629 ok(!lstrcmpA(prop,
4630 "my%NOVAR%"), "Expected \"my%%NOVAR%%\", got \"%s\"\n", prop);
4632 size = MAX_PATH;
4633 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
4634 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4635 todo_wine
4637 ok(!memcmp(prop, "\0one\0two\0\0", 10),
4638 "Expected \"\\0one\\0two\\0\\0\"\n");
4641 size = MAX_PATH;
4642 lstrcpyA(path, "#xCDAB3412EF907856");
4643 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
4644 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4645 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4647 size = MAX_PATH;
4648 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
4649 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4650 ok(!lstrcmpA(prop, "##regszdata"),
4651 "Expected \"##regszdata\", got \"%s\"\n", prop);
4653 size = MAX_PATH;
4654 sprintf(path, "%s\\FileName1", expected);
4655 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
4656 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4657 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4659 size = MAX_PATH;
4660 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
4661 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4662 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4664 size = MAX_PATH;
4665 sprintf(path, "%s\\", expected);
4666 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
4667 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4668 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4670 size = MAX_PATH;
4671 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
4672 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4673 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4675 size = MAX_PATH;
4676 sprintf(path, "%s\\", expected);
4677 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
4678 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4679 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4681 size = MAX_PATH;
4682 r = MsiGetPropertyA(hpkg, "SIGPROP14", prop, &size);
4683 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4684 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4686 size = MAX_PATH;
4687 r = MsiGetPropertyA(hpkg, "SIGPROP15", prop, &size);
4688 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4689 ok(!lstrcmpA(prop, "regszdata"),
4690 "Expected \"regszdata\", got \"%s\"\n", prop);
4692 size = MAX_PATH;
4693 r = MsiGetPropertyA(hpkg, "SIGPROP16", prop, &size);
4694 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4695 ok(!lstrcmpA(prop, "regszdata"),
4696 "Expected \"regszdata\", got \"%s\"\n", prop);
4698 if (users)
4700 size = MAX_PATH;
4701 r = MsiGetPropertyA(hpkg, "SIGPROP17", prop, &size);
4702 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4703 ok(!lstrcmpA(prop, "regszdata"),
4704 "Expected \"regszdata\", got \"%s\"\n", prop);
4707 size = MAX_PATH;
4708 r = MsiGetPropertyA(hpkg, "SIGPROP18", prop, &size);
4709 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4710 ok(!lstrcmpA(prop, "defvalue"),
4711 "Expected \"defvalue\", got \"%s\"\n", prop);
4713 size = MAX_PATH;
4714 r = MsiGetPropertyA(hpkg, "SIGPROP19", prop, &size);
4715 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4716 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4718 size = MAX_PATH;
4719 r = MsiGetPropertyA(hpkg, "SIGPROP20", prop, &size);
4720 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4721 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4723 if (version)
4725 size = MAX_PATH;
4726 sprintf(path, "%s\\FileName3.dll", expected);
4727 r = MsiGetPropertyA(hpkg, "SIGPROP21", prop, &size);
4728 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4729 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4731 size = MAX_PATH;
4732 r = MsiGetPropertyA(hpkg, "SIGPROP22", prop, &size);
4733 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4734 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4736 size = MAX_PATH;
4737 sprintf(path, "%s\\FileName5.dll", expected);
4738 r = MsiGetPropertyA(hpkg, "SIGPROP23", prop, &size);
4739 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4740 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4743 if (!is_root(CURR_DIR))
4745 size = MAX_PATH;
4746 lstrcpyA(path, expected);
4747 ptr = strrchr(path, '\\') + 1;
4748 *ptr = '\0';
4749 r = MsiGetPropertyA(hpkg, "SIGPROP24", prop, &size);
4750 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4751 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4753 size = MAX_PATH;
4754 sprintf(path, "%s\\", expected);
4755 r = MsiGetPropertyA(hpkg, "SIGPROP25", prop, &size);
4756 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4757 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4759 size = MAX_PATH;
4760 r = MsiGetPropertyA(hpkg, "SIGPROP26", prop, &size);
4761 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4762 if (is_root(CURR_DIR))
4763 ok(!lstrcmpA(prop, CURR_DIR), "Expected \"%s\", got \"%s\"\n", CURR_DIR, prop);
4764 else
4765 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4767 size = MAX_PATH;
4768 r = MsiGetPropertyA(hpkg, "SIGPROP27", prop, &size);
4769 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4770 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4772 size = MAX_PATH;
4773 r = MsiGetPropertyA(hpkg, "SIGPROP28", prop, &size);
4774 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4775 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4777 size = MAX_PATH;
4778 sprintf(path, "%s\\FileName1", expected);
4779 r = MsiGetPropertyA(hpkg, "SIGPROP29", prop, &size);
4780 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4781 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4783 size = MAX_PATH;
4784 sprintf(path, "%s\\FileName1", expected);
4785 r = MsiGetPropertyA(hpkg, "SIGPROP30", prop, &size);
4786 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4787 if (space)
4788 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
4789 else
4790 todo_wine ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
4792 RegSetValueA(hklm, NULL, REG_SZ, "", 0);
4793 RegDeleteValueA(hklm, "Value1");
4794 RegDeleteValueA(hklm, "Value2");
4795 RegDeleteValueA(hklm, "Value3");
4796 RegDeleteValueA(hklm, "Value4");
4797 RegDeleteValueA(hklm, "Value5");
4798 RegDeleteValueA(hklm, "Value6");
4799 RegDeleteValueA(hklm, "Value7");
4800 RegDeleteValueA(hklm, "Value8");
4801 RegDeleteValueA(hklm, "Value9");
4802 RegDeleteValueA(hklm, "Value10");
4803 RegDeleteValueA(hklm, "Value11");
4804 RegDeleteValueA(hklm, "Value12");
4805 RegDeleteValueA(hklm, "Value13");
4806 RegDeleteValueA(hklm, "Value14");
4807 RegDeleteValueA(hklm, "Value15");
4808 RegDeleteValueA(hklm, "Value16");
4809 RegDeleteValueA(hklm, "Value17");
4810 RegDeleteKeyA(hklm, "");
4811 RegCloseKey(hklm);
4813 RegDeleteValueA(classes, "Value1");
4814 RegDeleteKeyA(classes, "");
4815 RegCloseKey(classes);
4817 RegDeleteValueA(hkcu, "Value1");
4818 RegDeleteKeyA(hkcu, "");
4819 RegCloseKey(hkcu);
4821 RegDeleteValueA(users, "Value1");
4822 RegDeleteKeyA(users, "");
4823 RegCloseKey(users);
4825 DeleteFileA("FileName1");
4826 DeleteFileA("FileName3.dll");
4827 DeleteFileA("FileName4.dll");
4828 DeleteFileA("FileName5.dll");
4829 MsiCloseHandle(hpkg);
4830 DeleteFileA(msifile);
4833 static void delete_win_ini(LPCSTR file)
4835 CHAR path[MAX_PATH];
4837 GetWindowsDirectoryA(path, MAX_PATH);
4838 lstrcatA(path, "\\");
4839 lstrcatA(path, file);
4841 DeleteFileA(path);
4844 static void test_appsearch_inilocator(void)
4846 MSIHANDLE hpkg, hdb;
4847 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
4848 BOOL version;
4849 LPCSTR str;
4850 LPSTR ptr;
4851 DWORD size;
4852 UINT r;
4854 version = TRUE;
4855 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
4856 version = FALSE;
4858 DeleteFileA("test.dll");
4860 WritePrivateProfileStringA("Section", "Key", "keydata,field2", "IniFile.ini");
4862 strcpy(expected, CURR_DIR);
4863 if (is_root(CURR_DIR)) expected[2] = 0;
4865 create_test_file("FileName1");
4866 sprintf(path, "%s\\FileName1", expected);
4867 WritePrivateProfileStringA("Section", "Key2", path, "IniFile.ini");
4869 WritePrivateProfileStringA("Section", "Key3", expected, "IniFile.ini");
4871 sprintf(path, "%s\\IDontExist", expected);
4872 WritePrivateProfileStringA("Section", "Key4", path, "IniFile.ini");
4874 create_file_with_version("FileName2.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4875 sprintf(path, "%s\\FileName2.dll", expected);
4876 WritePrivateProfileStringA("Section", "Key5", path, "IniFile.ini");
4878 create_file_with_version("FileName3.dll", MAKELONG(1, 2), MAKELONG(3, 4));
4879 sprintf(path, "%s\\FileName3.dll", expected);
4880 WritePrivateProfileStringA("Section", "Key6", path, "IniFile.ini");
4882 create_file_with_version("FileName4.dll", MAKELONG(2, 1), MAKELONG(4, 3));
4883 sprintf(path, "%s\\FileName4.dll", expected);
4884 WritePrivateProfileStringA("Section", "Key7", path, "IniFile.ini");
4886 hdb = create_package_db();
4887 ok(hdb, "Expected a valid database handle\n");
4889 r = create_appsearch_table(hdb);
4890 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4892 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
4893 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4895 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
4896 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4898 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
4899 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4901 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
4902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4904 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
4905 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4907 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
4908 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4910 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
4911 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4913 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
4914 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4916 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
4917 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4919 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
4920 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4922 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
4923 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4925 r = add_appsearch_entry(hdb, "'SIGPROP12', 'NewSignature12'");
4926 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4928 r = create_inilocator_table(hdb);
4929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4931 /* msidbLocatorTypeRawValue, field 1 */
4932 str = "'NewSignature1', 'IniFile.ini', 'Section', 'Key', 1, 2";
4933 r = add_inilocator_entry(hdb, str);
4934 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4936 /* msidbLocatorTypeRawValue, field 2 */
4937 str = "'NewSignature2', 'IniFile.ini', 'Section', 'Key', 2, 2";
4938 r = add_inilocator_entry(hdb, str);
4939 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4941 /* msidbLocatorTypeRawValue, entire field */
4942 str = "'NewSignature3', 'IniFile.ini', 'Section', 'Key', 0, 2";
4943 r = add_inilocator_entry(hdb, str);
4944 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4946 /* msidbLocatorTypeFile */
4947 str = "'NewSignature4', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4948 r = add_inilocator_entry(hdb, str);
4949 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4951 /* msidbLocatorTypeDirectory, file */
4952 str = "'NewSignature5', 'IniFile.ini', 'Section', 'Key2', 1, 0";
4953 r = add_inilocator_entry(hdb, str);
4954 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4956 /* msidbLocatorTypeDirectory, directory */
4957 str = "'NewSignature6', 'IniFile.ini', 'Section', 'Key3', 1, 0";
4958 r = add_inilocator_entry(hdb, str);
4959 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4961 /* msidbLocatorTypeFile, file, no signature */
4962 str = "'NewSignature7', 'IniFile.ini', 'Section', 'Key2', 1, 1";
4963 r = add_inilocator_entry(hdb, str);
4964 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4966 /* msidbLocatorTypeFile, dir, no signature */
4967 str = "'NewSignature8', 'IniFile.ini', 'Section', 'Key3', 1, 1";
4968 r = add_inilocator_entry(hdb, str);
4969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4971 /* msidbLocatorTypeFile, file does not exist */
4972 str = "'NewSignature9', 'IniFile.ini', 'Section', 'Key4', 1, 1";
4973 r = add_inilocator_entry(hdb, str);
4974 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4976 /* msidbLocatorTypeFile, signature with version */
4977 str = "'NewSignature10', 'IniFile.ini', 'Section', 'Key5', 1, 1";
4978 r = add_inilocator_entry(hdb, str);
4979 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4981 /* msidbLocatorTypeFile, signature with version, ver > max */
4982 str = "'NewSignature11', 'IniFile.ini', 'Section', 'Key6', 1, 1";
4983 r = add_inilocator_entry(hdb, str);
4984 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4986 /* msidbLocatorTypeFile, signature with version, sig->name ignored */
4987 str = "'NewSignature12', 'IniFile.ini', 'Section', 'Key7', 1, 1";
4988 r = add_inilocator_entry(hdb, str);
4989 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4991 r = create_signature_table(hdb);
4992 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4994 r = add_signature_entry(hdb, "'NewSignature4', 'FileName1', '', '', '', '', '', '', ''");
4995 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
4997 r = add_signature_entry(hdb, "'NewSignature9', 'IDontExist', '', '', '', '', '', '', ''");
4998 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5000 r = add_signature_entry(hdb, "'NewSignature10', 'FileName2.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5001 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5003 r = add_signature_entry(hdb, "'NewSignature11', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5004 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5006 r = add_signature_entry(hdb, "'NewSignature12', 'ignored', '1.1.1.1', '2.1.1.1', '', '', '', '', ''");
5007 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5009 r = package_from_db(hdb, &hpkg);
5010 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5012 skip("Not enough rights to perform tests\n");
5013 goto error;
5015 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5017 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5019 r = MsiDoActionA(hpkg, "AppSearch");
5020 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5022 size = MAX_PATH;
5023 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5024 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5025 ok(!lstrcmpA(prop, "keydata"), "Expected \"keydata\", got \"%s\"\n", prop);
5027 size = MAX_PATH;
5028 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5029 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5030 ok(!lstrcmpA(prop, "field2"), "Expected \"field2\", got \"%s\"\n", prop);
5032 size = MAX_PATH;
5033 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5034 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5035 ok(!lstrcmpA(prop, "keydata,field2"),
5036 "Expected \"keydata,field2\", got \"%s\"\n", prop);
5038 size = MAX_PATH;
5039 sprintf(path, "%s\\FileName1", expected);
5040 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5041 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5042 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5044 size = MAX_PATH;
5045 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5046 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5047 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5049 size = MAX_PATH;
5050 sprintf(path, "%s\\", expected);
5051 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5052 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5053 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5055 size = MAX_PATH;
5056 sprintf(path, "%s\\", expected);
5057 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5058 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5059 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5061 if (!is_root(CURR_DIR))
5063 size = MAX_PATH;
5064 lstrcpyA(path, expected);
5065 ptr = strrchr(path, '\\');
5066 *(ptr + 1) = 0;
5067 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5068 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5069 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5071 size = MAX_PATH;
5072 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5073 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5074 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5076 if (version)
5078 size = MAX_PATH;
5079 sprintf(path, "%s\\FileName2.dll", expected);
5080 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5081 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5082 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5084 size = MAX_PATH;
5085 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5086 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5087 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5089 size = MAX_PATH;
5090 sprintf(path, "%s\\FileName4.dll", expected);
5091 r = MsiGetPropertyA(hpkg, "SIGPROP12", prop, &size);
5092 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5093 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5096 MsiCloseHandle(hpkg);
5098 error:
5099 delete_win_ini("IniFile.ini");
5100 DeleteFileA("FileName1");
5101 DeleteFileA("FileName2.dll");
5102 DeleteFileA("FileName3.dll");
5103 DeleteFileA("FileName4.dll");
5104 DeleteFileA(msifile);
5108 * MSI AppSearch action on DrLocator table always returns absolute paths.
5109 * If a relative path was set, it returns the first absolute path that
5110 * matches or an empty string if it didn't find anything.
5111 * This helper function replicates this behaviour.
5113 static void search_absolute_directory(LPSTR absolute, LPCSTR relative)
5115 int i, size;
5116 DWORD attr, drives;
5118 size = lstrlenA(relative);
5119 drives = GetLogicalDrives();
5120 lstrcpyA(absolute, "A:\\");
5121 for (i = 0; i < 26; absolute[0] = '\0', i++)
5123 if (!(drives & (1 << i)))
5124 continue;
5126 absolute[0] = 'A' + i;
5127 if (GetDriveTypeA(absolute) != DRIVE_FIXED)
5128 continue;
5130 lstrcpynA(absolute + 3, relative, size + 1);
5131 attr = GetFileAttributesA(absolute);
5132 if (attr != INVALID_FILE_ATTRIBUTES &&
5133 (attr & FILE_ATTRIBUTE_DIRECTORY))
5135 if (absolute[3 + size - 1] != '\\')
5136 lstrcatA(absolute, "\\");
5137 break;
5139 absolute[3] = '\0';
5143 static void test_appsearch_drlocator(void)
5145 MSIHANDLE hpkg, hdb;
5146 char path[MAX_PATH], expected[MAX_PATH], prop[MAX_PATH];
5147 BOOL version;
5148 LPCSTR str;
5149 DWORD size;
5150 UINT r;
5152 version = TRUE;
5153 if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
5154 version = FALSE;
5156 DeleteFileA("test.dll");
5158 create_test_file("FileName1");
5159 CreateDirectoryA("one", NULL);
5160 CreateDirectoryA("one\\two", NULL);
5161 CreateDirectoryA("one\\two\\three", NULL);
5162 create_test_file("one\\two\\three\\FileName2");
5163 CreateDirectoryA("another", NULL);
5164 create_file_with_version("FileName3.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5165 create_file_with_version("FileName4.dll", MAKELONG(1, 2), MAKELONG(3, 4));
5166 create_file_with_version("FileName5.dll", MAKELONG(2, 1), MAKELONG(4, 3));
5168 hdb = create_package_db();
5169 ok(hdb, "Expected a valid database handle\n");
5171 r = create_appsearch_table(hdb);
5172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5174 r = add_appsearch_entry(hdb, "'SIGPROP1', 'NewSignature1'");
5175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5177 r = add_appsearch_entry(hdb, "'SIGPROP2', 'NewSignature2'");
5178 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5180 r = add_appsearch_entry(hdb, "'SIGPROP3', 'NewSignature3'");
5181 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5183 r = add_appsearch_entry(hdb, "'SIGPROP4', 'NewSignature4'");
5184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5186 r = add_appsearch_entry(hdb, "'SIGPROP5', 'NewSignature5'");
5187 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5189 r = add_appsearch_entry(hdb, "'SIGPROP6', 'NewSignature6'");
5190 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5192 r = add_appsearch_entry(hdb, "'SIGPROP7', 'NewSignature7'");
5193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5195 r = add_appsearch_entry(hdb, "'SIGPROP8', 'NewSignature8'");
5196 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5198 r = add_appsearch_entry(hdb, "'SIGPROP9', 'NewSignature9'");
5199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5201 r = add_appsearch_entry(hdb, "'SIGPROP10', 'NewSignature10'");
5202 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5204 r = add_appsearch_entry(hdb, "'SIGPROP11', 'NewSignature11'");
5205 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5207 r = add_appsearch_entry(hdb, "'SIGPROP13', 'NewSignature13'");
5208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5210 r = create_drlocator_table(hdb);
5211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5213 strcpy(expected, CURR_DIR);
5214 if (is_root(CURR_DIR)) expected[2] = 0;
5216 /* no parent, full path, depth 0, signature */
5217 sprintf(path, "'NewSignature1', '', '%s', 0", expected);
5218 r = add_drlocator_entry(hdb, path);
5219 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5221 /* no parent, full path, depth 0, no signature */
5222 sprintf(path, "'NewSignature2', '', '%s', 0", expected);
5223 r = add_drlocator_entry(hdb, path);
5224 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5226 /* no parent, relative path, depth 0, no signature */
5227 sprintf(path, "'NewSignature3', '', '%s', 0", expected + 3);
5228 r = add_drlocator_entry(hdb, path);
5229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5231 /* no parent, full path, depth 2, signature */
5232 sprintf(path, "'NewSignature4', '', '%s', 2", expected);
5233 r = add_drlocator_entry(hdb, path);
5234 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5236 /* no parent, full path, depth 3, signature */
5237 sprintf(path, "'NewSignature5', '', '%s', 3", expected);
5238 r = add_drlocator_entry(hdb, path);
5239 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5241 /* no parent, full path, depth 1, signature is dir */
5242 sprintf(path, "'NewSignature6', '', '%s', 1", expected);
5243 r = add_drlocator_entry(hdb, path);
5244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5246 /* parent is in DrLocator, relative path, depth 0, signature */
5247 sprintf(path, "'NewSignature7', 'NewSignature1', 'one\\two\\three', 1");
5248 r = add_drlocator_entry(hdb, path);
5249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5251 /* no parent, full path, depth 0, signature w/ version */
5252 sprintf(path, "'NewSignature8', '', '%s', 0", expected);
5253 r = add_drlocator_entry(hdb, path);
5254 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5256 /* no parent, full path, depth 0, signature w/ version, ver > max */
5257 sprintf(path, "'NewSignature9', '', '%s', 0", expected);
5258 r = add_drlocator_entry(hdb, path);
5259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5261 /* no parent, full path, depth 0, signature w/ version, sig->name not ignored */
5262 sprintf(path, "'NewSignature10', '', '%s', 0", expected);
5263 r = add_drlocator_entry(hdb, path);
5264 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5266 /* no parent, relative empty path, depth 0, no signature */
5267 sprintf(path, "'NewSignature11', '', '', 0");
5268 r = add_drlocator_entry(hdb, path);
5269 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5271 r = create_reglocator_table(hdb);
5272 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5274 /* parent */
5275 r = add_reglocator_entry(hdb, "NewSignature12", 2, "htmlfile\\shell\\open\\nonexistent", "", 1);
5276 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5278 /* parent is in RegLocator, no path, depth 0, no signature */
5279 sprintf(path, "'NewSignature13', 'NewSignature12', '', 0");
5280 r = add_drlocator_entry(hdb, path);
5281 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5283 r = create_signature_table(hdb);
5284 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5286 str = "'NewSignature1', 'FileName1', '', '', '', '', '', '', ''";
5287 r = add_signature_entry(hdb, str);
5288 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5290 str = "'NewSignature4', 'FileName2', '', '', '', '', '', '', ''";
5291 r = add_signature_entry(hdb, str);
5292 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5294 str = "'NewSignature5', 'FileName2', '', '', '', '', '', '', ''";
5295 r = add_signature_entry(hdb, str);
5296 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5298 str = "'NewSignature6', 'another', '', '', '', '', '', '', ''";
5299 r = add_signature_entry(hdb, str);
5300 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5302 str = "'NewSignature7', 'FileName2', '', '', '', '', '', '', ''";
5303 r = add_signature_entry(hdb, str);
5304 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5306 str = "'NewSignature8', 'FileName3.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5307 r = add_signature_entry(hdb, str);
5308 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5310 str = "'NewSignature9', 'FileName4.dll', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5311 r = add_signature_entry(hdb, str);
5312 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5314 str = "'NewSignature10', 'necessary', '1.1.1.1', '2.1.1.1', '', '', '', '', ''";
5315 r = add_signature_entry(hdb, str);
5316 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5318 r = package_from_db(hdb, &hpkg);
5319 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5321 skip("Not enough rights to perform tests\n");
5322 goto error;
5324 ok(r == ERROR_SUCCESS, "Expected a valid package handle %u\n", r);
5326 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5328 r = MsiDoActionA(hpkg, "AppSearch");
5329 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5331 size = MAX_PATH;
5332 sprintf(path, "%s\\FileName1", expected);
5333 r = MsiGetPropertyA(hpkg, "SIGPROP1", prop, &size);
5334 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5335 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5337 size = MAX_PATH;
5338 sprintf(path, "%s\\", expected);
5339 r = MsiGetPropertyA(hpkg, "SIGPROP2", prop, &size);
5340 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5341 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5343 size = MAX_PATH;
5344 search_absolute_directory(path, expected + 3);
5345 r = MsiGetPropertyA(hpkg, "SIGPROP3", prop, &size);
5346 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5347 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5349 size = MAX_PATH;
5350 r = MsiGetPropertyA(hpkg, "SIGPROP4", prop, &size);
5351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5352 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5354 size = MAX_PATH;
5355 sprintf(path, "%s\\one\\two\\three\\FileName2", expected);
5356 r = MsiGetPropertyA(hpkg, "SIGPROP5", prop, &size);
5357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5358 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5360 size = MAX_PATH;
5361 r = MsiGetPropertyA(hpkg, "SIGPROP6", prop, &size);
5362 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5363 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5365 size = MAX_PATH;
5366 sprintf(path, "%s\\one\\two\\three\\FileName2", expected);
5367 r = MsiGetPropertyA(hpkg, "SIGPROP7", prop, &size);
5368 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5369 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5371 if (version)
5373 size = MAX_PATH;
5374 sprintf(path, "%s\\FileName3.dll", expected);
5375 r = MsiGetPropertyA(hpkg, "SIGPROP8", prop, &size);
5376 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5377 ok(!lstrcmpA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5379 size = MAX_PATH;
5380 r = MsiGetPropertyA(hpkg, "SIGPROP9", prop, &size);
5381 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5382 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5384 size = MAX_PATH;
5385 r = MsiGetPropertyA(hpkg, "SIGPROP10", prop, &size);
5386 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5387 ok(!lstrcmpA(prop, ""), "Expected \"\", got \"%s\"\n", prop);
5390 size = MAX_PATH;
5391 search_absolute_directory(path, "");
5392 r = MsiGetPropertyA(hpkg, "SIGPROP11", prop, &size);
5393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5394 ok(!lstrcmpiA(prop, path), "Expected \"%s\", got \"%s\"\n", path, prop);
5396 size = MAX_PATH;
5397 strcpy(path, "c:\\");
5398 r = MsiGetPropertyA(hpkg, "SIGPROP13", prop, &size);
5399 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
5400 ok(!prop[0], "Expected \"\", got \"%s\"\n", prop);
5402 MsiCloseHandle(hpkg);
5404 error:
5405 DeleteFileA("FileName1");
5406 DeleteFileA("FileName3.dll");
5407 DeleteFileA("FileName4.dll");
5408 DeleteFileA("FileName5.dll");
5409 DeleteFileA("one\\two\\three\\FileName2");
5410 RemoveDirectoryA("one\\two\\three");
5411 RemoveDirectoryA("one\\two");
5412 RemoveDirectoryA("one");
5413 RemoveDirectoryA("another");
5414 DeleteFileA(msifile);
5417 static void test_featureparents(void)
5419 MSIHANDLE hpkg;
5420 UINT r;
5421 MSIHANDLE hdb;
5423 hdb = create_package_db();
5424 ok ( hdb, "failed to create package database\n" );
5426 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'");
5427 ok( r == ERROR_SUCCESS, "cannot add directory: %d\n", r );
5429 r = create_feature_table( hdb );
5430 ok( r == ERROR_SUCCESS, "cannot create Feature table: %d\n", r );
5432 r = create_component_table( hdb );
5433 ok( r == ERROR_SUCCESS, "cannot create Component table: %d\n", r );
5435 r = create_feature_components_table( hdb );
5436 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table: %d\n", r );
5438 r = create_file_table( hdb );
5439 ok( r == ERROR_SUCCESS, "cannot create File table: %d\n", r );
5441 /* msidbFeatureAttributesFavorLocal */
5442 r = add_feature_entry( hdb, "'zodiac', '', '', '', 2, 1, '', 0" );
5443 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5445 /* msidbFeatureAttributesFavorSource */
5446 r = add_feature_entry( hdb, "'perseus', '', '', '', 2, 1, '', 1" );
5447 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5449 /* msidbFeatureAttributesFavorLocal */
5450 r = add_feature_entry( hdb, "'orion', '', '', '', 2, 1, '', 0" );
5451 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5453 /* msidbFeatureAttributesUIDisallowAbsent */
5454 r = add_feature_entry( hdb, "'lyra', '', '', '', 2, 1, '', 16" );
5455 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5457 /* disabled because of install level */
5458 r = add_feature_entry( hdb, "'waters', '', '', '', 15, 101, '', 9" );
5459 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5461 /* child feature of disabled feature */
5462 r = add_feature_entry( hdb, "'bayer', 'waters', '', '', 14, 1, '', 9" );
5463 ok( r == ERROR_SUCCESS, "cannot add feature: %d\n", r );
5465 /* component of disabled feature (install level) */
5466 r = add_component_entry( hdb, "'delphinus', '', 'TARGETDIR', 0, '', 'delphinus_file'" );
5467 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5469 /* component of disabled child feature (install level) */
5470 r = add_component_entry( hdb, "'hydrus', '', 'TARGETDIR', 0, '', 'hydrus_file'" );
5471 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5473 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5474 r = add_component_entry( hdb, "'leo', '', 'TARGETDIR', 0, '', 'leo_file'" );
5475 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5477 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5478 r = add_component_entry( hdb, "'virgo', '', 'TARGETDIR', 1, '', 'virgo_file'" );
5479 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5481 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5482 r = add_component_entry( hdb, "'libra', '', 'TARGETDIR', 2, '', 'libra_file'" );
5483 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5485 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesLocalOnly */
5486 r = add_component_entry( hdb, "'cassiopeia', '', 'TARGETDIR', 0, '', 'cassiopeia_file'" );
5487 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5489 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesSourceOnly */
5490 r = add_component_entry( hdb, "'cepheus', '', 'TARGETDIR', 1, '', 'cepheus_file'" );
5491 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5493 /* msidbFeatureAttributesFavorSource:msidbComponentAttributesOptional */
5494 r = add_component_entry( hdb, "'andromeda', '', 'TARGETDIR', 2, '', 'andromeda_file'" );
5495 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5497 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesLocalOnly */
5498 r = add_component_entry( hdb, "'canis', '', 'TARGETDIR', 0, '', 'canis_file'" );
5499 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5501 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesSourceOnly */
5502 r = add_component_entry( hdb, "'monoceros', '', 'TARGETDIR', 1, '', 'monoceros_file'" );
5503 ok( r == ERROR_SUCCESS, "cannot add component: %d\n", r );
5505 /* msidbFeatureAttributesFavorLocal:msidbComponentAttributesOptional */
5506 r = add_component_entry( hdb, "'lepus', '', 'TARGETDIR', 2, '', 'lepus_file'" );
5507 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5509 r = add_feature_components_entry( hdb, "'zodiac', 'leo'" );
5510 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5512 r = add_feature_components_entry( hdb, "'zodiac', 'virgo'" );
5513 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5515 r = add_feature_components_entry( hdb, "'zodiac', 'libra'" );
5516 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5518 r = add_feature_components_entry( hdb, "'perseus', 'cassiopeia'" );
5519 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5521 r = add_feature_components_entry( hdb, "'perseus', 'cepheus'" );
5522 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5524 r = add_feature_components_entry( hdb, "'perseus', 'andromeda'" );
5525 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5527 r = add_feature_components_entry( hdb, "'orion', 'leo'" );
5528 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5530 r = add_feature_components_entry( hdb, "'orion', 'virgo'" );
5531 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5533 r = add_feature_components_entry( hdb, "'orion', 'libra'" );
5534 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5536 r = add_feature_components_entry( hdb, "'orion', 'cassiopeia'" );
5537 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5539 r = add_feature_components_entry( hdb, "'orion', 'cepheus'" );
5540 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5542 r = add_feature_components_entry( hdb, "'orion', 'andromeda'" );
5543 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5545 r = add_feature_components_entry( hdb, "'orion', 'canis'" );
5546 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5548 r = add_feature_components_entry( hdb, "'orion', 'monoceros'" );
5549 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5551 r = add_feature_components_entry( hdb, "'orion', 'lepus'" );
5552 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5554 r = add_feature_components_entry( hdb, "'waters', 'delphinus'" );
5555 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5557 r = add_feature_components_entry( hdb, "'bayer', 'hydrus'" );
5558 ok( r == ERROR_SUCCESS, "cannot add feature components: %d\n", r );
5560 r = add_file_entry( hdb, "'leo_file', 'leo', 'leo.txt', 100, '', '1033', 8192, 1" );
5561 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5563 r = add_file_entry( hdb, "'virgo_file', 'virgo', 'virgo.txt', 0, '', '1033', 8192, 1" );
5564 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5566 r = add_file_entry( hdb, "'libra_file', 'libra', 'libra.txt', 0, '', '1033', 8192, 1" );
5567 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5569 r = add_file_entry( hdb, "'cassiopeia_file', 'cassiopeia', 'cassiopeia.txt', 0, '', '1033', 8192, 1" );
5570 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5572 r = add_file_entry( hdb, "'cepheus_file', 'cepheus', 'cepheus.txt', 0, '', '1033', 8192, 1" );
5573 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5575 r = add_file_entry( hdb, "'andromeda_file', 'andromeda', 'andromeda.txt', 0, '', '1033', 8192, 1" );
5576 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5578 r = add_file_entry( hdb, "'canis_file', 'canis', 'canis.txt', 0, '', '1033', 8192, 1" );
5579 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5581 r = add_file_entry( hdb, "'monoceros_file', 'monoceros', 'monoceros.txt', 0, '', '1033', 8192, 1" );
5582 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5584 r = add_file_entry( hdb, "'lepus_file', 'lepus', 'lepus.txt', 0, '', '1033', 8192, 1" );
5585 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5587 r = add_file_entry( hdb, "'delphinus_file', 'delphinus', 'delphinus.txt', 0, '', '1033', 8192, 1" );
5588 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5590 r = add_file_entry( hdb, "'hydrus_file', 'hydrus', 'hydrus.txt', 0, '', '1033', 8192, 1" );
5591 ok( r == ERROR_SUCCESS, "cannot add file: %d\n", r);
5593 r = package_from_db( hdb, &hpkg );
5594 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5596 skip("Not enough rights to perform tests\n");
5597 DeleteFileA(msifile);
5598 return;
5600 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5602 MsiCloseHandle( hdb );
5604 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5606 r = MsiDoActionA( hpkg, "CostInitialize");
5607 ok( r == ERROR_SUCCESS, "cost init failed\n");
5609 r = MsiDoActionA( hpkg, "FileCost");
5610 ok( r == ERROR_SUCCESS, "file cost failed\n");
5612 r = MsiDoActionA( hpkg, "CostFinalize");
5613 ok( r == ERROR_SUCCESS, "cost finalize failed\n");
5615 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5616 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
5617 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5618 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5619 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5620 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5622 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5623 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5624 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5625 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5626 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5627 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5628 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5629 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5630 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5631 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5632 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5634 r = MsiSetFeatureStateA(hpkg, "orion", INSTALLSTATE_ABSENT);
5635 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5637 r = MsiSetFeatureStateA(hpkg, "lyra", INSTALLSTATE_ABSENT);
5638 ok( r == ERROR_SUCCESS, "failed to set feature state: %d\n", r);
5640 r = MsiSetFeatureStateA(hpkg, "nosuchfeature", INSTALLSTATE_ABSENT);
5641 ok( r == ERROR_UNKNOWN_FEATURE, "Expected ERROR_UNKNOWN_FEATURE, got %u\n", r);
5643 test_feature_states( __LINE__, hpkg, "zodiac", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_LOCAL, FALSE );
5644 test_feature_states( __LINE__, hpkg, "perseus", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_SOURCE, FALSE );
5645 test_feature_states( __LINE__, hpkg, "orion", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, FALSE );
5646 test_feature_states( __LINE__, hpkg, "lyra", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_ABSENT, FALSE );
5647 test_feature_states( __LINE__, hpkg, "waters", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5648 test_feature_states( __LINE__, hpkg, "bayer", ERROR_SUCCESS, INSTALLSTATE_ABSENT, INSTALLSTATE_UNKNOWN, FALSE );
5650 test_component_states( __LINE__, hpkg, "leo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5651 test_component_states( __LINE__, hpkg, "virgo", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5652 test_component_states( __LINE__, hpkg, "libra", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5653 test_component_states( __LINE__, hpkg, "cassiopeia", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_LOCAL, FALSE );
5654 test_component_states( __LINE__, hpkg, "cepheus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5655 test_component_states( __LINE__, hpkg, "andromeda", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_SOURCE, FALSE );
5656 test_component_states( __LINE__, hpkg, "canis", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5657 test_component_states( __LINE__, hpkg, "monoceros", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5658 test_component_states( __LINE__, hpkg, "lepus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5659 test_component_states( __LINE__, hpkg, "delphinus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5660 test_component_states( __LINE__, hpkg, "hydrus", ERROR_SUCCESS, INSTALLSTATE_UNKNOWN, INSTALLSTATE_UNKNOWN, FALSE );
5662 MsiCloseHandle(hpkg);
5663 DeleteFileA(msifile);
5666 static void test_installprops(void)
5668 MSIHANDLE hpkg, hdb;
5669 CHAR path[MAX_PATH], buf[MAX_PATH];
5670 DWORD size, type;
5671 LANGID langid;
5672 HKEY hkey1, hkey2;
5673 int res;
5674 UINT r;
5675 REGSAM access = KEY_ALL_ACCESS;
5676 SYSTEM_INFO si;
5677 INSTALLUILEVEL uilevel;
5679 if (is_wow64)
5680 access |= KEY_WOW64_64KEY;
5682 lstrcpyA(path, CURR_DIR);
5683 if (!is_root(CURR_DIR)) lstrcatA(path, "\\");
5684 lstrcatA(path, msifile);
5686 uilevel = MsiSetInternalUI(INSTALLUILEVEL_BASIC|INSTALLUILEVEL_SOURCERESONLY, NULL);
5688 hdb = create_package_db();
5689 ok( hdb, "failed to create database\n");
5691 r = package_from_db(hdb, &hpkg);
5692 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
5694 skip("Not enough rights to perform tests\n");
5695 MsiSetInternalUI(uilevel, NULL);
5696 DeleteFileA(msifile);
5697 return;
5699 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
5701 MsiCloseHandle(hdb);
5703 buf[0] = 0;
5704 size = MAX_PATH;
5705 r = MsiGetPropertyA(hpkg, "UILevel", buf, &size);
5706 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5707 ok( !lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5709 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
5711 buf[0] = 0;
5712 size = MAX_PATH;
5713 r = MsiGetPropertyA(hpkg, "UILevel", buf, &size);
5714 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5715 ok( !lstrcmpA(buf, "3"), "Expected \"3\", got \"%s\"\n", buf);
5717 buf[0] = 0;
5718 size = MAX_PATH;
5719 r = MsiGetPropertyA(hpkg, "DATABASE", buf, &size);
5720 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5721 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5723 RegOpenKeyA(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
5724 RegOpenKeyExA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
5726 size = MAX_PATH;
5727 type = REG_SZ;
5728 *path = '\0';
5729 if (RegQueryValueExA(hkey1, "DefName", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5731 size = MAX_PATH;
5732 type = REG_SZ;
5733 RegQueryValueExA(hkey2, "RegisteredOwner", NULL, &type, (LPBYTE)path, &size);
5736 buf[0] = 0;
5737 size = MAX_PATH;
5738 r = MsiGetPropertyA(hpkg, "USERNAME", buf, &size);
5739 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5740 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5742 size = MAX_PATH;
5743 type = REG_SZ;
5744 *path = '\0';
5745 if (RegQueryValueExA(hkey1, "DefCompany", NULL, &type, (LPBYTE)path, &size) != ERROR_SUCCESS)
5747 size = MAX_PATH;
5748 type = REG_SZ;
5749 RegQueryValueExA(hkey2, "RegisteredOrganization", NULL, &type, (LPBYTE)path, &size);
5752 if (*path)
5754 buf[0] = 0;
5755 size = MAX_PATH;
5756 r = MsiGetPropertyA(hpkg, "COMPANYNAME", buf, &size);
5757 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5758 ok( !lstrcmpA(buf, path), "Expected %s, got %s\n", path, buf);
5761 buf[0] = 0;
5762 size = MAX_PATH;
5763 r = MsiGetPropertyA(hpkg, "VersionDatabase", buf, &size);
5764 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5765 trace("VersionDatabase = %s\n", buf);
5767 buf[0] = 0;
5768 size = MAX_PATH;
5769 r = MsiGetPropertyA(hpkg, "VersionMsi", buf, &size);
5770 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5771 trace("VersionMsi = %s\n", buf);
5773 buf[0] = 0;
5774 size = MAX_PATH;
5775 r = MsiGetPropertyA(hpkg, "Date", buf, &size);
5776 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5777 trace("Date = %s\n", buf);
5779 buf[0] = 0;
5780 size = MAX_PATH;
5781 r = MsiGetPropertyA(hpkg, "Time", buf, &size);
5782 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5783 trace("Time = %s\n", buf);
5785 buf[0] = 0;
5786 size = MAX_PATH;
5787 r = MsiGetPropertyA(hpkg, "PackageCode", buf, &size);
5788 ok( r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5789 trace("PackageCode = %s\n", buf);
5791 buf[0] = 0;
5792 size = MAX_PATH;
5793 r = MsiGetPropertyA(hpkg, "ComputerName", buf, &size);
5794 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5795 trace("ComputerName = %s\n", buf);
5797 langid = GetUserDefaultLangID();
5798 sprintf(path, "%d", langid);
5800 buf[0] = 0;
5801 size = MAX_PATH;
5802 r = MsiGetPropertyA(hpkg, "UserLanguageID", buf, &size);
5803 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5804 ok( !lstrcmpA(buf, path), "Expected \"%s\", got \"%s\"\n", path, buf);
5806 res = GetSystemMetrics(SM_CXSCREEN);
5807 buf[0] = 0;
5808 size = MAX_PATH;
5809 r = MsiGetPropertyA(hpkg, "ScreenX", buf, &size);
5810 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5811 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5813 res = GetSystemMetrics(SM_CYSCREEN);
5814 buf[0] = 0;
5815 size = MAX_PATH;
5816 r = MsiGetPropertyA(hpkg, "ScreenY", buf, &size);
5817 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS got %d\n", r);
5818 ok(atol(buf) == res, "Expected %d, got %ld\n", res, atol(buf));
5820 if (pGetSystemInfo && pSHGetFolderPathA)
5822 pGetSystemInfo(&si);
5823 if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_AMD64)
5825 buf[0] = 0;
5826 size = MAX_PATH;
5827 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5828 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5829 ok(buf[0], "property not set\n");
5831 buf[0] = 0;
5832 size = MAX_PATH;
5833 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5834 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5835 ok(buf[0], "property not set\n");
5837 buf[0] = 0;
5838 size = MAX_PATH;
5839 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5840 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5841 ok(buf[0], "property not set\n");
5843 buf[0] = 0;
5844 size = MAX_PATH;
5845 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5846 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5847 GetSystemDirectoryA(path, MAX_PATH);
5848 if (size) buf[size - 1] = 0;
5849 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5851 buf[0] = 0;
5852 size = MAX_PATH;
5853 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5854 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5855 pGetSystemWow64DirectoryA(path, MAX_PATH);
5856 if (size) buf[size - 1] = 0;
5857 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5859 buf[0] = 0;
5860 size = MAX_PATH;
5861 r = MsiGetPropertyA(hpkg, "ProgramFiles64Folder", buf, &size);
5862 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5863 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5864 if (size) buf[size - 1] = 0;
5865 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5867 buf[0] = 0;
5868 size = MAX_PATH;
5869 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
5870 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5871 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
5872 if (size) buf[size - 1] = 0;
5873 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5875 buf[0] = 0;
5876 size = MAX_PATH;
5877 r = MsiGetPropertyA(hpkg, "CommonFiles64Folder", buf, &size);
5878 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5879 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5880 if (size) buf[size - 1] = 0;
5881 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5883 buf[0] = 0;
5884 size = MAX_PATH;
5885 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
5886 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5887 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
5888 if (size) buf[size - 1] = 0;
5889 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5891 buf[0] = 0;
5892 size = MAX_PATH;
5893 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
5894 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5895 ok(buf[0], "property not set\n");
5897 else if (S(U(si)).wProcessorArchitecture == PROCESSOR_ARCHITECTURE_INTEL)
5899 if (!is_wow64)
5901 buf[0] = 0;
5902 size = MAX_PATH;
5903 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5904 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5905 ok(buf[0], "property not set\n");
5907 buf[0] = 0;
5908 size = MAX_PATH;
5909 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5910 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5911 ok(!buf[0], "property set\n");
5913 buf[0] = 0;
5914 size = MAX_PATH;
5915 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5916 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5917 ok(!buf[0], "property set\n");
5919 buf[0] = 0;
5920 size = MAX_PATH;
5921 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5922 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5923 ok(!buf[0], "property set\n");
5925 buf[0] = 0;
5926 size = MAX_PATH;
5927 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5928 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5929 GetSystemDirectoryA(path, MAX_PATH);
5930 if (size) buf[size - 1] = 0;
5931 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5933 buf[0] = 0;
5934 size = MAX_PATH;
5935 r = MsiGetPropertyA(hpkg, "ProgramFiles64Folder", buf, &size);
5936 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5937 ok(!buf[0], "property set\n");
5939 buf[0] = 0;
5940 size = MAX_PATH;
5941 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
5942 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5943 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES, NULL, 0, path);
5944 if (size) buf[size - 1] = 0;
5945 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5947 buf[0] = 0;
5948 size = MAX_PATH;
5949 r = MsiGetPropertyA(hpkg, "CommonFiles64Folder", buf, &size);
5950 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5951 ok(!buf[0], "property set\n");
5953 buf[0] = 0;
5954 size = MAX_PATH;
5955 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
5956 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5957 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMON, NULL, 0, path);
5958 if (size) buf[size - 1] = 0;
5959 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5961 buf[0] = 0;
5962 size = MAX_PATH;
5963 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
5964 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5965 ok(!buf[0], "property set\n");
5967 else
5969 buf[0] = 0;
5970 size = MAX_PATH;
5971 r = MsiGetPropertyA(hpkg, "Intel", buf, &size);
5972 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5973 ok(buf[0], "property not set\n");
5975 buf[0] = 0;
5976 size = MAX_PATH;
5977 r = MsiGetPropertyA(hpkg, "MsiAMD64", buf, &size);
5978 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5979 ok(buf[0], "property not set\n");
5981 buf[0] = 0;
5982 size = MAX_PATH;
5983 r = MsiGetPropertyA(hpkg, "Msix64", buf, &size);
5984 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5985 ok(buf[0], "property not set\n");
5987 buf[0] = 0;
5988 size = MAX_PATH;
5989 r = MsiGetPropertyA(hpkg, "System64Folder", buf, &size);
5990 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5991 GetSystemDirectoryA(path, MAX_PATH);
5992 if (size) buf[size - 1] = 0;
5993 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
5995 buf[0] = 0;
5996 size = MAX_PATH;
5997 r = MsiGetPropertyA(hpkg, "SystemFolder", buf, &size);
5998 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
5999 pGetSystemWow64DirectoryA(path, MAX_PATH);
6000 if (size) buf[size - 1] = 0;
6001 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6003 buf[0] = 0;
6004 size = MAX_PATH;
6005 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder64", buf, &size);
6006 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6007 ok(!buf[0], "property set\n");
6009 buf[0] = 0;
6010 size = MAX_PATH;
6011 r = MsiGetPropertyA(hpkg, "ProgramFilesFolder", buf, &size);
6012 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6013 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILESX86, NULL, 0, path);
6014 if (size) buf[size - 1] = 0;
6015 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6017 buf[0] = 0;
6018 size = MAX_PATH;
6019 r = MsiGetPropertyA(hpkg, "CommonFilesFolder64", buf, &size);
6020 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6021 ok(!buf[0], "property set\n");
6023 buf[0] = 0;
6024 size = MAX_PATH;
6025 r = MsiGetPropertyA(hpkg, "CommonFilesFolder", buf, &size);
6026 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6027 pSHGetFolderPathA(NULL, CSIDL_PROGRAM_FILES_COMMONX86, NULL, 0, path);
6028 if (size) buf[size - 1] = 0;
6029 ok(!lstrcmpiA(path, buf), "expected \"%s\", got \"%s\"\n", path, buf);
6031 buf[0] = 0;
6032 size = MAX_PATH;
6033 r = MsiGetPropertyA(hpkg, "VersionNT64", buf, &size);
6034 ok(r == ERROR_SUCCESS, "failed to get property: %d\n", r);
6035 ok(buf[0], "property not set\n");
6040 CloseHandle(hkey1);
6041 CloseHandle(hkey2);
6042 MsiCloseHandle(hpkg);
6043 DeleteFileA(msifile);
6044 MsiSetInternalUI(uilevel, NULL);
6047 static void test_launchconditions(void)
6049 MSIHANDLE hpkg;
6050 MSIHANDLE hdb;
6051 UINT r;
6053 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6055 hdb = create_package_db();
6056 ok( hdb, "failed to create package database\n" );
6058 r = create_launchcondition_table( hdb );
6059 ok( r == ERROR_SUCCESS, "cannot create LaunchCondition table: %d\n", r );
6061 r = add_launchcondition_entry( hdb, "'X = \"1\"', 'one'" );
6062 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
6064 /* invalid condition */
6065 r = add_launchcondition_entry( hdb, "'X != \"1\"', 'one'" );
6066 ok( r == ERROR_SUCCESS, "cannot add launch condition: %d\n", r );
6068 r = package_from_db( hdb, &hpkg );
6069 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6071 skip("Not enough rights to perform tests\n");
6072 DeleteFileA(msifile);
6073 return;
6075 ok( r == ERROR_SUCCESS, "failed to create package %u\n", r );
6077 MsiCloseHandle( hdb );
6079 r = MsiSetPropertyA( hpkg, "X", "1" );
6080 ok( r == ERROR_SUCCESS, "failed to set property\n" );
6082 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6084 /* invalid conditions are ignored */
6085 r = MsiDoActionA( hpkg, "LaunchConditions" );
6086 ok( r == ERROR_SUCCESS, "cost init failed\n" );
6088 /* verify LaunchConditions still does some verification */
6089 r = MsiSetPropertyA( hpkg, "X", "2" );
6090 ok( r == ERROR_SUCCESS, "failed to set property\n" );
6092 r = MsiDoActionA( hpkg, "LaunchConditions" );
6093 ok( r == ERROR_INSTALL_FAILURE, "Expected ERROR_INSTALL_FAILURE, got %d\n", r );
6095 MsiCloseHandle( hpkg );
6096 DeleteFileA( msifile );
6099 static void test_ccpsearch(void)
6101 MSIHANDLE hdb, hpkg;
6102 CHAR prop[MAX_PATH];
6103 DWORD size = MAX_PATH;
6104 UINT r;
6106 hdb = create_package_db();
6107 ok(hdb, "failed to create package database\n");
6109 r = create_ccpsearch_table(hdb);
6110 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6112 r = add_ccpsearch_entry(hdb, "'CCP_random'");
6113 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6115 r = add_ccpsearch_entry(hdb, "'RMCCP_random'");
6116 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6118 r = create_reglocator_table(hdb);
6119 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6121 r = add_reglocator_entry(hdb, "CCP_random", 0, "htmlfile\\shell\\open\\nonexistent", "", 1);
6122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6124 r = create_drlocator_table(hdb);
6125 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6127 r = add_drlocator_entry(hdb, "'RMCCP_random', '', 'C:\\', '0'");
6128 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6130 r = create_signature_table(hdb);
6131 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6133 r = package_from_db(hdb, &hpkg);
6134 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6136 skip("Not enough rights to perform tests\n");
6137 DeleteFileA(msifile);
6138 return;
6140 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6142 MsiCloseHandle(hdb);
6144 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6146 r = MsiDoActionA(hpkg, "CCPSearch");
6147 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6149 r = MsiGetPropertyA(hpkg, "CCP_Success", prop, &size);
6150 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6151 ok(!lstrcmpA(prop, "1"), "Expected 1, got %s\n", prop);
6153 MsiCloseHandle(hpkg);
6154 DeleteFileA(msifile);
6157 static void test_complocator(void)
6159 MSIHANDLE hdb, hpkg;
6160 UINT r;
6161 CHAR prop[MAX_PATH];
6162 CHAR expected[MAX_PATH];
6163 DWORD size = MAX_PATH;
6165 hdb = create_package_db();
6166 ok(hdb, "failed to create package database\n");
6168 r = create_appsearch_table(hdb);
6169 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6171 r = add_appsearch_entry(hdb, "'ABELISAURUS', 'abelisaurus'");
6172 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6174 r = add_appsearch_entry(hdb, "'BACTROSAURUS', 'bactrosaurus'");
6175 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6177 r = add_appsearch_entry(hdb, "'CAMELOTIA', 'camelotia'");
6178 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6180 r = add_appsearch_entry(hdb, "'DICLONIUS', 'diclonius'");
6181 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6183 r = add_appsearch_entry(hdb, "'ECHINODON', 'echinodon'");
6184 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6186 r = add_appsearch_entry(hdb, "'FALCARIUS', 'falcarius'");
6187 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6189 r = add_appsearch_entry(hdb, "'GALLIMIMUS', 'gallimimus'");
6190 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6192 r = add_appsearch_entry(hdb, "'HAGRYPHUS', 'hagryphus'");
6193 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6195 r = add_appsearch_entry(hdb, "'IGUANODON', 'iguanodon'");
6196 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6198 r = add_appsearch_entry(hdb, "'JOBARIA', 'jobaria'");
6199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6201 r = add_appsearch_entry(hdb, "'KAKURU', 'kakuru'");
6202 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6204 r = add_appsearch_entry(hdb, "'LABOCANIA', 'labocania'");
6205 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6207 r = add_appsearch_entry(hdb, "'MEGARAPTOR', 'megaraptor'");
6208 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6210 r = add_appsearch_entry(hdb, "'NEOSODON', 'neosodon'");
6211 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6213 r = add_appsearch_entry(hdb, "'OLOROTITAN', 'olorotitan'");
6214 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6216 r = add_appsearch_entry(hdb, "'PANTYDRACO', 'pantydraco'");
6217 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6219 r = create_complocator_table(hdb);
6220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6222 r = add_complocator_entry(hdb, "'abelisaurus', '{E3619EED-305A-418C-B9C7-F7D7377F0934}', 1");
6223 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6225 r = add_complocator_entry(hdb, "'bactrosaurus', '{D56B688D-542F-42Ef-90FD-B6DA76EE8119}', 0");
6226 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6228 r = add_complocator_entry(hdb, "'camelotia', '{8211BE36-2466-47E3-AFB7-6AC72E51AED2}', 1");
6229 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6231 r = add_complocator_entry(hdb, "'diclonius', '{5C767B20-A33C-45A4-B80B-555E512F01AE}', 0");
6232 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6234 r = add_complocator_entry(hdb, "'echinodon', '{A19E16C5-C75D-4699-8111-C4338C40C3CB}', 1");
6235 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6237 r = add_complocator_entry(hdb, "'falcarius', '{17762FA1-A7AE-4CC6-8827-62873C35361D}', 0");
6238 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6240 r = add_complocator_entry(hdb, "'gallimimus', '{75EBF568-C959-41E0-A99E-9050638CF5FB}', 1");
6241 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6243 r = add_complocator_entry(hdb, "'hagrphus', '{D4969B72-17D9-4AB6-BE49-78F2FEE857AC}', 0");
6244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6246 r = add_complocator_entry(hdb, "'iguanodon', '{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}', 1");
6247 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6249 r = add_complocator_entry(hdb, "'jobaria', '{243C22B1-8C51-4151-B9D1-1AE5265E079E}', 0");
6250 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6252 r = add_complocator_entry(hdb, "'kakuru', '{5D0F03BA-50BC-44F2-ABB1-72C972F4E514}', 1");
6253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6255 r = add_complocator_entry(hdb, "'labocania', '{C7DDB60C-7828-4046-A6F8-699D5E92F1ED}', 0");
6256 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6258 r = add_complocator_entry(hdb, "'megaraptor', '{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}', 1");
6259 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6261 r = add_complocator_entry(hdb, "'neosodon', '{0B499649-197A-48EF-93D2-AF1C17ED6E90}', 0");
6262 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6264 r = add_complocator_entry(hdb, "'olorotitan', '{54E9E91F-AED2-46D5-A25A-7E50AFA24513}', 1");
6265 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6267 r = add_complocator_entry(hdb, "'pantydraco', '{2A989951-5565-4FA7-93A7-E800A3E67D71}', 0");
6268 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6270 r = create_signature_table(hdb);
6271 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6273 r = add_signature_entry(hdb, "'abelisaurus', 'abelisaurus', '', '', '', '', '', '', ''");
6274 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6276 r = add_signature_entry(hdb, "'bactrosaurus', 'bactrosaurus', '', '', '', '', '', '', ''");
6277 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6279 r = add_signature_entry(hdb, "'camelotia', 'camelotia', '', '', '', '', '', '', ''");
6280 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6282 r = add_signature_entry(hdb, "'diclonius', 'diclonius', '', '', '', '', '', '', ''");
6283 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6285 r = add_signature_entry(hdb, "'iguanodon', 'iguanodon', '', '', '', '', '', '', ''");
6286 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6288 r = add_signature_entry(hdb, "'jobaria', 'jobaria', '', '', '', '', '', '', ''");
6289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6291 r = add_signature_entry(hdb, "'kakuru', 'kakuru', '', '', '', '', '', '', ''");
6292 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6294 r = add_signature_entry(hdb, "'labocania', 'labocania', '', '', '', '', '', '', ''");
6295 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6297 r = package_from_db(hdb, &hpkg);
6298 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6300 skip("Not enough rights to perform tests\n");
6301 DeleteFileA(msifile);
6302 return;
6304 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6306 MsiCloseHandle(hdb);
6308 create_test_file("abelisaurus");
6309 create_test_file("bactrosaurus");
6310 create_test_file("camelotia");
6311 create_test_file("diclonius");
6312 create_test_file("echinodon");
6313 create_test_file("falcarius");
6314 create_test_file("gallimimus");
6315 create_test_file("hagryphus");
6316 CreateDirectoryA("iguanodon", NULL);
6317 CreateDirectoryA("jobaria", NULL);
6318 CreateDirectoryA("kakuru", NULL);
6319 CreateDirectoryA("labocania", NULL);
6320 CreateDirectoryA("megaraptor", NULL);
6321 CreateDirectoryA("neosodon", NULL);
6322 CreateDirectoryA("olorotitan", NULL);
6323 CreateDirectoryA("pantydraco", NULL);
6325 set_component_path("abelisaurus", MSIINSTALLCONTEXT_MACHINE,
6326 "{E3619EED-305A-418C-B9C7-F7D7377F0934}", NULL, FALSE);
6327 set_component_path("bactrosaurus", MSIINSTALLCONTEXT_MACHINE,
6328 "{D56B688D-542F-42Ef-90FD-B6DA76EE8119}", NULL, FALSE);
6329 set_component_path("echinodon", MSIINSTALLCONTEXT_MACHINE,
6330 "{A19E16C5-C75D-4699-8111-C4338C40C3CB}", NULL, FALSE);
6331 set_component_path("falcarius", MSIINSTALLCONTEXT_MACHINE,
6332 "{17762FA1-A7AE-4CC6-8827-62873C35361D}", NULL, FALSE);
6333 set_component_path("iguanodon", MSIINSTALLCONTEXT_MACHINE,
6334 "{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}", NULL, FALSE);
6335 set_component_path("jobaria", MSIINSTALLCONTEXT_MACHINE,
6336 "{243C22B1-8C51-4151-B9D1-1AE5265E079E}", NULL, FALSE);
6337 set_component_path("megaraptor", MSIINSTALLCONTEXT_MACHINE,
6338 "{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}", NULL, FALSE);
6339 set_component_path("neosodon", MSIINSTALLCONTEXT_MACHINE,
6340 "{0B499649-197A-48EF-93D2-AF1C17ED6E90}", NULL, FALSE);
6342 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6344 r = MsiDoActionA(hpkg, "AppSearch");
6345 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6347 size = MAX_PATH;
6348 r = MsiGetPropertyA(hpkg, "ABELISAURUS", prop, &size);
6349 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6351 lstrcpyA(expected, CURR_DIR);
6352 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6353 lstrcatA(expected, "abelisaurus");
6354 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6355 "Expected %s or empty string, got %s\n", expected, prop);
6357 size = MAX_PATH;
6358 r = MsiGetPropertyA(hpkg, "BACTROSAURUS", prop, &size);
6359 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6360 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6362 size = MAX_PATH;
6363 r = MsiGetPropertyA(hpkg, "CAMELOTIA", prop, &size);
6364 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6365 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6367 size = MAX_PATH;
6368 r = MsiGetPropertyA(hpkg, "DICLONIUS", prop, &size);
6369 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6370 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6372 size = MAX_PATH;
6373 r = MsiGetPropertyA(hpkg, "ECHINODON", prop, &size);
6374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6376 lstrcpyA(expected, CURR_DIR);
6377 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6378 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6379 "Expected %s or empty string, got %s\n", expected, prop);
6381 size = MAX_PATH;
6382 r = MsiGetPropertyA(hpkg, "FALCARIUS", prop, &size);
6383 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6384 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6386 size = MAX_PATH;
6387 r = MsiGetPropertyA(hpkg, "GALLIMIMUS", prop, &size);
6388 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6389 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6391 size = MAX_PATH;
6392 r = MsiGetPropertyA(hpkg, "HAGRYPHUS", prop, &size);
6393 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6394 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6396 size = MAX_PATH;
6397 r = MsiGetPropertyA(hpkg, "IGUANODON", prop, &size);
6398 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6399 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6401 size = MAX_PATH;
6402 r = MsiGetPropertyA(hpkg, "JOBARIA", prop, &size);
6403 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6404 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6406 size = MAX_PATH;
6407 r = MsiGetPropertyA(hpkg, "KAKURU", prop, &size);
6408 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6409 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6411 size = MAX_PATH;
6412 r = MsiGetPropertyA(hpkg, "LABOCANIA", prop, &size);
6413 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6414 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6416 size = MAX_PATH;
6417 r = MsiGetPropertyA(hpkg, "MEGARAPTOR", prop, &size);
6418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6420 lstrcpyA(expected, CURR_DIR);
6421 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6422 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6423 "Expected %s or empty string, got %s\n", expected, prop);
6425 size = MAX_PATH;
6426 r = MsiGetPropertyA(hpkg, "NEOSODON", prop, &size);
6427 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6429 lstrcpyA(expected, CURR_DIR);
6430 if (!is_root(CURR_DIR)) lstrcatA(expected, "\\");
6431 lstrcatA(expected, "neosodon\\");
6432 ok(!lstrcmpA(prop, expected) || !lstrcmpA(prop, ""),
6433 "Expected %s or empty string, got %s\n", expected, prop);
6435 size = MAX_PATH;
6436 r = MsiGetPropertyA(hpkg, "OLOROTITAN", prop, &size);
6437 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6438 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6440 size = MAX_PATH;
6441 r = MsiGetPropertyA(hpkg, "PANTYDRACO", prop, &size);
6442 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6443 ok(!lstrcmpA(prop, ""), "Expected , got %s\n", prop);
6445 MsiCloseHandle(hpkg);
6446 DeleteFileA("abelisaurus");
6447 DeleteFileA("bactrosaurus");
6448 DeleteFileA("camelotia");
6449 DeleteFileA("diclonius");
6450 DeleteFileA("echinodon");
6451 DeleteFileA("falcarius");
6452 DeleteFileA("gallimimus");
6453 DeleteFileA("hagryphus");
6454 RemoveDirectoryA("iguanodon");
6455 RemoveDirectoryA("jobaria");
6456 RemoveDirectoryA("kakuru");
6457 RemoveDirectoryA("labocania");
6458 RemoveDirectoryA("megaraptor");
6459 RemoveDirectoryA("neosodon");
6460 RemoveDirectoryA("olorotitan");
6461 RemoveDirectoryA("pantydraco");
6462 delete_component_path("{E3619EED-305A-418C-B9C7-F7D7377F0934}",
6463 MSIINSTALLCONTEXT_MACHINE, NULL);
6464 delete_component_path("{D56B688D-542F-42Ef-90FD-B6DA76EE8119}",
6465 MSIINSTALLCONTEXT_MACHINE, NULL);
6466 delete_component_path("{A19E16C5-C75D-4699-8111-C4338C40C3CB}",
6467 MSIINSTALLCONTEXT_MACHINE, NULL);
6468 delete_component_path("{17762FA1-A7AE-4CC6-8827-62873C35361D}",
6469 MSIINSTALLCONTEXT_MACHINE, NULL);
6470 delete_component_path("{8E0DA02E-F6A7-4A8F-B25D-6F564C492308}",
6471 MSIINSTALLCONTEXT_MACHINE, NULL);
6472 delete_component_path("{243C22B1-8C51-4151-B9D1-1AE5265E079E}",
6473 MSIINSTALLCONTEXT_MACHINE, NULL);
6474 delete_component_path("{8B1034B7-BD5E-41ac-B52C-0105D3DFD74D}",
6475 MSIINSTALLCONTEXT_MACHINE, NULL);
6476 delete_component_path("{0B499649-197A-48EF-93D2-AF1C17ED6E90}",
6477 MSIINSTALLCONTEXT_MACHINE, NULL);
6478 DeleteFileA(msifile);
6481 static void set_suminfo_prop(MSIHANDLE db, DWORD prop, DWORD val)
6483 MSIHANDLE summary;
6484 UINT r;
6486 r = MsiGetSummaryInformationA(db, NULL, 1, &summary);
6487 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6489 r = MsiSummaryInfoSetPropertyA(summary, prop, VT_I4, val, NULL, NULL);
6490 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6492 r = MsiSummaryInfoPersist(summary);
6493 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r);
6495 MsiCloseHandle(summary);
6498 static void test_MsiGetSourcePath(void)
6500 MSIHANDLE hdb, hpkg;
6501 CHAR path[MAX_PATH];
6502 CHAR cwd[MAX_PATH];
6503 CHAR subsrc[MAX_PATH];
6504 CHAR sub2[MAX_PATH];
6505 DWORD size;
6506 UINT r;
6508 lstrcpyA(cwd, CURR_DIR);
6509 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
6511 lstrcpyA(subsrc, cwd);
6512 lstrcatA(subsrc, "subsource");
6513 lstrcatA(subsrc, "\\");
6515 lstrcpyA(sub2, subsrc);
6516 lstrcatA(sub2, "sub2");
6517 lstrcatA(sub2, "\\");
6519 /* uncompressed source */
6521 hdb = create_package_db();
6522 ok( hdb, "failed to create database\n");
6524 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
6526 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
6527 ok(r == S_OK, "failed\n");
6529 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'subtarget:subsource'");
6530 ok(r == S_OK, "failed\n");
6532 r = add_directory_entry(hdb, "'SubDir2', 'SubDir', 'sub2'");
6533 ok(r == S_OK, "failed\n");
6535 r = MsiDatabaseCommit(hdb);
6536 ok(r == ERROR_SUCCESS , "Failed to commit database\n");
6538 r = package_from_db(hdb, &hpkg);
6539 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
6541 skip("Not enough rights to perform tests\n");
6542 DeleteFileA(msifile);
6543 return;
6545 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6547 MsiCloseHandle(hdb);
6549 /* invalid database handle */
6550 size = MAX_PATH;
6551 lstrcpyA(path, "kiwi");
6552 r = MsiGetSourcePathA(-1, "TARGETDIR", path, &size);
6553 ok(r == ERROR_INVALID_HANDLE,
6554 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
6555 ok(!lstrcmpA(path, "kiwi"),
6556 "Expected path to be unchanged, got \"%s\"\n", path);
6557 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6559 /* NULL szFolder */
6560 size = MAX_PATH;
6561 lstrcpyA(path, "kiwi");
6562 r = MsiGetSourcePathA(hpkg, NULL, path, &size);
6563 ok(r == ERROR_INVALID_PARAMETER,
6564 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6565 ok(!lstrcmpA(path, "kiwi"),
6566 "Expected path to be unchanged, got \"%s\"\n", path);
6567 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6569 /* empty szFolder */
6570 size = MAX_PATH;
6571 lstrcpyA(path, "kiwi");
6572 r = MsiGetSourcePathA(hpkg, "", path, &size);
6573 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6574 ok(!lstrcmpA(path, "kiwi"),
6575 "Expected path to be unchanged, got \"%s\"\n", path);
6576 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6578 /* try TARGETDIR */
6579 size = MAX_PATH;
6580 lstrcpyA(path, "kiwi");
6581 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6582 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6583 ok(!lstrcmpA(path, "kiwi"),
6584 "Expected path to be unchanged, got \"%s\"\n", path);
6585 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6587 size = MAX_PATH;
6588 lstrcpyA(path, "kiwi");
6589 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6590 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6591 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6592 ok(size == 0, "Expected 0, got %d\n", size);
6594 size = MAX_PATH;
6595 lstrcpyA(path, "kiwi");
6596 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6597 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6598 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6599 ok(size == 0, "Expected 0, got %d\n", size);
6601 /* try SourceDir */
6602 size = MAX_PATH;
6603 lstrcpyA(path, "kiwi");
6604 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6605 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6606 ok(!lstrcmpA(path, "kiwi"),
6607 "Expected path to be unchanged, got \"%s\"\n", path);
6608 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6610 /* try SOURCEDIR */
6611 size = MAX_PATH;
6612 lstrcpyA(path, "kiwi");
6613 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6614 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6615 ok(!lstrcmpA(path, "kiwi"),
6616 "Expected path to be unchanged, got \"%s\"\n", path);
6617 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6619 /* source path does not exist, but the property exists */
6620 size = MAX_PATH;
6621 lstrcpyA(path, "kiwi");
6622 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6623 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6624 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6625 ok(size == 0, "Expected 0, got %d\n", size);
6627 size = MAX_PATH;
6628 lstrcpyA(path, "kiwi");
6629 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6630 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6631 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
6632 ok(size == 0, "Expected 0, got %d\n", size);
6634 /* try SubDir */
6635 size = MAX_PATH;
6636 lstrcpyA(path, "kiwi");
6637 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6638 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6639 ok(!lstrcmpA(path, "kiwi"),
6640 "Expected path to be unchanged, got \"%s\"\n", path);
6641 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6643 /* try SubDir2 */
6644 size = MAX_PATH;
6645 lstrcpyA(path, "kiwi");
6646 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6647 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6648 ok(!lstrcmpA(path, "kiwi"),
6649 "Expected path to be unchanged, got \"%s\"\n", path);
6650 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6652 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
6654 r = MsiDoActionA(hpkg, "CostInitialize");
6655 ok(r == ERROR_SUCCESS, "cost init failed\n");
6657 /* try TARGETDIR after CostInitialize */
6658 size = MAX_PATH;
6659 lstrcpyA(path, "kiwi");
6660 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6661 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6662 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6663 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6665 /* try SourceDir after CostInitialize */
6666 size = MAX_PATH;
6667 lstrcpyA(path, "kiwi");
6668 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6669 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6670 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6671 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6673 /* try SOURCEDIR after CostInitialize */
6674 size = MAX_PATH;
6675 lstrcpyA(path, "kiwi");
6676 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6677 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6678 ok(!lstrcmpA(path, "kiwi"),
6679 "Expected path to be unchanged, got \"%s\"\n", path);
6680 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6682 /* source path does not exist, but the property exists */
6683 size = MAX_PATH;
6684 lstrcpyA(path, "kiwi");
6685 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6686 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6687 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6688 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6690 size = MAX_PATH;
6691 lstrcpyA(path, "kiwi");
6692 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6693 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6694 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6695 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6697 /* try SubDir after CostInitialize */
6698 size = MAX_PATH;
6699 lstrcpyA(path, "kiwi");
6700 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6701 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6702 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6703 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6705 /* try SubDir2 after CostInitialize */
6706 size = MAX_PATH;
6707 lstrcpyA(path, "kiwi");
6708 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6709 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6710 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6711 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6713 r = MsiDoActionA(hpkg, "ResolveSource");
6714 ok(r == ERROR_SUCCESS, "file cost failed\n");
6716 /* try TARGETDIR after ResolveSource */
6717 size = MAX_PATH;
6718 lstrcpyA(path, "kiwi");
6719 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6720 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6721 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6722 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6724 /* try SourceDir after ResolveSource */
6725 size = MAX_PATH;
6726 lstrcpyA(path, "kiwi");
6727 r = MsiGetSourcePathA(hpkg, "SourceDir", 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 ResolveSource */
6733 size = MAX_PATH;
6734 lstrcpyA(path, "kiwi");
6735 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6736 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6737 ok(!lstrcmpA(path, "kiwi"),
6738 "Expected path to be unchanged, got \"%s\"\n", path);
6739 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6741 /* source path does not exist, but the property exists */
6742 size = MAX_PATH;
6743 lstrcpyA(path, "kiwi");
6744 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6745 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6746 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6747 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6749 size = MAX_PATH;
6750 lstrcpyA(path, "kiwi");
6751 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6752 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6753 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6754 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6756 /* try SubDir after ResolveSource */
6757 size = MAX_PATH;
6758 lstrcpyA(path, "kiwi");
6759 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6760 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6761 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6762 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6764 /* try SubDir2 after ResolveSource */
6765 size = MAX_PATH;
6766 lstrcpyA(path, "kiwi");
6767 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6768 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6769 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6770 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6772 r = MsiDoActionA(hpkg, "FileCost");
6773 ok(r == ERROR_SUCCESS, "file cost failed\n");
6775 /* try TARGETDIR after FileCost */
6776 size = MAX_PATH;
6777 lstrcpyA(path, "kiwi");
6778 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6779 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6780 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6781 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6783 /* try SourceDir after FileCost */
6784 size = MAX_PATH;
6785 lstrcpyA(path, "kiwi");
6786 r = MsiGetSourcePathA(hpkg, "SourceDir", 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 FileCost */
6792 size = MAX_PATH;
6793 lstrcpyA(path, "kiwi");
6794 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6795 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6796 ok(!lstrcmpA(path, "kiwi"),
6797 "Expected path to be unchanged, got \"%s\"\n", path);
6798 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6800 /* source path does not exist, but the property exists */
6801 size = MAX_PATH;
6802 lstrcpyA(path, "kiwi");
6803 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6804 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6805 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6806 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6808 size = MAX_PATH;
6809 lstrcpyA(path, "kiwi");
6810 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6811 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6812 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6813 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6815 /* try SubDir after FileCost */
6816 size = MAX_PATH;
6817 lstrcpyA(path, "kiwi");
6818 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6819 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6820 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6821 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6823 /* try SubDir2 after FileCost */
6824 size = MAX_PATH;
6825 lstrcpyA(path, "kiwi");
6826 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6827 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6828 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6829 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6831 r = MsiDoActionA(hpkg, "CostFinalize");
6832 ok(r == ERROR_SUCCESS, "file cost failed\n");
6834 /* try TARGETDIR after CostFinalize */
6835 size = MAX_PATH;
6836 lstrcpyA(path, "kiwi");
6837 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6838 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6839 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6840 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6842 /* try SourceDir after CostFinalize */
6843 size = MAX_PATH;
6844 lstrcpyA(path, "kiwi");
6845 r = MsiGetSourcePathA(hpkg, "SourceDir", 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 CostFinalize */
6851 size = MAX_PATH;
6852 lstrcpyA(path, "kiwi");
6853 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6854 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6855 ok(!lstrcmpA(path, "kiwi"),
6856 "Expected path to be unchanged, got \"%s\"\n", path);
6857 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6859 /* source path does not exist, but the property exists */
6860 size = MAX_PATH;
6861 lstrcpyA(path, "kiwi");
6862 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
6863 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6864 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6865 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6867 size = MAX_PATH;
6868 lstrcpyA(path, "kiwi");
6869 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
6870 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6871 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6872 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6874 /* try SubDir after CostFinalize */
6875 size = MAX_PATH;
6876 lstrcpyA(path, "kiwi");
6877 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
6878 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6879 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
6880 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
6882 /* try SubDir2 after CostFinalize */
6883 size = MAX_PATH;
6884 lstrcpyA(path, "kiwi");
6885 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
6886 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6887 ok(!lstrcmpA(path, sub2), "Expected \"%s\", got \"%s\"\n", sub2, path);
6888 ok(size == lstrlenA(sub2), "Expected %d, got %d\n", lstrlenA(sub2), size);
6890 /* nonexistent directory */
6891 size = MAX_PATH;
6892 lstrcpyA(path, "kiwi");
6893 r = MsiGetSourcePathA(hpkg, "IDontExist", path, &size);
6894 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6895 ok(!lstrcmpA(path, "kiwi"),
6896 "Expected path to be unchanged, got \"%s\"\n", path);
6897 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6899 /* NULL szPathBuf */
6900 size = MAX_PATH;
6901 r = MsiGetSourcePathA(hpkg, "SourceDir", NULL, &size);
6902 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6903 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6905 /* NULL pcchPathBuf */
6906 lstrcpyA(path, "kiwi");
6907 r = MsiGetSourcePathA(hpkg, "SourceDir", path, NULL);
6908 ok(r == ERROR_INVALID_PARAMETER,
6909 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
6910 ok(!lstrcmpA(path, "kiwi"),
6911 "Expected path to be unchanged, got \"%s\"\n", path);
6913 /* pcchPathBuf is 0 */
6914 size = 0;
6915 lstrcpyA(path, "kiwi");
6916 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6917 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6918 ok(!lstrcmpA(path, "kiwi"),
6919 "Expected path to be unchanged, got \"%s\"\n", path);
6920 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6922 /* pcchPathBuf does not have room for NULL terminator */
6923 size = lstrlenA(cwd);
6924 lstrcpyA(path, "kiwi");
6925 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6926 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
6927 ok(!strncmp(path, cwd, lstrlenA(cwd) - 1),
6928 "Expected path with no backslash, got \"%s\"\n", path);
6929 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6931 /* pcchPathBuf has room for NULL terminator */
6932 size = lstrlenA(cwd) + 1;
6933 lstrcpyA(path, "kiwi");
6934 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6935 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6936 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6937 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6939 /* remove property */
6940 r = MsiSetPropertyA(hpkg, "SourceDir", NULL);
6941 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6943 /* try SourceDir again */
6944 size = MAX_PATH;
6945 lstrcpyA(path, "kiwi");
6946 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6947 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6948 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
6949 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
6951 /* set property to a valid directory */
6952 r = MsiSetPropertyA(hpkg, "SOURCEDIR", cwd);
6953 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6955 /* try SOURCEDIR again */
6956 size = MAX_PATH;
6957 lstrcpyA(path, "kiwi");
6958 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6959 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6960 ok(!lstrcmpA(path, "kiwi"),
6961 "Expected path to be unchanged, got \"%s\"\n", path);
6962 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6964 MsiCloseHandle(hpkg);
6966 /* compressed source */
6968 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
6969 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
6971 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeCompressed);
6973 r = package_from_db(hdb, &hpkg);
6974 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
6976 /* try TARGETDIR */
6977 size = MAX_PATH;
6978 lstrcpyA(path, "kiwi");
6979 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
6980 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6981 ok(!lstrcmpA(path, "kiwi"),
6982 "Expected path to be unchanged, got \"%s\"\n", path);
6983 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6985 /* try SourceDir */
6986 size = MAX_PATH;
6987 lstrcpyA(path, "kiwi");
6988 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
6989 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6990 ok(!lstrcmpA(path, "kiwi"),
6991 "Expected path to be unchanged, got \"%s\"\n", path);
6992 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
6994 /* try SOURCEDIR */
6995 size = MAX_PATH;
6996 lstrcpyA(path, "kiwi");
6997 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
6998 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
6999 ok(!lstrcmpA(path, "kiwi"),
7000 "Expected path to be unchanged, got \"%s\"\n", path);
7001 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7003 /* source path nor the property exist */
7004 size = MAX_PATH;
7005 lstrcpyA(path, "kiwi");
7006 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7007 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7008 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7009 ok(size == 0, "Expected 0, got %d\n", size);
7011 size = MAX_PATH;
7012 lstrcpyA(path, "kiwi");
7013 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7014 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7015 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7016 ok(size == 0, "Expected 0, got %d\n", size);
7018 /* try SubDir */
7019 size = MAX_PATH;
7020 lstrcpyA(path, "kiwi");
7021 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7022 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7023 ok(!lstrcmpA(path, "kiwi"),
7024 "Expected path to be unchanged, got \"%s\"\n", path);
7025 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7027 /* try SubDir2 */
7028 size = MAX_PATH;
7029 lstrcpyA(path, "kiwi");
7030 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7031 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7032 ok(!lstrcmpA(path, "kiwi"),
7033 "Expected path to be unchanged, got \"%s\"\n", path);
7034 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7036 r = MsiDoActionA(hpkg, "CostInitialize");
7037 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7039 /* try TARGETDIR after CostInitialize */
7040 size = MAX_PATH;
7041 lstrcpyA(path, "kiwi");
7042 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7043 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7044 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7045 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7047 /* try SourceDir after CostInitialize */
7048 size = MAX_PATH;
7049 lstrcpyA(path, "kiwi");
7050 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7051 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7052 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7053 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7055 /* try SOURCEDIR after CostInitialize */
7056 size = MAX_PATH;
7057 lstrcpyA(path, "kiwi");
7058 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7059 todo_wine
7061 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7062 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7063 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7066 /* source path does not exist, but the property exists */
7067 size = MAX_PATH;
7068 lstrcpyA(path, "kiwi");
7069 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7070 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7071 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7072 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7074 size = MAX_PATH;
7075 lstrcpyA(path, "kiwi");
7076 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7077 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7078 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7079 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7081 /* try SubDir after CostInitialize */
7082 size = MAX_PATH;
7083 lstrcpyA(path, "kiwi");
7084 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7085 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7086 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7087 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7089 /* try SubDir2 after CostInitialize */
7090 size = MAX_PATH;
7091 lstrcpyA(path, "kiwi");
7092 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7093 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7094 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7095 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7097 r = MsiDoActionA(hpkg, "ResolveSource");
7098 ok(r == ERROR_SUCCESS, "file cost failed\n");
7100 /* try TARGETDIR after ResolveSource */
7101 size = MAX_PATH;
7102 lstrcpyA(path, "kiwi");
7103 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7104 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7105 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7106 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7108 /* try SourceDir after ResolveSource */
7109 size = MAX_PATH;
7110 lstrcpyA(path, "kiwi");
7111 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7112 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7113 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7114 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7116 /* try SOURCEDIR after ResolveSource */
7117 size = MAX_PATH;
7118 lstrcpyA(path, "kiwi");
7119 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7120 todo_wine
7122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7123 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7124 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7127 /* source path and the property exist */
7128 size = MAX_PATH;
7129 lstrcpyA(path, "kiwi");
7130 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7131 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7132 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7133 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7135 size = MAX_PATH;
7136 lstrcpyA(path, "kiwi");
7137 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7138 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7139 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7140 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7142 /* try SubDir after ResolveSource */
7143 size = MAX_PATH;
7144 lstrcpyA(path, "kiwi");
7145 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7146 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7147 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7148 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7150 /* try SubDir2 after ResolveSource */
7151 size = MAX_PATH;
7152 lstrcpyA(path, "kiwi");
7153 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7154 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7155 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7156 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7158 r = MsiDoActionA(hpkg, "FileCost");
7159 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7161 /* try TARGETDIR after CostFinalize */
7162 size = MAX_PATH;
7163 lstrcpyA(path, "kiwi");
7164 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7165 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7166 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7167 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7169 /* try SourceDir after CostFinalize */
7170 size = MAX_PATH;
7171 lstrcpyA(path, "kiwi");
7172 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7173 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7174 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7175 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7177 /* try SOURCEDIR after CostFinalize */
7178 size = MAX_PATH;
7179 lstrcpyA(path, "kiwi");
7180 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7181 todo_wine
7183 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7184 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7185 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7188 /* source path and the property exist */
7189 size = MAX_PATH;
7190 lstrcpyA(path, "kiwi");
7191 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7192 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7193 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7194 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7196 size = MAX_PATH;
7197 lstrcpyA(path, "kiwi");
7198 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7199 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7200 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7201 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7203 /* try SubDir after CostFinalize */
7204 size = MAX_PATH;
7205 lstrcpyA(path, "kiwi");
7206 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7207 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7208 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7209 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7211 /* try SubDir2 after CostFinalize */
7212 size = MAX_PATH;
7213 lstrcpyA(path, "kiwi");
7214 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7216 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7217 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7219 r = MsiDoActionA(hpkg, "CostFinalize");
7220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7222 /* try TARGETDIR after CostFinalize */
7223 size = MAX_PATH;
7224 lstrcpyA(path, "kiwi");
7225 r = MsiGetSourcePathA(hpkg, "TARGETDIR", path, &size);
7226 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7227 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7228 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7230 /* try SourceDir after CostFinalize */
7231 size = MAX_PATH;
7232 lstrcpyA(path, "kiwi");
7233 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7234 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7235 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7236 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7238 /* try SOURCEDIR after CostFinalize */
7239 size = MAX_PATH;
7240 lstrcpyA(path, "kiwi");
7241 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7242 todo_wine
7244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7245 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7246 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7249 /* source path and the property exist */
7250 size = MAX_PATH;
7251 lstrcpyA(path, "kiwi");
7252 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7253 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7254 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7255 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7257 size = MAX_PATH;
7258 lstrcpyA(path, "kiwi");
7259 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7260 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7261 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7262 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7264 /* try SubDir after CostFinalize */
7265 size = MAX_PATH;
7266 lstrcpyA(path, "kiwi");
7267 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7268 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7269 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7270 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7272 /* try SubDir2 after CostFinalize */
7273 size = MAX_PATH;
7274 lstrcpyA(path, "kiwi");
7275 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7276 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7277 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7278 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7280 MsiCloseHandle(hpkg);
7281 DeleteFileA(msifile);
7284 static void test_shortlongsource(void)
7286 MSIHANDLE hdb, hpkg;
7287 CHAR path[MAX_PATH];
7288 CHAR cwd[MAX_PATH];
7289 CHAR subsrc[MAX_PATH];
7290 DWORD size;
7291 UINT r;
7293 lstrcpyA(cwd, CURR_DIR);
7294 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
7296 lstrcpyA(subsrc, cwd);
7297 lstrcatA(subsrc, "long");
7298 lstrcatA(subsrc, "\\");
7300 /* long file names */
7302 hdb = create_package_db();
7303 ok( hdb, "failed to create database\n");
7305 set_suminfo_prop(hdb, PID_WORDCOUNT, 0);
7307 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7308 ok(r == S_OK, "failed\n");
7310 r = add_directory_entry(hdb, "'SubDir', 'TARGETDIR', 'short|long'");
7311 ok(r == S_OK, "failed\n");
7313 /* CostInitialize:short */
7314 r = add_directory_entry(hdb, "'SubDir2', 'TARGETDIR', 'one|two'");
7315 ok(r == S_OK, "failed\n");
7317 /* CostInitialize:long */
7318 r = add_directory_entry(hdb, "'SubDir3', 'TARGETDIR', 'three|four'");
7319 ok(r == S_OK, "failed\n");
7321 /* FileCost:short */
7322 r = add_directory_entry(hdb, "'SubDir4', 'TARGETDIR', 'five|six'");
7323 ok(r == S_OK, "failed\n");
7325 /* FileCost:long */
7326 r = add_directory_entry(hdb, "'SubDir5', 'TARGETDIR', 'seven|eight'");
7327 ok(r == S_OK, "failed\n");
7329 /* CostFinalize:short */
7330 r = add_directory_entry(hdb, "'SubDir6', 'TARGETDIR', 'nine|ten'");
7331 ok(r == S_OK, "failed\n");
7333 /* CostFinalize:long */
7334 r = add_directory_entry(hdb, "'SubDir7', 'TARGETDIR', 'eleven|twelve'");
7335 ok(r == S_OK, "failed\n");
7337 MsiDatabaseCommit(hdb);
7339 r = package_from_db(hdb, &hpkg);
7340 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7342 skip("Not enough rights to perform tests\n");
7343 DeleteFileA(msifile);
7344 return;
7346 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7348 MsiCloseHandle(hdb);
7350 CreateDirectoryA("one", NULL);
7351 CreateDirectoryA("four", NULL);
7353 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7355 r = MsiDoActionA(hpkg, "CostInitialize");
7356 ok(r == ERROR_SUCCESS, "file cost failed\n");
7358 CreateDirectoryA("five", NULL);
7359 CreateDirectoryA("eight", NULL);
7361 r = MsiDoActionA(hpkg, "FileCost");
7362 ok(r == ERROR_SUCCESS, "file cost failed\n");
7364 CreateDirectoryA("nine", NULL);
7365 CreateDirectoryA("twelve", NULL);
7367 r = MsiDoActionA(hpkg, "CostFinalize");
7368 ok(r == ERROR_SUCCESS, "file cost failed\n");
7370 /* neither short nor long source directories exist */
7371 size = MAX_PATH;
7372 lstrcpyA(path, "kiwi");
7373 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7374 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7375 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7376 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7378 CreateDirectoryA("short", NULL);
7380 /* short source directory exists */
7381 size = MAX_PATH;
7382 lstrcpyA(path, "kiwi");
7383 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7384 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7385 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7386 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7388 CreateDirectoryA("long", NULL);
7390 /* both short and long source directories exist */
7391 size = MAX_PATH;
7392 lstrcpyA(path, "kiwi");
7393 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7394 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7395 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7396 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7398 lstrcpyA(subsrc, cwd);
7399 lstrcatA(subsrc, "two");
7400 lstrcatA(subsrc, "\\");
7402 /* short dir exists before CostInitialize */
7403 size = MAX_PATH;
7404 lstrcpyA(path, "kiwi");
7405 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7406 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7407 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7408 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7410 lstrcpyA(subsrc, cwd);
7411 lstrcatA(subsrc, "four");
7412 lstrcatA(subsrc, "\\");
7414 /* long dir exists before CostInitialize */
7415 size = MAX_PATH;
7416 lstrcpyA(path, "kiwi");
7417 r = MsiGetSourcePathA(hpkg, "SubDir3", path, &size);
7418 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7419 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7420 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7422 lstrcpyA(subsrc, cwd);
7423 lstrcatA(subsrc, "six");
7424 lstrcatA(subsrc, "\\");
7426 /* short dir exists before FileCost */
7427 size = MAX_PATH;
7428 lstrcpyA(path, "kiwi");
7429 r = MsiGetSourcePathA(hpkg, "SubDir4", path, &size);
7430 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7431 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7432 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7434 lstrcpyA(subsrc, cwd);
7435 lstrcatA(subsrc, "eight");
7436 lstrcatA(subsrc, "\\");
7438 /* long dir exists before FileCost */
7439 size = MAX_PATH;
7440 lstrcpyA(path, "kiwi");
7441 r = MsiGetSourcePathA(hpkg, "SubDir5", path, &size);
7442 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7443 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7444 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7446 lstrcpyA(subsrc, cwd);
7447 lstrcatA(subsrc, "ten");
7448 lstrcatA(subsrc, "\\");
7450 /* short dir exists before CostFinalize */
7451 size = MAX_PATH;
7452 lstrcpyA(path, "kiwi");
7453 r = MsiGetSourcePathA(hpkg, "SubDir6", path, &size);
7454 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7455 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7456 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7458 lstrcpyA(subsrc, cwd);
7459 lstrcatA(subsrc, "twelve");
7460 lstrcatA(subsrc, "\\");
7462 /* long dir exists before CostFinalize */
7463 size = MAX_PATH;
7464 lstrcpyA(path, "kiwi");
7465 r = MsiGetSourcePathA(hpkg, "SubDir7", path, &size);
7466 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7467 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7468 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7470 MsiCloseHandle(hpkg);
7471 RemoveDirectoryA("short");
7472 RemoveDirectoryA("long");
7473 RemoveDirectoryA("one");
7474 RemoveDirectoryA("four");
7475 RemoveDirectoryA("five");
7476 RemoveDirectoryA("eight");
7477 RemoveDirectoryA("nine");
7478 RemoveDirectoryA("twelve");
7480 /* short file names */
7482 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_DIRECT, &hdb);
7483 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7485 set_suminfo_prop(hdb, PID_WORDCOUNT, msidbSumInfoSourceTypeSFN);
7487 r = package_from_db(hdb, &hpkg);
7488 ok(r == ERROR_SUCCESS, "failed to create package %u\n", r);
7490 MsiCloseHandle(hdb);
7492 CreateDirectoryA("one", NULL);
7493 CreateDirectoryA("four", NULL);
7495 r = MsiDoActionA(hpkg, "CostInitialize");
7496 ok(r == ERROR_SUCCESS, "file cost failed\n");
7498 CreateDirectoryA("five", NULL);
7499 CreateDirectoryA("eight", NULL);
7501 r = MsiDoActionA(hpkg, "FileCost");
7502 ok(r == ERROR_SUCCESS, "file cost failed\n");
7504 CreateDirectoryA("nine", NULL);
7505 CreateDirectoryA("twelve", NULL);
7507 r = MsiDoActionA(hpkg, "CostFinalize");
7508 ok(r == ERROR_SUCCESS, "file cost failed\n");
7510 lstrcpyA(subsrc, cwd);
7511 lstrcatA(subsrc, "short");
7512 lstrcatA(subsrc, "\\");
7514 /* neither short nor long source directories exist */
7515 size = MAX_PATH;
7516 lstrcpyA(path, "kiwi");
7517 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7518 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7519 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7520 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7522 CreateDirectoryA("short", NULL);
7524 /* short source directory exists */
7525 size = MAX_PATH;
7526 lstrcpyA(path, "kiwi");
7527 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7528 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7529 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7530 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7532 CreateDirectoryA("long", NULL);
7534 /* both short and long source directories exist */
7535 size = MAX_PATH;
7536 lstrcpyA(path, "kiwi");
7537 r = MsiGetSourcePathA(hpkg, "SubDir", path, &size);
7538 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7539 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7540 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7542 lstrcpyA(subsrc, cwd);
7543 lstrcatA(subsrc, "one");
7544 lstrcatA(subsrc, "\\");
7546 /* short dir exists before CostInitialize */
7547 size = MAX_PATH;
7548 lstrcpyA(path, "kiwi");
7549 r = MsiGetSourcePathA(hpkg, "SubDir2", path, &size);
7550 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7551 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7552 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7554 lstrcpyA(subsrc, cwd);
7555 lstrcatA(subsrc, "three");
7556 lstrcatA(subsrc, "\\");
7558 /* long dir exists before CostInitialize */
7559 size = MAX_PATH;
7560 lstrcpyA(path, "kiwi");
7561 r = MsiGetSourcePathA(hpkg, "SubDir3", path, &size);
7562 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7563 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7564 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7566 lstrcpyA(subsrc, cwd);
7567 lstrcatA(subsrc, "five");
7568 lstrcatA(subsrc, "\\");
7570 /* short dir exists before FileCost */
7571 size = MAX_PATH;
7572 lstrcpyA(path, "kiwi");
7573 r = MsiGetSourcePathA(hpkg, "SubDir4", path, &size);
7574 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7575 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7576 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7578 lstrcpyA(subsrc, cwd);
7579 lstrcatA(subsrc, "seven");
7580 lstrcatA(subsrc, "\\");
7582 /* long dir exists before FileCost */
7583 size = MAX_PATH;
7584 lstrcpyA(path, "kiwi");
7585 r = MsiGetSourcePathA(hpkg, "SubDir5", path, &size);
7586 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7587 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7588 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7590 lstrcpyA(subsrc, cwd);
7591 lstrcatA(subsrc, "nine");
7592 lstrcatA(subsrc, "\\");
7594 /* short dir exists before CostFinalize */
7595 size = MAX_PATH;
7596 lstrcpyA(path, "kiwi");
7597 r = MsiGetSourcePathA(hpkg, "SubDir6", path, &size);
7598 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7599 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7600 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7602 lstrcpyA(subsrc, cwd);
7603 lstrcatA(subsrc, "eleven");
7604 lstrcatA(subsrc, "\\");
7606 /* long dir exists before CostFinalize */
7607 size = MAX_PATH;
7608 lstrcpyA(path, "kiwi");
7609 r = MsiGetSourcePathA(hpkg, "SubDir7", path, &size);
7610 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7611 ok(!lstrcmpA(path, subsrc), "Expected \"%s\", got \"%s\"\n", subsrc, path);
7612 ok(size == lstrlenA(subsrc), "Expected %d, got %d\n", lstrlenA(subsrc), size);
7614 MsiCloseHandle(hpkg);
7615 RemoveDirectoryA("short");
7616 RemoveDirectoryA("long");
7617 RemoveDirectoryA("one");
7618 RemoveDirectoryA("four");
7619 RemoveDirectoryA("five");
7620 RemoveDirectoryA("eight");
7621 RemoveDirectoryA("nine");
7622 RemoveDirectoryA("twelve");
7623 DeleteFileA(msifile);
7626 static void test_sourcedir(void)
7628 MSIHANDLE hdb, hpkg;
7629 CHAR package[12];
7630 CHAR path[MAX_PATH];
7631 CHAR cwd[MAX_PATH];
7632 CHAR subsrc[MAX_PATH];
7633 DWORD size;
7634 UINT r;
7636 lstrcpyA(cwd, CURR_DIR);
7637 if (!is_root(CURR_DIR)) lstrcatA(cwd, "\\");
7639 lstrcpyA(subsrc, cwd);
7640 lstrcatA(subsrc, "long");
7641 lstrcatA(subsrc, "\\");
7643 hdb = create_package_db();
7644 ok( hdb, "failed to create database\n");
7646 r = add_directory_entry(hdb, "'TARGETDIR', '', 'SourceDir'");
7647 ok(r == S_OK, "failed\n");
7649 sprintf(package, "#%u", hdb);
7650 r = MsiOpenPackageA(package, &hpkg);
7651 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
7653 skip("Not enough rights to perform tests\n");
7654 goto error;
7656 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7658 /* properties only */
7660 /* SourceDir prop */
7661 size = MAX_PATH;
7662 lstrcpyA(path, "kiwi");
7663 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7664 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7665 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7666 ok(size == 0, "Expected 0, got %d\n", size);
7668 /* SOURCEDIR prop */
7669 size = MAX_PATH;
7670 lstrcpyA(path, "kiwi");
7671 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7672 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7673 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7674 ok(size == 0, "Expected 0, got %d\n", size);
7676 MsiSetInternalUI(INSTALLUILEVEL_NONE, NULL);
7678 r = MsiDoActionA(hpkg, "CostInitialize");
7679 ok(r == ERROR_SUCCESS, "file cost failed\n");
7681 /* SourceDir after CostInitialize */
7682 size = MAX_PATH;
7683 lstrcpyA(path, "kiwi");
7684 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7685 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7686 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7687 ok(size == 0, "Expected 0, got %d\n", size);
7689 /* SOURCEDIR after CostInitialize */
7690 size = MAX_PATH;
7691 lstrcpyA(path, "kiwi");
7692 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7693 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7694 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7695 ok(size == 0, "Expected 0, got %d\n", size);
7697 r = MsiDoActionA(hpkg, "FileCost");
7698 ok(r == ERROR_SUCCESS, "file cost failed\n");
7700 /* SourceDir after FileCost */
7701 size = MAX_PATH;
7702 lstrcpyA(path, "kiwi");
7703 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7704 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7705 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7706 ok(size == 0, "Expected 0, got %d\n", size);
7708 /* SOURCEDIR after FileCost */
7709 size = MAX_PATH;
7710 lstrcpyA(path, "kiwi");
7711 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7712 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7713 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7714 ok(size == 0, "Expected 0, got %d\n", size);
7716 r = MsiDoActionA(hpkg, "CostFinalize");
7717 ok(r == ERROR_SUCCESS, "file cost failed\n");
7719 /* SourceDir after CostFinalize */
7720 size = MAX_PATH;
7721 lstrcpyA(path, "kiwi");
7722 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7723 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7724 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7725 ok(size == 0, "Expected 0, got %d\n", size);
7727 /* SOURCEDIR after CostFinalize */
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 size = MAX_PATH;
7736 lstrcpyA(path, "kiwi");
7737 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7738 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7739 ok(!lstrcmpA(path, "kiwi"), "Expected \"kiwi\", got \"%s\"\n", path);
7740 ok(size == MAX_PATH, "Expected %d, got %d\n", MAX_PATH, size);
7742 /* SOURCEDIR after calling MsiGetSourcePath */
7743 size = MAX_PATH;
7744 lstrcpyA(path, "kiwi");
7745 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7746 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7747 todo_wine {
7748 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7749 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7752 r = MsiDoActionA(hpkg, "ResolveSource");
7753 ok(r == ERROR_SUCCESS, "file cost failed\n");
7755 /* SourceDir after ResolveSource */
7756 size = MAX_PATH;
7757 lstrcpyA(path, "kiwi");
7758 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7759 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7760 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7761 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7763 /* SOURCEDIR after ResolveSource */
7764 size = MAX_PATH;
7765 lstrcpyA(path, "kiwi");
7766 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7767 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7768 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7769 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7771 /* random casing */
7772 size = MAX_PATH;
7773 lstrcpyA(path, "kiwi");
7774 r = MsiGetPropertyA(hpkg, "SoUrCeDiR", path, &size);
7775 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7776 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7777 ok(size == 0, "Expected 0, got %d\n", size);
7779 MsiCloseHandle(hpkg);
7781 /* reset the package state */
7782 sprintf(package, "#%i", hdb);
7783 r = MsiOpenPackageA(package, &hpkg);
7784 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7786 /* test how MsiGetSourcePath affects the properties */
7788 /* SourceDir prop */
7789 size = MAX_PATH;
7790 lstrcpyA(path, "kiwi");
7791 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7792 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7793 todo_wine
7795 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7796 ok(size == 0, "Expected 0, got %d\n", size);
7799 size = MAX_PATH;
7800 lstrcpyA(path, "kiwi");
7801 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7802 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7803 ok(!lstrcmpA(path, "kiwi"),
7804 "Expected path to be unchanged, got \"%s\"\n", path);
7805 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7807 /* SourceDir after MsiGetSourcePath */
7808 size = MAX_PATH;
7809 lstrcpyA(path, "kiwi");
7810 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7811 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7812 todo_wine
7814 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7815 ok(size == 0, "Expected 0, got %d\n", size);
7818 /* SOURCEDIR prop */
7819 size = MAX_PATH;
7820 lstrcpyA(path, "kiwi");
7821 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7822 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7823 todo_wine
7825 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7826 ok(size == 0, "Expected 0, got %d\n", size);
7829 size = MAX_PATH;
7830 lstrcpyA(path, "kiwi");
7831 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7832 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7833 ok(!lstrcmpA(path, "kiwi"),
7834 "Expected path to be unchanged, got \"%s\"\n", path);
7835 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7837 /* SOURCEDIR prop after MsiGetSourcePath */
7838 size = MAX_PATH;
7839 lstrcpyA(path, "kiwi");
7840 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7841 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7842 todo_wine
7844 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7845 ok(size == 0, "Expected 0, got %d\n", size);
7848 r = MsiDoActionA(hpkg, "CostInitialize");
7849 ok(r == ERROR_SUCCESS, "file cost failed\n");
7851 /* SourceDir after CostInitialize */
7852 size = MAX_PATH;
7853 lstrcpyA(path, "kiwi");
7854 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7855 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7856 todo_wine
7858 ok(!lstrcmpA(path, ""), "Expected \"\", got \"%s\"\n", path);
7859 ok(size == 0, "Expected 0, got %d\n", size);
7862 size = MAX_PATH;
7863 lstrcpyA(path, "kiwi");
7864 r = MsiGetSourcePathA(hpkg, "SourceDir", path, &size);
7865 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7866 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7867 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7869 /* SourceDir after MsiGetSourcePath */
7870 size = MAX_PATH;
7871 lstrcpyA(path, "kiwi");
7872 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7873 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7874 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7875 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7877 /* SOURCEDIR after CostInitialize */
7878 size = MAX_PATH;
7879 lstrcpyA(path, "kiwi");
7880 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7881 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7882 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7883 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7885 /* SOURCEDIR source path still does not exist */
7886 size = MAX_PATH;
7887 lstrcpyA(path, "kiwi");
7888 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7889 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7890 ok(!lstrcmpA(path, "kiwi"),
7891 "Expected path to be unchanged, got \"%s\"\n", path);
7892 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7894 r = MsiDoActionA(hpkg, "FileCost");
7895 ok(r == ERROR_SUCCESS, "file cost failed\n");
7897 /* SourceDir after FileCost */
7898 size = MAX_PATH;
7899 lstrcpyA(path, "kiwi");
7900 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7901 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7902 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7903 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7905 /* SOURCEDIR after FileCost */
7906 size = MAX_PATH;
7907 lstrcpyA(path, "kiwi");
7908 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7909 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7910 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7911 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7913 /* SOURCEDIR source path still does not exist */
7914 size = MAX_PATH;
7915 lstrcpyA(path, "kiwi");
7916 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7917 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7918 ok(!lstrcmpA(path, "kiwi"),
7919 "Expected path to be unchanged, got \"%s\"\n", path);
7920 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7922 r = MsiDoActionA(hpkg, "CostFinalize");
7923 ok(r == ERROR_SUCCESS, "file cost failed\n");
7925 /* SourceDir after CostFinalize */
7926 size = MAX_PATH;
7927 lstrcpyA(path, "kiwi");
7928 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7929 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7930 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7931 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7933 /* SOURCEDIR after CostFinalize */
7934 size = MAX_PATH;
7935 lstrcpyA(path, "kiwi");
7936 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7937 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7938 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7939 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7941 /* SOURCEDIR source path still does not exist */
7942 size = MAX_PATH;
7943 lstrcpyA(path, "kiwi");
7944 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7945 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7946 ok(!lstrcmpA(path, "kiwi"),
7947 "Expected path to be unchanged, got \"%s\"\n", path);
7948 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7950 r = MsiDoActionA(hpkg, "ResolveSource");
7951 ok(r == ERROR_SUCCESS, "file cost failed\n");
7953 /* SourceDir after ResolveSource */
7954 size = MAX_PATH;
7955 lstrcpyA(path, "kiwi");
7956 r = MsiGetPropertyA(hpkg, "SourceDir", path, &size);
7957 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7958 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7959 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7961 /* SOURCEDIR after ResolveSource */
7962 size = MAX_PATH;
7963 lstrcpyA(path, "kiwi");
7964 r = MsiGetPropertyA(hpkg, "SOURCEDIR", path, &size);
7965 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
7966 ok(!lstrcmpA(path, cwd), "Expected \"%s\", got \"%s\"\n", cwd, path);
7967 ok(size == lstrlenA(cwd), "Expected %d, got %d\n", lstrlenA(cwd), size);
7969 /* SOURCEDIR source path still does not exist */
7970 size = MAX_PATH;
7971 lstrcpyA(path, "kiwi");
7972 r = MsiGetSourcePathA(hpkg, "SOURCEDIR", path, &size);
7973 ok(r == ERROR_DIRECTORY, "Expected ERROR_DIRECTORY, got %d\n", r);
7974 ok(!lstrcmpA(path, "kiwi"),
7975 "Expected path to be unchanged, got \"%s\"\n", path);
7976 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
7978 MsiCloseHandle(hpkg);
7980 error:
7981 MsiCloseHandle(hdb);
7982 DeleteFileA(msifile);
7985 struct access_res
7987 BOOL gothandle;
7988 DWORD lasterr;
7989 BOOL ignore;
7992 static const struct access_res create[16] =
7994 { TRUE, ERROR_SUCCESS, TRUE },
7995 { TRUE, ERROR_SUCCESS, TRUE },
7996 { TRUE, ERROR_SUCCESS, FALSE },
7997 { TRUE, ERROR_SUCCESS, FALSE },
7998 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
7999 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8000 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8001 { TRUE, ERROR_SUCCESS, FALSE },
8002 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8003 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8004 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8005 { TRUE, ERROR_SUCCESS, TRUE },
8006 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8007 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8008 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8009 { TRUE, ERROR_SUCCESS, TRUE }
8012 static const struct access_res create_commit[16] =
8014 { TRUE, ERROR_SUCCESS, TRUE },
8015 { TRUE, ERROR_SUCCESS, TRUE },
8016 { TRUE, ERROR_SUCCESS, FALSE },
8017 { TRUE, ERROR_SUCCESS, FALSE },
8018 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8019 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8020 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8021 { TRUE, ERROR_SUCCESS, FALSE },
8022 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8023 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8024 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8025 { TRUE, ERROR_SUCCESS, TRUE },
8026 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8027 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8028 { FALSE, ERROR_SHARING_VIOLATION, FALSE },
8029 { TRUE, ERROR_SUCCESS, TRUE }
8032 static const struct access_res create_close[16] =
8034 { TRUE, ERROR_SUCCESS, FALSE },
8035 { TRUE, ERROR_SUCCESS, FALSE },
8036 { TRUE, ERROR_SUCCESS, FALSE },
8037 { TRUE, ERROR_SUCCESS, FALSE },
8038 { TRUE, ERROR_SUCCESS, FALSE },
8039 { TRUE, ERROR_SUCCESS, FALSE },
8040 { TRUE, ERROR_SUCCESS, FALSE },
8041 { TRUE, ERROR_SUCCESS, FALSE },
8042 { TRUE, ERROR_SUCCESS, FALSE },
8043 { TRUE, ERROR_SUCCESS, FALSE },
8044 { TRUE, ERROR_SUCCESS, FALSE },
8045 { TRUE, ERROR_SUCCESS, FALSE },
8046 { TRUE, ERROR_SUCCESS, FALSE },
8047 { TRUE, ERROR_SUCCESS, FALSE },
8048 { TRUE, ERROR_SUCCESS, FALSE },
8049 { TRUE, ERROR_SUCCESS }
8052 static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
8054 DWORD access = 0, share = 0;
8055 DWORD lasterr;
8056 HANDLE hfile;
8057 int i, j, idx = 0;
8059 for (i = 0; i < 4; i++)
8061 if (i == 0) access = 0;
8062 if (i == 1) access = GENERIC_READ;
8063 if (i == 2) access = GENERIC_WRITE;
8064 if (i == 3) access = GENERIC_READ | GENERIC_WRITE;
8066 for (j = 0; j < 4; j++)
8068 if (ares[idx].ignore)
8069 continue;
8071 if (j == 0) share = 0;
8072 if (j == 1) share = FILE_SHARE_READ;
8073 if (j == 2) share = FILE_SHARE_WRITE;
8074 if (j == 3) share = FILE_SHARE_READ | FILE_SHARE_WRITE;
8076 SetLastError(0xdeadbeef);
8077 hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
8078 FILE_ATTRIBUTE_NORMAL, 0);
8079 lasterr = GetLastError();
8081 ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
8082 "(%d, handle, %d): Expected %d, got %d\n",
8083 line, idx, ares[idx].gothandle,
8084 (hfile != INVALID_HANDLE_VALUE));
8086 ok(lasterr == ares[idx].lasterr, "(%d, lasterr, %d): Expected %d, got %d\n",
8087 line, idx, ares[idx].lasterr, lasterr);
8089 CloseHandle(hfile);
8090 idx++;
8095 #define test_file_access(file, ares) _test_file_access(file, ares, __LINE__)
8097 static void test_access(void)
8099 MSIHANDLE hdb;
8100 UINT r;
8102 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
8103 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8105 test_file_access(msifile, create);
8107 r = MsiDatabaseCommit(hdb);
8108 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8110 test_file_access(msifile, create_commit);
8111 MsiCloseHandle(hdb);
8113 test_file_access(msifile, create_close);
8114 DeleteFileA(msifile);
8116 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATEDIRECT, &hdb);
8117 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8119 test_file_access(msifile, create);
8121 r = MsiDatabaseCommit(hdb);
8122 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8124 test_file_access(msifile, create_commit);
8125 MsiCloseHandle(hdb);
8127 test_file_access(msifile, create_close);
8128 DeleteFileA(msifile);
8131 static void test_emptypackage(void)
8133 MSIHANDLE hpkg = 0, hdb = 0, hsuminfo = 0;
8134 MSIHANDLE hview = 0, hrec = 0;
8135 MSICONDITION condition;
8136 CHAR buffer[MAX_PATH];
8137 DWORD size;
8138 UINT r;
8140 r = MsiOpenPackageA("", &hpkg);
8141 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8143 skip("Not enough rights to perform tests\n");
8144 return;
8146 todo_wine
8148 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8151 hdb = MsiGetActiveDatabase(hpkg);
8152 todo_wine
8154 ok(hdb != 0, "Expected a valid database handle\n");
8157 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Tables`", &hview);
8158 todo_wine
8160 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8162 r = MsiViewExecute(hview, 0);
8163 todo_wine
8165 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8168 r = MsiViewFetch(hview, &hrec);
8169 todo_wine
8171 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8174 buffer[0] = 0;
8175 size = MAX_PATH;
8176 r = MsiRecordGetStringA(hrec, 1, buffer, &size);
8177 todo_wine
8179 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8180 ok(!lstrcmpA(buffer, "_Property"),
8181 "Expected \"_Property\", got \"%s\"\n", buffer);
8184 MsiCloseHandle(hrec);
8186 r = MsiViewFetch(hview, &hrec);
8187 todo_wine
8189 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8192 size = MAX_PATH;
8193 r = MsiRecordGetStringA(hrec, 1, buffer, &size);
8194 todo_wine
8196 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8197 ok(!lstrcmpA(buffer, "#_FolderCache"),
8198 "Expected \"_Property\", got \"%s\"\n", buffer);
8201 MsiCloseHandle(hrec);
8202 MsiViewClose(hview);
8203 MsiCloseHandle(hview);
8205 condition = MsiDatabaseIsTablePersistentA(hdb, "_Property");
8206 todo_wine
8208 ok(condition == MSICONDITION_FALSE,
8209 "Expected MSICONDITION_FALSE, got %d\n", condition);
8212 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Property`", &hview);
8213 todo_wine
8215 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8217 r = MsiViewExecute(hview, 0);
8218 todo_wine
8220 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8223 /* _Property table is not empty */
8224 r = MsiViewFetch(hview, &hrec);
8225 todo_wine
8227 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8230 MsiCloseHandle(hrec);
8231 MsiViewClose(hview);
8232 MsiCloseHandle(hview);
8234 condition = MsiDatabaseIsTablePersistentA(hdb, "#_FolderCache");
8235 todo_wine
8237 ok(condition == MSICONDITION_FALSE,
8238 "Expected MSICONDITION_FALSE, got %d\n", condition);
8241 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `#_FolderCache`", &hview);
8242 todo_wine
8244 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8246 r = MsiViewExecute(hview, 0);
8247 todo_wine
8249 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8252 /* #_FolderCache is not empty */
8253 r = MsiViewFetch(hview, &hrec);
8254 todo_wine
8256 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8259 MsiCloseHandle(hrec);
8260 MsiViewClose(hview);
8261 MsiCloseHandle(hview);
8263 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Streams`", &hview);
8264 todo_wine
8266 ok(r == ERROR_BAD_QUERY_SYNTAX,
8267 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8270 r = MsiDatabaseOpenViewA(hdb, "SELECT * FROM `_Storages`", &hview);
8271 todo_wine
8273 ok(r == ERROR_BAD_QUERY_SYNTAX,
8274 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8277 r = MsiGetSummaryInformationA(hdb, NULL, 0, &hsuminfo);
8278 todo_wine
8280 ok(r == ERROR_INSTALL_PACKAGE_INVALID,
8281 "Expected ERROR_INSTALL_PACKAGE_INVALID, got %d\n", r);
8284 MsiCloseHandle(hsuminfo);
8286 r = MsiDatabaseCommit(hdb);
8287 todo_wine
8289 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8292 MsiCloseHandle(hdb);
8293 MsiCloseHandle(hpkg);
8296 static void test_MsiGetProductProperty(void)
8298 static const WCHAR prodcode_propW[] = {'P','r','o','d','u','c','t','C','o','d','e',0};
8299 static const WCHAR nonexistentW[] = {'I','D','o','n','t','E','x','i','s','t',0};
8300 static const WCHAR newpropW[] = {'N','e','w','P','r','o','p','e','r','t','y',0};
8301 static const WCHAR appleW[] = {'a','p','p','l','e',0};
8302 static const WCHAR emptyW[] = {0};
8303 WCHAR valW[MAX_PATH];
8304 MSIHANDLE hprod, hdb;
8305 CHAR val[MAX_PATH];
8306 CHAR path[MAX_PATH];
8307 CHAR query[MAX_PATH];
8308 CHAR keypath[MAX_PATH*2];
8309 CHAR prodcode[MAX_PATH];
8310 WCHAR prodcodeW[MAX_PATH];
8311 CHAR prod_squashed[MAX_PATH];
8312 WCHAR prod_squashedW[MAX_PATH];
8313 HKEY prodkey, userkey, props;
8314 DWORD size;
8315 LONG res;
8316 UINT r;
8317 REGSAM access = KEY_ALL_ACCESS;
8319 GetCurrentDirectoryA(MAX_PATH, path);
8320 lstrcatA(path, "\\");
8322 create_test_guid(prodcode, prod_squashed);
8323 MultiByteToWideChar(CP_ACP, 0, prodcode, -1, prodcodeW, MAX_PATH);
8324 squash_guid(prodcodeW, prod_squashedW);
8326 if (is_wow64)
8327 access |= KEY_WOW64_64KEY;
8329 r = MsiOpenDatabaseW(msifileW, MSIDBOPEN_CREATE, &hdb);
8330 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8332 r = MsiDatabaseCommit(hdb);
8333 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8335 r = set_summary_info(hdb);
8336 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8338 r = run_query(hdb,
8339 "CREATE TABLE `Directory` ( "
8340 "`Directory` CHAR(255) NOT NULL, "
8341 "`Directory_Parent` CHAR(255), "
8342 "`DefaultDir` CHAR(255) NOT NULL "
8343 "PRIMARY KEY `Directory`)");
8344 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8346 r = run_query(hdb,
8347 "CREATE TABLE `Property` ( "
8348 "`Property` CHAR(72) NOT NULL, "
8349 "`Value` CHAR(255) "
8350 "PRIMARY KEY `Property`)");
8351 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8353 sprintf(query, "INSERT INTO `Property` "
8354 "(`Property`, `Value`) "
8355 "VALUES( 'ProductCode', '%s' )", prodcode);
8356 r = run_query(hdb, query);
8357 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8359 r = MsiDatabaseCommit(hdb);
8360 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8362 MsiCloseHandle(hdb);
8364 lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
8365 lstrcatA(keypath, prod_squashed);
8367 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &prodkey, NULL);
8368 if (res == ERROR_ACCESS_DENIED)
8370 skip("Not enough rights to perform tests\n");
8371 DeleteFileA(msifile);
8372 return;
8374 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8376 lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\");
8377 lstrcatA(keypath, "Installer\\UserData\\S-1-5-18\\Products\\");
8378 lstrcatA(keypath, prod_squashed);
8380 res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &userkey, NULL);
8381 if (res == ERROR_ACCESS_DENIED)
8383 skip("Not enough rights to perform tests\n");
8384 RegDeleteKeyA(prodkey, "");
8385 RegCloseKey(prodkey);
8386 return;
8388 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8390 res = RegCreateKeyExA(userkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
8391 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8393 lstrcpyA(val, path);
8394 lstrcatA(val, "\\");
8395 lstrcatA(val, msifile);
8396 res = RegSetValueExA(props, "LocalPackage", 0, REG_SZ,
8397 (const BYTE *)val, lstrlenA(val) + 1);
8398 ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
8400 hprod = 0xdeadbeef;
8401 r = MsiOpenProductA(prodcode, &hprod);
8402 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8403 ok(hprod != 0 && hprod != 0xdeadbeef, "Expected a valid product handle\n");
8405 /* hProduct is invalid */
8406 size = MAX_PATH;
8407 lstrcpyA(val, "apple");
8408 r = MsiGetProductPropertyA(0xdeadbeef, "ProductCode", val, &size);
8409 ok(r == ERROR_INVALID_HANDLE,
8410 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8411 ok(!lstrcmpA(val, "apple"),
8412 "Expected val to be unchanged, got \"%s\"\n", val);
8413 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8415 size = MAX_PATH;
8416 lstrcpyW(valW, appleW);
8417 r = MsiGetProductPropertyW(0xdeadbeef, prodcode_propW, valW, &size);
8418 ok(r == ERROR_INVALID_HANDLE,
8419 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8420 ok(!lstrcmpW(valW, appleW),
8421 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8422 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8424 /* szProperty is NULL */
8425 size = MAX_PATH;
8426 lstrcpyA(val, "apple");
8427 r = MsiGetProductPropertyA(hprod, NULL, val, &size);
8428 ok(r == ERROR_INVALID_PARAMETER,
8429 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8430 ok(!lstrcmpA(val, "apple"),
8431 "Expected val to be unchanged, got \"%s\"\n", val);
8432 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8434 size = MAX_PATH;
8435 lstrcpyW(valW, appleW);
8436 r = MsiGetProductPropertyW(hprod, NULL, valW, &size);
8437 ok(r == ERROR_INVALID_PARAMETER,
8438 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8439 ok(!lstrcmpW(valW, appleW),
8440 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8441 ok(size == MAX_PATH, "Expected size to be unchanged, got %d\n", size);
8443 /* szProperty is empty */
8444 size = MAX_PATH;
8445 lstrcpyA(val, "apple");
8446 r = MsiGetProductPropertyA(hprod, "", val, &size);
8447 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8448 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8449 ok(size == 0, "Expected 0, got %d\n", size);
8451 size = MAX_PATH;
8452 lstrcpyW(valW, appleW);
8453 r = MsiGetProductPropertyW(hprod, emptyW, valW, &size);
8454 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8455 ok(*valW == 0, "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8456 ok(size == 0, "Expected 0, got %d\n", size);
8458 /* get the property */
8459 size = MAX_PATH;
8460 lstrcpyA(val, "apple");
8461 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8462 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8463 ok(!lstrcmpA(val, prodcode),
8464 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8465 ok(size == lstrlenA(prodcode),
8466 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8468 size = MAX_PATH;
8469 lstrcpyW(valW, appleW);
8470 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8471 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8472 ok(!lstrcmpW(valW, prodcodeW),
8473 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8474 ok(size == lstrlenW(prodcodeW),
8475 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8477 /* lpValueBuf is NULL */
8478 size = MAX_PATH;
8479 r = MsiGetProductPropertyA(hprod, "ProductCode", NULL, &size);
8480 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8481 ok(size == lstrlenA(prodcode),
8482 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8484 size = MAX_PATH;
8485 r = MsiGetProductPropertyW(hprod, prodcode_propW, NULL, &size);
8486 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8487 ok(size == lstrlenW(prodcodeW),
8488 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8490 /* pcchValueBuf is NULL */
8491 lstrcpyA(val, "apple");
8492 r = MsiGetProductPropertyA(hprod, "ProductCode", val, NULL);
8493 ok(r == ERROR_INVALID_PARAMETER,
8494 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8495 ok(!lstrcmpA(val, "apple"),
8496 "Expected val to be unchanged, got \"%s\"\n", val);
8497 ok(size == lstrlenA(prodcode),
8498 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8500 lstrcpyW(valW, appleW);
8501 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, NULL);
8502 ok(r == ERROR_INVALID_PARAMETER,
8503 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8504 ok(!lstrcmpW(valW, appleW),
8505 "Expected val to be unchanged, got %s\n", wine_dbgstr_w(valW));
8506 ok(size == lstrlenW(prodcodeW),
8507 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8509 /* pcchValueBuf is too small */
8510 size = 4;
8511 lstrcpyA(val, "apple");
8512 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8513 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8514 ok(!strncmp(val, prodcode, 3),
8515 "Expected first 3 chars of \"%s\", got \"%s\"\n", prodcode, val);
8516 ok(size == lstrlenA(prodcode),
8517 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8519 size = 4;
8520 lstrcpyW(valW, appleW);
8521 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8522 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8523 ok(!memcmp(valW, prodcodeW, 3 * sizeof(WCHAR)),
8524 "Expected first 3 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8525 ok(size == lstrlenW(prodcodeW),
8526 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8528 /* pcchValueBuf does not leave room for NULL terminator */
8529 size = lstrlenA(prodcode);
8530 lstrcpyA(val, "apple");
8531 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8532 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8533 ok(!strncmp(val, prodcode, lstrlenA(prodcode) - 1),
8534 "Expected first 37 chars of \"%s\", got \"%s\"\n", prodcode, val);
8535 ok(size == lstrlenA(prodcode),
8536 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8538 size = lstrlenW(prodcodeW);
8539 lstrcpyW(valW, appleW);
8540 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8541 ok(r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %d\n", r);
8542 ok(!memcmp(valW, prodcodeW, lstrlenW(prodcodeW) - 1),
8543 "Expected first 37 chars of %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8544 ok(size == lstrlenW(prodcodeW),
8545 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8547 /* pcchValueBuf has enough room for NULL terminator */
8548 size = lstrlenA(prodcode) + 1;
8549 lstrcpyA(val, "apple");
8550 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8551 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8552 ok(!lstrcmpA(val, prodcode),
8553 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8554 ok(size == lstrlenA(prodcode),
8555 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8557 size = lstrlenW(prodcodeW) + 1;
8558 lstrcpyW(valW, appleW);
8559 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8560 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8561 ok(!lstrcmpW(valW, prodcodeW),
8562 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8563 ok(size == lstrlenW(prodcodeW),
8564 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8566 /* nonexistent property */
8567 size = MAX_PATH;
8568 lstrcpyA(val, "apple");
8569 r = MsiGetProductPropertyA(hprod, "IDontExist", val, &size);
8570 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8571 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8572 ok(size == 0, "Expected 0, got %d\n", size);
8574 size = MAX_PATH;
8575 lstrcpyW(valW, appleW);
8576 r = MsiGetProductPropertyW(hprod, nonexistentW, valW, &size);
8577 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8578 ok(!lstrcmpW(valW, emptyW), "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8579 ok(size == 0, "Expected 0, got %d\n", size);
8581 r = MsiSetPropertyA(hprod, "NewProperty", "value");
8582 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8584 /* non-product property set */
8585 size = MAX_PATH;
8586 lstrcpyA(val, "apple");
8587 r = MsiGetProductPropertyA(hprod, "NewProperty", val, &size);
8588 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8589 ok(!lstrcmpA(val, ""), "Expected \"\", got \"%s\"\n", val);
8590 ok(size == 0, "Expected 0, got %d\n", size);
8592 size = MAX_PATH;
8593 lstrcpyW(valW, appleW);
8594 r = MsiGetProductPropertyW(hprod, newpropW, valW, &size);
8595 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8596 ok(!lstrcmpW(valW, emptyW), "Expected \"\", got %s\n", wine_dbgstr_w(valW));
8597 ok(size == 0, "Expected 0, got %d\n", size);
8599 r = MsiSetPropertyA(hprod, "ProductCode", "value");
8600 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8602 /* non-product property that is also a product property set */
8603 size = MAX_PATH;
8604 lstrcpyA(val, "apple");
8605 r = MsiGetProductPropertyA(hprod, "ProductCode", val, &size);
8606 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8607 ok(!lstrcmpA(val, prodcode),
8608 "Expected \"%s\", got \"%s\"\n", prodcode, val);
8609 ok(size == lstrlenA(prodcode),
8610 "Expected %d, got %d\n", lstrlenA(prodcode), size);
8612 size = MAX_PATH;
8613 lstrcpyW(valW, appleW);
8614 r = MsiGetProductPropertyW(hprod, prodcode_propW, valW, &size);
8615 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8616 ok(!lstrcmpW(valW, prodcodeW),
8617 "Expected %s, got %s\n", wine_dbgstr_w(prodcodeW), wine_dbgstr_w(valW));
8618 ok(size == lstrlenW(prodcodeW),
8619 "Expected %d, got %d\n", lstrlenW(prodcodeW), size);
8621 MsiCloseHandle(hprod);
8623 RegDeleteValueA(props, "LocalPackage");
8624 delete_key(props, "", access);
8625 RegCloseKey(props);
8626 delete_key(userkey, "", access);
8627 RegCloseKey(userkey);
8628 delete_key(prodkey, "", access);
8629 RegCloseKey(prodkey);
8630 DeleteFileA(msifile);
8633 static void test_MsiSetProperty(void)
8635 MSIHANDLE hpkg, hdb, hrec;
8636 CHAR buf[MAX_PATH];
8637 LPCSTR query;
8638 DWORD size;
8639 UINT r;
8641 r = package_from_db(create_package_db(), &hpkg);
8642 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8644 skip("Not enough rights to perform tests\n");
8645 DeleteFileA(msifile);
8646 return;
8648 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
8650 /* invalid hInstall */
8651 r = MsiSetPropertyA(0, "Prop", "Val");
8652 ok(r == ERROR_INVALID_HANDLE,
8653 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8655 /* invalid hInstall */
8656 r = MsiSetPropertyA(0xdeadbeef, "Prop", "Val");
8657 ok(r == ERROR_INVALID_HANDLE,
8658 "Expected ERROR_INVALID_HANDLE, got %d\n", r);
8660 /* szName is NULL */
8661 r = MsiSetPropertyA(hpkg, NULL, "Val");
8662 ok(r == ERROR_INVALID_PARAMETER,
8663 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8665 /* both szName and szValue are NULL */
8666 r = MsiSetPropertyA(hpkg, NULL, NULL);
8667 ok(r == ERROR_INVALID_PARAMETER,
8668 "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
8670 /* szName is empty */
8671 r = MsiSetPropertyA(hpkg, "", "Val");
8672 ok(r == ERROR_FUNCTION_FAILED,
8673 "Expected ERROR_FUNCTION_FAILED, got %d\n", r);
8675 /* szName is empty and szValue is NULL */
8676 r = MsiSetPropertyA(hpkg, "", NULL);
8677 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8679 /* set a property */
8680 r = MsiSetPropertyA(hpkg, "Prop", "Val");
8681 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8683 /* get the property */
8684 size = MAX_PATH;
8685 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8686 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8687 ok(!lstrcmpA(buf, "Val"), "Expected \"Val\", got \"%s\"\n", buf);
8688 ok(size == 3, "Expected 3, got %d\n", size);
8690 /* update the property */
8691 r = MsiSetPropertyA(hpkg, "Prop", "Nuvo");
8692 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8694 /* get the property */
8695 size = MAX_PATH;
8696 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8697 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8698 ok(!lstrcmpA(buf, "Nuvo"), "Expected \"Nuvo\", got \"%s\"\n", buf);
8699 ok(size == 4, "Expected 4, got %d\n", size);
8701 hdb = MsiGetActiveDatabase(hpkg);
8702 ok(hdb != 0, "Expected a valid database handle\n");
8704 /* set prop is not in the _Property table */
8705 query = "SELECT * FROM `_Property` WHERE `Property` = 'Prop'";
8706 r = do_query(hdb, query, &hrec);
8707 ok(r == ERROR_BAD_QUERY_SYNTAX,
8708 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8710 /* set prop is not in the Property table */
8711 query = "SELECT * FROM `Property` WHERE `Property` = 'Prop'";
8712 r = do_query(hdb, query, &hrec);
8713 ok(r == ERROR_BAD_QUERY_SYNTAX,
8714 "Expected ERROR_BAD_QUERY_SYNTAX, got %d\n", r);
8716 MsiCloseHandle(hdb);
8718 /* szValue is an empty string */
8719 r = MsiSetPropertyA(hpkg, "Prop", "");
8720 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8722 /* try to get the property */
8723 size = MAX_PATH;
8724 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8725 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8726 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8727 ok(size == 0, "Expected 0, got %d\n", size);
8729 /* reset the property */
8730 r = MsiSetPropertyA(hpkg, "Prop", "BlueTap");
8731 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8733 /* delete the property */
8734 r = MsiSetPropertyA(hpkg, "Prop", NULL);
8735 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8737 /* try to get the property */
8738 size = MAX_PATH;
8739 r = MsiGetPropertyA(hpkg, "Prop", buf, &size);
8740 ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
8741 ok(!lstrcmpA(buf, ""), "Expected \"\", got \"%s\"\n", buf);
8742 ok(size == 0, "Expected 0, got %d\n", size);
8744 MsiCloseHandle(hpkg);
8745 DeleteFileA(msifile);
8748 static void test_MsiApplyMultiplePatches(void)
8750 UINT r, type = GetDriveTypeW(NULL);
8752 if (!pMsiApplyMultiplePatchesA) {
8753 win_skip("MsiApplyMultiplePatchesA not found\n");
8754 return;
8757 r = pMsiApplyMultiplePatchesA(NULL, NULL, NULL);
8758 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8760 r = pMsiApplyMultiplePatchesA("", NULL, NULL);
8761 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8763 r = pMsiApplyMultiplePatchesA(";", NULL, NULL);
8764 if (type == DRIVE_FIXED)
8765 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8766 else
8767 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8769 r = pMsiApplyMultiplePatchesA(" ;", NULL, NULL);
8770 if (type == DRIVE_FIXED)
8771 todo_wine ok(r == ERROR_PATCH_PACKAGE_OPEN_FAILED, "Expected ERROR_PATCH_PACKAGE_OPEN_FAILED, got %u\n", r);
8772 else
8773 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8775 r = pMsiApplyMultiplePatchesA(";;", NULL, NULL);
8776 if (type == DRIVE_FIXED)
8777 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8778 else
8779 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8781 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;", NULL, NULL);
8782 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8784 r = pMsiApplyMultiplePatchesA(";nosuchpatchpackage", NULL, NULL);
8785 if (type == DRIVE_FIXED)
8786 todo_wine ok(r == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %u\n", r);
8787 else
8788 ok(r == ERROR_INVALID_NAME, "Expected ERROR_INVALID_NAME, got %u\n", r);
8790 r = pMsiApplyMultiplePatchesA("nosuchpatchpackage;nosuchpatchpackage", NULL, NULL);
8791 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8793 r = pMsiApplyMultiplePatchesA(" nosuchpatchpackage ; nosuchpatchpackage ", NULL, NULL);
8794 todo_wine ok(r == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %u\n", r);
8797 static void test_MsiApplyPatch(void)
8799 UINT r;
8801 r = MsiApplyPatchA(NULL, NULL, INSTALLTYPE_DEFAULT, NULL);
8802 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8804 r = MsiApplyPatchA("", NULL, INSTALLTYPE_DEFAULT, NULL);
8805 ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r);
8808 static void test_MsiEnumComponentCosts(void)
8810 MSIHANDLE hdb, hpkg;
8811 char package[12], drive[3];
8812 DWORD len;
8813 UINT r;
8814 int cost, temp;
8816 hdb = create_package_db();
8817 ok( hdb, "failed to create database\n" );
8819 r = create_property_table( hdb );
8820 ok( r == ERROR_SUCCESS, "cannot create Property table %u\n", r );
8822 r = add_property_entry( hdb, "'ProductCode', '{379B1C47-40C1-42FA-A9BB-BEBB6F1B0172}'" );
8823 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8825 r = add_property_entry( hdb, "'MSIFASTINSTALL', '1'" );
8826 ok( r == ERROR_SUCCESS, "cannot add property entry %u\n", r );
8828 r = add_directory_entry( hdb, "'TARGETDIR', '', 'SourceDir'" );
8829 ok( r == ERROR_SUCCESS, "failed to add directory entry %u\n" , r );
8831 r = create_media_table( hdb );
8832 ok( r == ERROR_SUCCESS, "cannot create Media table %u\n", r );
8834 r = add_media_entry( hdb, "'1', '2', 'cabinet', '', '', ''");
8835 ok( r == ERROR_SUCCESS, "cannot add media entry %u\n", r );
8837 r = create_file_table( hdb );
8838 ok( r == ERROR_SUCCESS, "cannot create File table %u\n", r );
8840 r = add_file_entry( hdb, "'one.txt', 'one', 'one.txt', 4096, '', '', 8192, 1" );
8841 ok( r == ERROR_SUCCESS, "cannot add file %u\n", r );
8843 r = create_component_table( hdb );
8844 ok( r == ERROR_SUCCESS, "cannot create Component table %u\n", r );
8846 r = add_component_entry( hdb, "'one', '{B2F86B9D-8447-4BC5-8883-750C45AA31CA}', 'TARGETDIR', 0, '', 'one.txt'" );
8847 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8849 r = add_component_entry( hdb, "'two', '{62A09F6E-0B74-4829-BDB7-CAB66F42CCE8}', 'TARGETDIR', 0, '', ''" );
8850 ok( r == ERROR_SUCCESS, "cannot add component %u\n", r );
8852 r = create_feature_table( hdb );
8853 ok( r == ERROR_SUCCESS, "cannot create Feature table %u\n", r );
8855 r = add_feature_entry( hdb, "'one', '', '', '', 0, 1, '', 0" );
8856 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8858 r = add_feature_entry( hdb, "'two', '', '', '', 0, 1, '', 0" );
8859 ok( r == ERROR_SUCCESS, "cannot add feature %u\n", r );
8861 r = create_feature_components_table( hdb );
8862 ok( r == ERROR_SUCCESS, "cannot create FeatureComponents table %u\n", r );
8864 r = add_feature_components_entry( hdb, "'one', 'one'" );
8865 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8867 r = add_feature_components_entry( hdb, "'two', 'two'" );
8868 ok( r == ERROR_SUCCESS, "cannot add feature/component pair %u\n", r );
8870 r = create_install_execute_sequence_table( hdb );
8871 ok( r == ERROR_SUCCESS, "cannot create InstallExecuteSequence table %u\n", r );
8873 r = add_install_execute_sequence_entry( hdb, "'CostInitialize', '', '800'" );
8874 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8876 r = add_install_execute_sequence_entry( hdb, "'FileCost', '', '900'" );
8877 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8879 r = add_install_execute_sequence_entry( hdb, "'CostFinalize', '', '1000'" );
8880 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8882 r = add_install_execute_sequence_entry( hdb, "'InstallValidate', '', '1100'" );
8883 ok( r == ERROR_SUCCESS, "cannot add install execute sequence entry %u\n", r );
8885 MsiDatabaseCommit( hdb );
8887 sprintf( package, "#%u", hdb );
8888 r = MsiOpenPackageA( package, &hpkg );
8889 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
8891 skip("Not enough rights to perform tests\n");
8892 goto error;
8894 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8896 r = MsiEnumComponentCostsA( 0, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8897 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8899 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8900 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8902 r = MsiEnumComponentCostsA( hpkg, NULL, 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8903 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8905 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8906 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8908 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, NULL, NULL, NULL, NULL );
8909 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8911 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, NULL, NULL, NULL );
8912 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8914 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, NULL, NULL, NULL );
8915 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8917 len = sizeof(drive);
8918 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, NULL, NULL );
8919 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8921 len = sizeof(drive);
8922 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, NULL );
8923 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8925 len = sizeof(drive);
8926 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8927 todo_wine ok( r == ERROR_INVALID_HANDLE_STATE, "Expected ERROR_INVALID_HANDLE_STATE, got %u\n", r );
8929 len = sizeof(drive);
8930 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, NULL, &len, &cost, &temp );
8931 ok( r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %u\n", r );
8933 MsiSetInternalUI( INSTALLUILEVEL_NONE, NULL );
8935 r = MsiDoActionA( hpkg, "CostInitialize" );
8936 ok( r == ERROR_SUCCESS, "CostInitialize failed %u\n", r );
8938 r = MsiDoActionA( hpkg, "FileCost" );
8939 ok( r == ERROR_SUCCESS, "FileCost failed %u\n", r );
8941 len = sizeof(drive);
8942 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8943 ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8945 r = MsiDoActionA( hpkg, "CostFinalize" );
8946 ok( r == ERROR_SUCCESS, "CostFinalize failed %u\n", r );
8948 /* contrary to what msdn says InstallValidate must be called too */
8949 len = sizeof(drive);
8950 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8951 todo_wine ok( r == ERROR_FUNCTION_NOT_CALLED, "Expected ERROR_FUNCTION_NOT_CALLED, got %u\n", r );
8953 r = MsiDoActionA( hpkg, "InstallValidate" );
8954 ok( r == ERROR_SUCCESS, "InstallValidate failed %u\n", r );
8956 len = 0;
8957 r = MsiEnumComponentCostsA( hpkg, "three", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8958 ok( r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %u\n", r );
8960 len = 0;
8961 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8962 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8963 ok( len == 2, "expected len == 2, got %u\n", len );
8965 len = 2;
8966 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8967 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8968 ok( len == 2, "expected len == 2, got %u\n", len );
8970 len = 2;
8971 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8972 ok( r == ERROR_MORE_DATA, "Expected ERROR_MORE_DATA, got %u\n", r );
8973 ok( len == 2, "expected len == 2, got %u\n", len );
8975 /* install state doesn't seem to matter */
8976 len = sizeof(drive);
8977 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
8978 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8980 len = sizeof(drive);
8981 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_ABSENT, drive, &len, &cost, &temp );
8982 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8984 len = sizeof(drive);
8985 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_SOURCE, drive, &len, &cost, &temp );
8986 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8988 len = sizeof(drive);
8989 drive[0] = 0;
8990 cost = temp = 0xdead;
8991 r = MsiEnumComponentCostsA( hpkg, "one", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
8992 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
8993 ok( len == 2, "expected len == 2, got %u\n", len );
8994 ok( drive[0], "expected a drive\n" );
8995 ok( cost && cost != 0xdead, "expected cost > 0, got %d\n", cost );
8996 ok( !temp, "expected temp == 0, got %d\n", temp );
8998 len = sizeof(drive);
8999 drive[0] = 0;
9000 cost = temp = 0xdead;
9001 r = MsiEnumComponentCostsA( hpkg, "two", 0, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9002 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9003 ok( len == 2, "expected len == 2, got %u\n", len );
9004 ok( drive[0], "expected a drive\n" );
9005 ok( !cost, "expected cost == 0, got %d\n", cost );
9006 ok( !temp, "expected temp == 0, got %d\n", temp );
9008 len = sizeof(drive);
9009 drive[0] = 0;
9010 cost = temp = 0xdead;
9011 r = MsiEnumComponentCostsA( hpkg, "", 0, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
9012 ok( r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %u\n", r );
9013 ok( len == 2, "expected len == 2, got %u\n", len );
9014 ok( drive[0], "expected a drive\n" );
9015 ok( !cost, "expected cost == 0, got %d\n", cost );
9016 ok( temp && temp != 0xdead, "expected temp > 0, got %d\n", temp );
9018 /* increased index */
9019 len = sizeof(drive);
9020 r = MsiEnumComponentCostsA( hpkg, "one", 1, INSTALLSTATE_LOCAL, drive, &len, &cost, &temp );
9021 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
9023 len = sizeof(drive);
9024 r = MsiEnumComponentCostsA( hpkg, "", 1, INSTALLSTATE_UNKNOWN, drive, &len, &cost, &temp );
9025 ok( r == ERROR_NO_MORE_ITEMS, "Expected ERROR_NO_MORE_ITEMS, got %u\n", r );
9027 MsiCloseHandle( hpkg );
9028 error:
9029 MsiCloseHandle( hdb );
9030 DeleteFileA( msifile );
9033 static void test_MsiDatabaseCommit(void)
9035 UINT r;
9036 MSIHANDLE hdb, hpkg = 0;
9037 char buf[32], package[12];
9038 DWORD sz;
9040 hdb = create_package_db();
9041 ok( hdb, "failed to create database\n" );
9043 r = create_property_table( hdb );
9044 ok( r == ERROR_SUCCESS, "can't create Property table %u\n", r );
9046 sprintf( package, "#%u", hdb );
9047 r = MsiOpenPackageA( package, &hpkg );
9048 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9050 skip("Not enough rights to perform tests\n");
9051 goto error;
9053 ok( r == ERROR_SUCCESS, "got %u\n", r );
9055 r = MsiSetPropertyA( hpkg, "PROP", "value" );
9056 ok( r == ERROR_SUCCESS, "got %u\n", r );
9058 buf[0] = 0;
9059 sz = sizeof(buf);
9060 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
9061 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
9062 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
9064 r = MsiDatabaseCommit( hdb );
9065 ok( r == ERROR_SUCCESS, "MsiDatabaseCommit returned %u\n", r );
9067 buf[0] = 0;
9068 sz = sizeof(buf);
9069 r = MsiGetPropertyA( hpkg, "PROP", buf, &sz );
9070 ok( r == ERROR_SUCCESS, "MsiGetPropertyA returned %u\n", r );
9071 ok( !lstrcmpA( buf, "value" ), "got \"%s\"\n", buf );
9073 MsiCloseHandle( hpkg );
9074 error:
9075 MsiCloseHandle( hdb );
9076 DeleteFileA( msifile );
9079 static int externalui_ran;
9081 static INT CALLBACK externalui_callback(void *context, UINT message_type, LPCSTR message)
9083 externalui_ran = 1;
9084 ok(message_type == INSTALLMESSAGE_USER, "expected INSTALLMESSAGE_USER, got %08x\n", message_type);
9085 return 0;
9088 static int externalui_record_ran;
9090 static INT CALLBACK externalui_record_callback(void *context, UINT message_type, MSIHANDLE hrecord)
9092 INT retval = context ? *((INT *)context) : 0;
9093 UINT r;
9094 externalui_record_ran = 1;
9095 ok(message_type == INSTALLMESSAGE_USER, "expected INSTALLMESSAGE_USER, got %08x\n", message_type);
9096 r = MsiRecordGetFieldCount(hrecord);
9097 ok(r == 1, "expected 1, got %u\n", r);
9098 r = MsiRecordGetInteger(hrecord, 1);
9099 todo_wine
9100 ok(r == 12345, "expected 12345, got %u\n", r);
9101 return retval;
9104 static void test_externalui(void)
9106 /* test that external UI handlers work correctly */
9108 INSTALLUI_HANDLERA prev;
9109 INSTALLUI_HANDLER_RECORD prev_record;
9110 MSIHANDLE hpkg, hrecord;
9111 UINT r;
9113 prev = MsiSetExternalUIA(externalui_callback, INSTALLLOGMODE_USER, NULL);
9115 r = package_from_db(create_package_db(), &hpkg);
9116 if (r == ERROR_INSTALL_PACKAGE_REJECTED)
9118 skip("Not enough rights to perform tests\n");
9119 DeleteFileA(msifile);
9120 return;
9122 ok(r == ERROR_SUCCESS, "Expected a valid package %u\n", r);
9124 hrecord = MsiCreateRecord(1);
9125 ok(hrecord, "Expected a valid record\n");
9126 r = MsiRecordSetStringA(hrecord, 0, "test message [1]");
9127 ok(r == ERROR_SUCCESS, "MsiSetString failed %u\n", r);
9128 r = MsiRecordSetInteger(hrecord, 1, 12345);
9129 ok(r == ERROR_SUCCESS, "MsiSetInteger failed %u\n", r);
9131 externalui_ran = 0;
9132 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9133 ok(r == 0, "expected 0, got %u\n", r);
9134 ok(externalui_ran == 1, "external UI callback did not run\n");
9136 if (pMsiSetExternalUIRecord)
9138 INT retval = 0;
9140 prev = MsiSetExternalUIA(prev, 0, NULL);
9141 ok(prev == externalui_callback, "wrong callback function %p\n", prev);
9142 r = pMsiSetExternalUIRecord(externalui_record_callback, INSTALLLOGMODE_USER, &retval, &prev_record);
9143 ok(r == ERROR_SUCCESS, "MsiSetExternalUIRecord failed %u\n", r);
9145 externalui_ran = externalui_record_ran = 0;
9146 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9147 ok(r == 0, "expected 0, got %u\n", r);
9148 ok(externalui_ran == 0, "external UI callback should not have run\n");
9149 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
9151 MsiSetExternalUIA(externalui_callback, INSTALLLOGMODE_USER, NULL);
9153 externalui_ran = externalui_record_ran = 0;
9154 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9155 ok(r == 0, "expected 0, got %u\n", r);
9156 ok(externalui_ran == 1, "external UI callback did not run\n");
9157 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
9159 retval = 1;
9160 externalui_ran = externalui_record_ran = 0;
9161 r = MsiProcessMessage(hpkg, INSTALLMESSAGE_USER, hrecord);
9162 todo_wine
9163 ok(r == 1, "expected 1, got %u\n", r);
9164 todo_wine
9165 ok(externalui_ran == 0, "external UI callback should not have run\n");
9166 ok(externalui_record_ran == 1, "external UI record callback did not run\n");
9168 else
9169 win_skip("MsiSetExternalUIRecord is not available\n");
9171 MsiCloseHandle(hpkg);
9172 DeleteFileA(msifile);
9175 START_TEST(package)
9177 STATEMGRSTATUS status;
9178 BOOL ret = FALSE;
9180 init_functionpointers();
9182 if (pIsWow64Process)
9183 pIsWow64Process(GetCurrentProcess(), &is_wow64);
9185 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
9187 /* Create a restore point ourselves so we circumvent the multitude of restore points
9188 * that would have been created by all the installation and removal tests.
9190 * This is not needed on version 5.0 where setting MSIFASTINSTALL prevents the
9191 * creation of restore points.
9193 if (pSRSetRestorePointA && !pMsiGetComponentPathExA)
9195 memset(&status, 0, sizeof(status));
9196 ret = notify_system_change(BEGIN_NESTED_SYSTEM_CHANGE, &status);
9199 test_createpackage();
9200 test_doaction();
9201 test_gettargetpath_bad();
9202 test_settargetpath();
9203 test_props();
9204 test_property_table();
9205 test_condition();
9206 test_msipackage();
9207 test_formatrecord2();
9208 test_states();
9209 test_getproperty();
9210 test_removefiles();
9211 test_appsearch();
9212 test_appsearch_complocator();
9213 test_appsearch_reglocator();
9214 test_appsearch_inilocator();
9215 test_appsearch_drlocator();
9216 test_featureparents();
9217 test_installprops();
9218 test_launchconditions();
9219 test_ccpsearch();
9220 test_complocator();
9221 test_MsiGetSourcePath();
9222 test_shortlongsource();
9223 test_sourcedir();
9224 test_access();
9225 test_emptypackage();
9226 test_MsiGetProductProperty();
9227 test_MsiSetProperty();
9228 test_MsiApplyMultiplePatches();
9229 test_MsiApplyPatch();
9230 test_MsiEnumComponentCosts();
9231 test_MsiDatabaseCommit();
9232 test_externalui();
9234 if (pSRSetRestorePointA && !pMsiGetComponentPathExA && ret)
9236 ret = notify_system_change(END_NESTED_SYSTEM_CHANGE, &status);
9237 if (ret)
9238 remove_restore_point(status.llSequenceNumber);