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.

158 lines
6.6 KiB

  1. #ifndef _PERFVAL_H_
  2. #define _PERFVAL_H_
  3. #include <winperf.h>
  4. #define WBEMPERF_OPEN_PROC_NOT_FOUND 0xC0100002
  5. #define WBEMPERF_COLLECT_PROC_NOT_FOUND 0xC0100003
  6. #define WBEMPERF_CLOSE_PROC_NOT_FOUND 0xC0100004
  7. #define WBEMPERF_OPEN_PROC_FAILURE 0xC0100005
  8. #define WBEMPERF_OPEN_PROC_EXCEPTION 0xC0100006
  9. //
  10. // Utility macro. This is used to reserve a DWORD multiple of
  11. // bytes for Unicode strings embedded in the definitional data,
  12. // viz., object instance names.
  13. //
  14. #define DWORD_MULTIPLE(x) (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
  15. // (assumes dword is 4 bytes)
  16. #define ALIGN_ON_DWORD(x) ((VOID *)(((DWORD_PTR)x & 3) ? (((DWORD_PTR)x & ~3) + 4) : ((DWORD_PTR)x)))
  17. #define QWORD_MULTIPLE(x) (((x+sizeof(LONGLONG)-1)/sizeof(LONGLONG))*sizeof(LONGLONG))
  18. // (assumes quadword is 8 bytes)
  19. #define ALIGN_ON_QWORD(x) ((VOID *)(((DWORD_PTR)x & 7) ? (((DWORD_PTR)x & ~7) + 8) : ((DWORD_PTR)x)))
  20. //
  21. // constants used by guard page testing
  22. //
  23. #define GUARD_PAGE_SIZE 1024
  24. #define GUARD_PAGE_CHAR 0xA5
  25. #define GUARD_PAGE_DWORD 0xA5A5A5A5
  26. #define LOG_UNDEFINED ((LONG)-1)
  27. #define LOG_NONE 0
  28. #define LOG_USER 1
  29. #define LOG_DEBUG 2
  30. #define LOG_VERBOSE 3
  31. #define EXT_TEST_UNDEFINED 0
  32. #define EXT_TEST_ALL 1
  33. #define EXT_TEST_BASIC 2
  34. #define EXT_TEST_NONE 3
  35. #define EXT_TEST_NOMEMALLOC 4
  36. #define WAIT_FOR_AND_LOCK_MUTEX(h) (h != NULL ? WaitForSingleObject(h, 10000) : WAIT_TIMEOUT)
  37. #define RELEASE_MUTEX(h) (h != NULL ? ReleaseMutex(h) : FALSE)
  38. // convert mS to relative time
  39. #define MakeTimeOutValue(ms) ((LONGLONG)((LONG)(ms) * -10000L))
  40. //
  41. // Definition of handle table for extensible objects
  42. //
  43. typedef PM_OPEN_PROC *OPENPROC;
  44. typedef PM_COLLECT_PROC *COLLECTPROC;
  45. typedef PM_QUERY_PROC *QUERYPROC;
  46. typedef PM_CLOSE_PROC *CLOSEPROC;
  47. #define EXT_OBJ_INFO_NAME_LENGTH 32
  48. typedef struct _EXT_OBJECT {
  49. LPVOID pNext; // not used
  50. HANDLE hMutex; // sync mutex for this function
  51. OPENPROC OpenProc; // address of the open routine
  52. LPSTR szOpenProcName; // open procedure name
  53. LPWSTR szLinkageString; // param for open proc
  54. DWORD dwOpenTimeout; // wait time in MS for open proc
  55. COLLECTPROC CollectProc; // address of the collect routine
  56. QUERYPROC QueryProc; // address of query proc
  57. LPSTR szCollectProcName; // collect procedure name
  58. DWORD dwCollectTimeout; // wait time in MS for collect proc
  59. CLOSEPROC CloseProc; // address of the close routine
  60. LPSTR szCloseProcName; // close procedure name
  61. HMODULE hLibrary ; // handle returned by LoadLibraryW
  62. LPWSTR szLibraryName; // full path of library
  63. HKEY hPerfKey; // handle to performance sub key fo this service
  64. DWORD dwNumObjects; // number of supported objects
  65. DWORD dwObjList[MAX_PERF_OBJECTS_IN_QUERY_FUNCTION]; // address of array of supported objects
  66. DWORD dwFlags; // flags
  67. LPWSTR szServiceName; // service name
  68. LONGLONG llLastUsedTime; // FILETIME of last access
  69. // Performance statistics
  70. LONGLONG llOpenTime; // total time spent in open procedure
  71. LONGLONG llCollectTime; // time spent in call in 100Ns Units
  72. DWORD dwCollectCount; // number of times Collect successfully called
  73. DWORD dwOpenCount; // number of Loads & opens
  74. DWORD dwCloseCount; // number of Unloads & closes
  75. DWORD dwLockoutCount; // count of lock timeouts
  76. DWORD dwErrorCount; // count of errors (other than timeouts)
  77. DWORD dwExceptionCount; // exceptions
  78. DWORD dwLowerGPViolations;
  79. DWORD dwUpperGPViolations;
  80. DWORD dwBadPointers;
  81. DWORD dwBufferSizeErrors;
  82. DWORD dwAlignmentErrors;
  83. DWORD dwObjectSizeErrors;
  84. DWORD dwInstanceSizeErrors;
  85. DWORD dwInstanceNameErrors;
  86. // last function call values
  87. LONGLONG llTimeBase; // time base frequency
  88. LONGLONG llFunctionTime; // time spent in last successful call in 100Ns Units
  89. DWORD dwNumObjectsRet; // number of objects returned by collect function
  90. DWORD dwRetBufSize; // buffer size returned by function
  91. } EXT_OBJECT , *PEXT_OBJECT ;
  92. // ext object flags
  93. #define PERF_EO_QUERY_FUNC ((DWORD)0x00000001) // use query proc
  94. #define PERF_EO_BAD_DLL ((DWORD)0x00000002) // true when DLL ret. error
  95. #define PERF_EO_KEEP_RESIDENT ((DWORD)0x00000004) // true if lib should not be trimmed
  96. #define PERF_EO_OBJ_IN_QUERY ((DWORD)0x80000000) // true when in query list
  97. typedef struct _EXT_CTR_PERF_DATA {
  98. // accumulating functions
  99. LONGLONG llElapsedTime; // cumulative time spent in call in 100Ns Units
  100. DWORD dwCollectCount; // number of times Collect successfully called
  101. DWORD dwOpenCount; // number of Loads & opens
  102. DWORD dwCloseCount; // number of Unloads & closes
  103. DWORD dwLockoutCount; // count of lock timeouts
  104. DWORD dwErrorCount; // count of errors (other than timeouts)
  105. DWORD dwExceptionCount; // exceptions
  106. DWORD dwLowerGPViolations;
  107. DWORD dwUpperGPViolations;
  108. DWORD dwBadPointers;
  109. DWORD dwBufferSizeErrors;
  110. DWORD dwAlignmentErrors;
  111. DWORD dwObjectSizeErrors;
  112. DWORD dwInstanceSizeErrors;
  113. DWORD dwReserved1;
  114. // last function call values
  115. LONGLONG llTimeBase; // time base frequency
  116. LONGLONG llFunctionTime; // time spent in call in 100Ns Units
  117. DWORD dwNumObjects; // number of objects returned by collect function
  118. DWORD dwRetBufSize; // buffer size returned by function
  119. } EXT_CTR_PERF_DATA, *PEXT_CTR_PERF_DATA;
  120. typedef struct _OPEN_PROC_WAIT_INFO {
  121. struct _OPEN_PROC_WAIT_INFO *pNext;
  122. LPWSTR szLibraryName;
  123. LPWSTR szServiceName;
  124. DWORD dwWaitTime;
  125. DWORD dwEventMsg;
  126. LPVOID pData;
  127. } OPEN_PROC_WAIT_INFO, FAR * LPOPEN_PROC_WAIT_INFO;
  128. #define NextObject(pObject) \
  129. ((PERF_OBJECT_TYPE *) ((PBYTE) pObject + pObject->TotalByteLength))
  130. #define FirstCounter(pObjectDef) \
  131. ((PERF_COUNTER_DEFINITION *) ((PCHAR)pObjectDef + pObjectDef->HeaderLength))
  132. #define NextCounter(pCounterDef) \
  133. ((PERF_COUNTER_DEFINITION *) ((PCHAR)pCounterDef + pCounterDef->ByteLength))
  134. #endif //_PERFVAL_H_