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.

424 lines
13 KiB

  1. /*++
  2. Copyright (C) 1996-1999 Microsoft Corporation
  3. Module Name:
  4. smonctrl.h
  5. Abstract:
  6. <abstract>
  7. --*/
  8. #ifndef _SMONCTRL_H_
  9. #define _SMONCTRL_H_
  10. #pragma warning ( disable : 4201)
  11. #include <pdh.h>
  12. #include "colefont.h"
  13. #include "graph.h"
  14. #define SMONCTRL_MAJ_VERSION 3
  15. #define SMONCTRL_MIN_VERSION 6
  16. #define WM_GRAPH_UPDATE (WM_USER + 1)
  17. #define UPDGRPH_COLOR 1
  18. #define UPDGRPH_FONT 2
  19. #define UPDGRPH_LAYOUT 3
  20. #define UPDGRPH_ADDCNTR 4
  21. #define UPDGRPH_DELCNTR 5
  22. #define UPDGRPH_PLOT 6
  23. #define UPDGRPH_VIEW 7
  24. #define UPDGRPH_LOGVIEW 8
  25. #define SLQ_COUNTER_LOG 0
  26. #define SLQ_TRACE_LOG 1
  27. #define SLQ_ALERT_LOG 2
  28. #define SMON_CTRL_LOG 3
  29. #define LODWORD(ll) ((DWORD)((LONGLONG)ll & 0x00000000FFFFFFFF))
  30. #define HIDWORD(ll) ((DWORD)(((LONGLONG)ll >> 32) & 0x00000000FFFFFFFF))
  31. #define MAKELONGLONG(low, high) \
  32. ((LONGLONG) (((DWORD) (low)) | ((LONGLONG) ((DWORD) (high))) << 32))
  33. typedef union {
  34. struct {
  35. SHORT iMajor;
  36. SHORT iMinor;
  37. };
  38. DWORD dwVersion;
  39. } SMONCTRL_VERSION_DATA;
  40. typedef struct
  41. {
  42. INT32 iWidth;
  43. INT32 iHeight;
  44. INT32 nSamples;
  45. INT32 iScaleMax;
  46. INT32 iScaleMin;
  47. BOOL bLegend; // Each BOOL is 4 bytes
  48. BOOL bLabels;
  49. BOOL bHorzGrid;
  50. BOOL bVertGrid;
  51. BOOL bValueBar;
  52. BOOL bManualUpdate;
  53. FLOAT fUpdateInterval;
  54. INT32 iDisplayType;
  55. INT32 nGraphTitleLen;
  56. INT32 nYaxisTitleLen;
  57. OLE_COLOR clrBackCtl;
  58. OLE_COLOR clrFore;
  59. OLE_COLOR clrBackPlot;
  60. INT32 nFileNameLen;
  61. INT32 iReserved1; // Spare for future use
  62. LONGLONG llStartDisp; // On 8-byte boundary
  63. LONGLONG llStopDisp;
  64. INT32 iAppearance;
  65. INT32 iBorderStyle;
  66. OLE_COLOR clrGrid;
  67. OLE_COLOR clrTimeBar;
  68. BOOL bHighlight;
  69. BOOL bToolbar;
  70. INT32 iReportValueType;
  71. BOOL bReadOnly;
  72. BOOL bMonitorDuplicateInstances;
  73. BOOL bAmbientFont;
  74. INT32 iDisplayFilter;
  75. INT32 iDataSourceType;
  76. INT32 iSqlDsnLen;
  77. INT32 iSqlLogSetNameLen;
  78. INT32 iColorIndex;
  79. INT32 iWidthIndex;
  80. INT32 iStyleIndex;
  81. LONG32 arrlReserved[22]; // Spare, fill out to 256 bytes
  82. } GRAPHCTRL_DATA3;
  83. enum COLLECT_MODE {
  84. COLLECT_ACTIVE = 1,
  85. COLLECT_SUSPEND,
  86. COLLECT_QUIT
  87. };
  88. enum eBorderStyle {
  89. eBorderFirst = 0,
  90. eBorderNone = eBorderFirst,
  91. eBorderSingle = 1,
  92. eBorderCount
  93. };
  94. enum eAppearance {
  95. eAppearFirst = 0,
  96. eAppearFlat = eAppearFirst,
  97. eAppear3D = 1,
  98. eAppearCount
  99. };
  100. typedef struct {
  101. HANDLE hEvent;
  102. HANDLE hThread;
  103. DWORD dwInterval;
  104. DWORD dwSampleTime;
  105. COLLECT_MODE iMode;
  106. } COLLECT_PROC_INFO;
  107. class CLogFileItem;
  108. class CGraphItem;
  109. class CCounterTree;
  110. class CStatsBar;
  111. class CSnapBar;
  112. class CSysmonToolbar;
  113. class CReport;
  114. class CLegend;
  115. class CGraphDisp;
  116. typedef struct {
  117. LPTSTR pszFileName;
  118. } LOG_FILE_INFO;
  119. typedef struct {
  120. HLOG hDataSource;
  121. LPTSTR szSqlDsnName;
  122. LPTSTR szSqlLogSetName;
  123. CLogFileItem * pFirstLogFile;
  124. INT32 nSamples;
  125. LONGLONG llBeginTime;
  126. LONGLONG llEndTime;
  127. LONGLONG llStartDisp;
  128. LONGLONG llStopDisp;
  129. LONGLONG llInterval;
  130. LONG lLogFileCount;
  131. } DATA_SOURCE_INFO;
  132. class CSysmonControl
  133. {
  134. friend class CPolyline;
  135. friend class CImpISystemMonitor;
  136. friend class CSysmonToolbar;
  137. friend LRESULT APIENTRY SysmonCtrlWndProc (HWND hWnd, UINT uiMsg, WPARAM wParam, LPARAM lParam);
  138. friend DWORD WINAPI CollectProc(CSysmonControl *pCtrl);
  139. public:
  140. CSysmonControl ( CPolyline *pObj );
  141. virtual ~CSysmonControl ( void );
  142. void put_BackCtlColor ( OLE_COLOR color );
  143. void put_FgndColor ( OLE_COLOR color, BOOL fAmbient );
  144. void put_BackPlotColor ( OLE_COLOR color, BOOL fAmbient );
  145. void put_GridColor ( OLE_COLOR color );
  146. void put_TimeBarColor ( OLE_COLOR color );
  147. HRESULT put_Font( LPFONT pIFont, BOOL fAmbient );
  148. HRESULT get_DataSourceType( eDataSourceTypeConstant& eDataSourceType );
  149. HRESULT put_DataSourceType( INT iDataSourceType );
  150. HRESULT AddSingleLogFile ( LPCTSTR pPath, CLogFileItem** ppLogFile = NULL );
  151. HRESULT RemoveSingleLogFile ( CLogFileItem* pLogFile );
  152. // TodoLogFiles: Move FirstLogFile, NumLogFiles, to Graph.h?
  153. CLogFileItem* FirstLogFile ( void ) { return m_DataSourceInfo.pFirstLogFile; };
  154. INT NumLogFiles ( void ){ return m_DataSourceInfo.lLogFileCount; };
  155. void put_Appearance( INT iApp, BOOL fAmbient );
  156. void put_BorderStyle( INT iStyle, BOOL fAmbient );
  157. void put_Highlight ( BOOL bState );
  158. void put_ManualUpdate ( BOOL bManual );
  159. static BOOL RegisterWndClass( void );
  160. COLORREF clrBackCtl ( void ) { return m_clrBackCtl; }
  161. COLORREF clrFgnd ( void ) { return m_clrFgnd; }
  162. COLORREF clrBackPlot ( void ) { return m_clrBackPlot; }
  163. COLORREF clrGrid ( void ) { return m_clrGrid; }
  164. COLORREF clrTimeBar ( void ) { return m_clrTimeBar; }
  165. INT Appearance( void ) { return m_iAppearance; }
  166. INT BorderStyle( void ) { return m_iBorderStyle; }
  167. eReportValueTypeConstant ReportValueType ( void );
  168. HFONT Font ( void ) { HFONT hFont; m_OleFont.GetHFont(&hFont); return hFont; }
  169. HFONT BoldFont( void ) { HFONT hFont; m_OleFont.GetHFontBold(&hFont); return hFont; }
  170. void FontChanged ( void );
  171. void IncrementVisuals ( void );
  172. BOOL Init ( HWND hWndParent );
  173. void DeInit ( void );
  174. BOOL AllocateSubcomponents ( void );
  175. void UpdateNonAmbientSysColors ( void );
  176. HRESULT LoadFromStream ( LPSTREAM pIStream );
  177. HRESULT SaveToStream ( LPSTREAM pIStream );
  178. HRESULT LoadFromPropertyBag ( IPropertyBag*, IErrorLog* );
  179. HRESULT SaveToPropertyBag ( IPropertyBag*, BOOL fSaveAllProps );
  180. HRESULT LoadCountersFromPropertyBag ( IPropertyBag*, IErrorLog*, BOOL bLoadData=TRUE );
  181. HRESULT LoadLogFilesFromPropertyBag ( IPropertyBag*, IErrorLog* );
  182. HRESULT LoadLogFilesFromMultiSz ( LPCWSTR szLogFileList );
  183. void Render ( HDC hDC, HDC hAttribDC, BOOL fMetafile, BOOL fEntire, LPRECT pRect );
  184. void UpdateGraph ( INT nUpdateType );
  185. void SetIntervalTimer ( void );
  186. PDH_STATUS UpdateCounterValues( BOOL bManual );
  187. HRESULT AddCounter ( LPTSTR pPath, CGraphItem* *ppCtr );
  188. HRESULT AddSingleCounter ( LPTSTR pPath, CGraphItem* *ppCtr );
  189. HRESULT DeleteCounter ( CGraphItem* pCtr, BOOL bPropagate );
  190. HRESULT Paste ( void );
  191. HRESULT Copy ( void );
  192. HRESULT Reset ( void );
  193. void SelectCounter ( CGraphItem* pCtr );
  194. void DblClickCounter ( CGraphItem* pCtr );
  195. CGraphItem* FirstCounter ( void );
  196. CGraphItem* LastCounter ( void );
  197. CCounterTree* CounterTree ( void );
  198. INT CounterIndex ( CGraphItem* pCtr );
  199. HWND Window ( void );
  200. HRESULT TranslateAccelerators( LPMSG pMsg );
  201. INT ConfirmSampleDataOverwrite ( void );
  202. HRESULT DisplayProperties ( DISPID dispID = DISPID_UNKNOWN );
  203. HRESULT AddCounters ( void );
  204. HRESULT SaveAs ( void );
  205. HRESULT SaveData ( void );
  206. void Activate ( void );
  207. BOOL IsUIDead ( void ) { return m_fUIDead; }
  208. BOOL IsUserMode ( void ) { return m_fUserMode; }
  209. BOOL IsReadOnly ( void );
  210. BOOL DisplayHelp ( HWND hWndSelf );
  211. void LockCounterData ( void ) { EnterCriticalSection(&m_CounterDataLock); }
  212. void UnlockCounterData ( void ) { LeaveCriticalSection(&m_CounterDataLock); }
  213. BOOL IsLogSource ( void );
  214. PHIST_CONTROL HistoryControl( void ) { return m_pHistCtrl; }
  215. BOOL DisplayMissedSampleMessage( void );
  216. void SetMissedSample ( void );
  217. void SetLogViewTempTimeRange(LONGLONG llStart, LONGLONG LLStop);
  218. void ResetLogViewTempTimeRange( void );
  219. double GetZoomFactor ( void ) { return m_dZoomFactor; };
  220. void CalcZoomFactor ( void );
  221. LONG GetSaveDataFilter ( void ) { return m_lSaveDataToLogFilterValue; };
  222. BOOL SetSaveDataFilter ( long lFilter )
  223. {
  224. if (lFilter) {
  225. m_lSaveDataToLogFilterValue = lFilter;
  226. return TRUE;
  227. }
  228. return FALSE;
  229. };
  230. void DrawBorder ( HDC hDC );
  231. BOOL WriteFileReportHeader(HANDLE hFile);
  232. // *** TodoMultiLogHandle: Temporary method. Remove when trace file post-processing supports multiple
  233. // open files.
  234. HQUERY TempGetQueryHandle ( void ){ return m_hQuery; };
  235. private:
  236. void ApplyChanges ( HDC hDC );
  237. void Paint ( void );
  238. void OnDblClick ( INT xPos, INT yPos );
  239. void OnDropFile ( WPARAM wParam );
  240. void DisplayContextMenu ( short x, short y );
  241. void UpdateGraphData ( void );
  242. void SizeComponents ( HDC hDC );
  243. void AssignFocus( VOID );
  244. BOOL InitView ( HWND hWndParent );
  245. PRECT GetNewClientRect ( void );
  246. PRECT GetCurrentClientRect ( void );
  247. void SetCurrentClientRect ( PRECT );
  248. HRESULT ProcessDataSourceType( LPCTSTR pszDataSourceName, INT iDataSourceType );
  249. LPCTSTR GetDataSourceName ( void );
  250. HLOG GetDataSourceHandle(void) { return m_DataSourceInfo.hDataSource; }
  251. HRESULT CopyToBuffer ( LPTSTR& rpszData, DWORD& rdwBufferSize );
  252. HRESULT PasteFromBuffer ( LPTSTR pszData, BOOL bAllSettings = FALSE );
  253. DWORD InitializeQuery ( void );
  254. DWORD ActivateQuery ( void );
  255. void CloseQuery ( void );
  256. HRESULT InitLogFileIntervals( void );
  257. void SampleLogFile ( BOOL bViewChange );
  258. void Clear( void );
  259. void FindNextValidStepNum(
  260. BOOL bDecrease,
  261. CGraphItem* pItem,
  262. LONGLONG llNewTime,
  263. INT& riNewStepNum,
  264. DWORD& rdwStatus );
  265. void GetNewLogViewStepNum(LONGLONG llNewTime, INT& riNewStepNum);
  266. DWORD ProcessCommandLine( void );
  267. HRESULT LoadFromFile( LPTSTR pszFileName, BOOL bAllData );
  268. DWORD RelogLogData (
  269. LPCTSTR szOutputFile,
  270. DWORD dwOutputLogType,
  271. PDH_TIME_INFO pdhTimeInfo,
  272. DWORD dwFilterCount);
  273. HRESULT GetSelectedCounter ( CGraphItem** ppCtr );
  274. DWORD BuildLogFileList (
  275. LPWSTR szLogFileList,
  276. BOOL bIsCommaDelimited,
  277. ULONG* pulBufLen );
  278. DWORD AddToErrorPathList ( LPCWSTR szPath );
  279. LPCWSTR GetErrorPathList ( DWORD* pdwListLen );
  280. void ClearErrorPathList ( void );
  281. DWORD AddToErrorLogFileList ( LPCWSTR szPath );
  282. LPCWSTR GetErrorLogFileList ( DWORD* pdwListLen );
  283. void ClearErrorLogFileList ( void );
  284. SMONCTRL_VERSION_DATA m_LoadedVersion;
  285. BOOL m_fInitialized;
  286. BOOL m_fViewInitialized;
  287. HWND m_hWnd;
  288. CLegend* m_pLegend;
  289. CGraphDisp* m_pGraphDisp;
  290. CStatsBar* m_pStatsBar;
  291. CSnapBar* m_pSnapBar;
  292. CReport* m_pReport;
  293. CSysmonToolbar* m_pToolbar;
  294. CPolyline *m_pObj;
  295. PHIST_CONTROL m_pHistCtrl;
  296. HQUERY m_hQuery;
  297. UINT m_TimerID;
  298. BOOLEAN m_fPendingUpdate;
  299. BOOLEAN m_fPendingSizeChg;
  300. BOOLEAN m_fPendingFontChg;
  301. BOOLEAN m_fPendingLogViewChg;
  302. BOOLEAN m_fPendingLogCntrChg;
  303. BOOLEAN m_fUIDead;
  304. BOOLEAN m_fUserMode;
  305. BOOLEAN m_fDuplicate;
  306. COLORREF m_clrBackCtl;
  307. COLORREF m_clrFgnd;
  308. COLORREF m_clrBackPlot;
  309. COLORREF m_clrGrid;
  310. COLORREF m_clrTimeBar;
  311. INT m_iAppearance;
  312. INT m_iBorderStyle;
  313. eDisplayTypeConstant m_eDisplayType;
  314. BOOL m_bLogFileSource;
  315. BOOL m_bSampleDataLoaded;
  316. double m_dZoomFactor;
  317. BOOL m_bLoadingCounters;
  318. BOOL m_bMissedSample;
  319. BOOL m_bDisplayedMissedSampleMessage;
  320. BOOL m_bSettingsLoaded;
  321. LONG m_lSaveDataToLogFilterValue;
  322. LCID m_lcidCurrent;
  323. // Item properties, for saving and loading counters.
  324. COLORREF m_clrCounter;
  325. INT m_iColorIndex;
  326. INT m_iWidthIndex;
  327. INT m_iStyleIndex;
  328. INT m_iScaleFactor;
  329. HFONT m_hFont;
  330. COleFont m_OleFont;
  331. PDH_BROWSE_DLG_CONFIG m_BrowseInfo;
  332. CGraphItem* m_pSelectedItem;
  333. HACCEL m_hAccel;
  334. DATA_SOURCE_INFO m_DataSourceInfo;
  335. COLLECT_PROC_INFO m_CollectInfo;
  336. CRITICAL_SECTION m_CounterDataLock;
  337. RECT m_rectCurrentClient;
  338. LPWSTR m_szErrorPathList;
  339. DWORD m_dwErrorPathListLen;
  340. DWORD m_dwErrorPathBufLen;
  341. };
  342. typedef CSysmonControl *PSYSMONCTRL;
  343. #endif