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.

304 lines
8.7 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. log_pm.h
  5. Abstract:
  6. <abstract>
  7. --*/
  8. #ifndef _LOG_PM_H_
  9. #define _LOG_PM_H_
  10. #include <windows.h>
  11. #include <winperf.h>
  12. #include "strings.h"
  13. // Filetimes are in 100NS units
  14. #define FILETIMES_PER_SECOND 10000000
  15. typedef PERF_DATA_BLOCK * PPERFDATA;
  16. //BEGIN definitions included from PERFMON\sizes.h
  17. #define MAX_SYSTEM_NAME_LENGTH 128
  18. //END definitions included from PERFMON\sizes.h
  19. #define LogFileIndexData 0x01
  20. #define LogFileIndexBookmark 0x02
  21. #define LogFileIndexCounterName 0x010
  22. #define PlayingBackLog() (PlaybackLog.iStatus == iPMStatusPlaying)
  23. #define IsDataIndex(pIndex) (pIndex->uFlags & LogFileIndexData)
  24. #define IsBookmarkIndex(pIndex) (pIndex->uFlags & LogFileIndexBookmark)
  25. #define IsCounterNameIndex(pIndex) (pIndex->uFlags & LogFileIndexCounterName)
  26. #define MAX_BTREE_DEPTH 40
  27. #define PDH_INVALID_POINTER ((LPVOID) -1)
  28. typedef struct _PDHI_LOG_MACHINE_NODE PDHI_LOG_MACHINE, * PPDHI_LOG_MACHINE;
  29. typedef struct _PDHI_LOG_OBJECT_NODE PDHI_LOG_OBJECT, * PPDHI_LOG_OBJECT;
  30. typedef struct _PDHI_LOG_COUNTER_NODE PDHI_LOG_COUNTER, * PPDHI_LOG_COUNTER;
  31. struct _PDHI_LOG_MACHINE_NODE {
  32. PPDHI_LOG_MACHINE next;
  33. PPDHI_LOG_OBJECT ObjTable;
  34. PPDHI_LOG_OBJECT ObjList;
  35. LPWSTR szMachine;
  36. PPERF_DATA_BLOCK pBlock;
  37. DWORD dwIndex;
  38. };
  39. struct _PDHI_LOG_OBJECT_NODE {
  40. PPDHI_LOG_COUNTER CtrTable;
  41. PPDHI_LOG_COUNTER CtrList;
  42. PPDHI_LOG_COUNTER InstTable;
  43. PPDHI_LOG_COUNTER InstList;
  44. PPDHI_LOG_OBJECT left;
  45. PPDHI_LOG_OBJECT right;
  46. PPDHI_LOG_OBJECT next;
  47. LPWSTR szObject;
  48. PPERF_OBJECT_TYPE pObjData;
  49. DWORD dwObject;
  50. DWORD dwIndex;
  51. BOOL bIsRed;
  52. BOOL bNeedExpand;
  53. };
  54. struct _PDHI_LOG_COUNTER_NODE {
  55. PPDHI_LOG_COUNTER left;
  56. PPDHI_LOG_COUNTER right;
  57. PPDHI_LOG_COUNTER next;
  58. ULONGLONG TimeStamp;
  59. LONGLONG TimeBase;
  60. LPWSTR szCounter;
  61. LPWSTR szInstance;
  62. LPWSTR szParent;
  63. DWORD dwCounterID;
  64. DWORD dwCounterType;
  65. DWORD dwDefaultScale;
  66. DWORD dwInstance;
  67. DWORD dwParent;
  68. BOOL bIsRed;
  69. };
  70. //BEGIN definitions included from PERFMON\typedefs.h
  71. typedef struct _COUNTERTEXT {
  72. struct _COUNTERTEXT * pNextTable;
  73. DWORD dwLangId;
  74. DWORD dwLastId;
  75. DWORD dwCounterSize;
  76. DWORD dwHelpSize;
  77. LPWSTR * TextString;
  78. LPWSTR HelpTextString;
  79. } COUNTERTEXT, * PCOUNTERTEXT;
  80. typedef struct PERFSYSTEMSTRUCT {
  81. struct PERFSYSTEMSTRUCT * pSystemNext;
  82. WCHAR sysName[MAX_SYSTEM_NAME_LENGTH+1];
  83. HKEY sysDataKey;
  84. COUNTERTEXT CounterInfo;
  85. DWORD FailureTime;
  86. LPWSTR lpszValue;
  87. BOOL bSystemNoLongerNeeded;
  88. BOOL bSystemCounterNameSaved;
  89. // the following used by perf data thread
  90. DWORD dwThreadID;
  91. HANDLE hThread;
  92. DWORD StateData;
  93. HANDLE hStateDataMutex;
  94. HANDLE hPerfDataEvent;
  95. PPERFDATA pSystemPerfData;
  96. // mainly used by Alert to report system up/down
  97. DWORD dwSystemState;
  98. // system version
  99. DWORD SysVersion;
  100. } PERFSYSTEM, * PPERFSYSTEM, ** PPPERFSYSTEM;
  101. //======================================//
  102. // Log File Data Types //
  103. //======================================//
  104. #define LogFileSignatureLen 6
  105. #define LogFileBlockMaxIndexes 100
  106. typedef struct LOGHEADERSTRUCT { // LOGHEADER
  107. WCHAR szSignature[LogFileSignatureLen];
  108. int iLength;
  109. WORD wVersion;
  110. WORD wRevision;
  111. long lBaseCounterNameOffset;
  112. } LOGHEADER, * PLOGHEADER;
  113. typedef struct LOGINDEXSTRUCT { // LOGINDEX
  114. UINT uFlags;
  115. SYSTEMTIME SystemTime;
  116. long lDataOffset;
  117. int iSystemsLogged;
  118. } LOGINDEX, * PLOGINDEX;
  119. #define LogIndexSignatureLen 7
  120. #define LogIndexSignature L"Index "
  121. #define LogIndexSignature1 "Perfmon Index"
  122. typedef struct LOGFILEINDEXBLOCKSTRUCT {
  123. WCHAR szSignature[LogIndexSignatureLen];
  124. int iNumIndexes ;
  125. LOGINDEX aIndexes[LogFileBlockMaxIndexes];
  126. DWORD lNextBlockOffset ;
  127. } LOGINDEXBLOCK, * PLOGINDEXBLOCK;
  128. typedef struct LOGPOSITIONSTRUCT {
  129. PLOGINDEXBLOCK pIndexBlock;
  130. int iIndex;
  131. int iPosition;
  132. } LOGPOSITION, * PLOGPOSITION;
  133. //======================================//
  134. // Bookmark Data Type //
  135. //======================================//
  136. #define BookmarkCommentLen 256
  137. typedef struct PDH_BOOKMARKSTRUCT {
  138. struct PDH_BOOKMARKSTRUCT * pBookmarkNext;
  139. SYSTEMTIME SystemTime;
  140. WCHAR szComment[BookmarkCommentLen];
  141. int iTic;
  142. } PDH_BOOKMARK, * PPDH_BOOKMARK, ** PPPDH_BOOKMARK;
  143. typedef struct _LOGFILECOUNTERNAME {
  144. WCHAR szComputer[MAX_SYSTEM_NAME_LENGTH];
  145. DWORD dwLastCounterId;
  146. DWORD dwLangId;
  147. long lBaseCounterNameOffset;
  148. long lCurrentCounterNameOffset;
  149. long lMatchLength;
  150. long lUnmatchCounterNames;
  151. } LOGFILECOUNTERNAME, * PLOGFILECOUNTERNAME, ** PPLOGFILECOUNTERNAME;
  152. typedef struct COUNTERNAMESTRUCT {
  153. struct COUNTERNAMESTRUCT * pCounterNameNext;
  154. LOGFILECOUNTERNAME CounterName;
  155. LPWSTR pRemainNames;
  156. } LOGCOUNTERNAME, * PLOGCOUNTERNAME;
  157. typedef struct _PDHI_PM_STRING PDHI_PM_STRING, * PPDHI_PM_STRING;
  158. struct _PDHI_PM_STRING {
  159. PPDHI_PM_STRING left;
  160. PPDHI_PM_STRING right;
  161. LPWSTR szString;
  162. DWORD dwIndex;
  163. BOOL bIsRed;
  164. };
  165. typedef struct _PMLOG_COUNTERNAMES PMLOG_COUNTERNAMES, * PPMLOG_COUNTERNAMES;
  166. struct _PMLOG_COUNTERNAMES {
  167. PPMLOG_COUNTERNAMES pNext;
  168. LPWSTR szSystemName;
  169. LPWSTR * szNameTable;
  170. PPDHI_PM_STRING StringTree;
  171. DWORD dwLangId;
  172. DWORD dwLastIndex;
  173. };
  174. typedef struct PLAYBACKLOGSTRUCT {
  175. LONGLONG llFileSize;
  176. LPWSTR szFilePath;
  177. PLOGHEADER pHeader;
  178. PPMLOG_COUNTERNAMES pFirstCounterNameTables;
  179. PPDHI_LOG_MACHINE MachineList;
  180. PLOGINDEX * LogIndexTable;
  181. DWORD dwFirstIndex;
  182. DWORD dwLastIndex;
  183. DWORD dwCurrentIndex;
  184. int iTotalTics;
  185. int iSelectedTics;
  186. LOGPOSITION BeginIndexPos;
  187. LOGPOSITION EndIndexPos;
  188. LOGPOSITION StartIndexPos;
  189. LOGPOSITION StopIndexPos;
  190. LOGPOSITION LastIndexPos; // pos of last index read
  191. PPDH_BOOKMARK pBookmarkFirst;
  192. LPWSTR pBaseCounterNames;
  193. long lBaseCounterNameSize;
  194. long lBaseCounterNameOffset;
  195. PLOGCOUNTERNAME pLogCounterNameFirst;
  196. } PLAYBACKLOG, * PPLAYBACKLOG;
  197. PDH_FUNCTION
  198. PdhiOpenInputPerfmonLog(
  199. PPDHI_LOG pLog
  200. );
  201. PDH_FUNCTION
  202. PdhiClosePerfmonLog(
  203. PPDHI_LOG pLog,
  204. DWORD dwFlags
  205. );
  206. PDH_FUNCTION
  207. PdhiGetPerfmonLogCounterInfo(
  208. PPDHI_LOG pLog,
  209. PPDHI_COUNTER pCounter
  210. );
  211. PDH_FUNCTION
  212. PdhiEnumMachinesFromPerfmonLog(
  213. PPDHI_LOG pLog,
  214. LPVOID pBuffer,
  215. LPDWORD lpdwBufferSize,
  216. BOOL bUnicodeDest
  217. );
  218. PDH_FUNCTION
  219. PdhiEnumObjectsFromPerfmonLog(
  220. PPDHI_LOG pLog,
  221. LPCWSTR szMachineName,
  222. LPVOID mszObjectList,
  223. LPDWORD pcchBufferSize,
  224. DWORD dwDetailLevel,
  225. BOOL bUnicode
  226. );
  227. PDH_FUNCTION
  228. PdhiEnumObjectItemsFromPerfmonLog(
  229. PPDHI_LOG hDataSource,
  230. LPCWSTR szMachineName,
  231. LPCWSTR szObjectName,
  232. PDHI_COUNTER_TABLE CounterTable,
  233. DWORD dwDetailLevel,
  234. DWORD dwFlags
  235. );
  236. PDH_FUNCTION
  237. PdhiGetMatchingPerfmonLogRecord(
  238. PPDHI_LOG pLog,
  239. LONGLONG * pStartTime,
  240. LPDWORD pdwIndex
  241. );
  242. PDH_FUNCTION
  243. PdhiGetCounterValueFromPerfmonLog(
  244. PPDHI_LOG hLog,
  245. DWORD dwIndex,
  246. PPDHI_COUNTER pCounter,
  247. PPDH_RAW_COUNTER pValue
  248. );
  249. PDH_FUNCTION
  250. PdhiGetTimeRangeFromPerfmonLog(
  251. PPDHI_LOG hLog,
  252. LPDWORD pdwNumEntries,
  253. PPDH_TIME_INFO pInfo,
  254. LPDWORD dwBufferSize
  255. );
  256. PDH_FUNCTION
  257. PdhiReadRawPerfmonLogRecord(
  258. PPDHI_LOG pLog,
  259. FILETIME * ftRecord,
  260. PPDH_RAW_LOG_RECORD pBuffer,
  261. LPDWORD pdwBufferLength
  262. );
  263. #endif // _LOG_PM_H_