diff --git a/dlls/pdh/pdh.spec b/dlls/pdh/pdh.spec index 6dfc73dcfed..7ed42076daa 100644 --- a/dlls/pdh/pdh.spec +++ b/dlls/pdh/pdh.spec @@ -64,7 +64,7 @@ @ stub PdhGetLogSetGUID @ stub PdhGetRawCounterArrayA @ stub PdhGetRawCounterArrayW -@ stub PdhGetRawCounterValue +@ stdcall PdhGetRawCounterValue(ptr ptr ptr) @ stub PdhIsRealTimeQuery @ stub PdhListLogFileHeaderA @ stub PdhListLogFileHeaderW diff --git a/dlls/pdh/pdh_main.c b/dlls/pdh/pdh_main.c index f89493ee0e2..a04d1ebed5f 100644 --- a/dlls/pdh/pdh_main.c +++ b/dlls/pdh/pdh_main.c @@ -326,6 +326,30 @@ PDH_STATUS WINAPI PdhGetFormattedCounterValue( PDH_HCOUNTER handle, DWORD format return ERROR_SUCCESS; } +/*********************************************************************** + * PdhGetRawCounterValue (PDH.@) + */ +PDH_STATUS WINAPI PdhGetRawCounterValue( PDH_HCOUNTER handle, LPDWORD type, + PPDH_RAW_COUNTER value ) +{ + struct counter *counter = handle; + + TRACE("%p %p %p\n", handle, type, value); + + if (!value) return PDH_INVALID_ARGUMENT; + if (!counter) return PDH_INVALID_HANDLE; + + value->CStatus = counter->status; + value->TimeStamp.dwLowDateTime = counter->stamp.dwLowDateTime; + value->TimeStamp.dwHighDateTime = counter->stamp.dwHighDateTime; + value->FirstValue = counter->one.largevalue;; + value->SecondValue = counter->two.largevalue; + value->MultiCount = 1; /* FIXME */ + + if (type) *type = counter->type; + return ERROR_SUCCESS; +} + /*********************************************************************** * PdhOpenQueryA (PDH.@) */ diff --git a/dlls/pdh/tests/pdh.c b/dlls/pdh/tests/pdh.c index 084fefc8892..6ddb0971d06 100644 --- a/dlls/pdh/tests/pdh.c +++ b/dlls/pdh/tests/pdh.c @@ -145,6 +145,40 @@ static void test_PdhGetFormattedCounterValue( void ) ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret); } +static void test_PdhGetRawCounterValue( void ) +{ + PDH_STATUS ret; + PDH_HQUERY query; + PDH_HCOUNTER counter; + PDH_RAW_COUNTER value; + + ret = PdhOpenQueryA( NULL, 0, &query ); + ok(ret == ERROR_SUCCESS, "PdhOpenQueryA failed 0x%08x\n", ret); + + ret = PdhAddCounterA( query, "\\System\\System Up Time", 0, &counter ); + ok(ret == ERROR_SUCCESS, "PdhAddCounterA failed 0x%08x\n", ret); + + ret = PdhGetRawCounterValue( NULL, NULL, &value ); + ok(ret == PDH_INVALID_HANDLE, "PdhGetRawCounterValue failed 0x%08x\n", ret); + + ret = PdhGetRawCounterValue( counter, NULL, NULL ); + ok(ret == PDH_INVALID_ARGUMENT, "PdhGetRawCounterValue failed 0x%08x\n", ret); + + ret = PdhGetRawCounterValue( counter, NULL, &value ); + ok(ret == ERROR_SUCCESS, "PdhGetRawCounterValue failed 0x%08x\n", ret); + ok(value.CStatus == ERROR_SUCCESS, "expected ERROR_SUCCESS got %x", value.CStatus); + + ret = PdhCollectQueryData( query ); + ok(ret == ERROR_SUCCESS, "PdhCollectQueryData failed 0x%08x\n", ret); + + ret = PdhGetRawCounterValue( counter, NULL, &value ); + ok(ret == ERROR_SUCCESS, "PdhGetRawCounterValue failed 0x%08x\n", ret); + ok(value.CStatus == ERROR_SUCCESS, "expected ERROR_SUCCESS got %x", value.CStatus); + + ret = PdhCloseQuery( query ); + ok(ret == ERROR_SUCCESS, "PdhCloseQuery failed 0x%08x\n", ret); +} + static void test_PdhSetCounterScaleFactor( void ) { PDH_STATUS ret; @@ -184,5 +218,6 @@ START_TEST(pdh) test_open_close_query(); test_add_remove_counter(); test_PdhGetFormattedCounterValue(); + test_PdhGetRawCounterValue(); test_PdhSetCounterScaleFactor(); }