Commit c4bf9fb7 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi/tests: Fix some more wow64 test failures.

parent c4511481
......@@ -32,6 +32,9 @@
#include "wine/test.h"
static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
DEFINE_GUID(GUID_NULL,0,0,0,0,0,0,0,0,0,0,0);
static const char *msifile = "winetest-automation.msi";
......@@ -199,6 +202,29 @@ static const msi_summary_info summary_info[] =
ADD_INFO_FILETIME(PID_LASTPRINTED, &systemtime)
};
static void init_functionpointers(void)
{
HMODULE hadvapi32 = GetModuleHandleA("advapi32.dll");
HMODULE hkernel32 = GetModuleHandleA("kernel32.dll");
#define GET_PROC(dll, func) \
p ## func = (void *)GetProcAddress(dll, #func); \
if(!p ## func) \
trace("GetProcAddress(%s) failed\n", #func);
GET_PROC(hadvapi32, RegDeleteKeyExA)
GET_PROC(hkernel32, IsWow64Process)
#undef GET_PROC
}
static LONG delete_key_portable( HKEY key, LPCSTR subkey, REGSAM access )
{
if (pRegDeleteKeyExA)
return pRegDeleteKeyExA( key, subkey, access, 0 );
return RegDeleteKeyA( key, subkey );
}
/*
* Database Helpers
*/
......@@ -2334,30 +2360,30 @@ static void test_Installer_Products(BOOL bProductInstalled)
/* Delete a registry subkey, including all its subkeys (RegDeleteKey does not work on keys with subkeys without
* deleting the subkeys first) */
static UINT delete_registry_key(HKEY hkeyParent, LPCSTR subkey)
static UINT delete_registry_key(HKEY hkeyParent, LPCSTR subkey, REGSAM access)
{
UINT ret;
CHAR *string = NULL;
HKEY hkey;
DWORD dwSize;
ret = RegOpenKey(hkeyParent, subkey, &hkey);
ret = RegOpenKeyEx(hkeyParent, subkey, 0, access, &hkey);
if (ret != ERROR_SUCCESS) return ret;
ret = RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, &dwSize, NULL, NULL, NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS) return ret;
if (!(string = HeapAlloc(GetProcessHeap(), 0, ++dwSize))) return ERROR_NOT_ENOUGH_MEMORY;
while (RegEnumKeyA(hkey, 0, string, dwSize) == ERROR_SUCCESS)
delete_registry_key(hkey, string);
delete_registry_key(hkey, string, access);
RegCloseKey(hkey);
HeapFree(GetProcessHeap(), 0, string);
RegDeleteKeyA(hkeyParent, subkey);
delete_key_portable(hkeyParent, subkey, access);
return ERROR_SUCCESS;
}
/* Find a specific registry subkey at any depth within the given key and subkey and return its parent key. */
static UINT find_registry_key(HKEY hkeyParent, LPCSTR subkey, LPCSTR findkey, HKEY *phkey)
static UINT find_registry_key(HKEY hkeyParent, LPCSTR subkey, LPCSTR findkey, REGSAM access, HKEY *phkey)
{
UINT ret;
CHAR *string = NULL;
......@@ -2368,7 +2394,7 @@ static UINT find_registry_key(HKEY hkeyParent, LPCSTR subkey, LPCSTR findkey, HK
*phkey = 0;
ret = RegOpenKey(hkeyParent, subkey, &hkey);
ret = RegOpenKeyEx(hkeyParent, subkey, 0, access, &hkey);
if (ret != ERROR_SUCCESS) return ret;
ret = RegQueryInfoKeyA(hkey, NULL, NULL, NULL, NULL, &dwSize, NULL, NULL, NULL, NULL, NULL, NULL);
if (ret != ERROR_SUCCESS) return ret;
......@@ -2382,7 +2408,7 @@ static UINT find_registry_key(HKEY hkeyParent, LPCSTR subkey, LPCSTR findkey, HK
*phkey = hkey;
found = TRUE;
}
else if (find_registry_key(hkey, string, findkey, phkey) == ERROR_SUCCESS) found = TRUE;
else if (find_registry_key(hkey, string, findkey, access, phkey) == ERROR_SUCCESS) found = TRUE;
}
if (*phkey != hkey) RegCloseKey(hkey);
......@@ -2400,6 +2426,11 @@ static void test_Installer_InstallProduct(void)
DWORD num, size, type;
int iValue, iCount;
IDispatch *pStringList = NULL;
REGSAM access = KEY_ALL_ACCESS;
BOOL wow64;
if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
access |= KEY_WOW64_64KEY;
create_test_files();
......@@ -2483,7 +2514,7 @@ static void test_Installer_InstallProduct(void)
ok(delete_pf("msitest\\filename", TRUE), "File not installed\n");
ok(delete_pf("msitest", FALSE), "File not installed\n");
res = RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", &hkey);
res = RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", 0, access, &hkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
size = MAX_PATH;
......@@ -2511,40 +2542,45 @@ static void test_Installer_InstallProduct(void)
RegCloseKey(hkey);
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest");
res = delete_key_portable(HKEY_LOCAL_MACHINE, "SOFTWARE\\Wine\\msitest", access);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* Remove registry keys written by RegisterProduct standard action */
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}");
res = delete_key_portable(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\{F1C3AF50-8B56-4A69-A00C-00773FE42F30}", access);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\D8E760ECA1E276347B43E42BDBDA5656");
res = delete_key_portable(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UpgradeCodes\\D8E760ECA1E276347B43E42BDBDA5656", access);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = find_registry_key(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData", "05FA3C1F65B896A40AC00077F34EF203", &hkey);
res = find_registry_key(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData", "05FA3C1F65B896A40AC00077F34EF203", access, &hkey);
ok(res == ERROR_SUCCESS ||
broken(res == ERROR_FILE_NOT_FOUND), /* win9x */
"Expected ERROR_SUCCESS, got %d\n", res);
if (res == ERROR_SUCCESS)
{
res = delete_registry_key(hkey, "05FA3C1F65B896A40AC00077F34EF203");
res = delete_registry_key(hkey, "05FA3C1F65B896A40AC00077F34EF203", access);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
RegCloseKey(hkey);
res = RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203");
res = delete_key_portable(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203", access);
ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
}
else
{
/* win9x defaults to a per-machine install. */
RegDeleteKeyA(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203");
delete_key_portable(HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Installer\\Products\\05FA3C1F65B896A40AC00077F34EF203", access);
}
/* Remove registry keys written by PublishProduct standard action */
res = RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\Installer", &hkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = delete_registry_key(hkey, "Products\\05FA3C1F65B896A40AC00077F34EF203");
res = delete_registry_key(hkey, "Products\\05FA3C1F65B896A40AC00077F34EF203", KEY_ALL_ACCESS);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = RegDeleteKeyA(hkey, "UpgradeCodes\\D8E760ECA1E276347B43E42BDBDA5656");
......@@ -2693,6 +2729,7 @@ START_TEST(automation)
CLSID clsid;
IUnknown *pUnk;
init_functionpointers();
GetSystemTimeAsFileTime(&systemtime);
GetCurrentDirectoryA(MAX_PATH, prev_path);
......
......@@ -37,6 +37,7 @@ static UINT (WINAPI *pMsiApplyMultiplePatchesA)(LPCSTR, LPCSTR, LPCSTR);
static BOOL (WINAPI *pConvertSidToStringSidA)(PSID, LPSTR*);
static LONG (WINAPI *pRegDeleteKeyExA)(HKEY, LPCSTR, REGSAM, DWORD);
static LONG (WINAPI *pRegDeleteKeyExW)(HKEY, LPCWSTR, REGSAM, DWORD);
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
static BOOL (WINAPI *pSRRemoveRestorePoint)(DWORD);
......@@ -56,6 +57,7 @@ static void init_functionpointers(void)
GET_PROC(hadvapi32, ConvertSidToStringSidA);
GET_PROC(hadvapi32, RegDeleteKeyExA)
GET_PROC(hadvapi32, RegDeleteKeyExW)
GET_PROC(hkernel32, IsWow64Process)
hsrclient = LoadLibraryA("srclient.dll");
......@@ -96,7 +98,7 @@ static LPSTR get_user_sid(LPSTR *usersid)
}
/* RegDeleteTreeW from dlls/advapi32/registry.c */
static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey, REGSAM access)
{
LONG ret;
DWORD dwMaxSubkeyLen, dwMaxValueLen;
......@@ -106,7 +108,7 @@ static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
if(lpszSubKey)
{
ret = RegOpenKeyExW(hKey, lpszSubKey, 0, KEY_READ, &hSubKey);
ret = RegOpenKeyExW(hKey, lpszSubKey, 0, access, &hSubKey);
if (ret) return ret;
}
......@@ -134,12 +136,17 @@ static LSTATUS package_RegDeleteTreeW(HKEY hKey, LPCWSTR lpszSubKey)
if (RegEnumKeyExW(hSubKey, 0, lpszName, &dwSize, NULL,
NULL, NULL, NULL)) break;
ret = package_RegDeleteTreeW(hSubKey, lpszName);
ret = package_RegDeleteTreeW(hSubKey, lpszName, access);
if (ret) goto cleanup;
}
if (lpszSubKey)
{
if (pRegDeleteKeyExW)
ret = pRegDeleteKeyExW(hKey, lpszSubKey, access, 0);
else
ret = RegDeleteKeyW(hKey, lpszSubKey);
}
else
while (TRUE)
{
......@@ -221,6 +228,11 @@ static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
CHAR path[MAX_PATH];
LPCSTR prod = NULL;
HKEY hkey;
REGSAM access = KEY_ALL_ACCESS;
BOOL wow64;
if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
access |= KEY_WOW64_64KEY;
MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
squash_guid(guidW, squashedW);
......@@ -259,7 +271,7 @@ static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
"7D2F387510109040002000060BECB6AB", usersid);
}
RegCreateKeyA(HKEY_LOCAL_MACHINE, comppath, &hkey);
RegCreateKeyExA(HKEY_LOCAL_MACHINE, comppath, 0, NULL, 0, access, NULL, &hkey, NULL);
lstrcpyA(path, CURR_DIR);
lstrcatA(path, "\\");
......@@ -268,7 +280,7 @@ static void set_component_path(LPCSTR filename, MSIINSTALLCONTEXT context,
RegSetValueExA(hkey, prod, 0, REG_SZ, (LPBYTE)path, lstrlenA(path));
RegCloseKey(hkey);
RegCreateKeyA(HKEY_LOCAL_MACHINE, prodpath, &hkey);
RegCreateKeyExA(HKEY_LOCAL_MACHINE, prodpath, 0, NULL, 0, access, NULL, &hkey, NULL);
RegCloseKey(hkey);
}
......@@ -280,6 +292,11 @@ static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR
CHAR squashed[MAX_PATH];
CHAR comppath[MAX_PATH];
CHAR prodpath[MAX_PATH];
REGSAM access = KEY_ALL_ACCESS;
BOOL wow64;
if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
access |= KEY_WOW64_64KEY;
MultiByteToWideChar(CP_ACP, 0, guid, -1, guidW, MAX_PATH);
squash_guid(guidW, squashedW);
......@@ -316,10 +333,10 @@ static void delete_component_path(LPCSTR guid, MSIINSTALLCONTEXT context, LPSTR
}
MultiByteToWideChar(CP_ACP, 0, comppath, -1, substrW, MAX_PATH);
package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
MultiByteToWideChar(CP_ACP, 0, prodpath, -1, substrW, MAX_PATH);
package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW);
package_RegDeleteTreeW(HKEY_LOCAL_MACHINE, substrW, access);
}
static UINT do_query(MSIHANDLE hdb, const char *query, MSIHANDLE *phrec)
......@@ -7806,19 +7823,19 @@ error:
static void test_appsearch_reglocator(void)
{
MSIHANDLE hpkg, hdb;
CHAR path[MAX_PATH];
CHAR prop[MAX_PATH];
DWORD binary[2];
DWORD size, val;
CHAR path[MAX_PATH], prop[MAX_PATH];
DWORD binary[2], size, val;
BOOL space, version;
HKEY hklm, classes;
HKEY hkcu, users;
LPSTR pathdata;
LPSTR pathvar;
HKEY hklm, classes, hkcu, users;
LPSTR pathdata, pathvar, ptr;
LPCSTR str;
LPSTR ptr;
LONG res;
UINT r;
REGSAM access = KEY_ALL_ACCESS;
BOOL wow64;
if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
access |= KEY_WOW64_64KEY;
version = TRUE;
if (!create_file_with_version("test.dll", MAKELONG(2, 1), MAKELONG(4, 3)))
......@@ -7858,7 +7875,7 @@ static void test_appsearch_reglocator(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
}
res = RegCreateKeyA(HKEY_LOCAL_MACHINE, "Software\\Wine", &hklm);
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, "Software\\Wine", 0, NULL, 0, access, NULL, &hklm, NULL);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
res = RegSetValueA(hklm, NULL, REG_SZ, "defvalue", 8);
......@@ -8464,7 +8481,7 @@ static void test_appsearch_reglocator(void)
RegDeleteValueA(hklm, "Value15");
RegDeleteValueA(hklm, "Value16");
RegDeleteValueA(hklm, "Value17");
RegDeleteKeyA(hklm, "");
delete_key(hklm, "", access);
RegCloseKey(hklm);
RegDeleteValueA(classes, "Value1");
......@@ -9476,13 +9493,17 @@ static void test_featureparents(void)
static void test_installprops(void)
{
MSIHANDLE hpkg, hdb;
CHAR path[MAX_PATH];
CHAR buf[MAX_PATH];
CHAR path[MAX_PATH], buf[MAX_PATH];
DWORD size, type;
LANGID langid;
HKEY hkey1, hkey2;
int res;
UINT r;
REGSAM access = KEY_ALL_ACCESS;
BOOL wow64;
if (pIsWow64Process && pIsWow64Process(GetCurrentProcess(), &wow64) && wow64)
access |= KEY_WOW64_64KEY;
GetCurrentDirectory(MAX_PATH, path);
lstrcat(path, "\\");
......@@ -9508,8 +9529,7 @@ static void test_installprops(void)
ok( !lstrcmp(buf, path), "Expected %s, got %s\n", path, buf);
RegOpenKey(HKEY_CURRENT_USER, "SOFTWARE\\Microsoft\\MS Setup (ACME)\\User Info", &hkey1);
RegOpenKey(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", &hkey2);
RegOpenKeyEx(HKEY_LOCAL_MACHINE, "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", 0, access, &hkey2);
size = MAX_PATH;
type = REG_SZ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment