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.

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