pdh: Fix parameter handling in PdhAddEnglishCounter{A, W} and PdhCollectQueryDataWithTime.
This commit is contained in:
parent
a83509c7d3
commit
cf8b16bc9e
|
@ -304,6 +304,9 @@ PDH_STATUS WINAPI PdhAddCounterW( PDH_HQUERY hquery, LPCWSTR path,
|
||||||
PDH_STATUS WINAPI PdhAddEnglishCounterA( PDH_HQUERY query, LPCSTR path,
|
PDH_STATUS WINAPI PdhAddEnglishCounterA( PDH_HQUERY query, LPCSTR path,
|
||||||
DWORD_PTR userdata, PDH_HCOUNTER *counter )
|
DWORD_PTR userdata, PDH_HCOUNTER *counter )
|
||||||
{
|
{
|
||||||
|
TRACE("%p %s %lx %p\n", query, debugstr_a(path), userdata, counter);
|
||||||
|
|
||||||
|
if (!query) return PDH_INVALID_ARGUMENT;
|
||||||
return PdhAddCounterA( query, path, userdata, counter );
|
return PdhAddCounterA( query, path, userdata, counter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,6 +316,9 @@ PDH_STATUS WINAPI PdhAddEnglishCounterA( PDH_HQUERY query, LPCSTR path,
|
||||||
PDH_STATUS WINAPI PdhAddEnglishCounterW( PDH_HQUERY query, LPCWSTR path,
|
PDH_STATUS WINAPI PdhAddEnglishCounterW( PDH_HQUERY query, LPCWSTR path,
|
||||||
DWORD_PTR userdata, PDH_HCOUNTER *counter )
|
DWORD_PTR userdata, PDH_HCOUNTER *counter )
|
||||||
{
|
{
|
||||||
|
TRACE("%p %s %lx %p\n", query, debugstr_w(path), userdata, counter);
|
||||||
|
|
||||||
|
if (!query) return PDH_INVALID_ARGUMENT;
|
||||||
return PdhAddCounterW( query, path, userdata, counter );
|
return PdhAddCounterW( query, path, userdata, counter );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -543,9 +549,13 @@ PDH_STATUS WINAPI PdhCollectQueryDataEx( PDH_HQUERY handle, DWORD interval, HAND
|
||||||
PDH_STATUS WINAPI PdhCollectQueryDataWithTime( PDH_HQUERY handle, LONGLONG *timestamp )
|
PDH_STATUS WINAPI PdhCollectQueryDataWithTime( PDH_HQUERY handle, LONGLONG *timestamp )
|
||||||
{
|
{
|
||||||
struct query *query = handle;
|
struct query *query = handle;
|
||||||
|
struct counter *counter;
|
||||||
|
struct list *item;
|
||||||
|
|
||||||
TRACE("%p %p\n", handle, timestamp);
|
TRACE("%p %p\n", handle, timestamp);
|
||||||
|
|
||||||
|
if (!timestamp) return PDH_INVALID_ARGUMENT;
|
||||||
|
|
||||||
EnterCriticalSection( &pdh_handle_cs );
|
EnterCriticalSection( &pdh_handle_cs );
|
||||||
if (!query || query->magic != PDH_MAGIC_QUERY)
|
if (!query || query->magic != PDH_MAGIC_QUERY)
|
||||||
{
|
{
|
||||||
|
@ -560,13 +570,11 @@ PDH_STATUS WINAPI PdhCollectQueryDataWithTime( PDH_HQUERY handle, LONGLONG *time
|
||||||
|
|
||||||
collect_query_data( query );
|
collect_query_data( query );
|
||||||
|
|
||||||
if (timestamp)
|
item = list_head( &query->counters );
|
||||||
{
|
counter = LIST_ENTRY( item, struct counter, entry );
|
||||||
struct list *item = list_head( &query->counters );
|
|
||||||
struct counter *counter = LIST_ENTRY( item, struct counter, entry );
|
|
||||||
|
|
||||||
*timestamp = ((LONGLONG)counter->stamp.dwHighDateTime << 32) | counter->stamp.dwLowDateTime;
|
*timestamp = ((LONGLONG)counter->stamp.dwHighDateTime << 32) | counter->stamp.dwLowDateTime;
|
||||||
}
|
|
||||||
LeaveCriticalSection( &pdh_handle_cs );
|
LeaveCriticalSection( &pdh_handle_cs );
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -211,11 +211,14 @@ static void test_PdhAddEnglishCounterA( void )
|
||||||
ret = PdhOpenQueryA( NULL, 0, &query );
|
ret = PdhOpenQueryA( NULL, 0, &query );
|
||||||
ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
|
ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
|
||||||
|
|
||||||
|
ret = PdhCollectQueryData( query );
|
||||||
|
ok(ret == PDH_NO_DATA, "PdhCollectQueryData failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhAddEnglishCounterA( NULL, "\\System\\System Up Time", 0, NULL );
|
ret = pPdhAddEnglishCounterA( NULL, "\\System\\System Up Time", 0, NULL );
|
||||||
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhAddEnglishCounterA( NULL, "\\System\\System Up Time", 0, &counter );
|
ret = pPdhAddEnglishCounterA( NULL, "\\System\\System Up Time", 0, &counter );
|
||||||
ok(ret == PDH_INVALID_HANDLE, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhAddEnglishCounterA( query, NULL, 0, &counter );
|
ret = pPdhAddEnglishCounterA( query, NULL, 0, &counter );
|
||||||
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterA failed 0x%08x\n", ret);
|
||||||
|
@ -249,11 +252,14 @@ static void test_PdhAddEnglishCounterW( void )
|
||||||
ret = PdhOpenQueryW( NULL, 0, &query );
|
ret = PdhOpenQueryW( NULL, 0, &query );
|
||||||
ok(ret == ERROR_SUCCESS, "PdhOpenQueryW failed 0x%08x\n", ret);
|
ok(ret == ERROR_SUCCESS, "PdhOpenQueryW failed 0x%08x\n", ret);
|
||||||
|
|
||||||
|
ret = PdhCollectQueryData( query );
|
||||||
|
ok(ret == PDH_NO_DATA, "PdhCollectQueryData failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhAddEnglishCounterW( NULL, system_uptime, 0, NULL );
|
ret = pPdhAddEnglishCounterW( NULL, system_uptime, 0, NULL );
|
||||||
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhAddEnglishCounterW( NULL, system_uptime, 0, &counter );
|
ret = pPdhAddEnglishCounterW( NULL, system_uptime, 0, &counter );
|
||||||
ok(ret == PDH_INVALID_HANDLE, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhAddEnglishCounterW( query, NULL, 0, &counter );
|
ret = pPdhAddEnglishCounterW( query, NULL, 0, &counter );
|
||||||
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhAddEnglishCounterW failed 0x%08x\n", ret);
|
||||||
|
@ -288,14 +294,17 @@ static void test_PdhCollectQueryDataWithTime( void )
|
||||||
ret = PdhOpenQueryA( NULL, 0, &query );
|
ret = PdhOpenQueryA( NULL, 0, &query );
|
||||||
ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
|
ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret);
|
||||||
|
|
||||||
|
ret = PdhCollectQueryData( query );
|
||||||
|
ok(ret == PDH_NO_DATA, "PdhCollectQueryData failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
|
ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter );
|
||||||
ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
|
ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhCollectQueryDataWithTime( NULL, NULL );
|
ret = pPdhCollectQueryDataWithTime( NULL, NULL );
|
||||||
ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhCollectQueryDataWithTime( query, NULL );
|
ret = pPdhCollectQueryDataWithTime( query, NULL );
|
||||||
ok(ret == ERROR_SUCCESS, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_ARGUMENT, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
|
||||||
|
|
||||||
ret = pPdhCollectQueryDataWithTime( NULL, &time );
|
ret = pPdhCollectQueryDataWithTime( NULL, &time );
|
||||||
ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
|
ok(ret == PDH_INVALID_HANDLE, "PdhCollectQueryDataWithTime failed 0x%08x\n", ret);
|
||||||
|
|
Loading…
Reference in New Issue