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.

124 lines
3.2 KiB

  1. //***************************************************************************
  2. //
  3. // NTEVTLOGF.H
  4. //
  5. // Module: WBEM NT EVENT PROVIDER
  6. //
  7. // Copyright (c) 1996-2001 Microsoft Corporation, All Rights Reserved
  8. //
  9. //***************************************************************************
  10. #ifndef _NT_EVT_PROV_EVTLOGF_H
  11. #define _NT_EVT_PROV_EVTLOGF_H
  12. class CEventlogFileAttributes
  13. {
  14. protected:
  15. CStringW m_logname;
  16. CStringW m_logpath;
  17. DWORD m_retention;
  18. DWORD m_fileSz;
  19. CArray<CStringW*, CStringW*> m_sources;
  20. DWORD ReadRegistry();
  21. void SetRetentionStr(IWbemClassObject *pClassObj, IWbemClassObject *pInstObj, DWORD dwVal);
  22. BOOL SetSuperClassProperties(IWbemClassObject *pInst);
  23. static ULONG GetIndex(wchar_t *indexStr, BOOL *bError);
  24. public:
  25. CEventlogFileAttributes(const wchar_t *log);
  26. DWORD UpdateRegistry(IWbemClassObject *pInst);
  27. DWORD EventLogOperation(const wchar_t *archive, BOOL bClear,
  28. WbemProvErrorObject &a_ErrorObject, BOOL &bSuccess);
  29. BOOL GenerateInstance(IWbemClassObject *pClassObj, IWbemClassObject* pAClassObj, IWbemClassObject **ppInst);
  30. ~CEventlogFileAttributes();
  31. };
  32. class CEventLogFile
  33. {
  34. private:
  35. static CStringW ExpandFileName ( const wchar_t *filepath ) ;
  36. static BOOL QueryRegForFileName(HKEY hk_Log, const wchar_t *valname, wchar_t **res, DWORD *dwType);
  37. protected:
  38. HANDLE m_hEvtLog;
  39. CStringW m_EvtLogName;
  40. BOOL m_bValid;
  41. BOOL m_bBuffer;
  42. DWORD m_BuffLen;
  43. DWORD m_Reason;
  44. BYTE *m_Buffer;
  45. CCriticalSection m_LogLock;
  46. public:
  47. CEventLogFile(const WCHAR *logname, BOOL bVerify);
  48. void ReadLastRecord();
  49. BOOL GetLastRecordID(DWORD &rec, DWORD &numrecs);
  50. DWORD ReadRecord(DWORD recID, DWORD *dwBytesRead = NULL, BOOL b_Back = FALSE);
  51. BOOL IsValid() {return m_bValid;}
  52. BOOL IsValidBuffer() {return m_bBuffer;}
  53. DWORD ReadFirstRecord();
  54. CStringW GetLogName() { return m_EvtLogName; }
  55. DWORD FindOldEvent(DWORD evtID, const wchar_t *source, DWORD *recID,time_t offset = 0);
  56. BYTE* GetBuffer() { return m_Buffer; }
  57. DWORD GetBufferLen() { return m_BuffLen; }
  58. DWORD GetReason() { return m_Reason; }
  59. virtual void RefreshHandle();
  60. static CStringW GetLogName(const wchar_t *file_name);
  61. static CStringW GetFileName(HKEY hk_Log, const wchar_t *valname = EVTLOG_REG_FILE_VALUE);
  62. static DWORD GetFileNames(HKEY hk_Log, CStringW **names, const wchar_t *valname = MSG_MODULE);
  63. static BOOL ms_bSetPrivilege;
  64. static BOOL SetSecurityLogPrivilege(BOOL bProcess = FALSE, LPCWSTR privName = SE_SECURITY_NAME);
  65. static HANDLE OpenLocalEventLog(LPCWSTR a_log, DWORD *a_Reason);
  66. virtual ~CEventLogFile();
  67. };
  68. class CMonitoredEventLogFile : public CEventLogFile, public ProvTaskObject
  69. {
  70. private:
  71. CEventProviderManager *m_parent;
  72. IWbemClassObject *m_Class;
  73. DWORD m_RecID;
  74. VARIANT m_VpsdSelfRel;
  75. BOOL SetEventDescriptor();
  76. public:
  77. CMonitoredEventLogFile(CEventProviderManager *parent, const wchar_t *logname);
  78. void SetProcessRecord(DWORD recID) { m_RecID = recID; }
  79. void Process();
  80. void RefreshHandle();
  81. BOOL GenerateInstance(IWbemClassObject **ppEvtInst, IWbemClassObject *pEmbedObj);
  82. ~CMonitoredEventLogFile();
  83. };
  84. #endif //_NT_EVT_PROV_EVTLOGF_H