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.

163 lines
4.2 KiB

  1. /*++ BUILD Version: 0001 // Increment this if a change has global effects
  2. Copyright (c) 1995 Microsoft Corporation
  3. Module Name:
  4. perfutil.h
  5. Abstract:
  6. This file supports routines used to parse and
  7. create Performance Monitor Data Structures.
  8. It actually supports Performance Object types with
  9. multiple instances
  10. Author:
  11. Bob Watson 28-Jul-1995
  12. Revision History:
  13. --*/
  14. #ifndef _PERFUTIL_H_
  15. #define _PERFUTIL_H_
  16. #include <windows.h>
  17. #include <winperf.h>
  18. #define MAX_INSTANCE_NAME 32
  19. #define SMALL_BUFFER_SIZE ((DWORD)4096)
  20. #define MEDIUM_BUFFER_SIZE ((DWORD)(4096*8))
  21. #define LARGE_BUFFER_SIZE ((DWORD)(4096*16))
  22. #define INCREMENT_BUFFER_SIZE ((DWORD)(4096*2))
  23. #define MAX_VALUE_NAME_LENGTH 256*sizeof(WCHAR)
  24. #define MAX_VALUE_DATA_LENGTH 256*sizeof(WCHAR)
  25. //
  26. // Until USER supports Unicode, we have to work in ASCII:
  27. //
  28. #define DEFAULT_NT_CODE_PAGE 437
  29. #define UNICODE_CODE_PAGE 0
  30. // enable this define to log process heap data to the event log
  31. #ifdef PROBE_HEAP_USAGE
  32. #undef PROBE_HEAP_USAGE
  33. #endif
  34. //
  35. // Utility macro. This is used to reserve a DWORD multiple of
  36. // bytes for Unicode strings embedded in the definitional data,
  37. // viz., object instance names.
  38. //
  39. // Assumes x is DWORD, and returns a DWORD
  40. //
  41. #define DWORD_MULTIPLE(x) (((ULONG)(x) + ((4)-1)) & ~((ULONG)(4)-1))
  42. #define QWORD_MULTIPLE(x) (((ULONG)(x) + ((8)-1)) & ~((ULONG)(8)-1))
  43. //
  44. // Returns a PVOID
  45. //
  46. #define ALIGN_ON_DWORD(x) \
  47. ((VOID *)(((ULONG_PTR)(x) + ((4)-1)) & ~((ULONG_PTR)(4)-1)))
  48. #define ALIGN_ON_QWORD(x) \
  49. ((VOID *)(((ULONG_PTR)(x) + ((8)-1)) & ~((ULONG_PTR)(8)-1)))
  50. extern const WCHAR GLOBAL_STRING[]; // Global command (get all local ctrs)
  51. extern const WCHAR FOREIGN_STRING[]; // get data from foreign computers
  52. extern const WCHAR COSTLY_STRING[];
  53. extern const WCHAR NULL_STRING[];
  54. extern const WCHAR szTotalValue[];
  55. extern const WCHAR szDefaultTotalString[];
  56. #define DEFAULT_TOTAL_STRING_LEN 14
  57. extern DWORD MESSAGE_LEVEL;
  58. #define QUERY_GLOBAL 1
  59. #define QUERY_ITEMS 2
  60. #define QUERY_FOREIGN 3
  61. #define QUERY_COSTLY 4
  62. // function prototypes for data collection routines
  63. typedef DWORD (APIENTRY PM_LOCAL_COLLECT_PROC) (LPVOID *, LPDWORD, LPDWORD);
  64. typedef struct _POS_FUNCTION_INFO {
  65. DWORD dwObjectId;
  66. DWORD dwCollectFunctionBit;
  67. DWORD dwDataFunctionBit;
  68. PM_LOCAL_COLLECT_PROC *pCollectFunction;
  69. } POS_FUNCTION_INFO, * PPOS_FUNCTION_INFO;
  70. //
  71. // The definition of the only routine of perfutil.c, It builds part of a
  72. // performance data instance (PERF_INSTANCE_DEFINITION) as described in
  73. // winperf.h
  74. //
  75. HANDLE MonOpenEventLog (IN LPWSTR);
  76. VOID MonCloseEventLog ();
  77. DWORD GetQueryType (IN LPWSTR);
  78. BOOL IsNumberInUnicodeList (DWORD, LPWSTR);
  79. BOOL
  80. MonBuildInstanceDefinition(
  81. PERF_INSTANCE_DEFINITION *pBuffer,
  82. PVOID *pBufferNext,
  83. DWORD ParentObjectTitleIndex,
  84. DWORD ParentObjectInstance,
  85. DWORD UniqueID,
  86. LPWSTR Name
  87. );
  88. LONG
  89. GetPerflibKeyValue (
  90. LPCWSTR szItem,
  91. DWORD dwRegType,
  92. DWORD dwMaxSize, // ... of pReturnBuffer in bytes
  93. LPVOID pReturnBuffer,
  94. DWORD dwDefaultSize, // ... of pDefault in bytes
  95. LPVOID pDefault
  96. );
  97. //
  98. // Memory Probe macro
  99. //
  100. #ifdef PROBE_HEAP_USAGE
  101. typedef struct _LOCAL_HEAP_INFO_BLOCK {
  102. DWORD AllocatedEntries;
  103. DWORD AllocatedBytes;
  104. DWORD FreeEntries;
  105. DWORD FreeBytes;
  106. } LOCAL_HEAP_INFO, *PLOCAL_HEAP_INFO;
  107. #define HEAP_PROBE() { \
  108. DWORD dwHeapStatus[5]; \
  109. NTSTATUS CallStatus; \
  110. dwHeapStatus[4] = __LINE__; \
  111. if (!(CallStatus = memprobe (dwHeapStatus, 16L, NULL))) { \
  112. REPORT_INFORMATION_DATA (TCP_HEAP_STATUS, LOG_DEBUG, \
  113. &dwHeapStatus, sizeof(dwHeapStatus)); \
  114. } else { \
  115. REPORT_ERROR_DATA (TCP_HEAP_STATUS_ERROR, LOG_DEBUG, \
  116. &CallStatus, sizeof (DWORD)); \
  117. } \
  118. }
  119. #else
  120. #define HEAP_PROBE() ;
  121. #endif
  122. #define ALLOCMEM(heap, flags, size) HeapAlloc (heap, flags, size)
  123. #define REALLOCMEM(heap, flags, pointer, newsize) \
  124. HeapReAlloc (heap, flags, pointer, newsize)
  125. #define FREEMEM(heap, flags, pointer) HeapFree (heap, flags, pointer)
  126. #endif //_PERFUTIL_H_