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

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jan 19 16:00:03 CST 2015


Module: wine
Branch: master
Commit: cdf3c23645889d0f1aeabd366c969feb34d5d808
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=cdf3c23645889d0f1aeabd366c969feb34d5d808

Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date:   Sun Jan 18 22:04:04 2015 +0900

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

---

 dlls/msi/action.c        | 34 +++++++++++++++++++++-------------
 dlls/msi/tests/install.c |  4 ++--
 2 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 34697f3..4b59b4e 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -2612,14 +2612,24 @@ static WCHAR *get_keypath( MSICOMPONENT *comp, HKEY root, const WCHAR *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;
     WCHAR *subkey, *p, *q;
     HKEY hkey, ret = NULL;
     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;
     p = subkey;
@@ -2636,7 +2646,7 @@ static HKEY open_key( HKEY root, const WCHAR *path, BOOL create )
     }
     if (q && q[1])
     {
-        ret = open_key( hkey, q + 1, create );
+        ret = open_key( comp, hkey, q + 1, create );
         RegCloseKey( hkey );
     }
     else ret = hkey;
@@ -2817,7 +2827,7 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
     BYTE *new_value, *old_value = NULL;
     HKEY  root_key, hkey;
     DWORD type, old_type, new_size, old_size = 0;
-    LPWSTR deformated, uikey, keypath;
+    LPWSTR deformated, uikey;
     const WCHAR *szRoot, *component, *name, *key, *str;
     MSICOMPONENT *comp;
     MSIRECORD * uirow;
@@ -2861,15 +2871,14 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
     strcpyW(uikey,szRoot);
     strcatW(uikey,deformated);
 
-    keypath = get_keypath( comp, root_key, deformated );
-    msi_free( deformated );
-    if (!(hkey = open_key( root_key, keypath, TRUE )))
+    if (!(hkey = open_key( comp, root_key, deformated, 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(keypath);
+        msi_free(deformated);
         return ERROR_FUNCTION_FAILED;
     }
+    msi_free( deformated );
     str = msi_record_get_string( row, 5, NULL );
     len = deformat_string( package, str, &deformated );
     new_value = parse_value( package, deformated, len, &type, &new_size );
@@ -2922,7 +2931,6 @@ static UINT ITERATE_WriteRegistryValues(MSIRECORD *row, LPVOID param)
     msi_free(old_value);
     msi_free(deformated);
     msi_free(uikey);
-    msi_free(keypath);
 
     return ERROR_SUCCESS;
 }
@@ -2957,7 +2965,7 @@ static void delete_key( HKEY root, const WCHAR *path )
     for (;;)
     {
         if ((p = strrchrW( subkey, '\\' ))) *p = 0;
-        hkey = open_key( root, subkey, FALSE );
+        hkey = open_key( NULL, root, subkey, FALSE );
         if (!hkey) break;
         if (p && p[1])
             res = RegDeleteKeyExW( hkey, p + 1, access, 0 );
@@ -2980,7 +2988,7 @@ static void delete_value( HKEY root, const WCHAR *path, const WCHAR *value )
     HKEY hkey;
     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 )))
             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 )
     LONG res;
     HKEY hkey;
 
-    if (!(hkey = open_key( root, path, FALSE ))) return;
+    if (!(hkey = open_key( NULL, root, path, FALSE ))) return;
     res = RegDeleteTreeW( hkey, NULL );
     if (res) TRACE("failed to delete subtree of %s (%d)\n", debugstr_w(path), res);
     delete_key( root, path );
diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c
index 7c4544a..e607bc9 100644
--- a/dlls/msi/tests/install.c
+++ b/dlls/msi/tests/install.c
@@ -5669,7 +5669,7 @@ static void test_mixed_package(void)
     res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                         "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
                         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) {
         size = sizeof(value);
         res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);
@@ -5732,7 +5732,7 @@ static void test_mixed_package(void)
     res = RegOpenKeyExA(HKEY_CLASSES_ROOT,
                         "CLSID\\{8dfef911-6885-41eb-b280-8f0304728e8b}\\InProcServer32",
                         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) {
         size = sizeof(value);
         res = RegQueryValueExA(hkey, "", NULL, NULL, (LPBYTE)value, &size);




More information about the wine-cvs mailing list