Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/advapi32/tests/registry.c | 23 +++++++++-------------- dlls/kernelbase/registry.c | 31 +++++++++++++++++++------------ 2 files changed, 28 insertions(+), 26 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 7e1348bf33d..3f3d7a4ac7a 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -3903,26 +3903,21 @@ static void test_performance_keys(void) todo_wine ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = RegOpenKeyA(keys[i], "Global", &key); - todo_wine_if (keys[i] == HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = RegOpenKeyExA(keys[i], "Global", 0, KEY_READ, &key); - todo_wine_if (keys[i] == HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
size = 0; ret = RegQueryValueA(keys[i], "Global", NULL, (LONG *)&size); - todo_wine_if (keys[i] == HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = RegSetValueA(keys[i], "Global", REG_SZ, "dummy", 5); - todo_wine_if (keys[i] == HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = RegQueryInfoKeyA(keys[i], NULL, NULL, NULL, &key_count, NULL, NULL, &value_count, NULL, NULL, NULL, NULL); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - ok(!ret, "got %u\n", ret); + todo_wine ok(!ret, "got %u\n", ret); todo_wine ok(!key_count, "got %u subkeys\n", key_count); todo_wine ok(value_count == 2, "got %u values\n", value_count);
@@ -3941,7 +3936,7 @@ static void test_performance_keys(void) }
ret = RegSetValueExA(HKEY_PERFORMANCE_DATA, "Global", 0, REG_SZ, (const BYTE *)"dummy", 5); - todo_wine ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = RegSetValueExA(HKEY_PERFORMANCE_TEXT, "Global", 0, REG_SZ, (const BYTE *)"dummy", 5); todo_wine ok(ret == ERROR_BADKEY, "got %u\n", ret); @@ -3952,7 +3947,7 @@ static void test_performance_keys(void) if (pRegSetKeyValueW) { ret = pRegSetKeyValueW(HKEY_PERFORMANCE_DATA, NULL, L"Global", REG_SZ, L"dummy", 10); - todo_wine ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = pRegSetKeyValueW(HKEY_PERFORMANCE_TEXT, NULL, L"Global", REG_SZ, L"dummy", 10); todo_wine ok(ret == ERROR_BADKEY, "got %u\n", ret); @@ -3962,7 +3957,7 @@ static void test_performance_keys(void) }
ret = RegEnumKeyA(HKEY_PERFORMANCE_DATA, 0, buffer, buffer_size); - todo_wine ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret); + ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
ret = RegEnumKeyA(HKEY_PERFORMANCE_TEXT, 0, buffer, buffer_size); todo_wine ok(ret == ERROR_NO_MORE_ITEMS, "got %u\n", ret); @@ -4101,7 +4096,7 @@ static void test_perflib_key(void) RtlInitUnicodeString(&string, L"\Registry\PerfData"); InitializeObjectAttributes(&attr, &string, OBJ_CASE_INSENSITIVE, NULL, NULL); ret = NtOpenKey((HANDLE *)&key, KEY_READ, &attr); - todo_wine ok(ret == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", ret); + ok(ret == STATUS_OBJECT_NAME_NOT_FOUND, "got %#x\n", ret);
free(buffer); } diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index d9d62e81b31..3a551ecbec5 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -56,7 +56,7 @@ static const WCHAR * const root_key_names[] = NULL, /* HKEY_CURRENT_USER is determined dynamically */ L"\Registry\Machine", L"\Registry\User", - L"\Registry\PerfData", + NULL, /* HKEY_PERFORMANCE_DATA is not a real key */ L"\Registry\Machine\System\CurrentControlSet\Hardware Profiles\Current", L"\Registry\DynData" }; @@ -330,21 +330,28 @@ static HKEY create_special_root_hkey( HKEY hkey, DWORD access ) /* map the hkey from special root to normal key if necessary */ static inline HKEY get_special_root_hkey( HKEY hkey, REGSAM access ) { - HKEY ret = hkey; + unsigned int index = HandleToUlong(hkey) - HandleToUlong(HKEY_SPECIAL_ROOT_FIRST); + DWORD wow64_flags = access & (KEY_WOW64_32KEY | KEY_WOW64_64KEY);
- if ((HandleToUlong(hkey) >= HandleToUlong(HKEY_SPECIAL_ROOT_FIRST)) - && (HandleToUlong(hkey) <= HandleToUlong(HKEY_SPECIAL_ROOT_LAST))) + switch (HandleToUlong(hkey)) { - REGSAM mask = 0; + case (LONG)(LONG_PTR)HKEY_CLASSES_ROOT: + if (wow64_flags) + return create_special_root_hkey( hkey, MAXIMUM_ALLOWED | wow64_flags ); + /* fall through */
- if (HandleToUlong(hkey) == HandleToUlong(HKEY_CLASSES_ROOT)) - mask = KEY_WOW64_32KEY | KEY_WOW64_64KEY; + case (LONG)(LONG_PTR)HKEY_CURRENT_USER: + case (LONG)(LONG_PTR)HKEY_LOCAL_MACHINE: + case (LONG)(LONG_PTR)HKEY_USERS: + case (LONG)(LONG_PTR)HKEY_CURRENT_CONFIG: + case (LONG)(LONG_PTR)HKEY_DYN_DATA: + if (special_root_keys[index]) + return special_root_keys[index]; + return create_special_root_hkey( hkey, MAXIMUM_ALLOWED );
- if ((access & mask) || - !(ret = special_root_keys[HandleToUlong(hkey) - HandleToUlong(HKEY_SPECIAL_ROOT_FIRST)])) - ret = create_special_root_hkey( hkey, MAXIMUM_ALLOWED | (access & mask) ); + default: + return hkey; } - return ret; }
@@ -1565,7 +1572,7 @@ LSTATUS WINAPI DECLSPEC_HOTPATCH RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWO hkey, debugstr_a(name), reserved, type, data, count, count ? *count : 0 );
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER; - if (hkey != HKEY_PERFORMANCE_DATA && !(hkey = get_special_root_hkey( hkey, 0 ))) + if (!(hkey = get_special_root_hkey( hkey, 0 ))) return ERROR_INVALID_HANDLE;
if (count) datalen = *count;