Commit f527e4a6 authored by Paul Gofman's avatar Paul Gofman Committed by Alexandre Julliard

advapi32: Add stub for PerfQueryCounterData().

parent 7e758014
...@@ -341,3 +341,23 @@ ULONG WINAPI PerfAddCounters( HANDLE query, PERF_COUNTER_IDENTIFIER *id, DWORD s ...@@ -341,3 +341,23 @@ ULONG WINAPI PerfAddCounters( HANDLE query, PERF_COUNTER_IDENTIFIER *id, DWORD s
id->Status = ERROR_WMI_GUID_NOT_FOUND; id->Status = ERROR_WMI_GUID_NOT_FOUND;
return ERROR_SUCCESS; return ERROR_SUCCESS;
} }
ULONG WINAPI PerfQueryCounterData( HANDLE query, PERF_DATA_HEADER *data, DWORD data_size, DWORD *size_needed )
{
FIXME( "query %p, data %p, data_size %lu, size_needed %p stub.\n", query, data, data_size, size_needed );
if (!size_needed) return ERROR_INVALID_PARAMETER;
*size_needed = sizeof(PERF_DATA_HEADER);
if (!data || data_size < sizeof(PERF_DATA_HEADER)) return ERROR_NOT_ENOUGH_MEMORY;
data->dwTotalSize = sizeof(PERF_DATA_HEADER);
data->dwNumCounters = 0;
QueryPerformanceCounter( (LARGE_INTEGER *)&data->PerfTimeStamp );
QueryPerformanceFrequency( (LARGE_INTEGER *)&data->PerfFreq );
GetSystemTimeAsFileTime( (FILETIME *)&data->PerfTime100NSec );
FileTimeToSystemTime( (FILETIME *)&data->PerfTime100NSec, &data->SystemTime );
return ERROR_SUCCESS;
}
...@@ -565,7 +565,7 @@ ...@@ -565,7 +565,7 @@
# @ stub PerfIncrementULongCounterValue # @ stub PerfIncrementULongCounterValue
# @ stub PerfIncrementULongLongCounterValue # @ stub PerfIncrementULongLongCounterValue
@ stdcall PerfOpenQueryHandle(wstr ptr) @ stdcall PerfOpenQueryHandle(wstr ptr)
# @ stub PerfQueryCounterData @ stdcall PerfQueryCounterData(long ptr long ptr)
# @ stub PerfQueryCounterInfo # @ stub PerfQueryCounterInfo
# @ stub PerfQueryCounterSetRegistrationInfo # @ stub PerfQueryCounterSetRegistrationInfo
# @ stub PerfQueryInstance # @ stub PerfQueryInstance
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "winerror.h" #include "winerror.h"
#include "perflib.h" #include "perflib.h"
#include "winperf.h" #include "winperf.h"
#include "winternl.h"
#include "wine/test.h" #include "wine/test.h"
...@@ -34,6 +35,7 @@ ...@@ -34,6 +35,7 @@
DEFINE_FUNCTION(PerfCloseQueryHandle); DEFINE_FUNCTION(PerfCloseQueryHandle);
DEFINE_FUNCTION(PerfOpenQueryHandle); DEFINE_FUNCTION(PerfOpenQueryHandle);
DEFINE_FUNCTION(PerfAddCounters); DEFINE_FUNCTION(PerfAddCounters);
DEFINE_FUNCTION(PerfQueryCounterData);
#undef DEFINE_FUNCTION #undef DEFINE_FUNCTION
static void init_functions(void) static void init_functions(void)
...@@ -44,6 +46,7 @@ static void init_functions(void) ...@@ -44,6 +46,7 @@ static void init_functions(void)
GET_FUNCTION(PerfCloseQueryHandle); GET_FUNCTION(PerfCloseQueryHandle);
GET_FUNCTION(PerfOpenQueryHandle); GET_FUNCTION(PerfOpenQueryHandle);
GET_FUNCTION(PerfAddCounters); GET_FUNCTION(PerfAddCounters);
GET_FUNCTION(PerfQueryCounterData);
#undef GET_FUNCTION #undef GET_FUNCTION
} }
...@@ -209,11 +212,19 @@ void test_provider_init(void) ...@@ -209,11 +212,19 @@ void test_provider_init(void)
DEFINE_GUID(TestCounterGUID, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33); DEFINE_GUID(TestCounterGUID, 0x12345678, 0x1234, 0x5678, 0x12, 0x34, 0x11, 0x11, 0x22, 0x22, 0x33, 0x33);
static ULONG64 trunc_nttime_ms(ULONG64 t)
{
return (t / 10000) * 10000;
}
static void test_perf_counters(void) static void test_perf_counters(void)
{ {
LARGE_INTEGER freq, qpc1, qpc2, nttime1, nttime2, systime;
char buffer[sizeof(PERF_COUNTER_IDENTIFIER) + 8]; char buffer[sizeof(PERF_COUNTER_IDENTIFIER) + 8];
PERF_COUNTER_IDENTIFIER *counter_id; PERF_COUNTER_IDENTIFIER *counter_id;
PERF_DATA_HEADER dh;
HANDLE query; HANDLE query;
DWORD size;
ULONG ret; ULONG ret;
if (!pPerfOpenQueryHandle) if (!pPerfOpenQueryHandle)
...@@ -244,6 +255,41 @@ static void test_perf_counters(void) ...@@ -244,6 +255,41 @@ static void test_perf_counters(void)
ok(!ret, "got ret %lu.\n", ret); ok(!ret, "got ret %lu.\n", ret);
ok(counter_id->Status == ERROR_WMI_GUID_NOT_FOUND, "got Status %#lx.\n", counter_id->Status); ok(counter_id->Status == ERROR_WMI_GUID_NOT_FOUND, "got Status %#lx.\n", counter_id->Status);
ret = pPerfQueryCounterData(query, NULL, 0, NULL);
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
size = 0xdeadbeef;
ret = pPerfQueryCounterData(query, NULL, 0, &size);
ok(ret == ERROR_NOT_ENOUGH_MEMORY, "got ret %lu.\n", ret);
ok(size == sizeof(dh), "got size %lu.\n", size);
ret = pPerfQueryCounterData(query, &dh, sizeof(dh), NULL);
ok(ret == ERROR_INVALID_PARAMETER, "got ret %lu.\n", ret);
QueryPerformanceFrequency(&freq);
QueryPerformanceCounter(&qpc1);
NtQuerySystemTime(&nttime1);
size = 0xdeadbeef;
ret = pPerfQueryCounterData(query, &dh, sizeof(dh), &size);
QueryPerformanceCounter(&qpc2);
NtQuerySystemTime(&nttime2);
SystemTimeToFileTime(&dh.SystemTime, (FILETIME *)&systime);
ok(!ret, "got ret %lu.\n", ret);
ok(size == sizeof(dh), "got size %lu.\n", size);
ok(dh.dwTotalSize == sizeof(dh), "got dwTotalSize %lu.\n", dh.dwTotalSize);
ok(!dh.dwNumCounters, "got dwNumCounters %lu.\n", dh.dwNumCounters);
ok(dh.PerfFreq == freq.QuadPart, "got PerfFreq %I64u.\n", dh.PerfFreq);
ok(dh.PerfTimeStamp >= qpc1.QuadPart && dh.PerfTimeStamp <= qpc2.QuadPart,
"got PerfTimeStamp %I64u, qpc1 %I64u, qpc2 %I64u.\n",
dh.PerfTimeStamp, qpc1.QuadPart, qpc2.QuadPart);
ok(dh.PerfTime100NSec >= nttime1.QuadPart && dh.PerfTime100NSec <= nttime2.QuadPart,
"got PerfTime100NSec %I64u, nttime1 %I64u, nttime2 %I64u.\n",
dh.PerfTime100NSec, nttime1.QuadPart, nttime2.QuadPart);
ok(systime.QuadPart >= trunc_nttime_ms(nttime1.QuadPart) && systime.QuadPart <= trunc_nttime_ms(nttime2.QuadPart),
"got systime %I64u, nttime1 %I64u, nttime2 %I64u, %d.\n",
systime.QuadPart, nttime1.QuadPart, nttime2.QuadPart, dh.SystemTime.wMilliseconds);
ret = pPerfCloseQueryHandle(query); ret = pPerfCloseQueryHandle(query);
ok(!ret, "got ret %lu.\n", ret); ok(!ret, "got ret %lu.\n", ret);
} }
......
...@@ -94,6 +94,15 @@ typedef struct _PERF_COUNTER_IDENTIFIER { ...@@ -94,6 +94,15 @@ typedef struct _PERF_COUNTER_IDENTIFIER {
#define PERF_WILDCARD_COUNTER 0xFFFFFFFF #define PERF_WILDCARD_COUNTER 0xFFFFFFFF
#define PERF_WILDCARD_INSTANCE L"*" #define PERF_WILDCARD_INSTANCE L"*"
typedef struct _PERF_DATA_HEADER {
ULONG dwTotalSize;
ULONG dwNumCounters;
LONGLONG PerfTimeStamp;
LONGLONG PerfTime100NSec;
LONGLONG PerfFreq;
SYSTEMTIME SystemTime;
} PERF_DATA_HEADER, *PPERF_DATA_HEADER;
PERF_COUNTERSET_INSTANCE WINAPI *PerfCreateInstance(HANDLE, const GUID *, const WCHAR *, ULONG); PERF_COUNTERSET_INSTANCE WINAPI *PerfCreateInstance(HANDLE, const GUID *, const WCHAR *, ULONG);
ULONG WINAPI PerfDeleteInstance(HANDLE, PERF_COUNTERSET_INSTANCE *); ULONG WINAPI PerfDeleteInstance(HANDLE, PERF_COUNTERSET_INSTANCE *);
ULONG WINAPI PerfSetCounterRefValue(HANDLE, PERF_COUNTERSET_INSTANCE *, ULONG, void *); ULONG WINAPI PerfSetCounterRefValue(HANDLE, PERF_COUNTERSET_INSTANCE *, ULONG, void *);
...@@ -105,6 +114,7 @@ ULONG WINAPI PerfStopProvider(HANDLE); ...@@ -105,6 +114,7 @@ ULONG WINAPI PerfStopProvider(HANDLE);
ULONG WINAPI PerfAddCounters(HANDLE, PERF_COUNTER_IDENTIFIER *, DWORD); ULONG WINAPI PerfAddCounters(HANDLE, PERF_COUNTER_IDENTIFIER *, DWORD);
ULONG WINAPI PerfCloseQueryHandle(HANDLE); ULONG WINAPI PerfCloseQueryHandle(HANDLE);
ULONG WINAPI PerfOpenQueryHandle(const WCHAR *, HANDLE *); ULONG WINAPI PerfOpenQueryHandle(const WCHAR *, HANDLE *);
ULONG WINAPI PerfQueryCounterData(HANDLE, PERF_DATA_HEADER *, DWORD, DWORD *);
#ifdef __cplusplus #ifdef __cplusplus
} /* extern "C" */ } /* extern "C" */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment