Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

845 lines
19 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. pdhidef.h
  5. Abstract:
  6. function definitions used internally by the performance data helper
  7. functions
  8. --*/
  9. #ifndef _PDHI_DEFS_H_
  10. #define _PDHI_DEFS_H_
  11. #pragma warning ( disable : 4115 )
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. #ifndef _DEBUG_MUTEXES
  16. #define _DEBUG_MUTEXES 0 // for debugging
  17. #endif
  18. //#define _SHOW_PDH_MEM_ALLOCS 1
  19. //#define _VALIDATE_PDH_MEM_ALLOCS 1
  20. #include <locale.h>
  21. #include "pdhitype.h" // required for data type definitions
  22. //#include "pdhmsg.h" // error message definitions
  23. //#include "strings.h" // for string constants
  24. #if DBG
  25. VOID
  26. __cdecl
  27. PdhDebugPrint(
  28. ULONG DebugPrintLevel,
  29. char* DebugMessage,
  30. ...
  31. );
  32. #define DebugPrint(x) PdhDebugPrint x
  33. #else
  34. #define DebugPrint(x)
  35. #endif
  36. #define STATIC_PDH_FUNCTION PDH_STATUS __stdcall
  37. #define STATIC_BOOL BOOL __stdcall
  38. #define STATIC_DWORD DWORD __stdcall
  39. #define PDH_PLA_MUTEX L"__PDH_PLA_MUTEX__"
  40. // global variable declarations
  41. extern HANDLE ThisDLLHandle;
  42. extern WCHAR szStaticLocalMachineName[];
  43. extern HANDLE hPdhDataMutex;
  44. extern HANDLE hPdhContextMutex;
  45. extern HANDLE hPdhPlaMutex;
  46. extern HANDLE hPdhHeap;
  47. extern HANDLE hEventLog;
  48. extern LONGLONG llRemoteRetryTime;
  49. extern BOOL bEnableRemotePdhAccess;
  50. extern DWORD dwPdhiLocalDefaultDataSource;
  51. extern LONG dwCurrentRealTimeDataSource;
  52. extern BOOL bProcessIsDetaching;
  53. #ifndef _SHOW_PDH_MEM_ALLOCS
  54. #define G_ALLOC(s) HeapAlloc (hPdhHeap, (HEAP_ZERO_MEMORY), s)
  55. #define G_REALLOC(h,s) HeapReAlloc (hPdhHeap, (HEAP_ZERO_MEMORY), h, s)
  56. #define G_FREE(h) if (h != NULL) HeapFree (hPdhHeap, 0, h)
  57. #define G_SIZE(h) HeapSize (hPdhHeap, 0, h)
  58. #else
  59. #ifdef _VALIDATE_PDH_MEM_ALLOCS
  60. __inline
  61. LPVOID
  62. PdhiHeapAlloc(DWORD s)
  63. {
  64. LPVOID lpRetVal;
  65. HeapValidate(hPdhHeap, 0, NULL);
  66. lpRetVal = HeapAlloc (hPdhHeap, HEAP_ZERO_MEMORY, s);
  67. return lpRetVal;
  68. }
  69. __inline
  70. LPVOID
  71. PdhiHeapReAlloc(LPVOID h, DWORD s)
  72. {
  73. LPVOID lpRetVal;
  74. HeapValidate(hPdhHeap, 0, NULL);
  75. lpRetVal = HeapReAlloc (hPdhHeap, HEAP_ZERO_MEMORY, h, s);
  76. return lpRetVal;
  77. }
  78. __inline
  79. BOOL
  80. PdhiHeapFree(LPVOID h)
  81. {
  82. BOOL bRetVal;
  83. if (h == NULL) return TRUE;
  84. HeapValidate(hPdhHeap, 0, NULL);
  85. bRetVal = HeapFree (hPdhHeap, 0, h);
  86. return bRetVal;
  87. }
  88. #define G_ALLOC(s) PdhiHeapAlloc (s)
  89. #define G_REALLOC(h,s) PdhiHeapReAlloc (h, s)
  90. #define G_FREE(h) PdhiHeapFree (h)
  91. #define G_SIZE(h) HeapSize (hPdhHeap, 0, h)
  92. #else
  93. __inline
  94. LPVOID
  95. PdhiHeapAlloc(LPSTR szSourceFileName, DWORD dwLineNo, SIZE_T s)
  96. {
  97. LPVOID lpRetVal;
  98. lpRetVal = HeapAlloc(hPdhHeap, HEAP_ZERO_MEMORY, s);
  99. #ifdef _WIN64
  100. DebugPrint((1, "G_ALLOC(%s#%d)(%I64d,0x%08X)\n",
  101. szSourceFileName, dwLineNo,
  102. (lpRetVal != NULL ? s : 0),
  103. lpRetVal));
  104. #else
  105. DebugPrint((1, "G_ALLOC(%s#%d)(%d,0x%08X)\n",
  106. szSourceFileName, dwLineNo,
  107. (lpRetVal != NULL ? s : 0),
  108. lpRetVal));
  109. #endif
  110. return lpRetVal;
  111. }
  112. __inline
  113. LPVOID
  114. PdhiHeapReAlloc(LPSTR szSourceFileName, DWORD dwLineNo, LPVOID h, SIZE_T s)
  115. {
  116. LPVOID lpRetVal;
  117. SIZE_T dwBeforeSize;
  118. DWORD dwCurrentThread = GetCurrentThreadId();
  119. dwBeforeSize = HeapSize (hPdhHeap, 0, h);
  120. lpRetVal = HeapReAlloc (hPdhHeap, HEAP_ZERO_MEMORY, h, s);
  121. #ifdef _WIN64
  122. DebugPrint((1, "G_REALLOC(%s#%d)(0x%08X,%I64d)(0x%08X,%I64d)\n",
  123. szSourceFileName, dwLineNo,
  124. h, dwBeforeSize,
  125. lpRetVal, (lpRetVal != NULL ? s : 0)));
  126. #else
  127. DebugPrint((1, "G_REALLOC(%s#%d)(0x%08X,%d)(0x%08X,%d)\n",
  128. szSourceFileName, dwLineNo,
  129. h, dwBeforeSize,
  130. lpRetVal, (lpRetVal != NULL ? s : 0)));
  131. #endif
  132. return lpRetVal;
  133. }
  134. __inline
  135. BOOL
  136. PdhiHeapFree(LPSTR szSourceFileName, DWORD dwLineNo, LPVOID h)
  137. {
  138. BOOL bRetVal;
  139. SIZE_T dwBlockSize;
  140. if (h == NULL) return TRUE;
  141. dwBlockSize = HeapSize (hPdhHeap, 0, h);
  142. bRetVal = HeapFree (hPdhHeap, 0, h);
  143. #ifdef _WIN64
  144. DebugPrint((1, "G_FREE(%s#%d)(0x%08X,%I64d)\n",
  145. szSourceFileName, dwLineNo,
  146. h,
  147. (bRetVal ? dwBlockSize : 0)));
  148. #else
  149. DebugPrint((1, "G_FREE(%s#%d)(0x%08X,%d)\n",
  150. szSourceFileName, dwLineNo,
  151. h,
  152. (bRetVal ? dwBlockSize : 0)));
  153. #endif
  154. return bRetVal;
  155. }
  156. #define G_ALLOC(s) PdhiHeapAlloc (__FILE__, __LINE__, s)
  157. #define G_REALLOC(h,s) PdhiHeapReAlloc (__FILE__, __LINE__, h, s)
  158. #define G_FREE(h) PdhiHeapFree (__FILE__, __LINE__, h)
  159. #define G_SIZE(h) HeapSize (hPdhHeap, 0, h)
  160. #endif
  161. #endif
  162. // (assumes dword is 4 bytes)
  163. #define ALIGN_ON_DWORD(x) ((VOID *)(((DWORD_PTR)(x) & 3) ? (((DWORD_PTR)(x) & ~3) + 4 ) : ((DWORD_PTR)(x))))
  164. #define DWORD_MULTIPLE(x) ((((x)+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
  165. #define CLEAR_FIRST_FOUR_BYTES(x) *(DWORD *)(x) = 0L
  166. // (assumes QuadWORD is 8 bytes)
  167. #define ALIGN_ON_QWORD(x) ((VOID *)(((DWORD_PTR)(x) & 7) ? (((DWORD_PTR)(x) & ~7) + 8) : ((DWORD_PTR)(x))))
  168. #define QWORD_MULTIPLE(x) ((((x)+sizeof(LONGLONG)-1)/sizeof(LONGLONG))*sizeof(LONGLONG))
  169. #define CLEAR_FIRST_EIGHT_BYTES(x) *(LONGLONG *)(x) = 0L
  170. #if _DEBUG_MUTEXES
  171. __inline
  172. DWORD
  173. PdhiLocalWaitForMutex (
  174. LPCSTR szSourceFileName,
  175. DWORD dwLineNo,
  176. HANDLE hMutex
  177. )
  178. {
  179. DWORD dwReturnValue = PDH_INVALID_PARAMETER;
  180. if (hMutex != NULL) {
  181. FILETIME ft;
  182. GetSystemTimeAsFileTime (&ft);
  183. dwReturnValue = WaitForSingleObject (hMutex, 60000);
  184. DebugPrint ((4, "\n[%8.8x] Mutex [%8.8x] %s by (%d) at: %s (%d)",
  185. ft.dwLowDateTime,
  186. (DWORD)hMutex,
  187. (dwReturnValue == 0 ? "Locked" : "Lock Failed"),
  188. GetCurrentThreadId(),
  189. szSourceFileName, dwLineNo));
  190. } else {
  191. DebugPrint((4, "\nLock of NULL Mutex attmpted at: %s (%d)",
  192. szSourceFileName, dwLineNo));
  193. dwReturnValue = PDH_INVALID_PARAMETER;
  194. }
  195. return dwReturnValue;
  196. }
  197. #define WAIT_FOR_AND_LOCK_MUTEX(h) PdhiLocalWaitForMutex (__FILE__, __LINE__, h);
  198. __inline
  199. void
  200. PdhiLocalReleaseMutex (
  201. LPCSTR szSourceFileName,
  202. DWORD dwLineNo,
  203. HANDLE hMutex
  204. )
  205. {
  206. BOOL bSuccess;
  207. LONG lPrevCount = 0;
  208. FILETIME ft;
  209. if (hMutex != NULL) {
  210. GetSystemTimeAsFileTime (&ft);
  211. bSuccess = ReleaseMutex (hMutex);
  212. DebugPrint((4, "\n[%8.8x] Mutex [%8.8x] %s by (%d) at: %s (%d)",
  213. ft.dwLowDateTime,
  214. (DWORD)hMutex,
  215. (bSuccess ? "Released" : "Release Failed"),
  216. GetCurrentThreadId(),
  217. szSourceFileName, dwLineNo));
  218. } else {
  219. DebugPrint((4, "\nRelease of NULL Mutex attempted at: %s (%d)",
  220. szSourceFileName, dwLineNo));
  221. }
  222. }
  223. #define RELEASE_MUTEX(h) PdhiLocalReleaseMutex (__FILE__, __LINE__, h);
  224. #else
  225. #define WAIT_FOR_AND_LOCK_MUTEX(h) (h != NULL ? WaitForSingleObject(h, 60000) : WAIT_TIMEOUT)
  226. #define RELEASE_MUTEX(h) (h != NULL ? ReleaseMutex(h) : FALSE)
  227. #endif
  228. #define LODWORD(ll) ((DWORD)((LONGLONG)ll & 0x00000000FFFFFFFF))
  229. #define HIDWORD(ll) ((DWORD)(((LONGLONG)ll >> 32) & 0x00000000FFFFFFFF))
  230. #define MAKELONGLONG(low, high) \
  231. ((LONGLONG) (((DWORD) (low)) | ((LONGLONG) ((DWORD) (high))) << 32))
  232. #define SMALL_BUFFER_SIZE 4096
  233. #define MEDIUM_BUFFER_SIZE 16834
  234. #define LARGE_BUFFER_SIZE 65536
  235. // set this to 1 to report code errors (i.e. debugging information)
  236. // to the event log.
  237. #define PDHI_REPORT_CODE_ERRORS 0
  238. // set this to 1 to report user errors (i.e. things the normal user
  239. // would care about) to the event log.
  240. #define PDHI_REPORT_USER_ERRORS 1
  241. // USER category errors are typically configuration, schema or access
  242. // access errors, errors the user can usually do something about
  243. #define PDH_EVENT_CATEGORY_USER 100
  244. // COUNTER category errors are errors returned do to valid data returning
  245. // invalid results. These are a special subset of USER Category errors.
  246. #define PDH_EVENT_CATEGORY_COUNTER 110
  247. // DEBUG category errors are of interest only to PDH developers as they
  248. // indicate problems that can normally only be fixed by modifying the
  249. // program code.
  250. #define PDH_EVENT_CATEGORY_DEBUG 200
  251. #define REPORT_EVENT(t,c,id) ReportEvent (hEventLog, t, c, id, NULL, 0, 0, NULL, NULL)
  252. __inline
  253. BOOL
  254. CounterIsOkToUse ( void *pCounterArg )
  255. {
  256. PPDHI_COUNTER pCounter = (PPDHI_COUNTER)pCounterArg;
  257. if (pCounter != NULL) {
  258. if (pCounter->dwFlags & PDHIC_COUNTER_UNUSABLE) {
  259. return FALSE;
  260. } else {
  261. return TRUE;
  262. }
  263. } else {
  264. return FALSE;
  265. }
  266. }
  267. DWORD
  268. DataSourceTypeH (
  269. IN HLOG hDataSource
  270. );
  271. DWORD
  272. DataSourceTypeW (
  273. IN LPCWSTR szDataSource
  274. );
  275. DWORD
  276. DataSourceTypeA (
  277. IN LPCSTR szDataSource
  278. );
  279. LPWSTR
  280. GetStringResource (
  281. DWORD dwResId
  282. );
  283. //
  284. // Log file entries
  285. //
  286. extern LPCSTR szTsvLogFileHeader;
  287. extern LPCSTR szCsvLogFileHeader;
  288. extern LPCSTR szBinLogFileHeader;
  289. extern LPCSTR szTsvType;
  290. extern LPCSTR szCsvType;
  291. extern LPCSTR szBinaryType;
  292. extern const DWORD dwFileHeaderLength;
  293. extern const DWORD dwTypeLoc;
  294. extern const DWORD dwVersionLoc;
  295. extern const DWORD dwFieldLength;
  296. DWORD
  297. UnmapReadonlyMappedFile (
  298. LPVOID pMemoryBase,
  299. BOOL *bNeedToCloseHandles
  300. );
  301. PDH_FUNCTION
  302. PdhiGetLogCounterInfo (
  303. IN HLOG hLog,
  304. IN PPDHI_COUNTER pCounter
  305. );
  306. PDH_FUNCTION
  307. PdhiEnumLoggedMachines (
  308. IN HLOG hDataSource,
  309. IN LPVOID mszMachineList,
  310. IN LPDWORD pcchBufferSize,
  311. IN BOOL bUnicode
  312. );
  313. PDH_FUNCTION
  314. PdhiEnumLoggedObjects (
  315. IN HLOG hDataSource,
  316. IN LPCWSTR szMachineName,
  317. IN LPVOID mszObjectList,
  318. IN LPDWORD pcchBufferSize,
  319. IN DWORD dwDetailLevel,
  320. IN BOOL bRefresh,
  321. IN BOOL bUnicode
  322. );
  323. PDH_FUNCTION
  324. PdhiEnumLoggedObjectItems (
  325. IN HLOG hDataSource,
  326. IN LPCWSTR szMachineName,
  327. IN LPCWSTR szObjectName,
  328. IN LPVOID mszCounterList,
  329. IN LPDWORD pdwCounterListLength,
  330. IN LPVOID mszInstanceList,
  331. IN LPDWORD pdwInstanceListLength,
  332. IN DWORD dwDetailLevel,
  333. IN DWORD dwFlags,
  334. IN BOOL bUnicode
  335. );
  336. BOOL
  337. PdhiDataSourceHasDetailLevelsH (
  338. IN HLOG hDataSource
  339. );
  340. BOOL
  341. PdhiDataSourceHasDetailLevels (
  342. IN LPWSTR szDataSource
  343. );
  344. PDH_FUNCTION
  345. PdhiGetMatchingLogRecord (
  346. IN HLOG hLog,
  347. IN LONGLONG *pStartTime,
  348. IN LPDWORD pdwIndex
  349. );
  350. PDH_FUNCTION
  351. PdhiGetCounterValueFromLogFile (
  352. IN HLOG hLog,
  353. IN DWORD dwIndex,
  354. IN PDHI_COUNTER * pCounter
  355. );
  356. STATIC_PDH_FUNCTION
  357. PdhiGetCounterInfo (
  358. IN HCOUNTER hCounter,
  359. IN BOOLEAN bRetrieveExplainText,
  360. IN LPDWORD pdwBufferSize,
  361. IN PPDH_COUNTER_INFO_W lpBuffer,
  362. IN BOOL bUnicode
  363. );
  364. // log.c
  365. BOOL
  366. PdhiCloseAllLoggers();
  367. ULONG HashCounter(
  368. LPWSTR szCounterName
  369. );
  370. void
  371. PdhiInitCounterHashTable(
  372. IN PDHI_COUNTER_TABLE pTable
  373. );
  374. void
  375. PdhiResetInstanceCount(
  376. IN PDHI_COUNTER_TABLE pTable
  377. );
  378. PDH_FUNCTION
  379. PdhiFindCounterInstList(
  380. IN PDHI_COUNTER_TABLE pHeadList,
  381. IN LPWSTR szCounter,
  382. OUT PPDHI_INST_LIST * pInstList
  383. );
  384. PDH_FUNCTION
  385. PdhiFindInstance(
  386. IN PLIST_ENTRY pHeadInst,
  387. IN LPWSTR szInstance,
  388. IN BOOLEAN bUpdateCount,
  389. OUT PPDHI_INSTANCE * pInstance
  390. );
  391. DWORD
  392. AddStringToMultiSz(
  393. IN LPVOID mszDest,
  394. IN LPWSTR szSource,
  395. IN BOOL bUnicodeDest
  396. );
  397. // query.c
  398. PDH_FUNCTION
  399. PdhiCollectQueryData (
  400. IN PPDHI_QUERY pQuery,
  401. IN LONGLONG *pllTimeStamp
  402. );
  403. BOOL
  404. PdhiQueryCleanup (
  405. );
  406. PDH_FUNCTION
  407. PdhiConvertUnicodeToAnsi(
  408. IN UINT uCodePage,
  409. IN LPWSTR wszSrc,
  410. IN LPSTR aszDest,
  411. IN LPDWORD pdwSize
  412. );
  413. // qutils.c
  414. DWORD
  415. WINAPI
  416. PdhiAsyncTimerThreadProc (
  417. LPVOID pArg
  418. );
  419. BOOL
  420. IsValidQuery (
  421. IN HQUERY hQuery
  422. );
  423. BOOL
  424. IsValidCounter (
  425. IN HCOUNTER hCounter
  426. );
  427. BOOL
  428. InitCounter (
  429. IN OUT PPDHI_COUNTER pCounter
  430. );
  431. BOOL
  432. ParseFullPathNameW (
  433. IN LPCWSTR szFullCounterPath,
  434. IN OUT PDWORD pdwBufferLength,
  435. IN OUT PPDHI_COUNTER_PATH pCounter,
  436. IN BOOL bWbemSyntax
  437. );
  438. BOOL
  439. ParseInstanceName (
  440. IN LPCWSTR szInstanceString,
  441. IN OUT LPWSTR szInstanceName,
  442. IN OUT LPWSTR szParentName,
  443. IN OUT LPDWORD lpIndex
  444. );
  445. BOOL
  446. FreeCounter (
  447. IN PPDHI_COUNTER pThisCounter
  448. );
  449. BOOL
  450. InitPerflibCounterInfo (
  451. IN OUT PPDHI_COUNTER pCounter
  452. );
  453. BOOL
  454. AddMachineToQueryLists (
  455. IN PPERF_MACHINE pMachine,
  456. IN PPDHI_COUNTER pNewCounter
  457. );
  458. BOOL
  459. UpdateRealTimeCounterValue (
  460. IN PPDHI_COUNTER pCounter
  461. );
  462. BOOL
  463. UpdateRealTimeMultiInstanceCounterValue (
  464. IN PPDHI_COUNTER pCounter
  465. );
  466. BOOL
  467. UpdateCounterValue (
  468. IN PPDHI_COUNTER pCounter,
  469. IN PPERF_DATA_BLOCK pPerfData
  470. );
  471. BOOL
  472. UpdateMultiInstanceCounterValue (
  473. IN PPDHI_COUNTER pCounter,
  474. IN PPERF_DATA_BLOCK pPerfData,
  475. IN LONGLONG TimeStamp
  476. );
  477. BOOL
  478. UpdateCounterObject(
  479. IN PPDHI_COUNTER pCounter
  480. );
  481. #define GPCDP_GET_BASE_DATA 0x00000001
  482. PVOID
  483. GetPerfCounterDataPtr (
  484. IN PPERF_DATA_BLOCK pPerfData,
  485. IN PPDHI_COUNTER_PATH pPath,
  486. IN PPERFLIB_COUNTER pplCtr,
  487. IN DWORD dwFlags,
  488. IN PPERF_OBJECT_TYPE *pPerfObject,
  489. IN PDWORD pStatus
  490. );
  491. LONG
  492. GetQueryPerfData (
  493. IN PPDHI_QUERY pQuery,
  494. IN LONGLONG *pTimeStamp
  495. );
  496. BOOL
  497. GetInstanceByNameMatch (
  498. IN PPERF_MACHINE pMachine,
  499. IN OUT PPDHI_COUNTER pCounter
  500. );
  501. PDH_FUNCTION
  502. PdhiResetLogBuffers (
  503. IN HLOG hLog
  504. );
  505. DWORD
  506. AddUniqueStringToMultiSz (
  507. IN LPVOID mszDest,
  508. IN LPSTR szSource,
  509. IN BOOL bUnicodeDest
  510. );
  511. DWORD
  512. AddUniqueWideStringToMultiSz (
  513. IN LPVOID mszDest,
  514. IN LPWSTR szSource,
  515. IN BOOL bUnicodeDest
  516. );
  517. BOOL
  518. PdhiBrowseDataSource (
  519. IN HWND hWndParent,
  520. IN LPVOID szFileName,
  521. IN LPDWORD pcchFileNameSize,
  522. IN BOOL bUnicodeString
  523. );
  524. LPWSTR
  525. PdhiGetExplainText (
  526. IN LPCWSTR szMachineName,
  527. IN LPCWSTR szObjectName,
  528. IN LPCWSTR szCounterName
  529. );
  530. LONG
  531. GetCurrentServiceState (
  532. SC_HANDLE hService,
  533. BOOL * bStopped,
  534. BOOL * bPaused
  535. );
  536. // wbem.cpp
  537. BOOL
  538. IsWbemDataSource (
  539. IN LPCWSTR szDataSource
  540. );
  541. PDH_FUNCTION
  542. PdhiFreeAllWbemServers (
  543. );
  544. PDH_FUNCTION
  545. PdhiGetWbemExplainText (
  546. IN LPCWSTR szMachineName,
  547. IN LPCWSTR szObjectName,
  548. IN LPCWSTR szCounterName,
  549. IN LPWSTR szExplain,
  550. IN LPDWORD pdwExplain
  551. );
  552. PDH_FUNCTION
  553. PdhiEnumWbemMachines (
  554. IN LPVOID pMachineList,
  555. IN LPDWORD pcchBufferSize,
  556. IN BOOL bUnicode
  557. );
  558. PDH_FUNCTION
  559. PdhiEnumWbemObjects (
  560. IN LPCWSTR szWideMachineName,
  561. IN LPVOID mszObjectList,
  562. IN LPDWORD pcchBufferSize,
  563. IN DWORD dwDetailLevel,
  564. IN BOOL bRefresh,
  565. IN BOOL bUnicode
  566. );
  567. PDH_FUNCTION
  568. PdhiGetDefaultWbemObject (
  569. IN LPCWSTR szMachineName,
  570. IN LPVOID szDefaultObjectName,
  571. IN LPDWORD pcchBufferSize,
  572. IN BOOL bUnicode
  573. );
  574. PDH_FUNCTION
  575. PdhiEnumWbemObjectItems (
  576. IN LPCWSTR szWideMachineName,
  577. IN LPCWSTR szWideObjectName,
  578. IN LPVOID mszCounterList,
  579. IN LPDWORD pcchCounterListLength,
  580. IN LPVOID mszInstanceList,
  581. IN LPDWORD pcchInstanceListLength,
  582. IN DWORD dwDetailLevel,
  583. IN DWORD dwFlags,
  584. IN BOOL bUnicode
  585. );
  586. PDH_FUNCTION
  587. PdhiGetDefaultWbemProperty (
  588. IN LPCWSTR szMachineName,
  589. IN LPCWSTR szObjectName,
  590. IN LPVOID szDefaultCounterName,
  591. IN LPDWORD pcchBufferSize,
  592. IN BOOL bUnicode
  593. );
  594. PDH_FUNCTION
  595. PdhiEncodeWbemPathW (
  596. IN PDH_COUNTER_PATH_ELEMENTS_W *pCounterPathElements,
  597. IN LPWSTR szFullPathBuffer,
  598. IN LPDWORD pcchBufferSize,
  599. IN LANGID LangId,
  600. IN DWORD dwFlags
  601. );
  602. PDH_FUNCTION
  603. PdhiDecodeWbemPathA (
  604. IN LPCSTR szFullPathBuffer,
  605. IN PDH_COUNTER_PATH_ELEMENTS_A *pCounterPathElements,
  606. IN LPDWORD pcchBufferSize,
  607. IN LANGID LangId,
  608. IN DWORD dwFlags
  609. );
  610. PDH_FUNCTION
  611. PdhiDecodeWbemPathW (
  612. IN LPCWSTR szFullPathBuffer,
  613. IN PDH_COUNTER_PATH_ELEMENTS_W *pCounterPathElements,
  614. IN LPDWORD pcchBufferSize,
  615. IN LANGID LangId,
  616. IN DWORD dwFlags
  617. );
  618. PDH_FUNCTION
  619. PdhiEncodeWbemPathA (
  620. PDH_COUNTER_PATH_ELEMENTS_A *pCounterPathElements,
  621. LPSTR szFullPathBuffer,
  622. LPDWORD pcchBufferSize,
  623. LANGID LangId,
  624. DWORD dwFlags
  625. );
  626. BOOL
  627. WbemInitCounter (
  628. IN PPDHI_COUNTER pCounter
  629. );
  630. LONG
  631. GetQueryWbemData (
  632. IN PPDHI_QUERY pQuery,
  633. IN LONGLONG *pllTimeStamp
  634. );
  635. PDH_FUNCTION
  636. PdhiCloseWbemCounter (
  637. PPDHI_COUNTER pCounter
  638. );
  639. PDH_FUNCTION
  640. PdhiFreeWbemQuery (
  641. PPDHI_QUERY pThisQuery
  642. );
  643. // Doubly-linked list manipulation routines. Implemented as macros
  644. // but logically these are procedures.
  645. //
  646. #define InitializeListHead(ListHead) (\
  647. (ListHead)->Flink = (ListHead)->Blink = (ListHead))
  648. #define IsListEmpty(ListHead) \
  649. ((ListHead)->Flink == (ListHead))
  650. #define RemoveHeadList(ListHead) \
  651. (ListHead)->Flink;\
  652. {RemoveEntryList((ListHead)->Flink)}
  653. #define RemoveTailList(ListHead) \
  654. (ListHead)->Blink;\
  655. {RemoveEntryList((ListHead)->Blink)}
  656. #define RemoveEntryList(Entry) {\
  657. PLIST_ENTRY _EX_Blink;\
  658. PLIST_ENTRY _EX_Flink;\
  659. _EX_Flink = (Entry)->Flink;\
  660. _EX_Blink = (Entry)->Blink;\
  661. _EX_Blink->Flink = _EX_Flink;\
  662. _EX_Flink->Blink = _EX_Blink;\
  663. }
  664. #define InsertTailList(ListHead,Entry) {\
  665. PLIST_ENTRY _EX_Blink;\
  666. PLIST_ENTRY _EX_ListHead;\
  667. _EX_ListHead = (ListHead);\
  668. _EX_Blink = _EX_ListHead->Blink;\
  669. (Entry)->Flink = _EX_ListHead;\
  670. (Entry)->Blink = _EX_Blink;\
  671. _EX_Blink->Flink = (Entry);\
  672. _EX_ListHead->Blink = (Entry);\
  673. }
  674. #define InsertHeadList(ListHead,Entry) {\
  675. PLIST_ENTRY _EX_Flink;\
  676. PLIST_ENTRY _EX_ListHead;\
  677. _EX_ListHead = (ListHead);\
  678. _EX_Flink = _EX_ListHead->Flink;\
  679. (Entry)->Flink = _EX_Flink;\
  680. (Entry)->Blink = _EX_ListHead;\
  681. _EX_Flink->Blink = (Entry);\
  682. _EX_ListHead->Flink = (Entry);\
  683. }
  684. #define PopEntryList(ListHead) \
  685. (ListHead)->Next;\
  686. {\
  687. PSINGLE_LIST_ENTRY FirstEntry;\
  688. FirstEntry = (ListHead)->Next;\
  689. if (FirstEntry != NULL) { \
  690. (ListHead)->Next = FirstEntry->Next;\
  691. } \
  692. }
  693. #define PushEntryList(ListHead,Entry) \
  694. (Entry)->Next = (ListHead)->Next; \
  695. (ListHead)->Next = (Entry)
  696. #ifdef __cplusplus
  697. }
  698. #endif
  699. #endif // _PDHI_DEFS_H_