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.

431 lines
16 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. CPropertySheet* GetInitialPropertySheet ();
  110. void SetInitialPropertySheet ( CPropertySheet* );
  111. void SetActivePropertyPage ( CSmPropertyPage* );
  112. virtual CSmCounterLogQuery* CastToCounterLogQuery( void ) { return NULL; };
  113. virtual CSmTraceLogQuery* CastToTraceLogQuery( void ) { return NULL; };
  114. virtual CSmAlertQuery* CastToAlertQuery( void ) { return NULL; };
  115. // Property bag persistence
  116. static HRESULT StringFromPropertyBag (
  117. IPropertyBag* pIPropBag,
  118. IErrorLog* pIErrorLog,
  119. UINT uiPropName,
  120. const CString& rstrDefault,
  121. LPWSTR *pszBuffer,
  122. LPDWORD pdwLength );
  123. static HRESULT DwordFromPropertyBag (
  124. IPropertyBag* pIPropBag,
  125. IErrorLog* pIErrorLog,
  126. UINT uiPropName,
  127. DWORD dwDefault,
  128. DWORD& rdwData );
  129. virtual HRESULT LoadFromPropertyBag ( IPropertyBag*, IErrorLog* );
  130. // Registry persistence
  131. static LONG ReadRegistryStringValue (
  132. HKEY hKey,
  133. LPCWSTR szValueName,
  134. LPCWSTR szNonLocValueName,
  135. LPCWSTR szDefault,
  136. LPWSTR *pszBuffer,
  137. LPDWORD pdwLength );
  138. static DWORD SmNoLocReadRegIndStrVal (
  139. HKEY hKey,
  140. UINT uiValueName,
  141. LPCWSTR szDefault,
  142. LPWSTR* pszBuffer,
  143. UINT* puiLength );
  144. static LONG ReadRegistryDwordValue (
  145. HKEY hKey,
  146. UINT uiValueName,
  147. DWORD dwDefault,
  148. LPDWORD pdwValue );
  149. static LPCWSTR GetNonLocRegValueName ( UINT uiValueName );
  150. static LPCWSTR GetNonLocHtmlPropName ( UINT uiValueName );
  151. // Public members
  152. static const CString cstrEmpty;
  153. DWORD m_fDirtyPassword;
  154. CString m_strUser;
  155. CString m_strPassword;
  156. // protected methods
  157. protected:
  158. virtual DWORD UpdateRegistry();
  159. virtual HRESULT SaveToPropertyBag ( IPropertyBag*, BOOL fSaveAllProps );
  160. //
  161. // Registry persistence
  162. //
  163. //
  164. // Note: Win2k, XP, and XPSP1 were shipped with registry value names as resources.
  165. // In some languages, these strings were localized. This causes problem when using MUI
  166. // to switch languages between systems. for .Net, read value using the non-localized
  167. // value name. If the value is not found, retry with the possibly localized name.
  168. //
  169. // When writing the value to the registry, use the nonlocalized value name.
  170. LONG ReadRegistryStringValue (
  171. HKEY hKey,
  172. UINT uiValueName,
  173. LPCWSTR szDefault,
  174. LPWSTR *pszBuffer,
  175. LPDWORD pdwLength );
  176. LONG WriteRegistryStringValue (
  177. HKEY hKey,
  178. UINT uiValueName,
  179. DWORD dwType,
  180. LPCWSTR pszBuffer,
  181. LPDWORD pdwLength );
  182. LONG WriteRegistryDwordValue (
  183. HKEY hKey,
  184. UINT uiValueName,
  185. LPDWORD pdwValue,
  186. DWORD dwType=REG_DWORD); // Also supports REG_BINARY
  187. LONG ReadRegistrySlqTime (
  188. HKEY hKey,
  189. UINT uiValueName,
  190. PSLQ_TIME_INFO pSlqDefault,
  191. PSLQ_TIME_INFO pSlqValue );
  192. LONG WriteRegistrySlqTime (
  193. HKEY hKey,
  194. UINT uiValueName,
  195. PSLQ_TIME_INFO pSlqTime );
  196. // Property bag persistence
  197. static HRESULT StringFromPropertyBag (
  198. IPropertyBag* pIPropBag,
  199. IErrorLog* pIErrorLog,
  200. const CString& rstrPropName,
  201. const CString& rstrNonLocPropName,
  202. const CString& rstrDefault,
  203. LPWSTR *pszBuffer,
  204. LPDWORD pdwLength );
  205. HRESULT StringToPropertyBag (
  206. IPropertyBag* pIPropBag,
  207. UINT uiPropName,
  208. const CString& rstrData );
  209. HRESULT StringToPropertyBag (
  210. IPropertyBag* pIPropBag,
  211. const CString& rstrNonLocPropName,
  212. const CString& rstrData );
  213. static HRESULT DwordFromPropertyBag (
  214. IPropertyBag* pIPropBag,
  215. IErrorLog* pIErrorLog,
  216. const CString& rstrNonLocPropName,
  217. const CString& rstrPropName,
  218. DWORD dwDefault,
  219. DWORD& rdwData );
  220. HRESULT DwordToPropertyBag (
  221. IPropertyBag* pPropBag,
  222. UINT uiPropName,
  223. DWORD dwData );
  224. HRESULT DwordToPropertyBag (
  225. IPropertyBag* pPropBag,
  226. const CString& rstrNonLocPropName,
  227. DWORD dwData );
  228. HRESULT DoubleFromPropertyBag (
  229. IPropertyBag* pIPropBag,
  230. IErrorLog* pIErrorLog,
  231. UINT uiPropName,
  232. DOUBLE dDefault,
  233. DOUBLE& rdData );
  234. HRESULT DoubleFromPropertyBag (
  235. IPropertyBag* pIPropBag,
  236. IErrorLog* pIErrorLog,
  237. const CString& rstrPropName,
  238. const CString& rstrNonLocPropName,
  239. DOUBLE dDefault,
  240. DOUBLE& rdData );
  241. HRESULT DoubleToPropertyBag (
  242. IPropertyBag* pPropBag,
  243. UINT uiPropName,
  244. DOUBLE dData );
  245. HRESULT DoubleToPropertyBag (
  246. IPropertyBag* pPropBag,
  247. const CString& rstrNonLocPropName,
  248. DOUBLE dData );
  249. HRESULT FloatFromPropertyBag (
  250. IPropertyBag* pIPropBag,
  251. IErrorLog* pIErrorLog,
  252. UINT uiPropName,
  253. FLOAT fDefault,
  254. FLOAT& rfData );
  255. HRESULT FloatFromPropertyBag (
  256. IPropertyBag* pIPropBag,
  257. IErrorLog* pIErrorLog,
  258. const CString& rstrPropName,
  259. const CString& rstrNonLocPropName,
  260. FLOAT fDefault,
  261. FLOAT& rfData );
  262. HRESULT FloatToPropertyBag (
  263. IPropertyBag* pPropBag,
  264. UINT uiPropName,
  265. FLOAT fData );
  266. HRESULT FloatToPropertyBag (
  267. IPropertyBag* pPropBag,
  268. const CString& rstrNonLocPropName,
  269. FLOAT fData );
  270. HRESULT LLTimeFromPropertyBag (
  271. IPropertyBag* pIPropBag,
  272. IErrorLog* pIErrorLog,
  273. UINT uiPropName,
  274. LONGLONG& rllDefault,
  275. LONGLONG& rllData );
  276. HRESULT LLTimeToPropertyBag (
  277. IPropertyBag* pIPropBag,
  278. UINT uiPropName,
  279. LONGLONG& rllData );
  280. HRESULT SlqTimeFromPropertyBag (
  281. IPropertyBag* pIPropBag,
  282. IErrorLog* pIErrorLog,
  283. DWORD dwFlags,
  284. PSLQ_TIME_INFO pSlqDefault,
  285. PSLQ_TIME_INFO pSlqData );
  286. HRESULT SlqTimeToPropertyBag (
  287. IPropertyBag* pPropBag,
  288. DWORD dwFlags,
  289. PSLQ_TIME_INFO pSlqData );
  290. // protected member variables
  291. protected:
  292. CString m_strName;
  293. CSmLogService* m_pLogService;
  294. HKEY m_hKeyQuery;
  295. BOOL m_bReadOnly;
  296. BOOL m_bExecuteOnly;
  297. CString m_strFileName;
  298. // Registry Values
  299. // Current state is private to avoid extra service query
  300. DWORD mr_dwCurrentState;
  301. // *** make time protected members private, access via Get, SetLogTime
  302. DWORD mr_dwAutoRestartMode;
  303. SLQ_TIME_INFO mr_stiSampleInterval;
  304. private:
  305. HRESULT CopyToBuffer ( LPWSTR& rpszData, DWORD& rdwBufferSize );
  306. DWORD UpdateRegistryScheduleValues ( void );
  307. DWORD UpdateRegistryLastModified ( void );
  308. BOOL LLTimeToVariantDate (LONGLONG llTime, DATE *pDate);
  309. BOOL VariantDateToLLTime (DATE Date, LONGLONG *pllTime);
  310. void InitDataStoreAttributesDefault ( const DWORD dwRegLogFileType, DWORD& rdwDefault );
  311. void ProcessLoadedDataStoreAttributes ( DWORD dwDataStoreAttributes );
  312. BOOL m_bIsModified;
  313. BOOL m_bIsNew;
  314. DWORD mr_dwRealTimeQuery;
  315. CString m_strLogFileType;
  316. // Registry Values
  317. CString mr_strLogKeyName;
  318. CString mr_strComment;
  319. CString mr_strCommentIndirect;
  320. DWORD mr_dwMaxSize; // in size determined by mr_dwFileSizeUnits, -1 = grow to disk full
  321. DWORD mr_dwFileSizeUnits;
  322. DWORD mr_dwAppendMode;
  323. CString mr_strBaseFileName;
  324. CString mr_strBaseFileNameIndirect;
  325. CString mr_strSqlName;
  326. CString mr_strDefaultDirectory;
  327. DWORD mr_dwLogAutoFormat;
  328. DWORD mr_dwCurrentSerialNumber;
  329. DWORD mr_dwLogFileType;
  330. CString mr_strEofCmdFile;
  331. SLQ_TIME_INFO mr_stiStart;
  332. SLQ_TIME_INFO mr_stiStop;
  333. SLQ_PROP_PAGE_SHARED m_PropData;
  334. CSmPropertyPage* m_pActivePropPage;
  335. CPropertySheet* m_pInitialPropertySheet;
  336. };
  337. typedef CSmLogQuery SLQUERY;
  338. typedef CSmLogQuery* PSLQUERY;
  339. #endif //_CLASS_SMLOGQRY_