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.

390 lines
15 KiB

  1. //***************************************************************************
  2. //
  3. // NTEVTSERV.H
  4. //
  5. // Module:
  6. //
  7. // Purpose: Genral purpose include file.
  8. //
  9. // Copyright (c) 1996-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. #ifndef _NT_EVT_PROV_NTEVTSERV_H
  13. #define _NT_EVT_PROV_NTEVTSERV_H
  14. typedef
  15. enum tag_WBEMPROVSTATUS
  16. {
  17. WBEM_PROV_NO_ERROR = 0,
  18. WBEM_PROV_S_NO_ERROR = 0,
  19. WBEM_PROV_S_NO_MORE_DATA = 0x40001,
  20. WBEM_PROV_S_ALREADY_EXISTS = WBEM_PROV_S_NO_MORE_DATA + 1,
  21. WBEM_PROV_S_NOT_FOUND = WBEM_PROV_S_ALREADY_EXISTS + 1,
  22. WBEM_PROV_S_RESET_TO_DEFAULT = WBEM_PROV_S_NOT_FOUND + 1,
  23. WBEM_PROV_E_FAILED = 0x80041001,
  24. WBEM_PROV_E_NOT_FOUND = WBEM_PROV_E_FAILED + 1,
  25. WBEM_PROV_E_ACCESS_DENIED = WBEM_PROV_E_NOT_FOUND + 1,
  26. WBEM_PROV_E_PROVIDER_FAILURE = WBEM_PROV_E_ACCESS_DENIED + 1,
  27. WBEM_PROV_E_TYPE_MISMATCH = WBEM_PROV_E_PROVIDER_FAILURE + 1,
  28. WBEM_PROV_E_OUT_OF_MEMORY = WBEM_PROV_E_TYPE_MISMATCH + 1,
  29. WBEM_PROV_E_INVALID_CONTEXT = WBEM_PROV_E_OUT_OF_MEMORY + 1,
  30. WBEM_PROV_E_INVALID_PARAMETER = WBEM_PROV_E_INVALID_CONTEXT + 1,
  31. WBEM_PROV_E_NOT_AVAILABLE = WBEM_PROV_E_INVALID_PARAMETER + 1,
  32. WBEM_PROV_E_CRITICAL_ERROR = WBEM_PROV_E_NOT_AVAILABLE + 1,
  33. WBEM_PROV_E_INVALID_STREAM = WBEM_PROV_E_CRITICAL_ERROR + 1,
  34. WBEM_PROV_E_NOT_SUPPORTED = WBEM_PROV_E_INVALID_STREAM + 1,
  35. WBEM_PROV_E_INVALID_SUPERCLASS = WBEM_PROV_E_NOT_SUPPORTED + 1,
  36. WBEM_PROV_E_INVALID_NAMESPACE = WBEM_PROV_E_INVALID_SUPERCLASS + 1,
  37. WBEM_PROV_E_INVALID_OBJECT = WBEM_PROV_E_INVALID_NAMESPACE + 1,
  38. WBEM_PROV_E_INVALID_CLASS = WBEM_PROV_E_INVALID_OBJECT + 1,
  39. WBEM_PROV_E_PROVIDER_NOT_FOUND = WBEM_PROV_E_INVALID_CLASS + 1,
  40. WBEM_PROV_E_INVALID_PROVIDER_REGISTRATION = WBEM_PROV_E_PROVIDER_NOT_FOUND + 1,
  41. WBEM_PROV_E_PROVIDER_LOAD_FAILURE = WBEM_PROV_E_INVALID_PROVIDER_REGISTRATION + 1,
  42. WBEM_PROV_E_INITIALIZATION_FAILURE = WBEM_PROV_E_PROVIDER_LOAD_FAILURE + 1,
  43. WBEM_PROV_E_TRANSPORT_FAILURE = WBEM_PROV_E_INITIALIZATION_FAILURE + 1,
  44. WBEM_PROV_E_INVALID_OPERATION = WBEM_PROV_E_TRANSPORT_FAILURE + 1,
  45. WBEM_PROV_E_INVALID_QUERY = WBEM_PROV_E_INVALID_OPERATION + 1,
  46. WBEM_PROV_E_INVALID_QUERY_TYPE = WBEM_PROV_E_INVALID_QUERY + 1,
  47. WBEM_PROV_E_ALREADY_EXISTS = WBEM_PROV_E_INVALID_QUERY_TYPE + 1,
  48. WBEM_PROV_E_OVERRIDE_NOT_ALLOWED = WBEM_PROV_E_ALREADY_EXISTS + 1,
  49. WBEM_PROV_E_PROPAGATED_QUALIFIER = WBEM_PROV_E_OVERRIDE_NOT_ALLOWED + 1,
  50. WBEM_PROV_E_UNEXPECTED = WBEM_PROV_E_PROPAGATED_QUALIFIER + 1,
  51. WBEM_PROV_E_ILLEGAL_OPERATION = WBEM_PROV_E_UNEXPECTED + 1,
  52. WBEM_PROV_E_CANNOT_BE_KEY = WBEM_PROV_E_ILLEGAL_OPERATION + 1,
  53. WBEM_PROV_E_INCOMPLETE_CLASS = WBEM_PROV_E_CANNOT_BE_KEY + 1,
  54. WBEM_PROV_E_INVALID_SYNTAX = WBEM_PROV_E_INCOMPLETE_CLASS + 1,
  55. WBEM_PROV_E_NONDECORATED_OBJECT = WBEM_PROV_E_INVALID_SYNTAX + 1,
  56. WBEM_PROV_E_READ_ONLY = WBEM_PROV_E_NONDECORATED_OBJECT + 1,
  57. WBEM_PROV_E_PROVIDER_NOT_CAPABLE = WBEM_PROV_E_READ_ONLY + 1,
  58. WBEM_PROV_E_CLASS_HAS_CHILDREN = WBEM_PROV_E_PROVIDER_NOT_CAPABLE + 1,
  59. WBEM_PROV_E_CLASS_HAS_INSTANCES = WBEM_PROV_E_CLASS_HAS_CHILDREN + 1 ,
  60. // Added
  61. WBEM_PROV_E_INVALID_PROPERTY = WBEM_PROV_E_CLASS_HAS_INSTANCES + 1 ,
  62. WBEM_PROV_E_INVALID_QUALIFIER = WBEM_PROV_E_INVALID_PROPERTY + 1 ,
  63. WBEM_PROV_E_INVALID_PATH = WBEM_PROV_E_INVALID_QUALIFIER + 1 ,
  64. WBEM_PROV_E_INVALID_PATHKEYPARAMETER = WBEM_PROV_E_INVALID_PATH + 1 ,
  65. WBEM_PROV_E_MISSINGPATHKEYPARAMETER = WBEM_PROV_E_INVALID_PATHKEYPARAMETER + 1 ,
  66. WBEM_PROV_E_INVALID_KEYORDERING = WBEM_PROV_E_MISSINGPATHKEYPARAMETER + 1 ,
  67. WBEM_PROV_E_DUPLICATEPATHKEYPARAMETER = WBEM_PROV_E_INVALID_KEYORDERING + 1 ,
  68. WBEM_PROV_E_MISSINGKEY = WBEM_PROV_E_DUPLICATEPATHKEYPARAMETER + 1 ,
  69. WBEM_PROV_E_INVALID_TRANSPORT = WBEM_PROV_E_MISSINGKEY + 1 ,
  70. WBEM_PROV_E_INVALID_TRANSPORTCONTEXT = WBEM_PROV_E_INVALID_TRANSPORT + 1 ,
  71. WBEM_PROV_E_TRANSPORT_ERROR = WBEM_PROV_E_INVALID_TRANSPORTCONTEXT + 1 ,
  72. WBEM_PROV_E_TRANSPORT_NO_RESPONSE = WBEM_PROV_E_TRANSPORT_ERROR + 1 ,
  73. WBEM_PROV_E_NOWRITABLEPROPERTIES = WBEM_PROV_E_TRANSPORT_NO_RESPONSE + 1 ,
  74. WBEM_PROV_E_NOREADABLEPROPERTIES = WBEM_PROV_E_NOWRITABLEPROPERTIES + 1
  75. } WBEMPROVSTATUS;
  76. class WbemProvErrorObject
  77. {
  78. private:
  79. enum tag_ProvPrivileges
  80. {
  81. PROV_PRIV_SECURITY = 1,
  82. PROV_PRIV_BACKUP = 2
  83. } PROVPRIVILEGES;
  84. wchar_t *m_provErrorMessage ;
  85. WBEMPROVSTATUS m_provErrorStatus ;
  86. WBEMSTATUS m_wbemErrorStatus ;
  87. BOOL m_privilegeFailed;
  88. DWORD m_PrivsReqd;
  89. DWORD m_PrivsFailed;
  90. BOOL SetPrivVariant ( VARIANT &a_V, DWORD dwVal );
  91. protected:
  92. public:
  93. WbemProvErrorObject () : m_privilegeFailed ( FALSE ) ,
  94. m_provErrorMessage ( NULL ) ,
  95. m_wbemErrorStatus ( WBEM_NO_ERROR ) ,
  96. m_provErrorStatus ( WBEM_PROV_NO_ERROR ),
  97. m_PrivsReqd (0),
  98. m_PrivsFailed (0) {}
  99. virtual ~WbemProvErrorObject () { delete [] m_provErrorMessage ; }
  100. void SetStatus ( WBEMPROVSTATUS a_provErrorStatus )
  101. {
  102. m_provErrorStatus = a_provErrorStatus ;
  103. }
  104. void SetWbemStatus ( WBEMSTATUS a_wbemErrorStatus )
  105. {
  106. m_wbemErrorStatus = a_wbemErrorStatus ;
  107. }
  108. void SetMessage ( wchar_t *a_provErrorMessage )
  109. {
  110. delete [] m_provErrorMessage ;
  111. m_provErrorMessage = UnicodeStringDuplicate ( a_provErrorMessage ) ;
  112. }
  113. void SetPrivilegeFailed ( BOOL a_PrivilegeFailed = TRUE )
  114. {
  115. m_privilegeFailed = a_PrivilegeFailed;
  116. }
  117. void SetBackupPrivRequired () { m_PrivsReqd = m_PrivsReqd | PROV_PRIV_BACKUP; }
  118. void SetSecurityPrivRequired () { m_PrivsReqd = m_PrivsReqd | PROV_PRIV_SECURITY; }
  119. void SetBackupPrivFailed () { m_PrivsFailed = m_PrivsFailed | PROV_PRIV_BACKUP; }
  120. void SetSecurityPrivFailed () { m_PrivsFailed = m_PrivsFailed | PROV_PRIV_SECURITY; }
  121. BOOL SetPrivRequiredVariant ( VARIANT &a_V ) { return SetPrivVariant(a_V, m_PrivsReqd); }
  122. BOOL SetPrivFailedVariant ( VARIANT &a_V ) { return SetPrivVariant(a_V, m_PrivsFailed); }
  123. wchar_t *GetMessage () { return m_provErrorMessage ; } ;
  124. WBEMPROVSTATUS GetStatus () { return m_provErrorStatus ; } ;
  125. WBEMSTATUS GetWbemStatus () { return m_wbemErrorStatus ; } ;
  126. BOOL GetPrivilegeFailed () { return m_privilegeFailed ; }
  127. } ;
  128. class CImpNTEvtProv : public IWbemServices, public IWbemProviderInit
  129. {
  130. private:
  131. BOOL m_Initialised ;
  132. LONG m_ReferenceCount ; //Object reference count
  133. CCriticalSection m_NotifyLock ;
  134. CCriticalSection m_ExtendedNotifyLock ;
  135. WbemNamespacePath m_NamespacePath ;
  136. wchar_t *m_Namespace ;
  137. IWbemServices *m_Server ;
  138. wchar_t *m_localeId ;
  139. BOOL m_GetNotifyCalled ;
  140. BOOL m_GetExtendedNotifyCalled ;
  141. IWbemClassObject *m_NotificationClassObject ;
  142. IWbemClassObject *m_ExtendedNotificationClassObject ;
  143. protected:
  144. public:
  145. CImpNTEvtProv () ;
  146. ~CImpNTEvtProv () ;
  147. // Implementation
  148. IWbemServices *GetServer () ;
  149. WbemNamespacePath *GetNamespacePath () { return & m_NamespacePath ; }
  150. wchar_t *GetNamespace () ;
  151. void SetNamespace ( wchar_t *a_Namespace ) ;
  152. void SetLocaleId ( wchar_t *a_localeId ) ;
  153. wchar_t *GetLocaleId () { return m_localeId ; }
  154. BOOL CreateExtendedNotificationObject (
  155. WbemProvErrorObject &a_errorObject,
  156. IWbemContext *pCtx
  157. ) ;
  158. BOOL CreateNotificationObject (
  159. WbemProvErrorObject &a_errorObject,
  160. IWbemContext *pCtx
  161. ) ;
  162. IWbemClassObject *GetNotificationObject (
  163. WbemProvErrorObject &a_errorObject,
  164. IWbemContext *pCtx
  165. ) ;
  166. IWbemClassObject *GetExtendedNotificationObject (
  167. WbemProvErrorObject &a_errorObject,
  168. IWbemContext *pCtx
  169. ) ;
  170. static HRESULT GetImpersonation();
  171. //Non-delegating object IUnknown
  172. STDMETHODIMP QueryInterface ( REFIID , LPVOID FAR * ) ;
  173. STDMETHODIMP_( ULONG ) AddRef () ;
  174. STDMETHODIMP_( ULONG ) Release () ;
  175. /* IWbemServices methods */
  176. HRESULT STDMETHODCALLTYPE OpenNamespace(
  177. /* [in] */ const BSTR Namespace,
  178. /* [in] */ long lFlags,
  179. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  180. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  181. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult) ;
  182. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  183. /* [in] */ IWbemObjectSink __RPC_FAR *pSink) ;
  184. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  185. /* [in] */ long lFlags,
  186. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler) ;
  187. HRESULT STDMETHODCALLTYPE GetObject(
  188. /* [in] */ const BSTR ObjectPath,
  189. /* [in] */ long lFlags,
  190. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  191. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  192. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  193. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  194. /* [in] */ const BSTR ObjectPath,
  195. /* [in] */ long lFlags,
  196. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  197. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  198. HRESULT STDMETHODCALLTYPE PutClass(
  199. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  200. /* [in] */ long lFlags,
  201. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  202. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  203. HRESULT STDMETHODCALLTYPE PutClassAsync(
  204. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  205. /* [in] */ long lFlags,
  206. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  207. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  208. HRESULT STDMETHODCALLTYPE DeleteClass(
  209. /* [in] */ const BSTR Class,
  210. /* [in] */ long lFlags,
  211. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  212. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  213. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  214. /* [in] */ const BSTR Class,
  215. /* [in] */ long lFlags,
  216. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  217. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  218. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  219. /* [in] */ const BSTR Superclass,
  220. /* [in] */ long lFlags,
  221. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  222. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  223. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  224. /* [in] */ const BSTR Superclass,
  225. /* [in] */ long lFlags,
  226. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  227. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  228. HRESULT STDMETHODCALLTYPE PutInstance(
  229. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  230. /* [in] */ long lFlags,
  231. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  232. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  233. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  234. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  235. /* [in] */ long lFlags,
  236. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  237. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  238. HRESULT STDMETHODCALLTYPE DeleteInstance(
  239. /* [in] */ const BSTR ObjectPath,
  240. /* [in] */ long lFlags,
  241. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  242. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  243. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  244. /* [in] */ const BSTR ObjectPath,
  245. /* [in] */ long lFlags,
  246. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  247. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  248. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  249. /* [in] */ const BSTR Class,
  250. /* [in] */ long lFlags,
  251. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  252. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  253. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  254. /* [in] */ const BSTR Class,
  255. /* [in] */ long lFlags,
  256. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  257. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  258. HRESULT STDMETHODCALLTYPE ExecQuery(
  259. /* [in] */ const BSTR QueryLanguage,
  260. /* [in] */ const BSTR Query,
  261. /* [in] */ long lFlags,
  262. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  263. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  264. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  265. /* [in] */ const BSTR QueryLanguage,
  266. /* [in] */ const BSTR Query,
  267. /* [in] */ long lFlags,
  268. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  269. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  270. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  271. /* [in] */ const BSTR QueryLanguage,
  272. /* [in] */ const BSTR Query,
  273. /* [in] */ long lFlags,
  274. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  275. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  276. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  277. /* [in] */ const BSTR QueryLanguage,
  278. /* [in] */ const BSTR Query,
  279. /* [in] */ long lFlags,
  280. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  281. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  282. HRESULT STDMETHODCALLTYPE ExecMethod(
  283. /* [in] */ const BSTR ObjectPath,
  284. /* [in] */ const BSTR MethodName,
  285. /* [in] */ long lFlags,
  286. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  287. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  288. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  289. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  290. HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  291. /* [in] */ const BSTR ObjectPath,
  292. /* [in] */ const BSTR MethodName,
  293. /* [in] */ long lFlags,
  294. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  295. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  296. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  297. /* IWbemProviderInit methods */
  298. HRESULT STDMETHODCALLTYPE Initialize (
  299. LPWSTR pszUser,
  300. LONG lFlags,
  301. LPWSTR pszNamespace,
  302. LPWSTR pszLocale,
  303. IWbemServices *pCIMOM, // For anybody
  304. IWbemContext *pCtx,
  305. IWbemProviderInitSink *pInitSink // For init signals
  306. );
  307. } ;
  308. #endif //_NT_EVT_PROV_NTEVTSERV_H