Akihiro Sagawa : advapi32: Fix HKLM\Software handling when opening with KEY_WOW64_32KEY.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon Jan 19 16:00:03 CST 2015
Module: wine
Branch: master
Commit: 03f6a6e924df300c709092a0621721ec6142e760
URL: http://source.winehq.org/git/wine.git/?a=commit;h=03f6a6e924df300c709092a0621721ec6142e760
Author: Akihiro Sagawa <sagawa.aki at gmail.com>
Date: Sun Jan 18 22:04:02 2015 +0900
advapi32: Fix HKLM\Software handling when opening with KEY_WOW64_32KEY.
---
dlls/advapi32/registry.c | 23 ++++++++++++++++++-----
dlls/advapi32/tests/registry.c | 8 +++-----
2 files changed, 21 insertions(+), 10 deletions(-)
diff --git a/dlls/advapi32/registry.c b/dlls/advapi32/registry.c
index 620dd6a..06833d6 100644
--- a/dlls/advapi32/registry.c
+++ b/dlls/advapi32/registry.c
@@ -127,12 +127,12 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES
{
BOOL force_wow32 = is_win64 && (access & KEY_WOW64_32KEY);
NTSTATUS status = STATUS_OBJECT_NAME_NOT_FOUND;
+ HANDLE subkey, root = attr->RootDirectory;
- if (!force_wow32) status = NtCreateKey( (HANDLE *)retkey, access, attr, 0, class, options, dispos );
+ if (!force_wow32) status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos );
if (status == STATUS_OBJECT_NAME_NOT_FOUND)
{
- HANDLE subkey, root = attr->RootDirectory;
WCHAR *buffer = attr->ObjectName->Buffer;
DWORD attrs, pos = 0, i = 0, len = attr->ObjectName->Length / sizeof(WCHAR);
UNICODE_STRING str;
@@ -160,7 +160,7 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES
if (i == len)
{
attr->Attributes = attrs;
- status = NtCreateKey( (PHANDLE)retkey, access, attr, 0, class, options, dispos );
+ status = NtCreateKey( &subkey, access, attr, 0, class, options, dispos );
}
else
{
@@ -177,6 +177,13 @@ static NTSTATUS create_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES
while (i < len && buffer[i] != '\\') i++;
}
}
+ attr->RootDirectory = subkey;
+ if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory )))
+ {
+ if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
+ attr->RootDirectory = subkey;
+ }
+ *retkey = attr->RootDirectory;
return status;
}
@@ -214,7 +221,7 @@ static NTSTATUS open_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *a
if (i == len)
{
attr->Attributes = attrs;
- status = NtOpenKey( (PHANDLE)retkey, access, attr );
+ status = NtOpenKey( &subkey, access, attr );
}
else
{
@@ -223,12 +230,18 @@ static NTSTATUS open_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *a
}
if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
if (status) return status;
- if (i == len) break;
attr->RootDirectory = subkey;
+ if (i == len) break;
while (i < len && buffer[i] == '\\') i++;
pos = i;
while (i < len && buffer[i] != '\\') i++;
}
+ if (force_wow32 && (subkey = open_wow6432node( attr->RootDirectory )))
+ {
+ if (attr->RootDirectory != root) NtClose( attr->RootDirectory );
+ attr->RootDirectory = subkey;
+ }
+ *retkey = attr->RootDirectory;
return status;
}
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c
index 3acda0e..f0cfb5c 100644
--- a/dlls/advapi32/tests/registry.c
+++ b/dlls/advapi32/tests/registry.c
@@ -2142,12 +2142,10 @@ static void test_redirection(void)
err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software", 0, NULL, 0,
KEY_WOW64_32KEY | KEY_ALL_ACCESS, NULL, &key, NULL );
ok( err == ERROR_SUCCESS, "RegCreateKeyExA failed: %u\n", err );
- dw = get_key_value( key, "Wine\\Winetest", 0 );
- todo_wine ok( dw == 32, "wrong value %u\n", dw );
+ check_key_value( key, "Wine\\Winetest", 0, 32 );
dw = get_key_value( key, "Wine\\Winetest", KEY_WOW64_64KEY );
- todo_wine ok( dw == 32 || broken(dw == 64) /* vista */, "wrong value %u\n", dw );
- dw = get_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY );
- todo_wine ok( dw == 32, "wrong value %u\n", dw );
+ ok( dw == 32 || broken(dw == 64) /* vista */, "wrong value %u\n", dw );
+ check_key_value( key, "Wine\\Winetest", KEY_WOW64_32KEY, 32 );
RegCloseKey( key );
}
More information about the wine-cvs
mailing list