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.

166 lines
6.9 KiB

  1. #ifndef _CTRTEST_H_
  2. #define _CTRTEST_H_
  3. #define WBEMPERF_OPEN_PROC_NOT_FOUND 0xC0100002
  4. #define WBEMPERF_COLLECT_PROC_NOT_FOUND 0xC0100003
  5. #define WBEMPERF_CLOSE_PROC_NOT_FOUND 0xC0100004
  6. #define WBEMPERF_OPEN_PROC_FAILURE 0xC0100005
  7. #define WBEMPERF_OPEN_PROC_EXCEPTION 0xC0100006
  8. #define DWORD_PTR DWORD
  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. //
  37. // Definition of handle table for extensible objects
  38. //
  39. typedef PM_OPEN_PROC *OPENPROC;
  40. typedef PM_COLLECT_PROC *COLLECTPROC;
  41. typedef PM_QUERY_PROC *QUERYPROC;
  42. typedef PM_CLOSE_PROC *CLOSEPROC;
  43. #define EXT_OBJ_INFO_NAME_LENGTH 32
  44. typedef struct _EXT_OBJECT {
  45. LPVOID pNext; // not used
  46. HANDLE hMutex; // sync mutex for this function
  47. OPENPROC OpenProc; // address of the open routine
  48. LPSTR szOpenProcName; // open procedure name
  49. LPWSTR szLinkageString; // param for open proc
  50. DWORD dwOpenTimeout; // wait time in MS for open proc
  51. COLLECTPROC CollectProc; // address of the collect routine
  52. QUERYPROC QueryProc; // address of query proc
  53. LPSTR szCollectProcName; // collect procedure name
  54. DWORD dwCollectTimeout; // wait time in MS for collect proc
  55. CLOSEPROC CloseProc; // address of the close routine
  56. LPSTR szCloseProcName; // close procedure name
  57. HMODULE hLibrary ; // handle returned by LoadLibraryW
  58. LPWSTR szLibraryName; // full path of library
  59. DWORD dwNumObjects; // number of supported objects
  60. DWORD dwObjList[MAX_PERF_OBJECTS_IN_QUERY_FUNCTION]; // address of array of supported objects
  61. DWORD dwFlags; // flags
  62. LPWSTR szServiceName; // service name
  63. LONGLONG llLastUsedTime; // FILETIME of last access
  64. // Performance statistics
  65. LONGLONG llOpenTime; // total time spent in open procedure
  66. LONGLONG llCollectTime; // time spent in call in 100Ns Units
  67. DWORD dwCollectCount; // number of times Collect successfully called
  68. DWORD dwOpenCount; // number of Loads & opens
  69. DWORD dwCloseCount; // number of Unloads & closes
  70. DWORD dwLockoutCount; // count of lock timeouts
  71. DWORD dwErrorCount; // count of errors (other than timeouts)
  72. DWORD dwExceptionCount; // exceptions
  73. DWORD dwLowerGPViolations;
  74. DWORD dwUpperGPViolations;
  75. DWORD dwBadPointers;
  76. DWORD dwBufferSizeErrors;
  77. DWORD dwAlignmentErrors;
  78. DWORD dwObjectSizeErrors;
  79. DWORD dwInstanceSizeErrors;
  80. DWORD dwInstanceNameErrors;
  81. // last function call values
  82. LONGLONG llTimeBase; // time base frequency
  83. LONGLONG llFunctionTime; // time spent in call in 100Ns Units
  84. DWORD dwNumObjectsRet; // number of objects returned by collect function
  85. DWORD dwRetBufSize; // buffer size returned by function
  86. BOOL bValid; // Is the object valid on this machine?
  87. LPWSTR szQueryString; // The string to query
  88. } EXT_OBJECT , *PEXT_OBJECT ;
  89. // ext object flags
  90. #define PERF_EO_QUERY_FUNC ((DWORD)0x00000001) // use query proc
  91. #define PERF_EO_BAD_DLL ((DWORD)0x00000002) // true when DLL ret. error
  92. #define PERF_EO_KEEP_RESIDENT ((DWORD)0x00000004) // true if lib should not be trimmed
  93. #define PERF_EO_OBJ_IN_QUERY ((DWORD)0x80000000) // true when in query list
  94. typedef struct _EXT_CTR_PERF_DATA {
  95. // accumulating functions
  96. LONGLONG llElapsedTime; // cumulative time spent in call in 100Ns Units
  97. DWORD dwCollectCount; // number of times Collect successfully called
  98. DWORD dwOpenCount; // number of Loads & opens
  99. DWORD dwCloseCount; // number of Unloads & closes
  100. DWORD dwLockoutCount; // count of lock timeouts
  101. DWORD dwErrorCount; // count of errors (other than timeouts)
  102. DWORD dwExceptionCount; // exceptions
  103. DWORD dwLowerGPViolations;
  104. DWORD dwUpperGPViolations;
  105. DWORD dwBadPointers;
  106. DWORD dwBufferSizeErrors;
  107. DWORD dwAlignmentErrors;
  108. DWORD dwObjectSizeErrors;
  109. DWORD dwInstanceSizeErrors;
  110. DWORD dwReserved1;
  111. // last function call values
  112. LONGLONG llTimeBase; // time base frequency
  113. LONGLONG llFunctionTime; // time spent in call in 100Ns Units
  114. DWORD dwNumObjects; // number of objects returned by collect function
  115. DWORD dwRetBufSize; // buffer size returned by function
  116. } EXT_CTR_PERF_DATA, *PEXT_CTR_PERF_DATA;
  117. typedef struct _OPEN_PROC_WAIT_INFO {
  118. struct _OPEN_PROC_WAIT_INFO *pNext;
  119. LPWSTR szLibraryName;
  120. LPWSTR szServiceName;
  121. DWORD dwWaitTime;
  122. DWORD dwEventMsg;
  123. LPVOID pData;
  124. } OPEN_PROC_WAIT_INFO, FAR * LPOPEN_PROC_WAIT_INFO;
  125. #define NextObject(pObject) \
  126. ((PERF_OBJECT_TYPE *) ((PBYTE) pObject + pObject->TotalByteLength))
  127. #define FirstCounter(pObjectDef) \
  128. ((PERF_COUNTER_DEFINITION *) ((PCHAR)pObjectDef + pObjectDef->HeaderLength))
  129. #define NextCounter(pCounterDef) \
  130. ((PERF_COUNTER_DEFINITION *) ((PCHAR)pCounterDef + pCounterDef->ByteLength))
  131. typedef struct _SAFE_BUFFER
  132. {
  133. DWORD dwBufSize; // Size of safe buffer
  134. DWORD dwCallBufSize; // Buffer size call parameter
  135. DWORD dwBufSizeIncrement; // Size of reallocation increment
  136. LPVOID lpLowGuardPage; // Pointer to the low guard bytes
  137. LPVOID lpHiGuardPage; // Pointer to the high guard bytes
  138. LPVOID lpEndPointer; // Pointer to the end of the buffer
  139. LPVOID lpBuffer; // Pointer to the full buffer
  140. LPVOID lpSafeBuffer; // Pointer to the safe buffer
  141. LPVOID lpCallBuffer; // Pointer to the call parameter
  142. } SAFE_BUFFER, *PSAFE_BUFFER;
  143. #endif //_CTRTEST_H_