[PATCH 1/2] advapi32: Attempt to open WOW64 key before the lowest level key, too

Andrew Eikum aeikum at codeweavers.com
Fri Oct 4 09:44:21 CDT 2013


Without this, we'll fail to open the correct key for e.g.
<Machine\Software\Classes> with KEY_WOW64_32KEY, which should resolve to
<Machine\Software\Wow6432Node\Classes>.
---
 dlls/advapi32/registry.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index e999ce6..fda050e 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -168,6 +168,16 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES
         }
         str.Buffer = buffer + pos;
         str.Length = (i - pos) * sizeof(WCHAR);
+        if (force_wow32 && pos)
+        {
+            if (is_wow6432node( &str )) force_wow32 = FALSE;
+            else if ((subkey = open_wow6432node( attr->RootDirectory, &str )))
+            {
+                if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
+                attr->RootDirectory = subkey;
+                force_wow32 = FALSE;
+            }
+        }
         attr->Attributes = attrs;
         status = NtCreateKey( (PHANDLE)retkey, access, attr, 0, class, options, dispos );
         if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
@@ -217,6 +227,16 @@ static NTSTATUS open_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *a
     }
     str.Buffer = buffer + pos;
     str.Length = (i - pos) * sizeof(WCHAR);
+    if (force_wow32 && pos)
+    {
+        if (is_wow6432node( &str )) force_wow32 = FALSE;
+        else if ((subkey = open_wow6432node( attr->RootDirectory, &str )))
+        {
+            if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
+            attr->RootDirectory = subkey;
+            force_wow32 = FALSE;
+        }
+    }
     attr->Attributes = attrs;
     status = NtOpenKey( (PHANDLE)retkey, access, attr );
     if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
-- 
1.8.4





More information about the wine-patches mailing list