Commit cdf3c236 authored by Akihiro Sagawa's avatar Akihiro Sagawa Committed by Alexandre Julliard

msi: Open 32-bit component registry keys with KEY_WOW64_32KEY flag.

parent 03f6a6e9
...@@ -2612,14 +2612,24 @@ static WCHAR *get_keypath( MSICOMPONENT *comp, HKEY root, const WCHAR *path ) ...@@ -2612,14 +2612,24 @@ static WCHAR *get_keypath( MSICOMPONENT *comp, HKEY root, const WCHAR *path )
return strdupW( path ); return strdupW( path );
} }
static HKEY open_key( HKEY root, const WCHAR *path, BOOL create ) static inline REGSAM get_registry_view( const MSICOMPONENT *comp )
{
REGSAM view = 0;
if (is_wow64 || is_64bit)
view |= (comp->Attributes & msidbComponentAttributes64bit) ? KEY_WOW64_64KEY : KEY_WOW64_32KEY;
return view;
}
static HKEY open_key( const MSICOMPONENT *comp, HKEY root, const WCHAR *path, BOOL create )
{ {
REGSAM access = KEY_ALL_ACCESS; REGSAM access = KEY_ALL_ACCESS;
WCHAR *subkey, *p, *q; WCHAR *subkey, *p, *q;
HKEY hkey, ret = NULL; HKEY hkey, ret = NULL;
LONG res; LONG res;
if (is_wow64) access |= KEY_WOW64_64KEY; if (comp)
access |= get_registry_view( comp );
else if (is_wow64) access |= KEY_WOW64_64KEY;
if (!(subkey = strdupW( path ))) return NULL; if (!(subkey = strdupW( path ))) return NULL;
p = subkey; p = subkey;
...@@ -2636,7 +2646,7 @@ static HKEY open_key( HKEY root, const WCHAR *path, BOOL create ) ...@@ -2636,7 +2646,7 @@ static HKEY open_key( HKEY root, const WCHAR *path, BOOL create )
} }
if (q && q[1]) if (q && q[1])
{ {
ret = open_key( hkey, q + 1, create ); ret = open_key( comp, hkey, q + 1, create );
RegCloseKey( hkey ); RegCloseKey( hkey );
} }
else ret = hkey; else ret = hkey;
...@@ -2817,7 +2827,7 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) ...@@ -2817,7 +2827,7 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
BYTE *new_value, *old_value = NULL; BYTE *new_value, *old_value = NULL;
HKEY root_key, hkey; HKEY root_key, hkey;
DWORD type, old_type, new_size, old_size = 0; DWORD type, old_type, new_size, old_size = 0;
LPWSTR deformated, uikey, keypath; LPWSTR deformated, uikey;
const WCHAR *szRoot, *component, *name, *key, *str; const WCHAR *szRoot, *component, *name, *key, *str;
MSICOMPONENT *comp; MSICOMPONENT *comp;
MSIRECORD * uirow; MSIRECORD * uirow;
...@@ -2861,15 +2871,14 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) ...@@ -2861,15 +2871,14 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
strcpyW(uikey,szRoot); strcpyW(uikey,szRoot);
strcatW(uikey,deformated); strcatW(uikey,deformated);
keypath = get_keypath( comp, root_key, deformated ); if (!(hkey = open_key( comp, root_key, deformated, TRUE )))
msi_free( deformated );
if (!(hkey = open_key( root_key, keypath, TRUE )))
{ {
ERR("Could not create key %s\n", debugstr_w(keypath)); ERR("Could not create key %s\n", debugstr_w(deformated));
msi_free(uikey); msi_free(uikey);
msi_free(keypath); msi_free(deformated);
return ERROR_FUNCTION_FAILED; return ERROR_FUNCTION_FAILED;
} }
msi_free( deformated );
str = msi_record_get_string( row, 5, NULL ); str = msi_record_get_string( row, 5, NULL );
len = deformat_string( package, str, &deformated ); len = deformat_string( package, str, &deformated );
new_value = parse_value( package, deformated, len, &type, &new_size ); new_value = parse_value( package, deformated, len, &type, &new_size );
...@@ -2922,7 +2931,6 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param) ...@@ -2922,7 +2931,6 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
msi_free(old_value); msi_free(old_value);
msi_free(deformated); msi_free(deformated);
msi_free(uikey); msi_free(uikey);
msi_free(keypath);
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
...@@ -2957,7 +2965,7 @@ static void delete_key( HKEY root, const WCHAR *path ) ...@@ -2957,7 +2965,7 @@ static void delete_key( HKEY root, const WCHAR *path )
for (;;) for (;;)
{ {
if ((p = strrchrW( subkey, '\\' ))) *p = 0; if ((p = strrchrW( subkey, '\\' ))) *p = 0;
hkey = open_key( root, subkey, FALSE ); hkey = open_key( NULL, root, subkey, FALSE );
if (!hkey) break; if (!hkey) break;
if (p && p[1]) if (p && p[1])
res = RegDeleteKeyExW( hkey, p + 1, access, 0 ); res = RegDeleteKeyExW( hkey, p + 1, access, 0 );
...@@ -2980,7 +2988,7 @@ static void delete_value( HKEY root, const WCHAR *path, const WCHAR *value ) ...@@ -2980,7 +2988,7 @@ static void delete_value( HKEY root, const WCHAR *path, const WCHAR *value )
HKEY hkey; HKEY hkey;
DWORD num_subkeys, num_values; DWORD num_subkeys, num_values;
if ((hkey = open_key( root, path, FALSE ))) if ((hkey = open_key( NULL, root, path, FALSE )))
{ {
if ((res = RegDeleteValueW( hkey, value ))) if ((res = RegDeleteValueW( hkey, value )))
TRACE("failed to delete value %s (%d)\n", debugstr_w(value), res); TRACE("failed to delete value %s (%d)\n", debugstr_w(value), res);
...@@ -3001,7 +3009,7 @@ static void delete_tree( HKEY root, const WCHAR *path ) ...@@ -3001,7 +3009,7 @@ static void delete_tree( HKEY root, const WCHAR *path )
LONG res; LONG res;
HKEY hkey; HKEY hkey;
if (!(hkey = open_key( root, path, FALSE ))) return; if (!(hkey = open_key( NULL, root, path, FALSE ))) return;
res = RegDeleteTreeW( hkey, NULL ); res = RegDeleteTreeW( hkey, NULL );
if (res) TRACE("failed to delete subtree of %s (%d)\n", debugstr_w(path), res); if (res) TRACE("failed to delete subtree of %s (%d)\n", debugstr_w(path), res);
delete_key( root, path ); delete_key( root, path );
......
...@@ -5669,7 +5669,7 @@ static void test_mixed_package(void) ...@@ -5669,7 +5669,7 @@ static void test_mixed_package(void)
res = RegOpenKeyExA(HKEY_CLASSES_ROOT, res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
"CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32", "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey); 0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
todo_wine ok(res == ERROR_SUCCESS, "can't open 32-bit CLSID key, got %d\n", res); ok(res == ERROR_SUCCESS, "can't open 32-bit CLSID key, got %d\n", res);
if (res == ERROR_SUCCESS) { if (res == ERROR_SUCCESS) {
size = sizeof(value); size = sizeof(value);
res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
...@@ -5732,7 +5732,7 @@ static void test_mixed_package(void) ...@@ -5732,7 +5732,7 @@ static void test_mixed_package(void)
res = RegOpenKeyExA(HKEY_CLASSES_ROOT, res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
"CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32", "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey); 0, KEY_ALL_ACCESS|KEY_WOW64_32KEY, &hkey);
todo_wine ok(res == ERROR_SUCCESS, "can't open 32-bit CLSID key, got %d\n", res); ok(res == ERROR_SUCCESS, "can't open 32-bit CLSID key, got %d\n", res);
if (res == ERROR_SUCCESS) { if (res == ERROR_SUCCESS) {
size = sizeof(value); size = sizeof(value);
res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size); res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
......
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