Skip to content

Commit

Permalink
kernelbase: Use KEY_WOW64_64KEY flag when 64 bit registry access is a…
Browse files Browse the repository at this point in the history
…ssumed.
  • Loading branch information
Paul Gofman authored and julliard committed Feb 28, 2024
1 parent 6198346 commit 6cbe072
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
22 changes: 22 additions & 0 deletions dlls/advapi32/tests/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,28 @@ static void test_redirection(void)
RegCloseKey( root32 );
RegCloseKey( root64 );

err = RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Software\\WOW6432Node\\test1\\test2", 0, NULL, 0,
KEY_WRITE | KEY_WOW64_32KEY, NULL, &key, NULL );
ok(!err, "got %#lx.\n", err);
RegCloseKey(key);

err = RegCreateKeyExW( HKEY_LOCAL_MACHINE, L"Software\\test1\\test2", 0, NULL, 0, KEY_WRITE | KEY_WOW64_32KEY,
NULL, &key, NULL );
ok(!err, "got %#lx.\n", err);
RegCloseKey(key);

err = RegOpenKeyExW( HKEY_LOCAL_MACHINE, L"Software\\test1\\test2", 0, KEY_WRITE | KEY_WOW64_32KEY, &key );
ok(!err, "got %#lx.\n", err);
RegCloseKey(key);

if (pRegDeleteTreeA)
{
err = pRegDeleteTreeA(HKEY_LOCAL_MACHINE, "Software\\WOW6432Node\\test1");
ok(!err, "got %#lx.\n", err);
err = pRegDeleteTreeA(HKEY_LOCAL_MACHINE, "Software\\test1");
ok(err == ERROR_FILE_NOT_FOUND, "got %#lx.\n", err);
}

/* Software\Classes is shared/reflected so behavior is different */

err = RegCreateKeyExA( HKEY_LOCAL_MACHINE, "Software\\Classes\\Wine",
Expand Down
4 changes: 2 additions & 2 deletions dlls/kernelbase/registry.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ static HANDLE open_wow6432node( HANDLE key )
attr.Attributes = 0;
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
if (NtOpenKeyEx( &ret, MAXIMUM_ALLOWED, &attr, 0 )) return key;
if (NtOpenKeyEx( &ret, MAXIMUM_ALLOWED | KEY_WOW64_64KEY, &attr, 0 )) return key;
return ret;
}

Expand Down Expand Up @@ -211,7 +211,7 @@ static NTSTATUS open_key( HKEY *retkey, HKEY root, UNICODE_STRING *name, DWORD o
static NTSTATUS open_subkey( HKEY *subkey, HKEY root, UNICODE_STRING *name, DWORD options, ACCESS_MASK access )
{
BOOL is_wow64_key = (is_win64 && (access & KEY_WOW64_32KEY)) || (is_wow64 && !(access & KEY_WOW64_64KEY));
ACCESS_MASK access_64 = access & ~KEY_WOW64_32KEY;
ACCESS_MASK access_64 = (access & ~KEY_WOW64_32KEY) | KEY_WOW64_64KEY;
DWORD i = 0, len = name->Length / sizeof(WCHAR);
WCHAR *buffer = name->Buffer;
UNICODE_STRING str;
Expand Down

0 comments on commit 6cbe072

Please sign in to comment.