Leaked source code of windows server 2003
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.

156 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. #define DWORD_MULTIPLE(x) (((x+sizeof(DWORD)-1)/sizeof(DWORD))*sizeof(DWORD))
  40. #define QWORD_MULTIPLE(x) (((x+sizeof(LONGLONG)-1)/sizeof(LONGLONG))*sizeof(LONGLONG))
  41. #define ALIGN_ON_DWORD(x) ((VOID *) (((ULONG_PTR) (x) + 3) & ~0x3))
  42. #define ALIGN_ON_QWORD(x) ((VOID *) (((ULONG_PTR) (x) + 7) & ~0x7))
  43. extern const WCHAR GLOBAL_STRING[]; // Global command (get all local ctrs)
  44. extern const WCHAR FOREIGN_STRING[]; // get data from foreign computers
  45. extern const WCHAR COSTLY_STRING[];
  46. extern const WCHAR NULL_STRING[];
  47. extern const WCHAR szTotalValue[];
  48. extern const WCHAR szDefaultTotalString[];
  49. #define DEFAULT_TOTAL_STRING_LEN 14
  50. extern DWORD MESSAGE_LEVEL;
  51. #define QUERY_GLOBAL 1
  52. #define QUERY_ITEMS 2
  53. #define QUERY_FOREIGN 3
  54. #define QUERY_COSTLY 4
  55. // function prototypes for data collection routines
  56. typedef DWORD (APIENTRY PM_LOCAL_COLLECT_PROC) (LPVOID *, LPDWORD, LPDWORD);
  57. typedef struct _POS_FUNCTION_INFO {
  58. DWORD dwObjectId;
  59. DWORD dwCollectFunctionBit;
  60. DWORD dwDataFunctionBit;
  61. PM_LOCAL_COLLECT_PROC *pCollectFunction;
  62. } POS_FUNCTION_INFO, * PPOS_FUNCTION_INFO;
  63. //
  64. // The definition of the only routine of perfutil.c, It builds part of a
  65. // performance data instance (PERF_INSTANCE_DEFINITION) as described in
  66. // winperf.h
  67. //
  68. HANDLE MonOpenEventLog (IN LPWSTR);
  69. VOID MonCloseEventLog ();
  70. DWORD GetQueryType (IN LPWSTR);
  71. BOOL IsNumberInUnicodeList (DWORD, LPWSTR);
  72. BOOL
  73. MonBuildInstanceDefinition(
  74. PERF_INSTANCE_DEFINITION *pBuffer,
  75. PVOID *pBufferNext,
  76. DWORD ParentObjectTitleIndex,
  77. DWORD ParentObjectInstance,
  78. DWORD UniqueID,
  79. LPWSTR Name
  80. );
  81. LONG
  82. GetPerflibKeyValue (
  83. LPCWSTR szItem,
  84. DWORD dwRegType,
  85. DWORD dwMaxSize, // ... of pReturnBuffer in bytes
  86. LPVOID pReturnBuffer,
  87. DWORD dwDefaultSize, // ... of pDefault in bytes
  88. LPVOID pDefault
  89. );
  90. //
  91. // Memory Probe macro
  92. //
  93. #ifdef PROBE_HEAP_USAGE
  94. typedef struct _LOCAL_HEAP_INFO_BLOCK {
  95. DWORD AllocatedEntries;
  96. DWORD AllocatedBytes;
  97. DWORD FreeEntries;
  98. DWORD FreeBytes;
  99. } LOCAL_HEAP_INFO, *PLOCAL_HEAP_INFO;
  100. #define HEAP_PROBE() { \
  101. DWORD dwHeapStatus[5]; \
  102. NTSTATUS CallStatus; \
  103. dwHeapStatus[4] = __LINE__; \
  104. if (!(CallStatus = memprobe (dwHeapStatus, 16L, NULL))) { \
  105. REPORT_INFORMATION_DATA (TCP_HEAP_STATUS, LOG_DEBUG, \
  106. &dwHeapStatus, sizeof(dwHeapStatus)); \
  107. } else { \
  108. REPORT_ERROR_DATA (TCP_HEAP_STATUS_ERROR, LOG_DEBUG, \
  109. &CallStatus, sizeof (DWORD)); \
  110. } \
  111. }
  112. #else
  113. #define HEAP_PROBE() ;
  114. #endif
  115. #define ALLOCMEM(heap, flags, size) HeapAlloc (heap, flags, size)
  116. #define REALLOCMEM(heap, flags, pointer, newsize) \
  117. HeapReAlloc (heap, flags, pointer, newsize)
  118. #define FREEMEM(heap, flags, pointer) HeapFree (heap, flags, pointer)
  119. #endif //_PERFUTIL_H_
  120.