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.

393 lines
14 KiB

  1. /*++
  2. Copyright (C) 1998-1999 Microsoft Corporation
  3. Module Name:
  4. smlogqry.h
  5. Abstract:
  6. Class definitions for the CSmLogQuery base class. This object
  7. is used to represent performance data log queries (a.k.a.
  8. sysmon log queries).
  9. --*/
  10. #ifndef _CLASS_SMLOGQRY_
  11. #define _CLASS_SMLOGQRY_
  12. #include "common.h"
  13. // Data shared between property pages before OnApply is executed.
  14. #define PASSWORD_CLEAN 0
  15. #define PASSWORD_SET 1
  16. #define PASSWORD_DIRTY 2
  17. typedef struct _SLQ_PROP_PAGE_SHARED {
  18. DWORD dwMaxFileSize; // in units determined by dwFileSizeUnits - Set by files page
  19. DWORD dwLogFileType; // Set by files page
  20. SLQ_TIME_INFO stiStartTime; // Set by schedule page
  21. SLQ_TIME_INFO stiStopTime; // Set by schedule page. Auto mode set by schedule and file pages.
  22. SLQ_TIME_INFO stiSampleTime; // Set by counters and alerts general page.
  23. CString strFileBaseName;// Set by files page
  24. CString strFolderName; // Set by files page
  25. CString strSqlName; // Set by files page
  26. int dwSuffix; // Set by files page
  27. DWORD dwSerialNumber; // Set by files page
  28. } SLQ_PROP_PAGE_SHARED, *PSLQ_PROP_PAGE_SHARED;
  29. class CSmLogService;
  30. class CSmCounterLogQuery;
  31. class CSmTraceLogQuery;
  32. class CSmAlertQuery;
  33. class CSmPropertyPage;
  34. class CSmLogQuery
  35. {
  36. // constructor/destructor
  37. public:
  38. CSmLogQuery( CSmLogService* );
  39. virtual ~CSmLogQuery( void );
  40. // public methods
  41. public:
  42. virtual DWORD Open ( const CString& rstrName, HKEY hKeyQuery, BOOL bReadOnly );
  43. virtual DWORD Close ( void );
  44. DWORD UpdateService( BOOL& rbRegistryUpdated );
  45. DWORD UpdateServiceSchedule( BOOL& rbRegistryUpdated );
  46. DWORD ManualStart( void );
  47. DWORD ManualStop( void );
  48. DWORD SaveAs( const CString& );
  49. virtual DWORD SyncSerialNumberWithRegistry( void );
  50. virtual DWORD SyncWithRegistry( void );
  51. HKEY GetQueryKey( void );
  52. CSmLogService* GetLogService ( void );
  53. DWORD GetMachineDisplayName ( CString& );
  54. virtual BOOL GetLogTime(PSLQ_TIME_INFO pTimeInfo, DWORD dwFlags);
  55. virtual BOOL SetLogTime(PSLQ_TIME_INFO pTimeInfo, const DWORD dwFlags);
  56. virtual BOOL GetDefaultLogTime(SLQ_TIME_INFO& rTimeInfo, DWORD dwFlags);
  57. virtual DWORD GetLogType( void );
  58. virtual const CString& GetLogFileType ( void );
  59. virtual void GetLogFileType ( DWORD& rdwFileType );
  60. virtual BOOL SetLogFileType ( const DWORD dwType );
  61. void GetDataStoreAppendMode(DWORD &rdwAppend);
  62. void SetDataStoreAppendMode(DWORD dwAppend);
  63. virtual const CString& GetLogFileName ( BOOL bLatestRunning = FALSE ); // 2000.1 GetFileName->GetLogFileName
  64. virtual DWORD GetLogFileName ( CString& );
  65. DWORD SetLogFileName ( const CString& rstrFileName );
  66. DWORD SetLogFileNameIndirect ( const CString& rstrFileName );
  67. virtual const CString& GetSqlName ( void );
  68. virtual DWORD GetSqlName ( CString& );
  69. DWORD SetSqlName ( const CString& rstrSqlName );
  70. DWORD GetFileNameParts ( CString& rstrFolder, CString& rstrName );
  71. DWORD SetFileNameParts (
  72. const CString& rstrFolder,
  73. const CString& rstrName );
  74. DWORD GetFileNameAutoFormat ( void );
  75. BOOL SetFileNameAutoFormat ( const DWORD );
  76. DWORD GetFileSerialNumber( void );
  77. BOOL SetFileSerialNumber ( const DWORD );
  78. const CString& GetLogName ( void );
  79. DWORD GetLogName ( CString& );
  80. DWORD SetLogName ( const CString& rstrLogName );
  81. const CString& GetLogKeyName ( void );
  82. DWORD GetLogKeyName ( CString& );
  83. DWORD SetLogKeyName ( const CString& rstrLogName );
  84. const CString& GetLogComment ( void );
  85. DWORD GetLogComment ( CString& );
  86. DWORD SetLogComment (const CString& rstrComment);
  87. DWORD SetLogCommentIndirect (const CString& rstrComment);
  88. DWORD GetMaxSize ( void );
  89. BOOL SetMaxSize ( const DWORD dwMaxSize );
  90. DWORD GetDataStoreSizeUnits ( void ){ return mr_dwFileSizeUnits; };
  91. DWORD GetEofCommand ( CString& );
  92. DWORD SetEofCommand ( const CString& rstrCmdString);
  93. DWORD GetState ( void );
  94. BOOL SetState ( const DWORD dwNewState );
  95. void SetNew ( const BOOL bNew ) { m_bIsNew = bNew; };
  96. BOOL IsRunning( void );
  97. BOOL IsAutoStart( void );
  98. BOOL IsAutoRestart( void );
  99. BOOL IsFirstModification ( void );
  100. BOOL IsReadOnly ( void ) { return m_bReadOnly; };
  101. BOOL IsExecuteOnly( void ) { return m_bExecuteOnly; };
  102. BOOL IsModifiable( void ) { return ( !IsExecuteOnly() && !IsReadOnly() ); };
  103. DWORD UpdateExecuteOnly ( void );
  104. BOOL GetPropPageSharedData ( PSLQ_PROP_PAGE_SHARED );
  105. BOOL SetPropPageSharedData ( PSLQ_PROP_PAGE_SHARED );
  106. void SyncPropPageSharedData ( void );
  107. void UpdatePropPageSharedData ( void );
  108. CWnd* GetActivePropertySheet ();
  109. void SetActivePropertyPage ( CSmPropertyPage* );
  110. virtual CSmCounterLogQuery* CastToCounterLogQuery( void ) { return NULL; };
  111. virtual CSmTraceLogQuery* CastToTraceLogQuery( void ) { return NULL; };
  112. virtual CSmAlertQuery* CastToAlertQuery( void ) { return NULL; };
  113. // Property bag persistence
  114. static HRESULT StringFromPropertyBag (
  115. IPropertyBag* pIPropBag,
  116. IErrorLog* pIErrorLog,
  117. UINT uiPropName,
  118. const CString& rstrDefault,
  119. LPTSTR *pszBuffer,
  120. LPDWORD pdwLength );
  121. static HRESULT DwordFromPropertyBag (
  122. IPropertyBag* pIPropBag,
  123. IErrorLog* pIErrorLog,
  124. UINT uiPropName,
  125. DWORD dwDefault,
  126. DWORD& rdwData );
  127. virtual HRESULT LoadFromPropertyBag ( IPropertyBag*, IErrorLog* );
  128. // Public members
  129. static const CString cstrEmpty;
  130. DWORD m_fDirtyPassword;
  131. CString m_strUser;
  132. CString m_strPassword;
  133. // protected methods
  134. protected:
  135. virtual DWORD UpdateRegistry();
  136. virtual HRESULT SaveToPropertyBag ( IPropertyBag*, BOOL fSaveAllProps );
  137. // Registry persistence
  138. LONG ReadRegistryStringValue (
  139. HKEY hKey,
  140. UINT uiValueName,
  141. LPCTSTR szDefault,
  142. LPTSTR *pszBuffer,
  143. LPDWORD pdwLength );
  144. LONG WriteRegistryStringValue (
  145. HKEY hKey,
  146. UINT uiValueName,
  147. DWORD dwType,
  148. LPCTSTR pszBuffer,
  149. LPDWORD pdwLength );
  150. LONG ReadRegistryDwordValue (
  151. HKEY hKey,
  152. UINT uiValueName,
  153. DWORD dwDefault,
  154. LPDWORD pdwValue );
  155. LONG WriteRegistryDwordValue (
  156. HKEY hKey,
  157. UINT uiValueName,
  158. LPDWORD pdwValue,
  159. DWORD dwType=REG_DWORD); // Also supports REG_BINARY
  160. LONG ReadRegistrySlqTime (
  161. HKEY hKey,
  162. UINT uiValueName,
  163. PSLQ_TIME_INFO pSlqDefault,
  164. PSLQ_TIME_INFO pSlqValue );
  165. LONG WriteRegistrySlqTime (
  166. HKEY hKey,
  167. UINT uiValueName,
  168. PSLQ_TIME_INFO pSlqTime );
  169. // Property bag persistence
  170. static HRESULT StringFromPropertyBag (
  171. IPropertyBag* pIPropBag,
  172. IErrorLog* pIErrorLog,
  173. const CString& rstrPropName,
  174. const CString& rstrDefault,
  175. LPTSTR *pszBuffer,
  176. LPDWORD pdwLength );
  177. HRESULT StringToPropertyBag (
  178. IPropertyBag* pIPropBag,
  179. UINT uiPropName,
  180. const CString& rstrData );
  181. HRESULT StringToPropertyBag (
  182. IPropertyBag* pIPropBag,
  183. const CString& rstrPropName,
  184. const CString& rstrData );
  185. static HRESULT DwordFromPropertyBag (
  186. IPropertyBag* pIPropBag,
  187. IErrorLog* pIErrorLog,
  188. const CString& rstrPropName,
  189. DWORD dwDefault,
  190. DWORD& rdwData );
  191. HRESULT DwordToPropertyBag (
  192. IPropertyBag* pPropBag,
  193. UINT uiPropName,
  194. DWORD dwData );
  195. HRESULT DwordToPropertyBag (
  196. IPropertyBag* pPropBag,
  197. const CString& rstrPropName,
  198. DWORD dwData );
  199. HRESULT DoubleFromPropertyBag (
  200. IPropertyBag* pIPropBag,
  201. IErrorLog* pIErrorLog,
  202. UINT uiPropName,
  203. DOUBLE dDefault,
  204. DOUBLE& rdData );
  205. HRESULT DoubleFromPropertyBag (
  206. IPropertyBag* pIPropBag,
  207. IErrorLog* pIErrorLog,
  208. const CString& rstrPropName,
  209. DOUBLE dDefault,
  210. DOUBLE& rdData );
  211. HRESULT DoubleToPropertyBag (
  212. IPropertyBag* pPropBag,
  213. UINT uiPropName,
  214. DOUBLE dData );
  215. HRESULT DoubleToPropertyBag (
  216. IPropertyBag* pPropBag,
  217. const CString& rstrPropName,
  218. DOUBLE dData );
  219. HRESULT FloatFromPropertyBag (
  220. IPropertyBag* pIPropBag,
  221. IErrorLog* pIErrorLog,
  222. UINT uiPropName,
  223. FLOAT fDefault,
  224. FLOAT& rfData );
  225. HRESULT FloatFromPropertyBag (
  226. IPropertyBag* pIPropBag,
  227. IErrorLog* pIErrorLog,
  228. const CString& rstrPropName,
  229. FLOAT fDefault,
  230. FLOAT& rfData );
  231. HRESULT FloatToPropertyBag (
  232. IPropertyBag* pPropBag,
  233. UINT uiPropName,
  234. FLOAT fData );
  235. HRESULT FloatToPropertyBag (
  236. IPropertyBag* pPropBag,
  237. const CString& rstrPropName,
  238. FLOAT fData );
  239. HRESULT LLTimeFromPropertyBag (
  240. IPropertyBag* pIPropBag,
  241. IErrorLog* pIErrorLog,
  242. UINT uiPropName,
  243. LONGLONG& rllDefault,
  244. LONGLONG& rllData );
  245. HRESULT LLTimeToPropertyBag (
  246. IPropertyBag* pIPropBag,
  247. UINT uiPropName,
  248. LONGLONG& rllData );
  249. HRESULT SlqTimeFromPropertyBag (
  250. IPropertyBag* pIPropBag,
  251. IErrorLog* pIErrorLog,
  252. DWORD dwFlags,
  253. PSLQ_TIME_INFO pSlqDefault,
  254. PSLQ_TIME_INFO pSlqData );
  255. HRESULT SlqTimeToPropertyBag (
  256. IPropertyBag* pPropBag,
  257. DWORD dwFlags,
  258. PSLQ_TIME_INFO pSlqData );
  259. // protected member variables
  260. protected:
  261. CString m_strName;
  262. CSmLogService* m_pLogService;
  263. HKEY m_hKeyQuery;
  264. BOOL m_bReadOnly;
  265. BOOL m_bExecuteOnly;
  266. CString m_strFileName;
  267. // Registry Values
  268. // Current state is private to avoid extra service query
  269. DWORD mr_dwCurrentState;
  270. // *** make time protected members private, access via Get, SetLogTime
  271. DWORD mr_dwAutoRestartMode;
  272. SLQ_TIME_INFO mr_stiSampleInterval;
  273. private:
  274. HRESULT CopyToBuffer ( LPTSTR& rpszData, DWORD& rdwBufferSize );
  275. DWORD UpdateRegistryScheduleValues ( void );
  276. DWORD UpdateRegistryLastModified ( void );
  277. BOOL LLTimeToVariantDate (LONGLONG llTime, DATE *pDate);
  278. BOOL VariantDateToLLTime (DATE Date, LONGLONG *pllTime);
  279. void InitDataStoreAttributesDefault ( const DWORD dwRegLogFileType, DWORD& rdwDefault );
  280. void ProcessLoadedDataStoreAttributes ( DWORD dwDataStoreAttributes );
  281. BOOL m_bIsModified;
  282. BOOL m_bIsNew;
  283. DWORD mr_dwRealTimeQuery;
  284. CString m_strLogFileType;
  285. // Registry Values
  286. CString mr_strLogKeyName;
  287. CString mr_strComment;
  288. CString mr_strCommentIndirect;
  289. DWORD mr_dwMaxSize; // in size determined by mr_dwFileSizeUnits, -1 = grow to disk full
  290. DWORD mr_dwFileSizeUnits;
  291. DWORD mr_dwAppendMode;
  292. CString mr_strBaseFileName;
  293. CString mr_strBaseFileNameIndirect;
  294. CString mr_strSqlName;
  295. CString mr_strDefaultDirectory;
  296. DWORD mr_dwLogAutoFormat;
  297. DWORD mr_dwCurrentSerialNumber;
  298. DWORD mr_dwLogFileType;
  299. CString mr_strEofCmdFile;
  300. SLQ_TIME_INFO mr_stiStart;
  301. SLQ_TIME_INFO mr_stiStop;
  302. SLQ_PROP_PAGE_SHARED m_PropData;
  303. CSmPropertyPage* m_pActivePropPage;
  304. };
  305. typedef CSmLogQuery SLQUERY;
  306. typedef CSmLogQuery* PSLQUERY;
  307. #endif //_CLASS_SMLOGQRY_