Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=33037 Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/advapi32/tests/registry.c | 134 +++++++++------------------------ dlls/kernelbase/registry.c | 11 ++- 2 files changed, 46 insertions(+), 99 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 4da2ce100ab..bccc5706131 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -3700,21 +3700,18 @@ static void test_performance_keys(void)
size = 0; ret = RegQueryValueExA(keys[i], names[j], NULL, NULL, NULL, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_MORE_DATA, "got %u\n", ret); + ok(ret == ERROR_MORE_DATA, "got %u\n", ret); ok(!size, "got size %u\n", size);
size = 10; ret = RegQueryValueExA(keys[i], names[j], NULL, NULL, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_MORE_DATA, "got %u\n", ret); - todo_wine_if (keys[i] == HKEY_PERFORMANCE_DATA) + ok(ret == ERROR_MORE_DATA, "got %u\n", ret); + todo_wine ok(size == 10, "got size %u\n", size);
size = buffer_size; ret = RegQueryValueExA(keys[i], names[j], NULL, NULL, NULL, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - ok(ret == ERROR_MORE_DATA, "got %u\n", ret); + ok(ret == ERROR_MORE_DATA, "got %u\n", ret);
QueryPerformanceCounter(&perftime1); NtQuerySystemTime(&systime1); @@ -3722,18 +3719,9 @@ static void test_performance_keys(void) size = buffer_size; type = 0xdeadbeef; ret = RegQueryValueExA(keys[i], names[j], NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_BINARY, "got type %u\n", type); - ok(size >= sizeof(PERF_DATA_BLOCK) && size < buffer_size, "got size %u\n", size); - } - - if (ret) - { - winetest_pop_context(); - continue; - } + ok(!ret, "got %u\n", ret); + ok(type == REG_BINARY, "got type %u\n", type); + ok(size >= sizeof(PERF_DATA_BLOCK) && size < buffer_size, "got size %u\n", size);
QueryPerformanceCounter(&perftime2); NtQuerySystemTime(&systime2); @@ -3785,129 +3773,81 @@ static void test_performance_keys(void)
size = 0xdeadbeef; ret = RegQueryValueExA(keys[i], "cOuNtEr", NULL, NULL, NULL, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(size > 0 && size < 0xdeadbeef, "got size %u\n", size); - } + ok(!ret, "got %u\n", ret); + ok(size > 0 && size < 0xdeadbeef, "got size %u\n", size);
type = 0xdeadbeef; size = 0; ret = RegQueryValueExA(keys[i], "cOuNtEr", NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(ret == ERROR_MORE_DATA, "got %u\n", ret); - ok(size > 0, "got size %u\n", size); - } + ok(ret == ERROR_MORE_DATA, "got %u\n", ret); + ok(size > 0, "got size %u\n", size);
type = 0xdeadbeef; size = buffer_size; ret = RegQueryValueExA(keys[i], "cOuNtEr", NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_MULTI_SZ, "got type %u\n", type); - } - if (type == REG_MULTI_SZ) - test_counter_values(buffer, keys[i]); + ok(!ret, "got %u\n", ret); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + test_counter_values(buffer, keys[i]);
type = 0xdeadbeef; size = buffer_size; ret = RegQueryValueExA(keys[i], "cOuNtErwine", NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_MULTI_SZ, "got type %u\n", type); - } - if (type == REG_MULTI_SZ) - test_counter_values(buffer, keys[i]); + ok(!ret, "got %u\n", ret); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + test_counter_values(buffer, keys[i]);
size = 0; ret = RegQueryValueExW(keys[i], L"cOuNtEr", NULL, NULL, NULL, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(size > 0, "got size %u\n", size); - } + ok(!ret, "got %u\n", ret); + ok(size > 0, "got size %u\n", size);
bufferW = malloc(size);
type = 0xdeadbeef; ret = RegQueryValueExW(keys[i], L"cOuNtEr", NULL, &type, bufferW, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_MULTI_SZ, "got type %u\n", type); - } - if (type == REG_MULTI_SZ) - { - WideCharToMultiByte(CP_ACP, 0, bufferW, size / sizeof(WCHAR), buffer, buffer_size, NULL, NULL); - test_counter_values(buffer, keys[i]); - } + ok(!ret, "got %u\n", ret); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + WideCharToMultiByte(CP_ACP, 0, bufferW, size / sizeof(WCHAR), buffer, buffer_size, NULL, NULL); + test_counter_values(buffer, keys[i]);
/* test the "Help" value */
size = 0xdeadbeef; ret = RegQueryValueExA(keys[i], "hElP", NULL, NULL, NULL, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(size > 0 && size < 0xdeadbeef, "got size %u\n", size); - } + ok(!ret, "got %u\n", ret); + ok(size > 0 && size < 0xdeadbeef, "got size %u\n", size);
type = 0xdeadbeef; size = 0; ret = RegQueryValueExA(keys[i], "hElP", NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(ret == ERROR_MORE_DATA, "got %u\n", ret); - ok(size > 0, "got size %u\n", size); - } + ok(ret == ERROR_MORE_DATA, "got %u\n", ret); + ok(size > 0, "got size %u\n", size);
type = 0xdeadbeef; size = buffer_size; ret = RegQueryValueExA(keys[i], "hElP", NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_MULTI_SZ, "got type %u\n", type); - } - if (type == REG_MULTI_SZ) - test_help_values(buffer, keys[i]); + test_help_values(buffer, keys[i]);
type = 0xdeadbeef; size = buffer_size; ret = RegQueryValueExA(keys[i], "hElPwine", NULL, &type, buffer, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_MULTI_SZ, "got type %u\n", type); - } - if (type == REG_MULTI_SZ) - test_help_values(buffer, keys[i]); + ok(!ret, "got %u\n", ret); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + test_help_values(buffer, keys[i]);
size = 0; ret = RegQueryValueExW(keys[i], L"hElP", NULL, NULL, NULL, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(size > 0, "got size %u\n", size); - } + ok(!ret, "got %u\n", ret); + ok(size > 0, "got size %u\n", size);
bufferW = malloc(size);
type = 0xdeadbeef; ret = RegQueryValueExW(keys[i], L"hElP", NULL, &type, bufferW, &size); - todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) - { - ok(!ret, "got %u\n", ret); - ok(type == REG_MULTI_SZ, "got type %u\n", type); - } - if (type == REG_MULTI_SZ) - { - WideCharToMultiByte(CP_ACP, 0, bufferW, size / sizeof(WCHAR), buffer, buffer_size, NULL, NULL); - test_help_values(buffer, keys[i]); - } + ok(!ret, "got %u\n", ret); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + WideCharToMultiByte(CP_ACP, 0, bufferW, size / sizeof(WCHAR), buffer, buffer_size, NULL, NULL); + test_help_values(buffer, keys[i]);
/* test other registry APIs */
diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index c3d5cdbc6e0..a8f0643e8bf 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -354,6 +354,13 @@ static inline HKEY get_special_root_hkey( HKEY hkey, REGSAM access ) } }
+static BOOL is_perf_key( HKEY key ) +{ + return HandleToUlong(key) == HandleToUlong(HKEY_PERFORMANCE_DATA) + || HandleToUlong(key) == HandleToUlong(HKEY_PERFORMANCE_TEXT) + || HandleToUlong(key) == HandleToUlong(HKEY_PERFORMANCE_NLSTEXT); +} +
/****************************************************************************** * RemapPredefinedHandleInternal (kernelbase.@) @@ -1526,7 +1533,7 @@ LSTATUS WINAPI DECLSPEC_HOTPATCH RegQueryValueExW( HKEY hkey, LPCWSTR name, LPDW
if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
- if (hkey == HKEY_PERFORMANCE_DATA) + if (is_perf_key( hkey )) return query_perf_data( name, type, data, count, TRUE );
if (!(hkey = get_special_root_hkey( hkey, 0 ))) return ERROR_INVALID_HANDLE; @@ -1632,7 +1639,7 @@ LSTATUS WINAPI DECLSPEC_HOTPATCH RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWO if ((status = RtlAnsiStringToUnicodeString( &nameW, &nameA, TRUE ))) return RtlNtStatusToDosError(status);
- if (hkey == HKEY_PERFORMANCE_DATA) + if (is_perf_key( hkey )) { DWORD ret = query_perf_data( nameW.Buffer, type, data, count, FALSE ); RtlFreeUnicodeString( &nameW );