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.

269 lines
8.2 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // EventProv.h
  7. //
  8. // Implementation File:
  9. // EventProv.cpp
  10. //
  11. // Description:
  12. // Definition of event provider class
  13. //
  14. // Author:
  15. // Henry Wang (HenryWa) 19-JAN-2000
  16. //
  17. // Notes:
  18. //
  19. //////////////////////////////////////////////////////////////////////////////
  20. #define EVENT_TABLE_SIZE 32
  21. #pragma once
  22. //////////////////////////////////////////////////////////////////////////////
  23. // Include Files
  24. //////////////////////////////////////////////////////////////////////////////
  25. //////////////////////////////////////////////////////////////////////////////
  26. // Forward Declarations
  27. //////////////////////////////////////////////////////////////////////////////
  28. class CEventProv;
  29. //////////////////////////////////////////////////////////////////////////////
  30. //++
  31. //
  32. // class CEventProv
  33. //
  34. // Description:
  35. // Event provider
  36. //
  37. //--
  38. //////////////////////////////////////////////////////////////////////////////
  39. class CEventProv
  40. : public IWbemEventProvider
  41. , public IWbemEventProviderSecurity
  42. , public IWbemProviderInit
  43. {
  44. public:
  45. enum EEventStatus
  46. {
  47. esPENDING,
  48. esRUNNING,
  49. esPENDING_STOP,
  50. esSTOPPPED,
  51. esMX
  52. };
  53. enum EClusterNotificationType
  54. {
  55. cntCLUSTER_STATE_CHANGE =
  56. CLUSTER_CHANGE_NODE_STATE |
  57. CLUSTER_CHANGE_RESOURCE_STATE |
  58. CLUSTER_CHANGE_NETWORK_STATE |
  59. CLUSTER_CHANGE_NETINTERFACE_STATE |
  60. CLUSTER_CHANGE_QUORUM_STATE |
  61. CLUSTER_CHANGE_CLUSTER_STATE,
  62. cntGROUP_STATE_CHANGE =
  63. CLUSTER_CHANGE_GROUP_STATE,
  64. cntRESOURCE_STATE_CHANGE =
  65. CLUSTER_CHANGE_RESOURCE_STATE,
  66. cntOBJECT_ADD =
  67. CLUSTER_CHANGE_NODE_ADDED |
  68. CLUSTER_CHANGE_RESOURCE_ADDED |
  69. CLUSTER_CHANGE_GROUP_ADDED |
  70. CLUSTER_CHANGE_RESOURCE_TYPE_ADDED |
  71. CLUSTER_CHANGE_NETWORK_ADDED |
  72. CLUSTER_CHANGE_NETINTERFACE_ADDED,
  73. cntOBJECT_REMOVE =
  74. CLUSTER_CHANGE_NODE_DELETED |
  75. CLUSTER_CHANGE_RESOURCE_DELETED |
  76. CLUSTER_CHANGE_GROUP_DELETED |
  77. CLUSTER_CHANGE_RESOURCE_TYPE_DELETED |
  78. CLUSTER_CHANGE_NETWORK_DELETED |
  79. CLUSTER_CHANGE_NETINTERFACE_DELETED,
  80. cntPROPERTY_CHANGE =
  81. CLUSTER_CHANGE_NODE_PROPERTY |
  82. CLUSTER_CHANGE_RESOURCE_PROPERTY |
  83. CLUSTER_CHANGE_GROUP_PROPERTY |
  84. CLUSTER_CHANGE_RESOURCE_TYPE_PROPERTY |
  85. CLUSTER_CHANGE_NETWORK_PROPERTY |
  86. CLUSTER_CHANGE_NETINTERFACE_PROPERTY |
  87. CLUSTER_CHANGE_CLUSTER_PROPERTY
  88. };
  89. enum EEventObjectType
  90. {
  91. eotHANDLE = 0,
  92. eotCLUSTER,
  93. eotNODE,
  94. eotGROUP,
  95. eotRESOURCE,
  96. eotRESOURCE_TYPE,
  97. eotNETWORK,
  98. eotNET_INTERFACE,
  99. eotREGISTRY,
  100. eotQUORUM,
  101. eotMX
  102. };
  103. typedef void (*FPSETPROP)(
  104. CWbemClassObject & pwcoIn,
  105. LPCWSTR pwszMofClassNameIn,
  106. LPCWSTR pwszObjectNameIn,
  107. EEventObjectType eotObjectTypeIn,
  108. DWORD dwEventMinorIn
  109. );
  110. struct SEventTypeTable
  111. {
  112. CLUSTER_CHANGE m_eType;
  113. EEventObjectType m_eotObjectType;
  114. LPCWSTR m_pwszMof;
  115. IWbemClassObject * m_pwco;
  116. FPSETPROP m_pfn;
  117. };
  118. void InsertTable(
  119. DWORD dwIdxIn,
  120. CLUSTER_CHANGE eTypeIn,
  121. EEventObjectType eotObjectTypeIn,
  122. LPCWSTR pwszMofIn,
  123. IWbemClassObject * pwcoIn,
  124. FPSETPROP pfnIn
  125. );
  126. SEventTypeTable m_EventTypeTable[ 32 ];
  127. CEventProv( void );
  128. ~CEventProv( void );
  129. //
  130. // IUnknown members
  131. //
  132. STDMETHODIMP QueryInterface( REFIID riid, LPVOID * ppv );
  133. STDMETHODIMP_( ULONG ) AddRef( void );
  134. STDMETHODIMP_( ULONG ) Release( void );
  135. // Inherited from IWbemEventProvider
  136. HRESULT STDMETHODCALLTYPE ProvideEvents(
  137. IWbemObjectSink * pSinkIn,
  138. long lFlagsIn
  139. );
  140. // Inherited from IWbemEventProviderSecurity
  141. HRESULT STDMETHODCALLTYPE AccessCheck(
  142. WBEM_CWSTR wszQueryLanguageIn,
  143. WBEM_CWSTR wszQueryIn,
  144. long lSidLengthIn,
  145. const BYTE * pSidIn
  146. );
  147. // Inherited from IWbemProviderInit
  148. HRESULT STDMETHODCALLTYPE Initialize(
  149. LPWSTR pwszUserIn,
  150. LONG lFlagsIn,
  151. LPWSTR pwszNamespaceIn,
  152. LPWSTR pwszLocaleIn,
  153. IWbemServices * pNamespaceIn,
  154. IWbemContext * pCtxIn,
  155. IWbemProviderInitSink * pInitSinkIn
  156. );
  157. static HRESULT S_HrCreateThis(
  158. IUnknown * pUnknownOuterIn,
  159. VOID ** ppvOut
  160. );
  161. protected:
  162. ULONG m_cRef;
  163. IWbemServices * m_pNs;
  164. IWbemObjectSink * m_pSink;
  165. IWbemClassObject * m_pEventAdd;
  166. IWbemClassObject * m_pEventRemove;
  167. IWbemClassObject * m_pEventProperty;
  168. IWbemClassObject * m_pEventState;
  169. IWbemClassObject * m_pEventGroupState;
  170. IWbemClassObject * m_pEventResourceState;
  171. EEventStatus m_esStatus;
  172. HANDLE m_hThread;
  173. BOOL m_fStopped;
  174. HCHANGE m_hChange;
  175. static void S_SetEventProperty(
  176. CWbemClassObject & pwcoInout,
  177. LPCWSTR pwszMofClassNameIn,
  178. LPCWSTR pwszObjectNameIn,
  179. EEventObjectType eotObjectTypeIn,
  180. DWORD dwEventMinorIn
  181. );
  182. static void S_AddEvent(
  183. CWbemClassObject & pwcoInout,
  184. LPCWSTR pwszMofClassNameIn,
  185. LPCWSTR pwszObjectNameIn,
  186. EEventObjectType eotObjectTypeIn,
  187. DWORD dwEventMinorIn
  188. );
  189. static void S_DeleteEvent(
  190. CWbemClassObject & pwcoInout,
  191. LPCWSTR pwszMofClassNameIn,
  192. LPCWSTR pwszObjectNameIn,
  193. EEventObjectType eotObjectTypeIn,
  194. DWORD dwEventMinorIn
  195. );
  196. static void S_SetNodeStateProperty(
  197. CWbemClassObject & pwcoInout,
  198. LPCWSTR pwszMofClassNameIn,
  199. LPCWSTR pwszObjectNameIn,
  200. EEventObjectType eotObjectTypeIn,
  201. DWORD dwEventMinorIn
  202. );
  203. static void S_SetGroupStateProperty(
  204. CWbemClassObject & pwcoInout,
  205. LPCWSTR pwszMofClassNameIn,
  206. LPCWSTR pwszObjectNameIn,
  207. EEventObjectType eotObjectTypeIn,
  208. DWORD dwEventMinorIn
  209. );
  210. static void S_SetResourceStateProperty(
  211. CWbemClassObject & pwcoInout,
  212. LPCWSTR pwszMofClassNameIn,
  213. LPCWSTR pwszObjectNameIn,
  214. EEventObjectType eotObjectTypeIn,
  215. DWORD dwEventMinorIn
  216. );
  217. static void S_SetNetworkStateProperty(
  218. CWbemClassObject & pwcoInout,
  219. LPCWSTR pwszMofClassNameIn,
  220. LPCWSTR pwszObjectNameIn,
  221. EEventObjectType eotObjectTypeIn,
  222. DWORD dwEventMinorIn
  223. );
  224. static void S_SetNetInterfaceStateProperty(
  225. CWbemClassObject & pwcoInout,
  226. LPCWSTR pwszMofClassNameIn,
  227. LPCWSTR pwszObjectNameIn,
  228. EEventObjectType eotObjectTypeIn,
  229. DWORD dwEventMinorIn
  230. );
  231. static DWORD WINAPI S_EventThread(
  232. LPVOID pArgIn
  233. );
  234. void InstanceThread( void );
  235. }; //*** class CEventProv