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.

193 lines
4.5 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. perfdata.h
  5. Abstract:
  6. <abstract>
  7. --*/
  8. #ifndef _PERFDATA_H_
  9. #define _PERFDATA_H_
  10. #define INITIAL_SIZE ((DWORD)0x00010000)
  11. #define EXTEND_SIZE ((DWORD)0x00008000)
  12. #define RESERVED 0L
  13. typedef LPVOID LPMEMORY;
  14. typedef HGLOBAL HMEMORY;
  15. #ifndef UNICODE_NULL
  16. // then the unicode string struct is probably not defined either
  17. typedef struct _UNICODE_STRING {
  18. USHORT Length;
  19. USHORT MaximumLength;
  20. PWSTR Buffer;
  21. } UNICODE_STRING, *PUNICODE_STRING;
  22. #define UNICODE_NULL ((WCHAR)0) // winnt
  23. #endif
  24. LPWSTR *
  25. BuildNameTable(
  26. LPWSTR szComputerName, // computer to query names from
  27. LANGID LangId, // language ID
  28. PPERF_MACHINE pMachine // to update member fields
  29. );
  30. #define FirstObject(pPerfData) \
  31. (PPERF_OBJECT_TYPE)((PBYTE)(pPerfData) + (pPerfData)->HeaderLength)
  32. #define NextObject(pObject) \
  33. (PPERF_OBJECT_TYPE)((pObject)->TotalByteLength != 0 ? (PPERF_OBJECT_TYPE)((PBYTE)(pObject) + (pObject)->TotalByteLength) : NULL)
  34. PERF_OBJECT_TYPE *
  35. GetObjectDefByTitleIndex(
  36. IN PERF_DATA_BLOCK *pDataBlock,
  37. IN DWORD ObjectTypeTitleIndex
  38. );
  39. PERF_OBJECT_TYPE *
  40. GetObjectDefByName (
  41. IN PERF_DATA_BLOCK *pDataBlock,
  42. IN DWORD dwLastNameIndex,
  43. IN LPCWSTR *NameArray,
  44. IN LPCWSTR szObjectName
  45. );
  46. #define FirstInstance(pObjectDef) \
  47. (PERF_INSTANCE_DEFINITION *)((PCHAR) pObjectDef + pObjectDef->DefinitionLength)
  48. __inline
  49. PERF_INSTANCE_DEFINITION *
  50. NextInstance(
  51. IN PERF_INSTANCE_DEFINITION *pInstDef
  52. )
  53. {
  54. PERF_COUNTER_BLOCK *pCounterBlock;
  55. pCounterBlock = (PERF_COUNTER_BLOCK *)
  56. ((PCHAR) pInstDef + pInstDef->ByteLength);
  57. return (PERF_INSTANCE_DEFINITION *)
  58. ((PCHAR) pCounterBlock + pCounterBlock->ByteLength);
  59. }
  60. PERF_INSTANCE_DEFINITION *
  61. GetInstance(
  62. IN PERF_OBJECT_TYPE *pObjectDef,
  63. IN LONG InstanceNumber
  64. );
  65. PERF_INSTANCE_DEFINITION *
  66. GetInstanceByUniqueId(
  67. IN PERF_OBJECT_TYPE *pObjectDef,
  68. IN LONG InstanceUniqueId
  69. );
  70. DWORD
  71. GetInstanceNameStr (PPERF_INSTANCE_DEFINITION pInstance,
  72. LPWSTR lpszInstance,
  73. DWORD dwCodePage);
  74. DWORD
  75. GetFullInstanceNameStr (
  76. PERF_DATA_BLOCK *pPerfData,
  77. PERF_OBJECT_TYPE *pObjectDef,
  78. PERF_INSTANCE_DEFINITION *pInstanceDef,
  79. LPWSTR szInstanceName
  80. );
  81. BOOL IsMatchingInstance (
  82. PERF_INSTANCE_DEFINITION *pInstanceDef,
  83. DWORD dwCodePage,
  84. LPWSTR szInstanceNameToMatch,
  85. DWORD dwInstanceNameLength
  86. );
  87. #define FirstCounter(pObjectDef) \
  88. (PERF_COUNTER_DEFINITION *)((PCHAR)(pObjectDef) + (pObjectDef)->HeaderLength)
  89. #define NextCounter(pCounterDef) \
  90. (PERF_COUNTER_DEFINITION *)(((pCounterDef)->ByteLength != 0) ? (PERF_COUNTER_DEFINITION *)((PCHAR)(pCounterDef) + (pCounterDef)->ByteLength) : NULL)
  91. PERF_COUNTER_DEFINITION *
  92. GetCounterDefByName (
  93. IN PERF_OBJECT_TYPE *pObject,
  94. IN DWORD dwLastNameIndex,
  95. IN LPWSTR *NameArray,
  96. IN LPWSTR szCounterName
  97. );
  98. PERF_COUNTER_DEFINITION *
  99. GetCounterDefByTitleIndex(
  100. IN PERF_OBJECT_TYPE *pObjectDef,
  101. IN BOOL bBaseCounterDef,
  102. IN DWORD CounterTitleIndex
  103. );
  104. LONG
  105. GetSystemPerfData (
  106. IN HKEY hKeySystem,
  107. IN PPERF_DATA_BLOCK *pPerfData,
  108. IN LPWSTR szObjectList,
  109. IN BOOL bCollectCostlyData
  110. );
  111. PERF_INSTANCE_DEFINITION *
  112. GetInstanceByName(
  113. PERF_DATA_BLOCK *pDataBlock,
  114. PERF_OBJECT_TYPE *pObjectDef,
  115. LPWSTR pInstanceName,
  116. LPWSTR pParentName,
  117. DWORD dwIndex
  118. );
  119. __inline
  120. LPWSTR GetInstanceName(PPERF_INSTANCE_DEFINITION pInstDef)
  121. {
  122. return (LPWSTR)((ULONG_PTR) pInstDef + pInstDef->NameOffset);
  123. }
  124. __inline
  125. PVOID
  126. GetCounterDataPtr (
  127. PERF_OBJECT_TYPE *pObjectDef,
  128. PERF_COUNTER_DEFINITION *pCounterDef
  129. )
  130. {
  131. PERF_COUNTER_BLOCK *pCtrBlock;
  132. pCtrBlock = (PERF_COUNTER_BLOCK *)((PCHAR)pObjectDef +
  133. pObjectDef->DefinitionLength);
  134. return (PVOID)((PCHAR)pCtrBlock + pCounterDef->CounterOffset);
  135. }
  136. __inline
  137. PVOID
  138. GetInstanceCounterDataPtr (
  139. PERF_OBJECT_TYPE *pObjectDef,
  140. PERF_INSTANCE_DEFINITION *pInstanceDef,
  141. PERF_COUNTER_DEFINITION *pCounterDef
  142. )
  143. {
  144. PERF_COUNTER_BLOCK *pCtrBlock;
  145. UNREFERENCED_PARAMETER (pObjectDef);
  146. pCtrBlock = (PERF_COUNTER_BLOCK *)((PCHAR)pInstanceDef +
  147. pInstanceDef->ByteLength);
  148. return (PVOID)((PCHAR)pCtrBlock + pCounterDef->CounterOffset);
  149. }
  150. #endif //_PERFDATA_H_