diff --git a/dlls/advapi32/tests/registry.c b/dlls/advapi32/tests/registry.c index eb9ab67f283..4ea0f68a844 100644 --- a/dlls/advapi32/tests/registry.c +++ b/dlls/advapi32/tests/registry.c @@ -27,6 +27,7 @@ #include "winbase.h" #include "winternl.h" #include "winreg.h" +#include "winperf.h" #include "winsvc.h" #include "winerror.h" #include "aclapi.h" @@ -3480,6 +3481,54 @@ static void test_RegNotifyChangeKeyValue(void) CloseHandle(event); } +static void test_RegQueryValueExPerformanceData(void) +{ + DWORD cbData, len; + BYTE *value; + DWORD dwret; + LONG limit = 6; + PERF_DATA_BLOCK *pdb; + + /* Test with data == NULL */ + dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, NULL, &cbData ); + todo_wine 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; + dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, value, &cbData ); + todo_wine ok( dwret == ERROR_MORE_DATA, "expected ERROR_MORE_DATA, got %d\n", dwret ); + while( dwret == ERROR_MORE_DATA && limit) + { + len = len * 10; + value = HeapReAlloc( GetProcessHeap(), 0, value, len ); + cbData = len; + dwret = RegQueryValueExA( HKEY_PERFORMANCE_DATA, "Global", NULL, NULL, value, &cbData ); + limit--; + } + ok(limit > 0, "too many times ERROR_MORE_DATA returned\n"); + + todo_wine ok(dwret == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %d\n", dwret); + + /* Check returned data */ + if (dwret == ERROR_SUCCESS) + { + todo_wine 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 */ + } + } + + HeapFree(GetProcessHeap(), 0, value); +} + + START_TEST(registry) { /* Load pointers for functions that are not available in all Windows versions */ @@ -3515,6 +3564,7 @@ START_TEST(registry) test_delete_key_value(); test_RegOpenCurrentUser(); test_RegNotifyChangeKeyValue(); + test_RegQueryValueExPerformanceData(); /* cleanup */ delete_key( hkey_main );