Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/advapi32/tests/registry.c | 517 +++++++++++++++++++++------------ 1 file changed, 338 insertions(+), 179 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 4daf40b7aad..7e1348bf33d 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -3600,218 +3600,377 @@ static void test_RegNotifyChangeKeyValue(void) CloseHandle(event); }
-#define cmp_li(a, b, c) cmp_li_real(a, b, c, __LINE__) -static void cmp_li_real(LARGE_INTEGER *l1, LARGE_INTEGER *l2, LONGLONG slack, int line) +static const char *find_counter_value(const char *text, const char *index) { - LONGLONG diff = l2->QuadPart - l1->QuadPart; - if (diff < 0) diff = -diff; - ok_(__FILE__, line)(diff <= slack, "values don't match: %s/%s\n", - wine_dbgstr_longlong(l1->QuadPart), wine_dbgstr_longlong(l2->QuadPart)); + const char *p = text; + + while (*p) + { + if (!strcmp(p, index)) + return p + strlen(p) + 1; + + p += strlen(p) + 1; + p += strlen(p) + 1; + } + + return NULL; }
-static void test_RegQueryValueExPerformanceData(void) +static void test_counter_values(const char *text, HKEY key) { - static const char * const names[] = { NULL, "", "Global", "2", "invalid counter name" }; - DWORD cbData, len, i, type; - BYTE *value; - DWORD dwret; - LONG limit = 6; - PERF_DATA_BLOCK *pdb; - HKEY hkey; - BYTE buf[256 + sizeof(PERF_DATA_BLOCK)]; + const char *p = text; + const char *name;
- /* Test with data == NULL */ - dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, NULL, &cbData ); - ok( dwret == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", dwret ); + ok(!strcmp(p, "1"), "got first index %s\n", debugstr_a(p)); + p += strlen(p) + 1; + ok(!strcmp(p, "1847"), "got first name %s\n", debugstr_a(p)); + p += strlen(p) + 1;
- dwret = RegQueryValueExW( HKEY_PERFORMANCE_DATA, L"Global", NULL, NULL, NULL, &cbData ); - ok( dwret == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", dwret ); - - /* Test ERROR_MORE_DATA, start with small buffer */ - len = 10; - value = HeapAlloc(GetProcessHeap(), 0, len); - cbData = len; - type = 0xdeadbeef; - dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, &type, value, &cbData ); - ok( dwret == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", dwret ); - ok(type == REG_BINARY, "got %u\n", type); - while( dwret == ERROR_MORE_DATA && limit) + while (*p) { - len = len * 10; - value = HeapReAlloc( GetProcessHeap(), 0, value, len ); - cbData = len; - type = 0xdeadbeef; - dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, &type, value, &cbData ); - limit--; - } - ok(limit > 0, "too many times ERROR_MORE_DATA returned\n"); + unsigned int index = atoi(p);
- ok(dwret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", dwret); - ok(type == REG_BINARY, "got %u\n", type); + ok(index > 0, "expected nonzero index\n");
- /* Check returned data */ - if (dwret == ERROR_SUCCESS) - { - ok(len >= sizeof(PERF_DATA_BLOCK), "got size %d\n", len); - if (len >= sizeof(PERF_DATA_BLOCK)) { - pdb = (PERF_DATA_BLOCK*) value; - ok(pdb->Signature[0] == 'P', "expected Signature[0] = 'P', got 0x%x\n", pdb->Signature[0]); - ok(pdb->Signature[1] == 'E', "expected Signature[1] = 'E', got 0x%x\n", pdb->Signature[1]); - ok(pdb->Signature[2] == 'R', "expected Signature[2] = 'R', got 0x%x\n", pdb->Signature[2]); - ok(pdb->Signature[3] == 'F', "expected Signature[3] = 'F', got 0x%x\n", pdb->Signature[3]); - /* TODO: check other field */ - } + p += strlen(p) + 1; + ok(*p, "name missing for %u\n", index); + p += strlen(p) + 1; }
- HeapFree(GetProcessHeap(), 0, value); + name = find_counter_value(text, "1846"); + ok(name != NULL, "did not find name\n"); + if (key != HKEY_PERFORMANCE_NLSTEXT) + ok(!strcmp(name, "End Marker"), "got name %s\n", debugstr_a(name)); +}
- for (i = 0; i < ARRAY_SIZE(names); i++) +static void test_help_values(const char *text, HKEY key) +{ + const char *p = text; + const char *name; + + while (*p) { - cbData = 0xdeadbeef; - dwret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, names[i], NULL, NULL, NULL, &cbData); - ok(dwret == ERROR_MORE_DATA, "%u/%s: got %u\n", i, names[i], dwret); - ok(cbData == 0, "got %u\n", cbData); + unsigned int index = atoi(p);
- cbData = 0; - dwret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, names[i], NULL, NULL, NULL, &cbData); - ok(dwret == ERROR_MORE_DATA, "%u/%s: got %u\n", i, names[i], dwret); - ok(cbData == 0, "got %u\n", cbData); + ok(index > 0, "expected nonzero index\n");
- cbData = 0xdeadbeef; - dwret = RegQueryValueExA(HKEY_PERFORMANCE_TEXT, names[i], NULL, NULL, NULL, &cbData); -todo_wine - ok(dwret == ERROR_MORE_DATA, "%u/%s: got %u\n", i, names[i], dwret); - ok(cbData == 0, "got %u\n", cbData); - - cbData = 0; - dwret = RegQueryValueExA(HKEY_PERFORMANCE_TEXT, names[i], NULL, NULL, NULL, &cbData); -todo_wine - ok(dwret == ERROR_MORE_DATA, "%u/%s: got %u\n", i, names[i], dwret); - ok(cbData == 0, "got %u\n", cbData); - - cbData = 0xdeadbeef; - dwret = RegQueryValueExA(HKEY_PERFORMANCE_NLSTEXT, names[i], NULL, NULL, NULL, &cbData); -todo_wine - ok(dwret == ERROR_MORE_DATA, "%u/%s: got %u\n", i, names[i], dwret); - ok(cbData == 0, "got %u\n", cbData); - - cbData = 0; - dwret = RegQueryValueExA(HKEY_PERFORMANCE_NLSTEXT, names[i], NULL, NULL, NULL, &cbData); -todo_wine - ok(dwret == ERROR_MORE_DATA, "%u/%s: got %u\n", i, names[i], dwret); - ok(cbData == 0, "got %u\n", cbData); + p += strlen(p) + 1; + p += strlen(p) + 1; }
- memset(buf, 0x77, sizeof(buf)); - type = 0xdeadbeef; - cbData = sizeof(buf); - dwret = RegQueryValueExA(HKEY_PERFORMANCE_DATA, "invalid counter name", NULL, &type, buf, &cbData); - ok(dwret == ERROR_SUCCESS, "got %u\n", dwret); - ok(type == REG_BINARY, "got %u\n", type); - if (dwret == ERROR_SUCCESS) + name = find_counter_value(text, "1847"); + ok(name != NULL, "did not find name\n"); + if (key != HKEY_PERFORMANCE_NLSTEXT) + ok(!strcmp(name, "End Marker"), "got name %s\n", debugstr_a(name)); +} + +static void test_performance_keys(void) +{ + static const HKEY keys[] = {HKEY_PERFORMANCE_DATA, HKEY_PERFORMANCE_TEXT, HKEY_PERFORMANCE_NLSTEXT}; + static const char *const names[] = {NULL, "", "Global", "2", "invalid counter name", "System"}; + DWORD size, type, sysname_len, expect_size, key_count, value_count; + LARGE_INTEGER perftime1, perftime2, systime1, systime2, freq; + WCHAR sysname[MAX_COMPUTERNAME_LENGTH + 1]; + unsigned int buffer_size = 1024 * 1024; + void *buffer, *bufferW; + PERF_DATA_BLOCK *data; + union { - SYSTEMTIME st; - WCHAR sysname[MAX_COMPUTERNAME_LENGTH + 1]; - DWORD sysname_len; - LARGE_INTEGER counter, freq, ftime; + FILETIME f; + LONGLONG l; + } file_time; + unsigned int i, j; + HKEY key; + LONG ret;
- GetSystemTime(&st); - GetSystemTimeAsFileTime((FILETIME *)&ftime); - QueryPerformanceCounter(&counter); - QueryPerformanceFrequency(&freq); + buffer = malloc(buffer_size);
- sysname_len = MAX_COMPUTERNAME_LENGTH + 1; - GetComputerNameW(sysname, &sysname_len); + sysname_len = ARRAY_SIZE(sysname); + GetComputerNameW(sysname, &sysname_len);
- pdb = (PERF_DATA_BLOCK *)buf; - ok(pdb->Signature[0] == 'P', "got '%c'\n", pdb->Signature[0]); - ok(pdb->Signature[1] == 'E', "got '%c'\n", pdb->Signature[1]); - ok(pdb->Signature[2] == 'R', "got '%c'\n", pdb->Signature[2]); - ok(pdb->Signature[3] == 'F', "got '%c'\n", pdb->Signature[3]); + for (i = 0; i < ARRAY_SIZE(keys); ++i) + { + winetest_push_context("key %p", keys[i]);
- ok(pdb->LittleEndian == 1, "got %u\n", pdb->LittleEndian); - ok(pdb->Version == 1, "got %u\n", pdb->Version); - ok(pdb->Revision == 1, "got %u\n", pdb->Revision); - len = (sizeof(*pdb) + pdb->SystemNameLength + 7) & ~7; - ok(pdb->TotalByteLength == len, "got %u vs %u\n", pdb->TotalByteLength, len); - ok(pdb->HeaderLength == pdb->TotalByteLength, "got %u\n", pdb->HeaderLength); - ok(pdb->NumObjectTypes == 0, "got %u\n", pdb->NumObjectTypes); -todo_wine - ok(pdb->DefaultObject != 0, "got %u\n", pdb->DefaultObject); - ok(pdb->SystemTime.wYear == st.wYear, "got %u\n", pdb->SystemTime.wYear); - ok(pdb->SystemTime.wMonth == st.wMonth, "got %u\n", pdb->SystemTime.wMonth); - ok(pdb->SystemTime.wDayOfWeek == st.wDayOfWeek, "got %u\n", pdb->SystemTime.wDayOfWeek); - ok(pdb->SystemTime.wDay == st.wDay, "got %u\n", pdb->SystemTime.wDay); - if (U(pdb->PerfTime).LowPart != 0x77777777) /* TestBot is broken */ - cmp_li(&pdb->PerfTime, &counter, freq.QuadPart); - if (U(pdb->PerfFreq).LowPart != 0x77777777) /* TestBot is broken */ - cmp_li(&pdb->PerfFreq, &freq, 0); - cmp_li(&pdb->PerfTime100nSec, &ftime, 200000); /* TestBot needs huge slack value */ - ok(pdb->SystemNameLength == (sysname_len + 1) * sizeof(WCHAR), "expected %u, got %u\n", - (sysname_len + 1) * 2 /*sizeof(WCHAR)*/, pdb->SystemNameLength); - ok(pdb->SystemNameOffset == sizeof(*pdb), "got %u\n", pdb->SystemNameOffset); - ok(!lstrcmpW(sysname, (LPCWSTR)(pdb + 1)), "%s != %s\n", - wine_dbgstr_w(sysname), wine_dbgstr_w((LPCWSTR)(pdb + 1))); - - len = pdb->TotalByteLength - (sizeof(*pdb) + pdb->SystemNameLength); - if (len) + for (j = 0; j < ARRAY_SIZE(names); ++j) { - BYTE remainder[8], *p; + winetest_push_context("value %s", debugstr_a(names[j]));
- memset(remainder, 0x77, sizeof(remainder)); - p = buf + sizeof(*pdb) + pdb->SystemNameLength; - ok(!memcmp(p, remainder, len), "remainder: %02x,%02x...\n", p[0], p[1]); + QueryPerformanceFrequency(&freq); + + 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(!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(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); + + QueryPerformanceCounter(&perftime1); + NtQuerySystemTime(&systime1); + + 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; + } + + QueryPerformanceCounter(&perftime2); + NtQuerySystemTime(&systime2); + + data = buffer; + ok(!wcsncmp(data->Signature, L"PERF", 4), "got signature %s\n", + debugstr_wn(data->Signature, 4)); + ok(data->LittleEndian == 1, "got endianness %u\n", data->LittleEndian); + ok(data->Version == 1, "got version %u\n", data->Version); + ok(data->Revision == 1, "got version %u\n", data->Revision); + ok(data->TotalByteLength == size, "expected size %u, got %u\n", + size, data->TotalByteLength); + + expect_size = sizeof(PERF_DATA_BLOCK) + data->SystemNameLength; + expect_size = (expect_size + 7) & ~7; + + ok(data->HeaderLength == expect_size, "expected header size %u, got %u\n", + expect_size, data->HeaderLength); + /* todo: test objects... */ + todo_wine ok(data->DefaultObject == 238, "got default object %u\n", data->DefaultObject); + + ok(data->PerfTime.QuadPart >= perftime1.QuadPart + && data->PerfTime.QuadPart <= perftime2.QuadPart, + "got times %I64u, %I64u, %I64u\n", + perftime1.QuadPart, data->PerfTime.QuadPart, perftime2.QuadPart); + ok(data->PerfFreq.QuadPart == freq.QuadPart, "expected frequency %I64u, got %I64u\n", + freq.QuadPart, data->PerfFreq.QuadPart); + ok(data->PerfTime100nSec.QuadPart >= systime1.QuadPart + && data->PerfTime100nSec.QuadPart <= systime2.QuadPart, + "got times %I64u, %I64u, %I64u\n", + systime1.QuadPart, data->PerfTime100nSec.QuadPart, systime2.QuadPart); + SystemTimeToFileTime(&data->SystemTime, &file_time.f); + /* SYSTEMTIME has a granularity of 1 ms */ + ok(file_time.l >= systime1.QuadPart - 10000 && file_time.l <= systime2.QuadPart, + "got times %I64u, %I64u, %I64u\n", systime1.QuadPart, file_time.l, systime2.QuadPart); + + ok(data->SystemNameLength == (sysname_len + 1) * sizeof(WCHAR), + "expected name len %u, got %u\n", + (sysname_len + 1) * sizeof(WCHAR), data->SystemNameLength); + ok(data->SystemNameOffset == sizeof(PERF_DATA_BLOCK), + "got name offset %u\n", data->SystemNameOffset); + ok(!wcscmp(sysname, (const WCHAR *)(data + 1)), "expected name %s, got %s\n", + debugstr_w(sysname), debugstr_w((const WCHAR *)(data + 1))); + + winetest_pop_context(); } + + /* test the "Counter" value */ + + size = 0xdeadbeef; + ret = RegQueryValueExA(keys[i], "cOuNtEr", NULL, NULL, NULL, &size); + todo_wine + { + 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); + todo_wine 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); + todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + if (type == REG_MULTI_SZ) + 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); + todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + if (type == REG_MULTI_SZ) + test_counter_values(buffer, keys[i]); + + size = 0; + ret = RegQueryValueExW(keys[i], L"cOuNtEr", NULL, NULL, NULL, &size); + todo_wine + { + 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 + { + 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]); + } + + /* test the "Help" value */ + + size = 0xdeadbeef; + ret = RegQueryValueExA(keys[i], "hElP", NULL, NULL, NULL, &size); + todo_wine + { + 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); + todo_wine 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); + todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + if (type == REG_MULTI_SZ) + 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); + todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + if (type == REG_MULTI_SZ) + test_help_values(buffer, keys[i]); + + size = 0; + ret = RegQueryValueExW(keys[i], L"hElP", NULL, NULL, NULL, &size); + todo_wine + { + 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 + { + 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]); + } + + /* test other registry APIs */ + + ret = RegOpenKeyA(keys[i], NULL, &key); + 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); + + 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); + + 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); + + 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); + + 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(!key_count, "got %u subkeys\n", key_count); + todo_wine ok(value_count == 2, "got %u values\n", value_count); + + size = buffer_size; + ret = RegEnumValueA(keys[i], 0, buffer, &size, NULL, NULL, NULL, NULL); + todo_wine ok(ret == ERROR_MORE_DATA, "got %u\n", ret); + ok(size == buffer_size, "got size %u\n", size); + + ret = RegCloseKey(keys[i]); + ok(!ret, "got %u\n", ret); + + ret = RegCloseKey(keys[i]); + ok(!ret, "got %u\n", ret); + + winetest_pop_context(); }
- dwret = RegOpenKeyA(HKEY_PERFORMANCE_DATA, NULL, &hkey); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); + ret = RegSetValueExA(HKEY_PERFORMANCE_DATA, "Global", 0, REG_SZ, (const BYTE *)"dummy", 5); + todo_wine ok(ret == ERROR_INVALID_HANDLE, "got %u\n", ret);
- dwret = RegOpenKeyA(HKEY_PERFORMANCE_DATA, "Global", &hkey); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); + ret = RegSetValueExA(HKEY_PERFORMANCE_TEXT, "Global", 0, REG_SZ, (const BYTE *)"dummy", 5); + todo_wine ok(ret == ERROR_BADKEY, "got %u\n", ret);
- dwret = RegOpenKeyExA(HKEY_PERFORMANCE_DATA, "Global", 0, KEY_READ, &hkey); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); - - dwret = RegQueryValueA(HKEY_PERFORMANCE_DATA, "Global", NULL, (LONG *)&cbData); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); - - dwret = RegSetValueA(HKEY_PERFORMANCE_DATA, "Global", REG_SZ, "dummy", 4); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); - - dwret = RegSetValueExA(HKEY_PERFORMANCE_DATA, "Global", 0, REG_SZ, (const BYTE *)"dummy", 40); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); - - cbData = sizeof(buf); - dwret = RegEnumKeyA(HKEY_PERFORMANCE_DATA, 0, (LPSTR)buf, cbData); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); - - cbData = sizeof(buf); - dwret = RegEnumValueA(HKEY_PERFORMANCE_DATA, 0, (LPSTR)buf, &cbData, NULL, NULL, NULL, NULL); -todo_wine - ok(dwret == ERROR_MORE_DATA, "got %u\n", dwret); -todo_wine - ok(cbData == sizeof(buf), "got %u\n", cbData); - - dwret = RegEnumValueA(HKEY_PERFORMANCE_DATA, 0, NULL, &cbData, NULL, NULL, NULL, NULL); - ok(dwret == ERROR_INVALID_PARAMETER, "got %u\n", dwret); + ret = RegSetValueExA(HKEY_PERFORMANCE_NLSTEXT, "Global", 0, REG_SZ, (const BYTE *)"dummy", 5); + todo_wine ok(ret == ERROR_BADKEY, "got %u\n", ret);
if (pRegSetKeyValueW) { - dwret = pRegSetKeyValueW(HKEY_PERFORMANCE_DATA, NULL, L"Global", REG_SZ, L"dummy", 10); -todo_wine - ok(dwret == ERROR_INVALID_HANDLE, "got %u\n", dwret); + ret = pRegSetKeyValueW(HKEY_PERFORMANCE_DATA, NULL, L"Global", REG_SZ, L"dummy", 10); + todo_wine 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); + + ret = pRegSetKeyValueW(HKEY_PERFORMANCE_NLSTEXT, NULL, L"Global", REG_SZ, L"dummy", 10); + todo_wine ok(ret == ERROR_BADKEY, "got %u\n", ret); }
- dwret = RegCloseKey(HKEY_PERFORMANCE_DATA); - ok(dwret == ERROR_SUCCESS, "got %u\n", dwret); + ret = RegEnumKeyA(HKEY_PERFORMANCE_DATA, 0, buffer, buffer_size); + todo_wine 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); + + ret = RegEnumKeyA(HKEY_PERFORMANCE_NLSTEXT, 0, buffer, buffer_size); + todo_wine ok(ret == ERROR_NO_MORE_ITEMS, "got %u\n", ret); + + free(buffer); }
static void test_perflib_key(void) @@ -4348,7 +4507,7 @@ START_TEST(registry) test_delete_key_value(); test_RegOpenCurrentUser(); test_RegNotifyChangeKeyValue(); - test_RegQueryValueExPerformanceData(); + test_performance_keys(); test_RegLoadMUIString(); test_EnumDynamicTimeZoneInformation(); test_perflib_key();
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;
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/advapi32/tests/registry.c | 18 ++++++++++++------ dlls/kernelbase/registry.c | 30 +++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 9 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 3f3d7a4ac7a..811117beadc 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -3785,7 +3785,7 @@ static void test_performance_keys(void)
size = 0xdeadbeef; ret = RegQueryValueExA(keys[i], "cOuNtEr", NULL, NULL, NULL, &size); - todo_wine + todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) { ok(!ret, "got %u\n", ret); ok(size > 0 && size < 0xdeadbeef, "got size %u\n", size); @@ -3795,15 +3795,19 @@ static void test_performance_keys(void) 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); - todo_wine ok(size > 0, "got size %u\n", size); + 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); - todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + } if (type == REG_MULTI_SZ) test_counter_values(buffer, keys[i]);
@@ -3811,14 +3815,16 @@ static void test_performance_keys(void) 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); - todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + } if (type == REG_MULTI_SZ) test_counter_values(buffer, keys[i]);
size = 0; ret = RegQueryValueExW(keys[i], L"cOuNtEr", NULL, NULL, NULL, &size); - todo_wine + todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) { ok(!ret, "got %u\n", ret); ok(size > 0, "got size %u\n", size); @@ -3828,7 +3834,7 @@ static void test_performance_keys(void)
type = 0xdeadbeef; ret = RegQueryValueExW(keys[i], L"cOuNtEr", NULL, &type, bufferW, &size); - todo_wine + todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) { ok(!ret, "got %u\n", ret); ok(type == REG_MULTI_SZ, "got type %u\n", type); diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 3a551ecbec5..31698cb0948 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -1204,6 +1204,27 @@ LONG WINAPI RegSetKeyValueA( HKEY hkey, LPCSTR subkey, LPCSTR name, DWORD type, return ret; }
+/* FIXME: we should read data from system32/perf009c.dat (or perf###c depending + * on locale) instead */ +static DWORD query_perf_names( DWORD *type, void *data, DWORD *ret_size, BOOL unicode ) +{ + static const WCHAR names[] = L"1\0" "1847\0" "1846\0End Marker\0"; + DWORD size = *ret_size; + + if (type) *type = REG_MULTI_SZ; + *ret_size = sizeof(names); + if (!unicode) *ret_size /= sizeof(WCHAR); + + if (!data) return ERROR_SUCCESS; + if (size < *ret_size) return ERROR_MORE_DATA; + + if (unicode) + memcpy( data, names, sizeof(names) ); + else + RtlUnicodeToMultiByteN( data, size, NULL, names, sizeof(names) ); + return ERROR_SUCCESS; +} + struct perf_provider { HMODULE perflib; @@ -1338,7 +1359,7 @@ static DWORD collect_data(struct perf_provider *provider, const WCHAR *query, vo
#define MAX_SERVICE_NAME 260
-static DWORD query_perf_data(const WCHAR *query, DWORD *type, void *data, DWORD *ret_size) +static DWORD query_perf_data( const WCHAR *query, DWORD *type, void *data, DWORD *ret_size, BOOL unicode ) { DWORD err, i, data_size; HKEY root; @@ -1347,6 +1368,9 @@ static DWORD query_perf_data(const WCHAR *query, DWORD *type, void *data, DWORD if (!ret_size) return ERROR_INVALID_PARAMETER;
+ if (!wcsnicmp( query, L"counter", 7 )) + return query_perf_names( type, data, ret_size, unicode ); + data_size = *ret_size; *ret_size = 0;
@@ -1480,7 +1504,7 @@ LSTATUS WINAPI DECLSPEC_HOTPATCH RegQueryValueExW( HKEY hkey, LPCWSTR name, LPDW if ((data && !count) || reserved) return ERROR_INVALID_PARAMETER;
if (hkey == HKEY_PERFORMANCE_DATA) - return query_perf_data(name, type, data, count); + return query_perf_data( name, type, data, count, TRUE );
if (!(hkey = get_special_root_hkey( hkey, 0 ))) return ERROR_INVALID_HANDLE;
@@ -1587,7 +1611,7 @@ LSTATUS WINAPI DECLSPEC_HOTPATCH RegQueryValueExA( HKEY hkey, LPCSTR name, LPDWO
if (hkey == HKEY_PERFORMANCE_DATA) { - DWORD ret = query_perf_data( nameW.Buffer, type, data, count ); + DWORD ret = query_perf_data( nameW.Buffer, type, data, count, FALSE ); RtlFreeUnicodeString( &nameW ); return ret; }
Signed-off-by: Zebediah Figura zfigura@codeweavers.com --- dlls/advapi32/tests/registry.c | 18 ++++++++++++------ dlls/kernelbase/registry.c | 23 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 6 deletions(-)
diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index 811117beadc..4da2ce100ab 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -3849,7 +3849,7 @@ static void test_performance_keys(void)
size = 0xdeadbeef; ret = RegQueryValueExA(keys[i], "hElP", NULL, NULL, NULL, &size); - todo_wine + todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) { ok(!ret, "got %u\n", ret); ok(size > 0 && size < 0xdeadbeef, "got size %u\n", size); @@ -3859,15 +3859,19 @@ static void test_performance_keys(void) 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); - todo_wine ok(size > 0, "got size %u\n", size); + 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); - todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + } if (type == REG_MULTI_SZ) test_help_values(buffer, keys[i]);
@@ -3875,14 +3879,16 @@ static void test_performance_keys(void) 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); - todo_wine ok(type == REG_MULTI_SZ, "got type %u\n", type); + ok(type == REG_MULTI_SZ, "got type %u\n", type); + } if (type == REG_MULTI_SZ) test_help_values(buffer, keys[i]);
size = 0; ret = RegQueryValueExW(keys[i], L"hElP", NULL, NULL, NULL, &size); - todo_wine + todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) { ok(!ret, "got %u\n", ret); ok(size > 0, "got size %u\n", size); @@ -3892,7 +3898,7 @@ static void test_performance_keys(void)
type = 0xdeadbeef; ret = RegQueryValueExW(keys[i], L"hElP", NULL, &type, bufferW, &size); - todo_wine + todo_wine_if (keys[i] != HKEY_PERFORMANCE_DATA) { ok(!ret, "got %u\n", ret); ok(type == REG_MULTI_SZ, "got type %u\n", type); diff --git a/dlls/kernelbase/registry.c b/dlls/kernelbase/registry.c index 31698cb0948..c3d5cdbc6e0 100644 --- a/dlls/kernelbase/registry.c +++ b/dlls/kernelbase/registry.c @@ -1225,6 +1225,27 @@ static DWORD query_perf_names( DWORD *type, void *data, DWORD *ret_size, BOOL un return ERROR_SUCCESS; }
+/* FIXME: we should read data from system32/perf009h.dat (or perf###h depending + * on locale) instead */ +static DWORD query_perf_help( DWORD *type, void *data, DWORD *ret_size, BOOL unicode ) +{ + static const WCHAR names[] = L"1847\0End Marker\0"; + DWORD size = *ret_size; + + if (type) *type = REG_MULTI_SZ; + *ret_size = sizeof(names); + if (!unicode) *ret_size /= sizeof(WCHAR); + + if (!data) return ERROR_SUCCESS; + if (size < *ret_size) return ERROR_MORE_DATA; + + if (unicode) + memcpy( data, names, sizeof(names) ); + else + RtlUnicodeToMultiByteN( data, size, NULL, names, sizeof(names) ); + return ERROR_SUCCESS; +} + struct perf_provider { HMODULE perflib; @@ -1370,6 +1391,8 @@ static DWORD query_perf_data( const WCHAR *query, DWORD *type, void *data, DWORD
if (!wcsnicmp( query, L"counter", 7 )) return query_perf_names( type, data, ret_size, unicode ); + if (!wcsnicmp( query, L"help", 4 )) + return query_perf_help( type, data, ret_size, unicode );
data_size = *ret_size; *ret_size = 0;
Hi,
While running your changed tests, I think I found new failures. Being a bot and all I'm not very good at pattern recognition, so I might be wrong, but could you please double-check?
Full results can be found at: https://testbot.winehq.org/JobDetails.pl?Key=95452
Your paranoid android.
=== w10pro64_ja (64 bit report) ===
advapi32: registry.c:551: Test failed: data_count set to 9 instead of 7 registry.c:556: Test failed: data set to 'xxxxxxxxx' instead of 'foobar' or 'xxxxxxx'
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 );