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.

176 lines
4.5 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. REGEREQ.H
  5. Abstract:
  6. History:
  7. --*/
  8. #ifndef __WBEM_REGEVENT_REQUEST__H_
  9. #define __WBEM_REGEVENT_REQUEST__H_
  10. #include <windows.h>
  11. #include <stdio.h>
  12. #include <wbemidl.h>
  13. #include "CWbemTime.h"
  14. #include <tss.h>
  15. #include <ql.h>
  16. #include <wbemcomn.h>
  17. #include "regedefs.h"
  18. class CRegEventProvider;
  19. class CRegistryEventRequest;
  20. class CRegistryTimerInstruction : public CTimerInstruction
  21. {
  22. long m_lRef;
  23. CWbemInterval m_Interval;
  24. CRegistryEventRequest* m_pReq;
  25. public:
  26. CRegistryTimerInstruction(CRegistryEventRequest* pReq);
  27. ~CRegistryTimerInstruction();
  28. void AddRef();
  29. void Release();
  30. int GetInstructionType() {return INSTTYPE_INTERNAL;}
  31. CWbemTime GetNextFiringTime(CWbemTime LastFiringTime,
  32. OUT long* plFiringCount) const;
  33. CWbemTime GetFirstFiringTime() const;
  34. HRESULT Fire(long lNumTimes, CWbemTime NextFiringTime);
  35. INTERNAL CRegistryEventRequest* GetRequest() {return m_pReq;}
  36. };
  37. class CRegistryInstructionTest : public CInstructionTest
  38. {
  39. class CRegistryEventRequest* m_pReq;
  40. public:
  41. CRegistryInstructionTest(CRegistryEventRequest* pReq) : m_pReq(pReq){}
  42. BOOL operator()(CTimerInstruction* pToTest);
  43. };
  44. class CRegistryEventRequest
  45. {
  46. protected:
  47. long m_lRef;
  48. BOOL m_bOK;
  49. CRegEventProvider* m_pProvider;
  50. DWORD m_dwMsWait;
  51. CFlexArray m_adwIds;
  52. HKEY m_hHive;
  53. WString m_wsHive;
  54. WString m_wsKey;
  55. HKEY m_hKey;
  56. HANDLE m_hEvent;
  57. DWORD m_dwLastCRC;
  58. long m_lActiveCount;
  59. BOOL m_bNew;
  60. HANDLE m_hWaitRegistration;
  61. CRITICAL_SECTION m_cs;
  62. public:
  63. CRegistryEventRequest(CRegEventProvider* pProvider,
  64. WBEM_QL1_TOLERANCE& Tolerance, DWORD dwId,
  65. HKEY hHive, LPWSTR wszHive, LPWSTR wszKey);
  66. virtual ~CRegistryEventRequest();
  67. BOOL IsOK() {return m_bOK;}
  68. BOOL IsActive() {return m_lActiveCount >= 0;}
  69. DWORD GetPrimaryId();
  70. BOOL DoesContainId(DWORD dwId);
  71. BOOL IsNew() {return m_bNew;}
  72. CRegEventProvider* GetProvider() { return m_pProvider; }
  73. void AddRef();
  74. void Release();
  75. DWORD GetMsWait() {return m_dwMsWait;}
  76. HRESULT Activate();
  77. HRESULT Reactivate(DWORD dwId, DWORD dwMsWait);
  78. HRESULT Deactivate(DWORD dwId);
  79. HRESULT ForceDeactivate(void);
  80. virtual HRESULT Execute(BOOL bOnTimer);
  81. HANDLE GetOnChangeHandle();
  82. BOOL ResetOnChangeHandle();
  83. virtual void CacheValue(){}
  84. virtual int GetType() = 0;
  85. virtual HRESULT CreateNewEvent(IWbemClassObject** ppEvent) = 0;
  86. virtual HRESULT ComputeCRC(DWORD& dwCRC) = 0;
  87. virtual BOOL IsSameAs(CRegistryEventRequest* pOther);
  88. void ProcessEvent();
  89. protected:
  90. HRESULT SetCommonProperties(IWbemClassObject* pEvent);
  91. };
  92. class CRegistryValueEventRequest : public CRegistryEventRequest
  93. {
  94. protected:
  95. WString m_wsValue;
  96. public:
  97. CRegistryValueEventRequest(CRegEventProvider* pProvider,
  98. WBEM_QL1_TOLERANCE& Tolerance, DWORD dwId, HKEY hHive,
  99. LPWSTR wszHive, LPWSTR wszKey, LPWSTR wszValue)
  100. : CRegistryEventRequest(pProvider, Tolerance, dwId, hHive,
  101. wszHive, wszKey), m_wsValue(wszValue)
  102. {}
  103. int GetType() {return e_RegValueChange;}
  104. HRESULT CreateNewEvent(IWbemClassObject** ppEvent);
  105. HRESULT ComputeCRC(DWORD& dwCRC);
  106. virtual HRESULT Execute(BOOL bOnTimer);
  107. virtual void CacheValue();
  108. BOOL IsSameAs(CRegistryEventRequest* pOther);
  109. };
  110. class CRegistryKeyEventRequest : public CRegistryEventRequest
  111. {
  112. public:
  113. CRegistryKeyEventRequest(CRegEventProvider* pProvider,
  114. WBEM_QL1_TOLERANCE& Tolerance, DWORD dwId, HKEY hHive,
  115. LPWSTR wszHive, LPWSTR wszKey)
  116. : CRegistryEventRequest(pProvider, Tolerance, dwId, hHive,
  117. wszHive, wszKey)
  118. {}
  119. int GetType() {return e_RegKeyChange;}
  120. HRESULT CreateNewEvent(IWbemClassObject** ppEvent);
  121. HRESULT ComputeCRC(DWORD& dwCRC);
  122. };
  123. class CRegistryTreeEventRequest : public CRegistryEventRequest
  124. {
  125. public:
  126. CRegistryTreeEventRequest(CRegEventProvider* pProvider,
  127. WBEM_QL1_TOLERANCE& Tolerance, DWORD dwId, HKEY hHive,
  128. LPWSTR wszHive, LPWSTR wszKey)
  129. : CRegistryEventRequest(pProvider, Tolerance, dwId, hHive,
  130. wszHive, wszKey)
  131. {}
  132. int GetType() {return e_RegTreeChange;}
  133. HRESULT CreateNewEvent(IWbemClassObject** ppEvent);
  134. HRESULT ComputeCRC(DWORD& dwCRC);
  135. };
  136. #endif