Signed-off-by: Nipun Garg nipung271@gmail.com --- dlls/pdh/pdh.spec | 6 ++--- dlls/pdh/pdh_main.c | 35 ++++++++++++++++++++++++ dlls/pdh/tests/pdh.c | 63 ++++++++++++++++++++++++++++++++++++++++++++ include/pdh.h | 23 ++++++++++++++++ 4 files changed, 124 insertions(+), 3 deletions(-)
diff --git a/dlls/pdh/pdh.spec b/dlls/pdh/pdh.spec index 5f61a8a42ca..0448cdde800 100644 --- a/dlls/pdh/pdh.spec +++ b/dlls/pdh/pdh.spec @@ -12,7 +12,7 @@ @ stub PdhBrowseCountersHW @ stub PdhBrowseCountersW @ stdcall PdhCalculateCounterFromRawValue(ptr long ptr ptr ptr) -@ stub PdhCloseLog +@ stdcall PdhCloseLog(ptr long) @ stdcall PdhCloseQuery(ptr) @ stdcall PdhCollectQueryData(ptr) @ stdcall PdhCollectQueryDataWithTime(ptr ptr) @@ -81,8 +81,8 @@ @ stdcall PdhLookupPerfNameByIndexW(wstr long ptr ptr) @ stdcall PdhMakeCounterPathA(ptr ptr ptr long) @ stdcall PdhMakeCounterPathW(ptr ptr ptr long) -@ stub PdhOpenLogA -@ stub PdhOpenLogW +@ stdcall PdhOpenLogA(str long ptr long long str ptr) +@ stdcall PdhOpenLogW(wstr long ptr long long wstr ptr) @ stdcall PdhOpenQuery(wstr long ptr) PdhOpenQueryW @ stdcall PdhOpenQueryA(str long ptr) @ stub PdhOpenQueryH diff --git a/dlls/pdh/pdh_main.c b/dlls/pdh/pdh_main.c index 73d4fef2a14..2d3ff71fbf4 100644 --- a/dlls/pdh/pdh_main.c +++ b/dlls/pdh/pdh_main.c @@ -358,6 +358,15 @@ PDH_STATUS WINAPI PdhCalculateCounterFromRawValue( PDH_HCOUNTER handle, DWORD fo return ret; }
+/*********************************************************************** + * PdhCloseLog (PDH.@) + */ +PDH_STATUS WINAPI PdhCloseLog( PDH_HLOG log, DWORD flags ) +{ + FIXME("(%p, %d): stub\n", log, flags); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return PDH_NOT_IMPLEMENTED; +}
/*********************************************************************** * PdhCloseQuery (PDH.@) @@ -963,6 +972,32 @@ PDH_STATUS WINAPI PdhOpenQueryW( LPCWSTR source, DWORD_PTR userdata, PDH_HQUERY return PDH_MEMORY_ALLOCATION_FAILURE; }
+/********************************************************************** + * PdhOpenLogA (PDH.@) + */ +PDH_STATUS WINAPI PdhOpenLogA( LPCSTR log_name, DWORD access_flags, + LPDWORD log_type, PDH_HQUERY query, DWORD max_size, + LPCSTR user_caption, PDH_HLOG *log ) +{ + FIXME("(%s, %d, %p, %p, %d, %s, %p): stub\n", log_name, access_flags, + log_type, query, max_size, user_caption, log); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return PDH_NOT_IMPLEMENTED; +} + +/********************************************************************** + * PdhOpenLogW (PDH.@) + */ +PDH_STATUS WINAPI PdhOpenLogW( LPCWSTR log_name, DWORD access_flags, + LPDWORD log_type, PDH_HQUERY query, DWORD max_size, + LPCWSTR user_caption, PDH_HLOG *log ) +{ + FIXME("(%s, %d, %p, %p, %d, %s, %p): stub\n", log_name, access_flags, + log_type, query, max_size, user_caption, log); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return PDH_NOT_IMPLEMENTED; +} + /*********************************************************************** * PdhRemoveCounter (PDH.@) */ diff --git a/dlls/pdh/tests/pdh.c b/dlls/pdh/tests/pdh.c index 71603f8c6ba..4e5b13d2c67 100644 --- a/dlls/pdh/tests/pdh.c +++ b/dlls/pdh/tests/pdh.c @@ -126,6 +126,66 @@ static void test_PdhOpenQueryW( void ) ok(ret == PDH_INVALID_HANDLE, "PdhCloseQuery failed 0x%08x\n", ret); }
+static void test_PdhOpenLogA( void ) +{ + PDH_STATUS ret; + PDH_HLOG log; + PDH_HQUERY query; + PDH_HCOUNTER counter; + DWORD log_type = PDH_LOG_TYPE_CSV; + + PdhOpenQueryA( NULL, 0, &query ); + PdhAddCounterA( query, "\System\System Up Time", 0, &counter ); + + ret = PdhOpenLogA( NULL, PDH_LOG_WRITE_ACCESS, &log_type, NULL, 0, NULL, NULL ); + todo_wine ok(ret == PDH_INVALID_ARGUMENT, "PdhOpenLogA failed 0x%08x\n", ret); + + ret = PdhOpenLogA( "test_log", PDH_LOG_WRITE_ACCESS | PDH_LOG_CREATE_ALWAYS, &log_type, query, 0, NULL, &log ); + todo_wine ok(ret == ERROR_SUCCESS, "PdhOpenLogA failed 0x%08x\n", ret); + + ret = PdhCloseLog( NULL, 0 ); + todo_wine ok(ret == PDH_CSTATUS_VALID_DATA, "PdhCloseLog failed 0x%08x\n", ret); + + ret = PdhCloseLog( &log, 0 ); + todo_wine ok(ret == PDH_INVALID_HANDLE, "PdhCloseLog failed 0x%08x\n", ret); + + ret = PdhCloseLog( log, 0 ); + todo_wine ok(ret == ERROR_SUCCESS, "PdhCloseLog failed 0x%08x\n", ret); + + ret = PdhCloseLog( log, 0 ); + todo_wine ok(ret == PDH_INVALID_HANDLE, "PdhCloseLog failed 0x%08x\n", ret); +} + +static void test_PdhOpenLogW( void ) +{ + PDH_STATUS ret; + PDH_HLOG log; + PDH_HQUERY query; + PDH_HCOUNTER counter; + DWORD log_type = PDH_LOG_TYPE_CSV; + + PdhOpenQueryW( NULL, 0, &query ); + PdhAddCounterW( query, L"\System\System Up Time", 0, &counter ); + + ret = PdhOpenLogW( NULL, PDH_LOG_WRITE_ACCESS, &log_type, NULL, 0, NULL, NULL ); + todo_wine ok(ret == PDH_INVALID_ARGUMENT, "PdhOpenLogW failed 0x%08x\n", ret); + + ret = PdhOpenLogW( L"test_log", PDH_LOG_WRITE_ACCESS | PDH_LOG_CREATE_ALWAYS, &log_type, query, 0, NULL, &log ); + todo_wine ok(ret == ERROR_SUCCESS, "PdhOpenLogW failed 0x%08x\n", ret); + + ret = PdhCloseLog( NULL, 0 ); + todo_wine ok(ret == PDH_CSTATUS_VALID_DATA, "PdhCloseLog failed 0x%08x\n", ret); + + ret = PdhCloseLog( &log, 0 ); + todo_wine ok(ret == PDH_INVALID_HANDLE, "PdhCloseLog failed 0x%08x\n", ret); + + ret = PdhCloseLog( log, 0 ); + todo_wine ok(ret == ERROR_SUCCESS, "PdhCloseLog failed 0x%08x\n", ret); + + ret = PdhCloseLog( log, 0 ); + todo_wine ok(ret == PDH_INVALID_HANDLE, "PdhCloseLog failed 0x%08x\n", ret); +} + static void test_PdhAddCounterA( void ) { PDH_STATUS ret; @@ -982,6 +1042,9 @@ START_TEST(pdh) test_PdhOpenQueryA(); test_PdhOpenQueryW();
+ test_PdhOpenLogA(); + test_PdhOpenLogW(); + test_PdhAddCounterA(); test_PdhAddCounterW();
diff --git a/include/pdh.h b/include/pdh.h index 3d688bd8ded..caecd7ce528 100644 --- a/include/pdh.h +++ b/include/pdh.h @@ -57,6 +57,25 @@ typedef PDH_HLOG HLOG; #define DATA_SOURCE_LOGFILE 0x00000002 #define DATA_SOURCE_WBEM 0x00000004
+#define PDH_LOG_READ_ACCESS 0x00010000 +#define PDH_LOG_WRITE_ACCESS 0x00020000 +#define PDH_LOG_UPDATE_ACCESS 0x00040000 + +#define PDH_LOG_CREATE_NEW 0x00000001 +#define PDH_LOG_CREATE_ALWAYS 0x00000002 +#define PDH_LOG_OPEN_ALWAYS 0x00000003 +#define PDH_LOG_OPEN_EXISTING 0x00000004 +#define PDH_LOG_OPT_USER_STRING 0x01000000 +#define PDH_LOG_OPT_CIRCULAR 0x02000000 + +#define PDH_LOG_TYPE_UNDEFINED 0x00000000 +#define PDH_LOG_TYPE_CSV 0x00000001 +#define PDH_LOG_TYPE_TSV 0x00000002 +#define PDH_LOG_TYPE_SQL 0x00000007 +#define PDH_LOG_TYPE_BINARY 0x00000008 + +#define PDH_FLAG_CLOSE_QUERY 0x00000001 + #ifdef WINE_NO_UNICODE_MACROS # define DECL_PDH_TYPE_AW(name) /* nothing */ #else /* WINE_NO_UNICODE_MACROS */ @@ -203,6 +222,7 @@ PDH_STATUS WINAPI PdhAddEnglishCounterW(PDH_HQUERY, LPCWSTR, DWORD_PTR, PDH_HCOU PDH_STATUS WINAPI PdhBindInputDataSourceA(PDH_HLOG *, const char *); PDH_STATUS WINAPI PdhBindInputDataSourceW(PDH_HLOG *, const WCHAR *); #define PdhBindInputDataSource WINELIB_NAME_AW(PdhBindInputDataSource) +PDH_STATUS WINAPI PdhCloseLog(PDH_HLOG, DWORD); PDH_STATUS WINAPI PdhCloseQuery(PDH_HQUERY); PDH_STATUS WINAPI PdhCollectQueryData(PDH_HQUERY); PDH_STATUS WINAPI PdhCollectQueryDataEx(PDH_HQUERY, DWORD, HANDLE); @@ -229,6 +249,9 @@ PDH_STATUS WINAPI PdhLookupPerfNameByIndexW(LPCWSTR, DWORD, LPWSTR, LPDWORD); PDH_STATUS WINAPI PdhMakeCounterPathA(PDH_COUNTER_PATH_ELEMENTS_A *, LPSTR, LPDWORD, DWORD); PDH_STATUS WINAPI PdhMakeCounterPathW(PDH_COUNTER_PATH_ELEMENTS_W *, LPWSTR, LPDWORD, DWORD); #define PdhMakeCounterPath WINELIB_NAME_AW(PdhMakeCounterPath) +PDH_STATUS WINAPI PdhOpenLogA(LPCSTR, DWORD, LPDWORD, PDH_HQUERY, DWORD, LPCSTR, PDH_HLOG *); +PDH_STATUS WINAPI PdhOpenLogW(LPCWSTR, DWORD, LPDWORD, PDH_HQUERY, DWORD, LPCWSTR, PDH_HLOG *); +#define PdhOpenLog WINELIB_NAME_AW(PdhOpenLog) PDH_STATUS WINAPI PdhOpenQueryA(LPCSTR, DWORD_PTR, PDH_HQUERY *); PDH_STATUS WINAPI PdhOpenQueryW(LPCWSTR, DWORD_PTR, PDH_HQUERY *); #define PdhOpenQuery WINELIB_NAME_AW(PdhOpenQuery)