ReactOS 0.4.17-dev-966-gf06eace
pdh_main.c File Reference
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#include "windef.h"
#include "winbase.h"
#include "pdh.h"
#include "pdhmsg.h"
#include "winperf.h"
#include "wine/debug.h"
#include "wine/list.h"
Include dependency graph for pdh_main.c:

Go to the source code of this file.

Classes

union  value
 
struct  counter
 
struct  query
 
struct  source
 

Macros

#define PDH_MAGIC_COUNTER   0x50444831 /* 'PDH1' */
 
#define PDH_MAGIC_QUERY   0x50444830 /* 'PDH0' */
 
#define TYPE_PROCESSOR_TIME
 
#define TYPE_UPTIME    (PERF_SIZE_LARGE | PERF_TYPE_COUNTER | PERF_COUNTER_ELAPSED | PERF_OBJECT_TIMER | PERF_DISPLAY_SECONDS)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (pdh)
 
static WCHAR * pdh_strdup_aw (const char *src)
 
static struct counter * create_counter (void)
 
static void destroy_counter (struct counter *counter)
 
static struct query * create_query (void)
 
static void destroy_query (struct query *query)
 
static void CALLBACK collect_processor_time (struct counter *counter)
 
static void CALLBACK collect_uptime (struct counter *counter)
 
static BOOL is_local_machine (const WCHAR *name, DWORD len)
 
static BOOL pdh_match_path (LPCWSTR fullpath, LPCWSTR path)
 
PDH_STATUS WINAPI PdhAddCounterA (PDH_HQUERY query, LPCSTR path, DWORD_PTR userdata, PDH_HCOUNTER *counter)
 
PDH_STATUS WINAPI PdhAddCounterW (PDH_HQUERY hquery, LPCWSTR path, DWORD_PTR userdata, PDH_HCOUNTER *hcounter)
 
PDH_STATUS WINAPI PdhAddEnglishCounterA (PDH_HQUERY query, LPCSTR path, DWORD_PTR userdata, PDH_HCOUNTER *counter)
 
PDH_STATUS WINAPI PdhAddEnglishCounterW (PDH_HQUERY query, LPCWSTR path, DWORD_PTR userdata, PDH_HCOUNTER *counter)
 
static PDH_STATUS format_value (struct counter *counter, DWORD format, union value *raw1, union value *raw2, PDH_FMT_COUNTERVALUE *value)
 
PDH_STATUS WINAPI PdhCalculateCounterFromRawValue (PDH_HCOUNTER handle, DWORD format, PPDH_RAW_COUNTER raw1, PPDH_RAW_COUNTER raw2, PPDH_FMT_COUNTERVALUE value)
 
PDH_STATUS WINAPI PdhCloseQuery (PDH_HQUERY handle)
 
static void collect_query_data (struct query *query)
 
PDH_STATUS WINAPI PdhCollectQueryData (PDH_HQUERY handle)
 
static DWORD CALLBACK collect_query_thread (void *arg)
 
PDH_STATUS WINAPI PdhCollectQueryDataEx (PDH_HQUERY handle, DWORD interval, HANDLE event)
 
PDH_STATUS WINAPI PdhCollectQueryDataWithTime (PDH_HQUERY handle, LONGLONG *timestamp)
 
PDH_STATUS WINAPI PdhExpandWildCardPathA (LPCSTR szDataSource, LPCSTR szWildCardPath, LPSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags)
 
PDH_STATUS WINAPI PdhExpandWildCardPathW (LPCWSTR szDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags)
 
PDH_STATUS WINAPI PdhExpandCounterPathA (LPCSTR szWildCardPath, LPSTR mszExpandedPathList, LPDWORD pcchPathListLength)
 
PDH_STATUS WINAPI PdhExpandCounterPathW (LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, LPDWORD pcchPathListLength)
 
PDH_STATUS WINAPI PdhGetCounterInfoA (PDH_HCOUNTER handle, BOOLEAN text, LPDWORD size, PPDH_COUNTER_INFO_A info)
 
PDH_STATUS WINAPI PdhGetCounterInfoW (PDH_HCOUNTER handle, BOOLEAN text, LPDWORD size, PPDH_COUNTER_INFO_W info)
 
PDH_STATUS WINAPI PdhGetCounterTimeBase (PDH_HCOUNTER handle, LONGLONG *base)
 
PDH_STATUS WINAPI PdhGetDllVersion (LPDWORD version)
 
PDH_STATUS WINAPI PdhGetFormattedCounterValue (PDH_HCOUNTER handle, DWORD format, LPDWORD type, PPDH_FMT_COUNTERVALUE value)
 
PDH_STATUS WINAPI PdhGetRawCounterValue (PDH_HCOUNTER handle, LPDWORD type, PPDH_RAW_COUNTER value)
 
PDH_STATUS WINAPI PdhLookupPerfIndexByNameA (LPCSTR machine, LPCSTR name, LPDWORD index)
 
PDH_STATUS WINAPI PdhLookupPerfIndexByNameW (LPCWSTR machine, LPCWSTR name, LPDWORD index)
 
PDH_STATUS WINAPI PdhLookupPerfNameByIndexA (LPCSTR machine, DWORD index, LPSTR buffer, LPDWORD size)
 
PDH_STATUS WINAPI PdhLookupPerfNameByIndexW (LPCWSTR machine, DWORD index, LPWSTR buffer, LPDWORD size)
 
PDH_STATUS WINAPI PdhOpenQueryA (LPCSTR source, DWORD_PTR userdata, PDH_HQUERY *query)
 
PDH_STATUS WINAPI PdhOpenQueryW (LPCWSTR source, DWORD_PTR userdata, PDH_HQUERY *handle)
 
PDH_STATUS WINAPI PdhRemoveCounter (PDH_HCOUNTER handle)
 
PDH_STATUS WINAPI PdhSetCounterScaleFactor (PDH_HCOUNTER handle, LONG factor)
 
PDH_STATUS WINAPI PdhValidatePathA (LPCSTR path)
 
static PDH_STATUS validate_path (LPCWSTR path)
 
PDH_STATUS WINAPI PdhValidatePathW (LPCWSTR path)
 
PDH_STATUS WINAPI PdhVbAddCounter (PDH_HQUERY query, LPCSTR path, PDH_HCOUNTER *counter)
 
double WINAPI PdhVbGetDoubleCounterValue (PDH_HCOUNTER handle, PDH_STATUS *counter_status)
 
PDH_STATUS WINAPI PdhValidatePathExA (PDH_HLOG source, LPCSTR path)
 
PDH_STATUS WINAPI PdhValidatePathExW (PDH_HLOG source, LPCWSTR path)
 
PDH_STATUS WINAPI PdhMakeCounterPathA (PDH_COUNTER_PATH_ELEMENTS_A *e, LPSTR buffer, LPDWORD buflen, DWORD flags)
 
PDH_STATUS WINAPI PdhMakeCounterPathW (PDH_COUNTER_PATH_ELEMENTS_W *e, LPWSTR buffer, LPDWORD buflen, DWORD flags)
 
PDH_STATUS WINAPI PdhEnumObjectItemsA (LPCSTR szDataSource, LPCSTR szMachineName, LPCSTR szObjectName, LPSTR mszCounterList, LPDWORD pcchCounterListLength, LPSTR mszInstanceList, LPDWORD pcchInstanceListLength, DWORD dwDetailLevel, DWORD dwFlags)
 
PDH_STATUS WINAPI PdhEnumObjectItemsW (LPCWSTR szDataSource, LPCWSTR szMachineName, LPCWSTR szObjectName, LPWSTR mszCounterList, LPDWORD pcchCounterListLength, LPWSTR mszInstanceList, LPDWORD pcchInstanceListLength, DWORD dwDetailLevel, DWORD dwFlags)
 
PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource (DWORD source)
 
PDH_STATUS WINAPI PdhGetLogFileTypeA (const char *log, DWORD *type)
 
PDH_STATUS WINAPI PdhGetLogFileTypeW (const WCHAR *log, DWORD *type)
 
PDH_STATUS WINAPI PdhBindInputDataSourceA (PDH_HLOG *source, const char *filenamelist)
 
PDH_STATUS WINAPI PdhBindInputDataSourceW (PDH_HLOG *source, const WCHAR *filenamelist)
 
PDH_STATUS WINAPI PdhConnectMachineA (const char *name)
 

Variables

static CRITICAL_SECTION pdh_handle_cs = { &pdh_handle_cs_debug, -1, 0, 0, 0, 0 }
 
static CRITICAL_SECTION_DEBUG pdh_handle_cs_debug
 
static const struct source counter_sources []
 

Macro Definition Documentation

◆ PDH_MAGIC_COUNTER

#define PDH_MAGIC_COUNTER   0x50444831 /* 'PDH1' */

Definition at line 88 of file pdh_main.c.

◆ PDH_MAGIC_QUERY

#define PDH_MAGIC_QUERY   0x50444830 /* 'PDH0' */

Definition at line 110 of file pdh_main.c.

◆ TYPE_PROCESSOR_TIME

#define TYPE_PROCESSOR_TIME
Value:
#define PERF_DELTA_COUNTER
Definition: winperf.h:37
#define PERF_SIZE_LARGE
Definition: winperf.h:15
#define PERF_TIMER_100NS
Definition: winperf.h:35
#define PERF_COUNTER_RATE
Definition: winperf.h:26
#define PERF_TYPE_COUNTER
Definition: winperf.h:19
#define PERF_DISPLAY_PERCENT
Definition: winperf.h:43
#define PERF_INVERSE_COUNTER
Definition: winperf.h:39

Definition at line 165 of file pdh_main.c.

◆ TYPE_UPTIME

Function Documentation

◆ collect_processor_time()

static void CALLBACK collect_processor_time ( struct counter *  counter)
static

Definition at line 153 of file pdh_main.c.

154{
155 counter->two.largevalue = 500000; /* FIXME */
157}
#define PDH_CSTATUS_VALID_DATA
Definition: pdhmsg.h:24
DWORD status
Definition: pdh_main.c:76
union value two
Definition: pdh_main.c:85
LONGLONG largevalue
Definition: pdh_main.c:67

◆ collect_query_data()

static void collect_query_data ( struct query *  query)
static

Definition at line 410 of file pdh_main.c.

411{
412 struct list *item;
413
415 {
417 struct counter *counter = LIST_ENTRY( item, struct counter, entry );
418
419 counter->collect( counter );
420
421 GetLocalTime( &time );
423 }
424}
Definition: list.h:39
BOOL WINAPI SystemTimeToFileTime(IN CONST SYSTEMTIME *lpSystemTime, OUT LPFILETIME lpFileTime)
Definition: time.c:153
VOID WINAPI GetLocalTime(OUT LPSYSTEMTIME lpSystemTime)
Definition: time.c:272
uint32_t entry
Definition: isohybrid.c:63
__u16 time
Definition: mkdosfs.c:8
#define LIST_FOR_EACH(cursor, list)
Definition: list.h:226
FILETIME stamp
Definition: pdh_main.c:82
struct list counters
Definition: pdh_main.c:120
#define LIST_ENTRY(type)
Definition: queue.h:175

Referenced by collect_query_thread(), PdhCollectQueryData(), and PdhCollectQueryDataWithTime().

◆ collect_query_thread()

static DWORD CALLBACK collect_query_thread ( void *  arg)
static

Definition at line 454 of file pdh_main.c.

455{
456 struct query *query = arg;
459
460 for (;;)
461 {
463
466 {
469 }
470
472
473 if (!SetEvent( query->wait ))
474 {
476 ExitThread( 0 );
477 }
479 }
480}
#define WAIT_TIMEOUT
Definition: dderror.h:14
VOID WINAPI ExitThread(IN DWORD uExitCode)
Definition: thread.c:365
unsigned long DWORD
Definition: ntddk_ex.h:95
static void collect_query_data(struct query *query)
Definition: pdh_main.c:410
#define PDH_MAGIC_QUERY
Definition: pdh_main.c:110
static CRITICAL_SECTION pdh_handle_cs
Definition: pdh_main.c:42
#define PDH_INVALID_HANDLE
Definition: pdhmsg.h:45
HANDLE wait
Definition: pdh_main.c:118
DWORD magic
Definition: pdh_main.c:114
DWORD interval
Definition: pdh_main.c:117
HANDLE stop
Definition: pdh_main.c:119
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:669
void WINAPI LeaveCriticalSection(LPCRITICAL_SECTION)
void WINAPI EnterCriticalSection(LPCRITICAL_SECTION)
void * arg
Definition: msvc.h:10

Referenced by PdhCollectQueryDataEx().

◆ collect_uptime()

static void CALLBACK collect_uptime ( struct counter *  counter)
static

Definition at line 159 of file pdh_main.c.

160{
163}
ULONGLONG WINAPI DECLSPEC_HOTPATCH GetTickCount64(void)
Definition: sync.c:192

◆ create_counter()

static struct counter * create_counter ( void  )
static

Definition at line 90 of file pdh_main.c.

91{
92 struct counter *counter;
93
94 if ((counter = calloc( 1, sizeof(struct counter) )))
95 {
97 return counter;
98 }
99 return NULL;
100}
#define NULL
Definition: types.h:112
#define PDH_MAGIC_COUNTER
Definition: pdh_main.c:88
#define calloc
Definition: rosglue.h:14
DWORD magic
Definition: pdh_main.c:72

Referenced by PdhAddCounterW().

◆ create_query()

static struct query * create_query ( void  )
static

Definition at line 123 of file pdh_main.c.

124{
125 struct query *query;
126
127 if ((query = calloc( 1, sizeof(struct query) )))
128 {
131 return query;
132 }
133 return NULL;
134}
static void list_init(struct list_entry *head)
Definition: list.h:51

Referenced by get_diskdrivetodiskpartition_pairs(), get_logicaldisktopartition_pairs(), msi_table_apply_transform(), PdhOpenQueryW(), and wbem_services_ExecMethod().

◆ destroy_counter()

static void destroy_counter ( struct counter *  counter)
static

Definition at line 102 of file pdh_main.c.

103{
104 /* Ensure compiler doesn't optimize out the assignment with 0. */
105 SecureZeroMemory( &counter->magic, sizeof( counter->magic ) );
106 free( counter->path );
107 free( counter );
108}
#define free
Definition: debug_ros.c:5
WCHAR * path
Definition: pdh_main.c:74
#define SecureZeroMemory
Definition: winbase.h:1441

Referenced by PdhCloseQuery(), and PdhRemoveCounter().

◆ destroy_query()

static void destroy_query ( struct query *  query)
static

Definition at line 136 of file pdh_main.c.

137{
138 /* Ensure compiler doesn't optimize out the assignment with 0. */
139 SecureZeroMemory( &query->magic, sizeof( query->magic ) );
140 free( query );
141}

Referenced by PdhCloseQuery().

◆ format_value()

static PDH_STATUS format_value ( struct counter *  counter,
DWORD  format,
union value *  raw1,
union value *  raw2,
PDH_FMT_COUNTERVALUE *  value 
)
static

Definition at line 301 of file pdh_main.c.

303{
304 LONG factor;
305
307 if (format & PDH_FMT_LONG)
308 {
309 if (format & PDH_FMT_1000) value->longValue = raw2->longvalue * 1000;
310 else value->longValue = raw2->longvalue * pow( 10, factor );
311 }
312 else if (format & PDH_FMT_LARGE)
313 {
314 if (format & PDH_FMT_1000) value->largeValue = raw2->largevalue * 1000;
315 else value->largeValue = raw2->largevalue * pow( 10, factor );
316 }
317 else if (format & PDH_FMT_DOUBLE)
318 {
319 if (format & PDH_FMT_1000) value->doubleValue = raw2->doublevalue * 1000;
320 else value->doubleValue = raw2->doublevalue * pow( 10, factor );
321 }
322 else
323 {
324 WARN("unknown format %lx\n", format);
326 }
327 return ERROR_SUCCESS;
328}
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERROR_SUCCESS
Definition: deptool.c:10
double pow(double x, double y)
Definition: freeldr.c:179
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint factor
Definition: glfuncs.h:178
#define PDH_FMT_LONG
Definition: pdh.h:49
#define PDH_FMT_DOUBLE
Definition: pdh.h:50
#define PDH_FMT_1000
Definition: pdh.h:53
#define PDH_FMT_LARGE
Definition: pdh.h:51
#define PDH_INVALID_ARGUMENT
Definition: pdhmsg.h:46
long LONG
Definition: pedump.c:60
LONG defaultscale
Definition: pdh_main.c:78
LONG scale
Definition: pdh_main.c:77
Definition: pdh_main.c:64
LONG longvalue
Definition: pdh_main.c:65
double doublevalue
Definition: pdh_main.c:66

Referenced by PdhCalculateCounterFromRawValue(), and PdhGetFormattedCounterValue().

◆ is_local_machine()

static BOOL is_local_machine ( const WCHAR *  name,
DWORD  len 
)
static

Definition at line 179 of file pdh_main.c.

180{
182 DWORD buflen = ARRAY_SIZE(buf);
183
184 if (!GetComputerNameW( buf, &buflen )) return FALSE;
185 return len == buflen && !wcsnicmp( name, buf, buflen );
186}
#define ARRAY_SIZE(A)
Definition: main.h:20
BOOL WINAPI GetComputerNameW(LPWSTR lpBuffer, LPDWORD lpnSize)
Definition: compname.c:446
#define FALSE
Definition: types.h:117
#define wcsnicmp
Definition: compat.h:14
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
GLenum GLsizei len
Definition: glext.h:6722
short WCHAR
Definition: pedump.c:58
Definition: name.c:39
#define MAX_COMPUTERNAME_LENGTH
Definition: winbase.h:268

Referenced by pdh_match_path().

◆ pdh_match_path()

static BOOL pdh_match_path ( LPCWSTR  fullpath,
LPCWSTR  path 
)
static

Definition at line 188 of file pdh_main.c.

189{
190 const WCHAR *p;
191
192 if (path[0] == '\\' && path[1] == '\\' && (p = wcschr( path + 2, '\\' )) &&
193 is_local_machine( path + 2, p - path - 2 ))
194 {
195 path += p - path;
196 }
197 if (wcschr( path, '\\' )) p = fullpath;
198 else p = wcsrchr( fullpath, '\\' ) + 1;
199 return !wcscmp( p, path );
200}
#define wcschr
Definition: compat.h:17
#define wcsrchr
Definition: compat.h:16
_ACRTIMP int __cdecl wcscmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:1977
GLfloat GLfloat p
Definition: glext.h:8902
static BOOL is_local_machine(const WCHAR *name, DWORD len)
Definition: pdh_main.c:179

Referenced by PdhAddCounterW(), PdhLookupPerfIndexByNameW(), and PdhValidatePathW().

◆ pdh_strdup_aw()

static WCHAR * pdh_strdup_aw ( const char *  src)
inlinestatic

Definition at line 52 of file pdh_main.c.

53{
54 int len;
55 WCHAR *dst;
56
57 if (!src) return NULL;
58 len = MultiByteToWideChar( CP_ACP, 0, src, -1, NULL, 0 );
59 if ((dst = malloc( len * sizeof(WCHAR) ))) MultiByteToWideChar( CP_ACP, 0, src, -1, dst, len );
60 return dst;
61}
#define malloc
Definition: debug_ros.c:4
#define CP_ACP
Definition: compat.h:109
#define MultiByteToWideChar
Definition: compat.h:110
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340

Referenced by PdhAddCounterA(), PdhLookupPerfIndexByNameA(), PdhLookupPerfNameByIndexA(), PdhMakeCounterPathA(), PdhOpenQueryA(), and PdhValidatePathA().

◆ PdhAddCounterA()

PDH_STATUS WINAPI PdhAddCounterA ( PDH_HQUERY  query,
LPCSTR  path,
DWORD_PTR  userdata,
PDH_HCOUNTER *  counter 
)

Definition at line 205 of file pdh_main.c.

207{
209 WCHAR *pathW;
210
211 TRACE("%p %s %Ix %p\n", query, debugstr_a(path), userdata, counter);
212
213 if (!path) return PDH_INVALID_ARGUMENT;
214
215 if (!(pathW = pdh_strdup_aw( path )))
217
218 ret = PdhAddCounterW( query, pathW, userdata, counter );
219
220 free( pathW );
221 return ret;
222}
return ret
Definition: mutex.c:147
#define debugstr_a
Definition: kernel32.h:31
static const WCHAR pathW[]
Definition: path.c:2368
LONG PDH_STATUS
Definition: pdh.h:35
static WCHAR * pdh_strdup_aw(const char *src)
Definition: pdh_main.c:52
PDH_STATUS WINAPI PdhAddCounterW(PDH_HQUERY hquery, LPCWSTR path, DWORD_PTR userdata, PDH_HCOUNTER *hcounter)
Definition: pdh_main.c:227
#define PDH_MEMORY_ALLOCATION_FAILURE
Definition: pdhmsg.h:44
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by PdhAddEnglishCounterA(), test_PdhAddCounterA(), test_PdhCollectQueryDataEx(), test_PdhCollectQueryDataWithTime(), test_PdhGetCounterInfoA(), test_PdhGetCounterTimeBase(), test_PdhGetFormattedCounterValue(), test_PdhGetRawCounterValue(), test_PdhSetCounterScaleFactor(), and test_PdhVbGetDoubleCounterValue().

◆ PdhAddCounterW()

PDH_STATUS WINAPI PdhAddCounterW ( PDH_HQUERY  hquery,
LPCWSTR  path,
DWORD_PTR  userdata,
PDH_HCOUNTER *  hcounter 
)

Definition at line 227 of file pdh_main.c.

229{
230 struct query *query = hquery;
231 struct counter *counter;
232 unsigned int i;
233
234 TRACE("%p %s %Ix %p\n", hquery, debugstr_w(path), userdata, hcounter);
235
236 if (!path || !hcounter) return PDH_INVALID_ARGUMENT;
237
239 if (!query || query->magic != PDH_MAGIC_QUERY)
240 {
242 return PDH_INVALID_HANDLE;
243 }
244
245 *hcounter = NULL;
246 for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
247 {
249 {
250 if ((counter = create_counter()))
251 {
253 counter->collect = counter_sources[i].collect;
254 counter->type = counter_sources[i].type;
256 counter->base = counter_sources[i].base;
258 counter->user = userdata;
259
261 *hcounter = counter;
262
264 return ERROR_SUCCESS;
265 }
268 }
269 }
272}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
static wchar_t * wcsdup(const wchar_t *str)
Definition: string.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define debugstr_w
Definition: kernel32.h:32
static BOOL pdh_match_path(LPCWSTR fullpath, LPCWSTR path)
Definition: pdh_main.c:188
static struct counter * create_counter(void)
Definition: pdh_main.c:90
static const struct source counter_sources[]
Definition: pdh_main.c:173
#define PDH_CSTATUS_NO_COUNTER
Definition: pdhmsg.h:42
DWORD type
Definition: pdh_main.c:75
struct list entry
Definition: pdh_main.c:73
DWORD_PTR user
Definition: pdh_main.c:79
DWORD_PTR queryuser
Definition: pdh_main.c:80
LONGLONG base
Definition: pdh_main.c:81
DWORD_PTR user
Definition: pdh_main.c:115

Referenced by PdhAddCounterA(), PdhAddEnglishCounterW(), test_PdhAddCounterW(), and test_PdhGetCounterInfoW().

◆ PdhAddEnglishCounterA()

PDH_STATUS WINAPI PdhAddEnglishCounterA ( PDH_HQUERY  query,
LPCSTR  path,
DWORD_PTR  userdata,
PDH_HCOUNTER *  counter 
)

Definition at line 277 of file pdh_main.c.

279{
280 TRACE("%p %s %Ix %p\n", query, debugstr_a(path), userdata, counter);
281
282 if (!counter) return PDH_INVALID_ARGUMENT;
283 if (!query) return PDH_INVALID_HANDLE;
284 return PdhAddCounterA( query, path, userdata, counter );
285}
PDH_STATUS WINAPI PdhAddCounterA(PDH_HQUERY query, LPCSTR path, DWORD_PTR userdata, PDH_HCOUNTER *counter)
Definition: pdh_main.c:205

Referenced by init_function_ptrs().

◆ PdhAddEnglishCounterW()

PDH_STATUS WINAPI PdhAddEnglishCounterW ( PDH_HQUERY  query,
LPCWSTR  path,
DWORD_PTR  userdata,
PDH_HCOUNTER *  counter 
)

Definition at line 290 of file pdh_main.c.

292{
293 TRACE("%p %s %Ix %p\n", query, debugstr_w(path), userdata, counter);
294
295 if (!counter) return PDH_INVALID_ARGUMENT;
296 if (!query) return PDH_INVALID_HANDLE;
297 return PdhAddCounterW( query, path, userdata, counter );
298}

Referenced by init_function_ptrs().

◆ PdhBindInputDataSourceA()

PDH_STATUS WINAPI PdhBindInputDataSourceA ( PDH_HLOG *  source,
const char *  filenamelist 
)

Definition at line 1273 of file pdh_main.c.

1274{
1275 FIXME("%p %s: stub\n", source, debugstr_a(filenamelist));
1276 return PDH_NOT_IMPLEMENTED;
1277}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define PDH_NOT_IMPLEMENTED
Definition: pdhmsg.h:68

◆ PdhBindInputDataSourceW()

PDH_STATUS WINAPI PdhBindInputDataSourceW ( PDH_HLOG *  source,
const WCHAR *  filenamelist 
)

Definition at line 1282 of file pdh_main.c.

1283{
1284 FIXME("%p %s: stub\n", source, debugstr_w(filenamelist));
1285 return PDH_NOT_IMPLEMENTED;
1286}

◆ PdhCalculateCounterFromRawValue()

PDH_STATUS WINAPI PdhCalculateCounterFromRawValue ( PDH_HCOUNTER  handle,
DWORD  format,
PPDH_RAW_COUNTER  raw1,
PPDH_RAW_COUNTER  raw2,
PPDH_FMT_COUNTERVALUE  value 
)

Definition at line 333 of file pdh_main.c.

336{
338 struct counter *counter = handle;
339
340 TRACE("%p 0x%08lx %p %p %p\n", handle, format, raw1, raw2, value);
341
342 if (!value) return PDH_INVALID_ARGUMENT;
343
346 {
348 return PDH_INVALID_HANDLE;
349 }
350
351 ret = format_value( counter, format, (union value *)&raw1->SecondValue,
352 (union value *)&raw2->SecondValue, value );
353
355 return ret;
356}
static PDH_STATUS format_value(struct counter *counter, DWORD format, union value *raw1, union value *raw2, PDH_FMT_COUNTERVALUE *value)
Definition: pdh_main.c:301
LONGLONG SecondValue
Definition: pdh.h:78

◆ PdhCloseQuery()

PDH_STATUS WINAPI PdhCloseQuery ( PDH_HQUERY  handle)

Definition at line 362 of file pdh_main.c.

363{
364 struct query *query = handle;
365 struct list *item, *next;
366
367 TRACE("%p\n", handle);
368
370 if (!query || query->magic != PDH_MAGIC_QUERY)
371 {
373 return PDH_INVALID_HANDLE;
374 }
375
376 if (query->thread)
377 {
379 SetEvent( query->stop );
381
383
386 {
388 return ERROR_SUCCESS;
389 }
392 query->thread = NULL;
393 }
394
396 {
397 struct counter *counter = LIST_ENTRY( item, struct counter, entry );
398
401 }
402
404
406 return ERROR_SUCCESS;
407}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static HANDLE thread
Definition: service.c:33
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
static void destroy_query(struct query *query)
Definition: pdh_main.c:136
static void destroy_counter(struct counter *counter)
Definition: pdh_main.c:102
static unsigned __int64 next
Definition: rand_nt.c:6
#define LIST_FOR_EACH_SAFE(cursor, cursor2, list)
Definition: list.h:230
HANDLE thread
Definition: pdh_main.c:116

Referenced by test_PdhAddCounterA(), test_PdhAddCounterW(), test_PdhAddEnglishCounterA(), test_PdhAddEnglishCounterW(), test_PdhCollectQueryDataEx(), test_PdhCollectQueryDataWithTime(), test_PdhGetCounterInfoA(), test_PdhGetCounterInfoW(), test_PdhGetCounterTimeBase(), test_PdhGetFormattedCounterValue(), test_PdhGetRawCounterValue(), test_PdhOpenQueryA(), test_PdhOpenQueryW(), test_PdhSetCounterScaleFactor(), and test_PdhVbGetDoubleCounterValue().

◆ PdhCollectQueryData()

PDH_STATUS WINAPI PdhCollectQueryData ( PDH_HQUERY  handle)

◆ PdhCollectQueryDataEx()

PDH_STATUS WINAPI PdhCollectQueryDataEx ( PDH_HQUERY  handle,
DWORD  interval,
HANDLE  event 
)

Definition at line 485 of file pdh_main.c.

486{
488 struct query *query = handle;
489
490 TRACE("%p %ld %p\n", handle, interval, event);
491
493 if (!query || query->magic != PDH_MAGIC_QUERY)
494 {
496 return PDH_INVALID_HANDLE;
497 }
498 if (list_empty( &query->counters ))
499 {
501 return PDH_NO_DATA;
502 }
503 if (query->thread)
504 {
506 SetEvent( query->stop );
508
510
513 {
515 return PDH_INVALID_HANDLE;
516 }
518 query->thread = NULL;
519 }
520 else if (!(query->stop = CreateEventW( NULL, FALSE, FALSE, NULL )))
521 {
522 ret = GetLastError();
524 return ret;
525 }
526 query->wait = event;
527 query->interval = interval * 1000;
529 {
530 ret = GetLastError();
532
534 return ret;
535 }
536
538 return ERROR_SUCCESS;
539}
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
static DWORD CALLBACK collect_query_thread(void *arg)
Definition: pdh_main.c:454
Definition: filter.c:185
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:587
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by test_PdhCollectQueryDataEx().

◆ PdhCollectQueryDataWithTime()

PDH_STATUS WINAPI PdhCollectQueryDataWithTime ( PDH_HQUERY  handle,
LONGLONG *  timestamp 
)

Definition at line 544 of file pdh_main.c.

545{
546 struct query *query = handle;
547 struct counter *counter;
548 struct list *item;
549
550 TRACE("%p %p\n", handle, timestamp);
551
552 if (!timestamp) return PDH_INVALID_ARGUMENT;
553
555 if (!query || query->magic != PDH_MAGIC_QUERY)
556 {
558 return PDH_INVALID_HANDLE;
559 }
560 if (list_empty( &query->counters ))
561 {
563 return PDH_NO_DATA;
564 }
565
567
569 counter = LIST_ENTRY( item, struct counter, entry );
570
572
574 return ERROR_SUCCESS;
575}
DWORD dwHighDateTime
Definition: mapidefs.h:66
DWORD dwLowDateTime
Definition: mapidefs.h:65
Definition: list.h:15
int64_t LONGLONG
Definition: typedefs.h:68

Referenced by init_function_ptrs().

◆ PdhConnectMachineA()

PDH_STATUS WINAPI PdhConnectMachineA ( const char *  name)

Definition at line 1291 of file pdh_main.c.

1292{
1293 FIXME("%s: stub\n", debugstr_a(name));
1294 return PDH_NOT_IMPLEMENTED;
1295}

◆ PdhEnumObjectItemsA()

PDH_STATUS WINAPI PdhEnumObjectItemsA ( LPCSTR  szDataSource,
LPCSTR  szMachineName,
LPCSTR  szObjectName,
LPSTR  mszCounterList,
LPDWORD  pcchCounterListLength,
LPSTR  mszInstanceList,
LPDWORD  pcchInstanceListLength,
DWORD  dwDetailLevel,
DWORD  dwFlags 
)

Definition at line 1218 of file pdh_main.c.

1221{
1222 FIXME("%s, %s, %s, %p, %p, %p, %p, %ld, 0x%lx: stub\n", debugstr_a(szDataSource), debugstr_a(szMachineName),
1223 debugstr_a(szObjectName), mszCounterList, pcchCounterListLength, mszInstanceList,
1224 pcchInstanceListLength, dwDetailLevel, dwFlags);
1225
1226 return PDH_NOT_IMPLEMENTED;
1227}
_In_ LPWSTR _In_ DWORD _In_ DWORD _In_ DWORD dwFlags
Definition: netsh.h:141

◆ PdhEnumObjectItemsW()

PDH_STATUS WINAPI PdhEnumObjectItemsW ( LPCWSTR  szDataSource,
LPCWSTR  szMachineName,
LPCWSTR  szObjectName,
LPWSTR  mszCounterList,
LPDWORD  pcchCounterListLength,
LPWSTR  mszInstanceList,
LPDWORD  pcchInstanceListLength,
DWORD  dwDetailLevel,
DWORD  dwFlags 
)

Definition at line 1232 of file pdh_main.c.

1235{
1236 FIXME("%s, %s, %s, %p, %p, %p, %p, %ld, 0x%lx: stub\n", debugstr_w(szDataSource), debugstr_w(szMachineName),
1237 debugstr_w(szObjectName), mszCounterList, pcchCounterListLength, mszInstanceList,
1238 pcchInstanceListLength, dwDetailLevel, dwFlags);
1239
1240 return PDH_NOT_IMPLEMENTED;
1241}

◆ PdhExpandCounterPathA()

PDH_STATUS WINAPI PdhExpandCounterPathA ( LPCSTR  szWildCardPath,
LPSTR  mszExpandedPathList,
LPDWORD  pcchPathListLength 
)

Definition at line 598 of file pdh_main.c.

599{
600 FIXME("%s, %p, %p: stub\n", debugstr_a(szWildCardPath), mszExpandedPathList, pcchPathListLength);
601 return PdhExpandWildCardPathA(NULL, szWildCardPath, mszExpandedPathList, pcchPathListLength, 0);
602}
PDH_STATUS WINAPI PdhExpandWildCardPathA(LPCSTR szDataSource, LPCSTR szWildCardPath, LPSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags)
Definition: pdh_main.c:580

◆ PdhExpandCounterPathW()

PDH_STATUS WINAPI PdhExpandCounterPathW ( LPCWSTR  szWildCardPath,
LPWSTR  mszExpandedPathList,
LPDWORD  pcchPathListLength 
)

Definition at line 607 of file pdh_main.c.

608{
609 FIXME("%s, %p, %p: stub\n", debugstr_w(szWildCardPath), mszExpandedPathList, pcchPathListLength);
610 return PdhExpandWildCardPathW(NULL, szWildCardPath, mszExpandedPathList, pcchPathListLength, 0);
611}
PDH_STATUS WINAPI PdhExpandWildCardPathW(LPCWSTR szDataSource, LPCWSTR szWildCardPath, LPWSTR mszExpandedPathList, LPDWORD pcchPathListLength, DWORD dwFlags)
Definition: pdh_main.c:589

◆ PdhExpandWildCardPathA()

PDH_STATUS WINAPI PdhExpandWildCardPathA ( LPCSTR  szDataSource,
LPCSTR  szWildCardPath,
LPSTR  mszExpandedPathList,
LPDWORD  pcchPathListLength,
DWORD  dwFlags 
)

Definition at line 580 of file pdh_main.c.

581{
582 FIXME("%s, %s, %p, %p, 0x%lx: stub\n", debugstr_a(szDataSource), debugstr_a(szWildCardPath), mszExpandedPathList, pcchPathListLength, dwFlags);
583 return PDH_NOT_IMPLEMENTED;
584}

Referenced by PdhExpandCounterPathA().

◆ PdhExpandWildCardPathW()

PDH_STATUS WINAPI PdhExpandWildCardPathW ( LPCWSTR  szDataSource,
LPCWSTR  szWildCardPath,
LPWSTR  mszExpandedPathList,
LPDWORD  pcchPathListLength,
DWORD  dwFlags 
)

Definition at line 589 of file pdh_main.c.

590{
591 FIXME("%s, %s, %p, %p, 0x%lx: stub\n", debugstr_w(szDataSource), debugstr_w(szWildCardPath), mszExpandedPathList, pcchPathListLength, dwFlags);
592 return PDH_NOT_IMPLEMENTED;
593}

Referenced by PdhExpandCounterPathW().

◆ PdhGetCounterInfoA()

PDH_STATUS WINAPI PdhGetCounterInfoA ( PDH_HCOUNTER  handle,
BOOLEAN  text,
LPDWORD  size,
PPDH_COUNTER_INFO_A  info 
)

Definition at line 616 of file pdh_main.c.

617{
618 struct counter *counter = handle;
619
620 TRACE("%p %d %p %p\n", handle, text, size, info);
621
624 {
626 return PDH_INVALID_HANDLE;
627 }
628 if (!size)
629 {
632 }
633 if (*size < sizeof(PDH_COUNTER_INFO_A))
634 {
635 *size = sizeof(PDH_COUNTER_INFO_A);
637 return PDH_MORE_DATA;
638 }
639
640 memset( info, 0, sizeof(PDH_COUNTER_INFO_A) );
641
642 info->dwType = counter->type;
643 info->CStatus = counter->status;
644 info->lScale = counter->scale;
645 info->lDefaultScale = counter->defaultscale;
646 info->dwUserData = counter->user;
647 info->dwQueryUserData = counter->queryuser;
648
649 *size = sizeof(PDH_COUNTER_INFO_A);
650
652 return ERROR_SUCCESS;
653}
const WCHAR * text
Definition: package.c:1826
GLsizeiptr size
Definition: glext.h:5919
struct _PDH_COUNTER_INFO_A PDH_COUNTER_INFO_A
#define PDH_MORE_DATA
Definition: pdhmsg.h:28
#define memset(x, y, z)
Definition: compat.h:39

Referenced by test_PdhGetCounterInfoA().

◆ PdhGetCounterInfoW()

PDH_STATUS WINAPI PdhGetCounterInfoW ( PDH_HCOUNTER  handle,
BOOLEAN  text,
LPDWORD  size,
PPDH_COUNTER_INFO_W  info 
)

Definition at line 658 of file pdh_main.c.

659{
660 struct counter *counter = handle;
661
662 TRACE("%p %d %p %p\n", handle, text, size, info);
663
666 {
668 return PDH_INVALID_HANDLE;
669 }
670 if (!size)
671 {
674 }
675 if (*size < sizeof(PDH_COUNTER_INFO_W))
676 {
677 *size = sizeof(PDH_COUNTER_INFO_W);
679 return PDH_MORE_DATA;
680 }
681
682 memset( info, 0, sizeof(PDH_COUNTER_INFO_W) );
683
684 info->dwType = counter->type;
685 info->CStatus = counter->status;
686 info->lScale = counter->scale;
687 info->lDefaultScale = counter->defaultscale;
688 info->dwUserData = counter->user;
689 info->dwQueryUserData = counter->queryuser;
690
691 *size = sizeof(PDH_COUNTER_INFO_W);
692
694 return ERROR_SUCCESS;
695}
struct _PDH_COUNTER_INFO_W PDH_COUNTER_INFO_W

Referenced by test_PdhGetCounterInfoW().

◆ PdhGetCounterTimeBase()

PDH_STATUS WINAPI PdhGetCounterTimeBase ( PDH_HCOUNTER  handle,
LONGLONG *  base 
)

Definition at line 700 of file pdh_main.c.

701{
702 struct counter *counter = handle;
703
704 TRACE("%p %p\n", handle, base);
705
706 if (!base) return PDH_INVALID_ARGUMENT;
707
710 {
712 return PDH_INVALID_HANDLE;
713 }
714
715 *base = counter->base;
716
718 return ERROR_SUCCESS;
719}

Referenced by test_PdhGetCounterTimeBase().

◆ PdhGetDllVersion()

PDH_STATUS WINAPI PdhGetDllVersion ( LPDWORD  version)

Definition at line 724 of file pdh_main.c.

725{
726 if (!version)
728
730
731 return ERROR_SUCCESS;
732}
static const WCHAR version[]
Definition: asmname.c:66
#define PDH_VERSION
Definition: pdh.h:42

Referenced by test_PdhGetDllVersion().

◆ PdhGetFormattedCounterValue()

PDH_STATUS WINAPI PdhGetFormattedCounterValue ( PDH_HCOUNTER  handle,
DWORD  format,
LPDWORD  type,
PPDH_FMT_COUNTERVALUE  value 
)

Definition at line 737 of file pdh_main.c.

739{
741 struct counter *counter = handle;
742
743 TRACE("%p %lx %p %p\n", handle, format, type, value);
744
745 if (!value) return PDH_INVALID_ARGUMENT;
746
749 {
751 return PDH_INVALID_HANDLE;
752 }
753 if (counter->status)
754 {
756 return PDH_INVALID_DATA;
757 }
759 {
760 value->CStatus = ERROR_SUCCESS;
761 if (type) *type = counter->type;
762 }
763
765 return ret;
766}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define PDH_INVALID_DATA
Definition: pdhmsg.h:55
union value one
Definition: pdh_main.c:84

Referenced by PdhVbGetDoubleCounterValue(), test_PdhCollectQueryDataEx(), test_PdhGetFormattedCounterValue(), and test_PdhVbGetDoubleCounterValue().

◆ PdhGetLogFileTypeA()

PDH_STATUS WINAPI PdhGetLogFileTypeA ( const char *  log,
DWORD *  type 
)

Definition at line 1255 of file pdh_main.c.

1256{
1257 FIXME("%s, %p: stub\n", debugstr_a(log), type);
1258 return PDH_NOT_IMPLEMENTED;
1259}
#define log(outFile, fmt,...)
Definition: util.h:15

◆ PdhGetLogFileTypeW()

PDH_STATUS WINAPI PdhGetLogFileTypeW ( const WCHAR *  log,
DWORD *  type 
)

Definition at line 1264 of file pdh_main.c.

1265{
1266 FIXME("%s, %p: stub\n", debugstr_w(log), type);
1267 return PDH_NOT_IMPLEMENTED;
1268}

◆ PdhGetRawCounterValue()

PDH_STATUS WINAPI PdhGetRawCounterValue ( PDH_HCOUNTER  handle,
LPDWORD  type,
PPDH_RAW_COUNTER  value 
)

Definition at line 771 of file pdh_main.c.

773{
774 struct counter *counter = handle;
775
776 TRACE("%p %p %p\n", handle, type, value);
777
778 if (!value) return PDH_INVALID_ARGUMENT;
779
782 {
784 return PDH_INVALID_HANDLE;
785 }
786
787 value->CStatus = counter->status;
788 value->TimeStamp.dwLowDateTime = counter->stamp.dwLowDateTime;
789 value->TimeStamp.dwHighDateTime = counter->stamp.dwHighDateTime;
790 value->FirstValue = counter->one.largevalue;
791 value->SecondValue = counter->two.largevalue;
792 value->MultiCount = 1; /* FIXME */
793
794 if (type) *type = counter->type;
795
797 return ERROR_SUCCESS;
798}

Referenced by test_PdhGetRawCounterValue().

◆ PdhLookupPerfIndexByNameA()

PDH_STATUS WINAPI PdhLookupPerfIndexByNameA ( LPCSTR  machine,
LPCSTR  name,
LPDWORD  index 
)

Definition at line 803 of file pdh_main.c.

804{
807 WCHAR *nameW;
808
809 TRACE("%s %s %p\n", debugstr_a(machine), debugstr_a(name), index);
810
811 if (!name) return PDH_INVALID_ARGUMENT;
812
814
815 if (!(nameW = pdh_strdup_aw( name )))
817
819
820 free( nameW );
821 free( machineW );
822 return ret;
823}
static const WCHAR nameW[]
Definition: main.c:49
GLuint index
Definition: glext.h:6031
static const WCHAR machineW[]
Definition: profile.c:105
static const char machine[]
Definition: profile.c:104
PDH_STATUS WINAPI PdhLookupPerfIndexByNameW(LPCWSTR machine, LPCWSTR name, LPDWORD index)
Definition: pdh_main.c:828

Referenced by test_PdhLookupPerfIndexByNameA().

◆ PdhLookupPerfIndexByNameW()

PDH_STATUS WINAPI PdhLookupPerfIndexByNameW ( LPCWSTR  machine,
LPCWSTR  name,
LPDWORD  index 
)

Definition at line 828 of file pdh_main.c.

829{
830 unsigned int i;
831
832 TRACE("%s %s %p\n", debugstr_w(machine), debugstr_w(name), index);
833
834 if (!name || !index) return PDH_INVALID_ARGUMENT;
835
836 if (machine)
837 {
838 FIXME("remote machine not supported\n");
840 }
841 for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
842 {
844 {
845 *index = counter_sources[i].index;
846 return ERROR_SUCCESS;
847 }
848 }
850}
#define PDH_STRING_NOT_FOUND
Definition: pdhmsg.h:69
#define PDH_CSTATUS_NO_MACHINE
Definition: pdhmsg.h:26

Referenced by PdhLookupPerfIndexByNameA(), and test_PdhLookupPerfIndexByNameW().

◆ PdhLookupPerfNameByIndexA()

PDH_STATUS WINAPI PdhLookupPerfNameByIndexA ( LPCSTR  machine,
DWORD  index,
LPSTR  buffer,
LPDWORD  size 
)

Definition at line 855 of file pdh_main.c.

856{
860 DWORD sizeW = ARRAY_SIZE(bufferW);
861
862 TRACE("%s %ld %p %p\n", debugstr_a(machine), index, buffer, size);
863
864 if (!buffer || !size) return PDH_INVALID_ARGUMENT;
865
867
868 if (!(ret = PdhLookupPerfNameByIndexW( machineW, index, bufferW, &sizeW )))
869 {
870 int required = WideCharToMultiByte( CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL );
871
872 if (*size < required) ret = PDH_MORE_DATA;
873 else WideCharToMultiByte( CP_ACP, 0, bufferW, -1, buffer, required, NULL, NULL );
874 *size = required;
875 }
876 free( machineW );
877 return ret;
878}
BOOL required
Definition: adapter_vk.c:1885
#define WideCharToMultiByte
Definition: compat.h:111
static const WCHAR sizeW[]
Definition: editor.c:79
GLuint buffer
Definition: glext.h:5915
#define PDH_MAX_COUNTER_NAME
Definition: pdh.h:47
PDH_STATUS WINAPI PdhLookupPerfNameByIndexW(LPCWSTR machine, DWORD index, LPWSTR buffer, LPDWORD size)
Definition: pdh_main.c:883

Referenced by test_PdhLookupPerfNameByIndexA().

◆ PdhLookupPerfNameByIndexW()

PDH_STATUS WINAPI PdhLookupPerfNameByIndexW ( LPCWSTR  machine,
DWORD  index,
LPWSTR  buffer,
LPDWORD  size 
)

Definition at line 883 of file pdh_main.c.

884{
886 unsigned int i;
887
888 TRACE("%s %ld %p %p\n", debugstr_w(machine), index, buffer, size);
889
890 if (machine)
891 {
892 FIXME("remote machine not supported\n");
894 }
895
896 if (!buffer || !size) return PDH_INVALID_ARGUMENT;
897 if (!index) return ERROR_SUCCESS;
898
899 for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
900 {
902 {
903 WCHAR *p = wcsrchr( counter_sources[i].path, '\\' ) + 1;
904 unsigned int required = lstrlenW( p ) + 1;
905
906 if (*size < required) ret = PDH_MORE_DATA;
907 else
908 {
909 lstrcpyW( buffer, p );
911 }
912 *size = required;
913 return ret;
914 }
915 }
917}
#define lstrcpyW
Definition: compat.h:749
#define lstrlenW
Definition: compat.h:750

Referenced by PdhLookupPerfNameByIndexA(), and test_PdhLookupPerfNameByIndexW().

◆ PdhMakeCounterPathA()

PDH_STATUS WINAPI PdhMakeCounterPathA ( PDH_COUNTER_PATH_ELEMENTS_A *  e,
LPSTR  buffer,
LPDWORD  buflen,
DWORD  flags 
)

Definition at line 1119 of file pdh_main.c.

1121{
1124 WCHAR *bufferW;
1125 DWORD buflenW;
1126
1127 TRACE("%p %p %p 0x%08lx\n", e, buffer, buflen, flags);
1128
1129 if (!e || !buflen) return PDH_INVALID_ARGUMENT;
1130
1131 memset( &eW, 0, sizeof(eW) );
1132 if (e->szMachineName && !(eW.szMachineName = pdh_strdup_aw( e->szMachineName ))) goto done;
1133 if (e->szObjectName && !(eW.szObjectName = pdh_strdup_aw( e->szObjectName ))) goto done;
1134 if (e->szInstanceName && !(eW.szInstanceName = pdh_strdup_aw( e->szInstanceName ))) goto done;
1135 if (e->szParentInstance && !(eW.szParentInstance = pdh_strdup_aw( e->szParentInstance ))) goto done;
1136 if (e->szCounterName && !(eW.szCounterName = pdh_strdup_aw( e->szCounterName ))) goto done;
1137 eW.dwInstanceIndex = e->dwInstanceIndex;
1138
1139 buflenW = 0;
1140 ret = PdhMakeCounterPathW( &eW, NULL, &buflenW, flags );
1141 if (ret == PDH_MORE_DATA)
1142 {
1143 if ((bufferW = malloc( buflenW * sizeof(WCHAR) )))
1144 {
1145 if (!(ret = PdhMakeCounterPathW( &eW, bufferW, &buflenW, flags )))
1146 {
1147 int len = WideCharToMultiByte(CP_ACP, 0, bufferW, -1, NULL, 0, NULL, NULL);
1148 if (*buflen >= len) WideCharToMultiByte(CP_ACP, 0, bufferW, -1, buffer, *buflen, NULL, NULL);
1149 else ret = PDH_MORE_DATA;
1150 *buflen = len;
1151 }
1152 free( bufferW );
1153 }
1154 else
1156 }
1157
1158done:
1159 free( eW.szMachineName );
1160 free( eW.szObjectName );
1161 free( eW.szInstanceName );
1162 free( eW.szParentInstance );
1163 free( eW.szCounterName );
1164 return ret;
1165}
GLbitfield flags
Definition: glext.h:7161
#define e
Definition: ke_i.h:82
PDH_STATUS WINAPI PdhMakeCounterPathW(PDH_COUNTER_PATH_ELEMENTS_W *e, LPWSTR buffer, LPDWORD buflen, DWORD flags)
Definition: pdh_main.c:1170

Referenced by test_PdhMakeCounterPathA().

◆ PdhMakeCounterPathW()

PDH_STATUS WINAPI PdhMakeCounterPathW ( PDH_COUNTER_PATH_ELEMENTS_W *  e,
LPWSTR  buffer,
LPDWORD  buflen,
DWORD  flags 
)

Definition at line 1170 of file pdh_main.c.

1172{
1175 DWORD len;
1176
1177 TRACE("%p %p %p 0x%08lx\n", e, buffer, buflen, flags);
1178
1179 if (flags) FIXME("unimplemented flags 0x%08lx\n", flags);
1180
1181 if (!e || !e->szCounterName || !e->szObjectName || !buflen)
1182 return PDH_INVALID_ARGUMENT;
1183
1184 path[0] = 0;
1185 if (e->szMachineName)
1186 {
1187 lstrcatW(path, L"\\\\");
1188 lstrcatW(path, e->szMachineName);
1189 }
1190 lstrcatW(path, L"\\");
1191 lstrcatW(path, e->szObjectName);
1192 if (e->szInstanceName)
1193 {
1194 lstrcatW(path, L"(");
1195 if (e->szParentInstance)
1196 {
1197 lstrcatW(path, e->szParentInstance);
1198 lstrcatW(path, L"/");
1199 }
1200 lstrcatW(path, e->szInstanceName);
1201 swprintf(instance, ARRAY_SIZE(instance), L"#%u", e->dwInstanceIndex);
1203 lstrcatW(path, L")");
1204 }
1205 lstrcatW(path, L"\\");
1206 lstrcatW(path, e->szCounterName);
1207
1208 len = lstrlenW(path) + 1;
1209 if (*buflen >= len) lstrcpyW(buffer, path);
1210 else ret = PDH_MORE_DATA;
1211 *buflen = len;
1212 return ret;
1213}
static HINSTANCE instance
Definition: main.c:35
#define swprintf
Definition: precomp.h:40
#define L(x)
Definition: resources.c:13
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274

Referenced by PdhMakeCounterPathA().

◆ PdhOpenQueryA()

PDH_STATUS WINAPI PdhOpenQueryA ( LPCSTR  source,
DWORD_PTR  userdata,
PDH_HQUERY *  query 
)

Definition at line 922 of file pdh_main.c.

923{
925 WCHAR *sourceW = NULL;
926
927 TRACE("%s %Ix %p\n", debugstr_a(source), userdata, query);
928
929 if (source && !(sourceW = pdh_strdup_aw( source ))) return PDH_MEMORY_ALLOCATION_FAILURE;
930
931 ret = PdhOpenQueryW( sourceW, userdata, query );
932 free( sourceW );
933
934 return ret;
935}
PDH_STATUS WINAPI PdhOpenQueryW(LPCWSTR source, DWORD_PTR userdata, PDH_HQUERY *handle)
Definition: pdh_main.c:940

Referenced by test_PdhAddCounterA(), test_PdhAddEnglishCounterA(), test_PdhCollectQueryDataEx(), test_PdhCollectQueryDataWithTime(), test_PdhGetCounterInfoA(), test_PdhGetCounterTimeBase(), test_PdhGetFormattedCounterValue(), test_PdhGetRawCounterValue(), test_PdhOpenQueryA(), test_PdhSetCounterScaleFactor(), and test_PdhVbGetDoubleCounterValue().

◆ PdhOpenQueryW()

PDH_STATUS WINAPI PdhOpenQueryW ( LPCWSTR  source,
DWORD_PTR  userdata,
PDH_HQUERY *  handle 
)

Definition at line 940 of file pdh_main.c.

941{
942 struct query *query;
943
944 TRACE("%s %Ix %p\n", debugstr_w(source), userdata, handle);
945
946 if (!handle) return PDH_INVALID_ARGUMENT;
947
948 if (source)
949 {
950 FIXME("log file data source not supported\n");
952 }
953 if ((query = create_query()))
954 {
955 query->user = userdata;
956 *handle = query;
957
958 return ERROR_SUCCESS;
959 }
961}
static struct query * create_query(void)
Definition: pdh_main.c:123

Referenced by PdhOpenQueryA(), test_PdhAddCounterW(), test_PdhAddEnglishCounterW(), test_PdhGetCounterInfoW(), and test_PdhOpenQueryW().

◆ PdhRemoveCounter()

PDH_STATUS WINAPI PdhRemoveCounter ( PDH_HCOUNTER  handle)

◆ PdhSetCounterScaleFactor()

PDH_STATUS WINAPI PdhSetCounterScaleFactor ( PDH_HCOUNTER  handle,
LONG  factor 
)

Definition at line 989 of file pdh_main.c.

990{
991 struct counter *counter = handle;
992
993 TRACE("%p\n", handle);
994
997 {
999 return PDH_INVALID_HANDLE;
1000 }
1001 if (factor < PDH_MIN_SCALE || factor > PDH_MAX_SCALE)
1002 {
1004 return PDH_INVALID_ARGUMENT;
1005 }
1006
1007 counter->scale = factor;
1008
1010 return ERROR_SUCCESS;
1011}
#define PDH_MAX_SCALE
Definition: pdh.h:44

Referenced by test_PdhGetCounterInfoA(), test_PdhGetCounterInfoW(), test_PdhGetFormattedCounterValue(), and test_PdhSetCounterScaleFactor().

◆ PdhSetDefaultRealTimeDataSource()

PDH_STATUS WINAPI PdhSetDefaultRealTimeDataSource ( DWORD  source)

Definition at line 1246 of file pdh_main.c.

1247{
1248 FIXME("%lu\n", source);
1249 return ERROR_SUCCESS;
1250}

◆ PdhValidatePathA()

PDH_STATUS WINAPI PdhValidatePathA ( LPCSTR  path)

Definition at line 1016 of file pdh_main.c.

1017{
1019 WCHAR *pathW;
1020
1021 TRACE("%s\n", debugstr_a(path));
1022
1023 if (!path) return PDH_INVALID_ARGUMENT;
1025
1027
1028 free( pathW );
1029 return ret;
1030}
PDH_STATUS WINAPI PdhValidatePathW(LPCWSTR path)
Definition: pdh_main.c:1042

Referenced by PdhValidatePathExA(), and test_PdhValidatePathA().

◆ PdhValidatePathExA()

PDH_STATUS WINAPI PdhValidatePathExA ( PDH_HLOG  source,
LPCSTR  path 
)

Definition at line 1089 of file pdh_main.c.

1090{
1091 TRACE("%p %s\n", source, debugstr_a(path));
1092
1093 if (source)
1094 {
1095 FIXME("log file data source not supported\n");
1096 return ERROR_SUCCESS;
1097 }
1098 return PdhValidatePathA( path );
1099}
PDH_STATUS WINAPI PdhValidatePathA(LPCSTR path)
Definition: pdh_main.c:1016

Referenced by init_function_ptrs().

◆ PdhValidatePathExW()

PDH_STATUS WINAPI PdhValidatePathExW ( PDH_HLOG  source,
LPCWSTR  path 
)

Definition at line 1104 of file pdh_main.c.

1105{
1106 TRACE("%p %s\n", source, debugstr_w(path));
1107
1108 if (source)
1109 {
1110 FIXME("log file data source not supported\n");
1111 return ERROR_SUCCESS;
1112 }
1113 return PdhValidatePathW( path );
1114}

Referenced by init_function_ptrs().

◆ PdhValidatePathW()

PDH_STATUS WINAPI PdhValidatePathW ( LPCWSTR  path)

Definition at line 1042 of file pdh_main.c.

1043{
1045 unsigned int i;
1046
1047 TRACE("%s\n", debugstr_w(path));
1048
1049 if ((ret = validate_path( path ))) return ret;
1050
1051 for (i = 0; i < ARRAY_SIZE(counter_sources); i++)
1053
1055}
static PDH_STATUS validate_path(LPCWSTR path)
Definition: pdh_main.c:1032

Referenced by PdhValidatePathA(), PdhValidatePathExW(), and test_PdhValidatePathW().

◆ PdhVbAddCounter()

PDH_STATUS WINAPI PdhVbAddCounter ( PDH_HQUERY  query,
LPCSTR  path,
PDH_HCOUNTER *  counter 
)

Definition at line 1060 of file pdh_main.c.

1061{
1062 FIXME("%p, %s, %p: stub!\n", query, debugstr_a(path), counter);
1063
1064 if (!path) return PDH_INVALID_ARGUMENT;
1065
1066 return PDH_NOT_IMPLEMENTED;
1067}

◆ PdhVbGetDoubleCounterValue()

double WINAPI PdhVbGetDoubleCounterValue ( PDH_HCOUNTER  handle,
PDH_STATUS *  counter_status 
)

Definition at line 1072 of file pdh_main.c.

1073{
1076
1077 TRACE( "%p %p\n", handle, counter_status );
1078
1079 memset( &value, 0, sizeof(value) );
1081
1082 if (counter_status) *counter_status = status;
1083 return value.doubleValue;
1084}
PDH_STATUS WINAPI PdhGetFormattedCounterValue(PDH_HCOUNTER handle, DWORD format, LPDWORD type, PPDH_FMT_COUNTERVALUE value)
Definition: pdh_main.c:737
Definition: ps.c:97

Referenced by init_function_ptrs().

◆ validate_path()

static PDH_STATUS validate_path ( LPCWSTR  path)
static

Definition at line 1032 of file pdh_main.c.

1033{
1034 if (!path || !*path) return PDH_INVALID_ARGUMENT;
1035 if (*path++ != '\\' || !wcschr( path, '\\' )) return PDH_CSTATUS_BAD_COUNTERNAME;
1036 return ERROR_SUCCESS;
1037 }
#define PDH_CSTATUS_BAD_COUNTERNAME
Definition: pdhmsg.h:49

Referenced by PdhValidatePathW().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( pdh  )

Variable Documentation

◆ counter_sources

const struct source counter_sources[]
static
Initial value:
=
{
{ 6, L"\\Processor(_Total)\\% Processor Time", collect_processor_time, TYPE_PROCESSOR_TIME, -5, 10000000 },
{ 674, L"\\System\\System Up Time", collect_uptime, TYPE_UPTIME, -3, 1000 }
}
static void CALLBACK collect_uptime(struct counter *counter)
Definition: pdh_main.c:159
#define TYPE_PROCESSOR_TIME
Definition: pdh_main.c:165
#define TYPE_UPTIME
Definition: pdh_main.c:169
static void CALLBACK collect_processor_time(struct counter *counter)
Definition: pdh_main.c:153

Definition at line 173 of file pdh_main.c.

Referenced by PdhAddCounterW(), PdhLookupPerfIndexByNameW(), PdhLookupPerfNameByIndexW(), and PdhValidatePathW().

◆ pdh_handle_cs

◆ pdh_handle_cs_debug

CRITICAL_SECTION_DEBUG pdh_handle_cs_debug
static
Initial value:
=
{
0, 0, &pdh_handle_cs,
0, 0, { (DWORD_PTR)(__FILE__ ": pdh_handle_cs") }
}
static CRITICAL_SECTION_DEBUG pdh_handle_cs_debug
Definition: pdh_main.c:43
#define DWORD_PTR
Definition: treelist.c:76

Definition at line 43 of file pdh_main.c.