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.

200 lines
8.6 KiB

  1. /*++
  2. Copyright (C) 1999-2000 Microsoft Corporation
  3. Module Name:
  4. proputil.h
  5. Abstract:
  6. <abstract>
  7. --*/
  8. #ifndef _PROPUTIL_H_
  9. #define _PROPUTIL_H_
  10. #include "stdafx.h"
  11. //===========================================================================
  12. // Constants
  13. //===========================================================================
  14. // Property constants represent indexes into the static PropertyDataMap table.
  15. extern const DWORD IdFirstProp;
  16. // The property constants in this first section have a one-to-one
  17. // correspondence between HTML parameter and registry value
  18. extern const DWORD IdCommentProp;
  19. extern const DWORD IdLogTypeProp;
  20. extern const DWORD IdCurrentStateProp;
  21. extern const DWORD IdLogFileMaxSizeProp;
  22. extern const DWORD IdLogFileBaseNameProp;
  23. extern const DWORD IdLogFileFolderProp;
  24. extern const DWORD IdLogFileSerialNumberProp;
  25. extern const DWORD IdLogFileAutoFormatProp;
  26. extern const DWORD IdLogFileTypeProp;
  27. extern const DWORD IdEofCommandFileProp;
  28. extern const DWORD IdCommandFileProp;
  29. extern const DWORD IdNetworkNameProp;
  30. extern const DWORD IdUserTextProp;
  31. extern const DWORD IdPerfLogNameProp;
  32. extern const DWORD IdTraceBufferSizeProp;
  33. extern const DWORD IdTraceBufferMinCountProp;
  34. extern const DWORD IdTraceBufferMaxCountProp;
  35. extern const DWORD IdTraceBufferFlushIntProp;
  36. extern const DWORD IdActionFlagsProp;
  37. extern const DWORD IdTraceFlagsProp;
  38. // Property constants below require special handling for BagToRegistry,
  39. // because there is not a one-to-one correspondence between HTML
  40. // parameter and registry value.
  41. extern const DWORD IdRestartProp;
  42. extern const DWORD IdStartProp;
  43. extern const DWORD IdStopProp;
  44. extern const DWORD IdSampleProp;
  45. extern const DWORD IdCounterListProp;
  46. extern const DWORD IdGuidListProp;
  47. /*
  48. // Not handled yet, or covered by special values above.
  49. // Some of these might be needed when writing to HTML file from registry.
  50. //
  51. extern const DWORD IdSysmonVersionProp;
  52. extern const DWORD IdSysmonCounterCountProp;
  53. extern const DWORD IdSysmonCounterPathProp;
  54. extern const DWORD IdAlertThresholdProp;
  55. extern const DWORD IdAlertOverUnderProp;
  56. extern const DWORD IdTraceProviderCountProp;
  57. extern const DWORD IdTraceProviderGuidProp;
  58. extern const DWORD IdLogNameProp;
  59. extern const DWORD IdAlertNameProp;
  60. extern const DWORD IdStartModeProp;
  61. extern const DWORD IdStartAtTimeProp;
  62. extern const DWORD IdStopModeProp;
  63. extern const DWORD IdStopAtTimeProp;
  64. extern const DWORD IdStopAfterUnitTypeProp;
  65. extern const DWORD IdStopAfterValueProp;
  66. extern const DWORD IdSampleIntUnitTypeProp;
  67. extern const DWORD IdSampleIntValueProp;
  68. extern const DWORD IdSysmonUpdateIntervalProp;
  69. extern const DWORD IdSysmonSampleCountProp;
  70. extern const DWORD IdSysmonLogFileNameProp;
  71. extern const DWORD IdExecuteOnlyProp;
  72. */
  73. extern const DWORD IdExecuteOnlyProp;
  74. class CPropertyBag;
  75. class CPropertyUtils;
  76. class CPropertyUtils {
  77. public:
  78. enum eMessageDisplayLevel {
  79. eAll = 0, //STATUS_SEVERITY_SUCCESS,
  80. eInfo = 1, //STATUS_SEVERITY_INFORMATIONAL,
  81. eWarnings = 2, //STATUS_SEVERITY_WARNING, // Default level
  82. eError = 3, //STATUS_SEVERITY_ERROR,
  83. eNone = 4, //STATUS_SEVERITY_ERROR + 1
  84. };
  85. CPropertyUtils ( LPCWSTR cszMachineName );
  86. CPropertyUtils (
  87. LPCWSTR cszMachineName,
  88. LPCWSTR cszQueryName,
  89. CPropertyBag*,
  90. HKEY hkeyQuery,
  91. HKEY hkeyQueryList );
  92. virtual ~CPropertyUtils ( void );
  93. void SetQueryName ( LPCWSTR );
  94. void SetPropertyBag ( CPropertyBag* );
  95. void SetQueryKey ( HKEY );
  96. void SetQueryListKey ( HKEY );
  97. void SetMessageDisplayLevel ( eMessageDisplayLevel );
  98. eMessageDisplayLevel GetMessageDisplayLevel ( void );
  99. // BagToRegistry requires property bag and parent registry key
  100. HRESULT BagToRegistry ( DWORD dwPropId, DWORD dwLogType = SLQ_COUNTER_LOG );
  101. // ValidateProperty requires property bag
  102. DWORD Validate ( DWORD dwPropId, DWORD dwLogType = SLQ_COUNTER_LOG );
  103. private:
  104. typedef DWORD ( *ValidationMethod )( CPropertyUtils*, DWORD, DWORD );
  105. typedef struct _PROPERTY_DATA_MAP {
  106. DWORD dwPropertyId;
  107. DWORD dwRegType;
  108. LPCWSTR cwszHtmlName;
  109. LPCWSTR cwszRegName;
  110. ValidationMethod fValidate;
  111. BOOL bRequired;
  112. DWORD dwMin;
  113. DWORD dwMax;
  114. } PROPERTY_DATA_MAP, *PPROPERTY_DATA_MAP;
  115. friend DWORD ValidateDwordInterval ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  116. friend DWORD ValidatePrimaryObjectList ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  117. friend DWORD ValidateSlqTimeInfo ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  118. friend DWORD ValidateMaxFileSize ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  119. friend DWORD ValidateLogFileType ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  120. friend DWORD ValidateString ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  121. friend DWORD ValidateTraceFlags ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  122. friend DWORD ValidateAlertActions ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  123. friend DWORD ValidateDirectoryPath ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  124. friend DWORD ValidateTraceBufferMaxCount ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  125. friend DWORD ValidateFileName ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  126. friend DWORD ValidateFilePath ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  127. friend DWORD ValidateLogExists ( CPropertyUtils* pUtils, DWORD dwPropId, DWORD dwLogType );
  128. HRESULT StringBagToRegistry ( DWORD dwPropId, DWORD dwLogType );
  129. HRESULT DwordBagToRegistry ( DWORD dwPropId, DWORD dwLogType );
  130. HRESULT SlqTimeBagToRegistry ( DWORD dwPropId, DWORD dwLogType );
  131. HRESULT MultiSzBagToRegistry ( DWORD dwPropId, DWORD dwLogType );
  132. HRESULT MultiSzBagToBufferAlloc (
  133. DWORD dwPropId,
  134. DWORD dwLogType,
  135. LPWSTR* pszMszBuf,
  136. DWORD* pdwMszBufLen,
  137. DWORD* pdwMszStringLen );
  138. LPCWSTR GetQueryName ( void );
  139. BOOL IsValidDateTime ( LONGLONG& rllDateTime );
  140. BOOL IsDisplayLevelMessage ( DWORD dwStatus );
  141. BOOL IsKernelTraceMode ( DWORD dwTraceFlags );
  142. DWORD GetInvalidStatus ( DWORD dwPropId );
  143. DWORD GetMissingStatus ( DWORD dwPropId );
  144. static const PROPERTY_DATA_MAP m_PropertyDataMap[];
  145. static const DWORD m_dwPropertyDataMapEntries;
  146. CPropertyBag* m_pPropBag;
  147. LPWSTR m_szPropBagBuffer;
  148. DWORD m_dwPropBagBufLen;
  149. eMessageDisplayLevel m_eMessageDisplayLevel;
  150. HKEY m_hkeyQuery;
  151. HKEY m_hkeyQueryList;
  152. WCHAR m_szQueryName[MAX_PATH + 1]; // Todo: Remove size limit
  153. WCHAR m_szMachineName[MAX_COMPUTERNAME_LENGTH + 1];
  154. };
  155. typedef CPropertyUtils *PCPropertyUtils;
  156. #endif //_PROPUTIL_H_