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.

332 lines
12 KiB

  1. ////////////////////////////////////////////////////////////////////
  2. //
  3. // WMIProv.h
  4. //
  5. // Purpose: Include file for the WMI_Provider
  6. //
  7. // Copyright (c) 1997-2002 Microsoft Corporation, All Rights Reserved
  8. //
  9. // history:
  10. // 05/16/97 jennymc updated
  11. //
  12. ////////////////////////////////////////////////////////////////////
  13. #ifndef _WMIPROV_H_
  14. #define _WMIPROV_H_
  15. class CRefresher;
  16. class CRefCacheElement;
  17. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  18. //
  19. // Provider interfaces are provided by objects of this class
  20. //
  21. ///////////////////////////////////////////////////////////////////////////////////////////////////////
  22. class CCritical_SectionWrapper
  23. {
  24. private:
  25. CRITICAL_SECTION *m_cs;
  26. public:
  27. CCritical_SectionWrapper( CRITICAL_SECTION * cs): m_cs (NULL)
  28. {
  29. if (cs)
  30. {
  31. try
  32. {
  33. EnterCriticalSection(cs);
  34. m_cs = cs;
  35. }
  36. catch(...)
  37. {
  38. }
  39. }
  40. }
  41. ~CCritical_SectionWrapper()
  42. {
  43. if (m_cs)
  44. {
  45. try
  46. {
  47. LeaveCriticalSection(m_cs);
  48. }
  49. catch(...)
  50. {
  51. }
  52. }
  53. }
  54. BOOL IsLocked () { return (m_cs != NULL); }
  55. };
  56. class CWMI_Prov : public IWbemServices, public IWbemProviderInit,public IWbemHiPerfProvider
  57. {
  58. protected:
  59. long m_cRef;
  60. IWbemServices * m_pIWbemServices;
  61. IWbemServices * m_pIWbemRepository;
  62. CHandleMap m_HandleMap;
  63. CHiPerfHandleMap m_HiPerfHandleMap;
  64. #if defined(_WIN64)
  65. CRITICAL_SECTION m_CS;
  66. WmiAllocator *m_Allocator ;
  67. WmiHashTable <LONG, ULONG_PTR, 17> *m_HashTable;
  68. LONG m_ID;
  69. #endif
  70. private:
  71. BOOL m_bInitialized ;
  72. public:
  73. inline BOOL Initialized ()
  74. {
  75. return m_bInitialized ;
  76. }
  77. inline CHiPerfHandleMap * HandleMapPtr() { return &m_HiPerfHandleMap; }
  78. inline IWbemServices * ServicesPtr() { return m_pIWbemServices;}
  79. inline IWbemServices * RepositoryPtr() { return m_pIWbemRepository;}
  80. enum{
  81. SUCCESS = 0,
  82. FAILURE = 1,
  83. NO_DATA_AVAILABLE = 2,
  84. DATA_AVAILABLE
  85. };
  86. CWMI_Prov();
  87. ~CWMI_Prov(void);
  88. //=======================================================
  89. // Non-delegating object IUnknown
  90. //=======================================================
  91. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  92. STDMETHODIMP_(ULONG) AddRef(void);
  93. STDMETHODIMP_(ULONG) Release(void);
  94. //=======================================================
  95. //IWbemServices supported interfaces
  96. //=======================================================
  97. STDMETHOD(OpenNamespace) (
  98. /* [in] */ const BSTR Namespace,
  99. /* [in] */ long lFlags,
  100. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  101. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  102. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult);
  103. STDMETHOD(Initialize)(
  104. /* [in] */ LPWSTR pszUser,
  105. /* [in] */ LONG lFlags,
  106. /* [in] */ LPWSTR pszNamespace,
  107. /* [in] */ LPWSTR pszLocale,
  108. /* [in] */ IWbemServices __RPC_FAR *pNamespace,
  109. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  110. /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink);
  111. STDMETHOD(GetObjectAsync)(
  112. /* [in] */ const BSTR ObjectPath,
  113. /* [in] */ long lFlags,
  114. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  115. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  116. STDMETHOD(CreateInstanceEnumAsync)(
  117. /* [in] */ const BSTR Class,
  118. /* [in] */ long lFlags,
  119. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  120. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  121. STDMETHOD(PutInstanceAsync)(
  122. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  123. /* [in] */ long lFlags,
  124. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  125. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  126. //========================================================
  127. // IWbemServices unsupported interfaces
  128. //========================================================
  129. STDMETHOD(GetTypeInfoCount) (THIS_ UINT * pctinfo)
  130. { return WBEM_E_NOT_SUPPORTED;}
  131. STDMETHOD(GetTypeInfo) (THIS_ UINT itinfo, LCID lcid, ITypeInfo * * pptinfo)
  132. { return WBEM_E_NOT_SUPPORTED;}
  133. STDMETHOD(GetIDsOfNames) (THIS_ REFIID riid, OLECHAR * * rgszNames, UINT cNames,LCID lcid, DISPID * rgdispid)
  134. { return WBEM_E_NOT_SUPPORTED;}
  135. STDMETHOD(Invoke) (THIS_ DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
  136. { return WBEM_E_NOT_SUPPORTED;}
  137. STDMETHOD(CreateInstanceEnum)(
  138. /* [in] */ const BSTR Class,
  139. /* [in] */ long lFlags,
  140. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  141. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  142. { return WBEM_E_NOT_SUPPORTED;}
  143. STDMETHOD(GetObject)( /* [in] */ const BSTR ObjectPath,
  144. /* [in] */ long lFlags,
  145. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  146. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  147. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  148. { return WBEM_E_NOT_SUPPORTED;}
  149. STDMETHOD(PutClassAsync)( /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  150. /* [in] */ long lFlags,
  151. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  152. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  153. { return WBEM_E_NOT_SUPPORTED;}
  154. STDMETHOD(CreateClassEnum)(/* [in] */ const BSTR Superclass,
  155. /* [in] */ long lFlags,
  156. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  157. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  158. { return E_NOTIMPL;}
  159. STDMETHOD(CreateClassEnumAsync)(
  160. /* [in] */ const BSTR Superclass,
  161. /* [in] */ long lFlags,
  162. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  163. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  164. { return E_NOTIMPL;}
  165. STDMETHOD(PutInstance) (
  166. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  167. /* [in] */ long lFlags,
  168. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  169. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  170. { return WBEM_E_NOT_SUPPORTED;}
  171. STDMETHOD(DeleteInstance)(
  172. /* [in] */ const BSTR ObjectPath,
  173. /* [in] */ long lFlags,
  174. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  175. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  176. { return WBEM_E_NOT_SUPPORTED;}
  177. STDMETHOD(DeleteInstanceAsync)(
  178. /* [in] */ const BSTR ObjectPath,
  179. /* [in] */ long lFlags,
  180. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  181. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  182. { return WBEM_E_NOT_SUPPORTED;}
  183. STDMETHOD(ExecQuery)(
  184. /* [in] */ const BSTR QueryLanguage,
  185. /* [in] */ const BSTR Query,
  186. /* [in] */ long lFlags,
  187. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  188. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  189. { return WBEM_E_NOT_SUPPORTED;}
  190. STDMETHOD(ExecQueryAsync)(
  191. /* [in] */ const BSTR QueryLanguage,
  192. /* [in] */ const BSTR Query,
  193. /* [in] */ long lFlags,
  194. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  195. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  196. STDMETHOD(CancelAsyncRequest)(THIS_ long lAsyncRequestHandle)
  197. { return WBEM_E_NOT_SUPPORTED;}
  198. STDMETHOD(CancelAsyncCall)(THIS_ IWbemObjectSink __RPC_FAR *pSink)
  199. { return WBEM_E_NOT_SUPPORTED;}
  200. STDMETHOD(QueryObjectSink)(THIS_ /* [in] */ long lFlags,
  201. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler)
  202. { return WBEM_E_NOT_SUPPORTED;}
  203. STDMETHOD(PutClass)( /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  204. /* [in] */ long lFlags,
  205. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  206. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  207. { return WBEM_E_NOT_SUPPORTED;}
  208. STDMETHOD(DeleteClass)( /* [in] */ const BSTR Class,
  209. /* [in] */ long lFlags,
  210. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  211. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  212. { return WBEM_E_NOT_SUPPORTED;}
  213. STDMETHOD(DeleteClassAsync)( /* [in] */ const BSTR Class,
  214. /* [in] */ long lFlags,
  215. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  216. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  217. { return WBEM_E_NOT_SUPPORTED;}
  218. STDMETHOD(ExecNotificationQueryAsync)(
  219. /* [in] */ const BSTR QueryLanguage,
  220. /* [in] */ const BSTR Query,
  221. /* [in] */ long lFlags,
  222. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  223. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  224. { return WBEM_E_NOT_SUPPORTED;}
  225. STDMETHOD(ExecNotificationQuery)(
  226. /* [in] */ const BSTR QueryLanguage,
  227. /* [in] */ const BSTR Query,
  228. /* [in] */ long lFlags,
  229. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  230. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  231. { return WBEM_E_NOT_SUPPORTED;}
  232. STDMETHOD(ExecMethod)(
  233. /* [in] */ const BSTR ObjectPath,
  234. /* [in] */ const BSTR MethodName,
  235. /* [in] */ long lFlags,
  236. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  237. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  238. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  239. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  240. { return WBEM_E_NOT_SUPPORTED;}
  241. STDMETHOD(ExecMethodAsync)( /* [in] */ const BSTR ObjectPath,
  242. /* [in] */ const BSTR MethodName,
  243. /* [in] */ long lFlags,
  244. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  245. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  246. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  247. //==========================================================
  248. // IWbemHiPerfProvider COM interfaces
  249. //==========================================================
  250. STDMETHOD(QueryInstances)( IWbemServices __RPC_FAR *pNamespace, WCHAR __RPC_FAR *wszClass,
  251. long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pSink );
  252. STDMETHOD(CreateRefresher)( IWbemServices __RPC_FAR *pNamespace, long lFlags, IWbemRefresher __RPC_FAR *__RPC_FAR *ppRefresher );
  253. STDMETHOD(CreateRefreshableObject)( IWbemServices __RPC_FAR *pNamespace, IWbemObjectAccess __RPC_FAR *pTemplate,
  254. IWbemRefresher __RPC_FAR *pRefresher, long lFlags,
  255. IWbemContext __RPC_FAR *pContext, IWbemObjectAccess __RPC_FAR *__RPC_FAR *ppRefreshable,
  256. long __RPC_FAR *plId );
  257. STDMETHOD(StopRefreshing)( IWbemRefresher __RPC_FAR *pRefresher, long lId, long lFlags );
  258. STDMETHOD(CreateRefreshableEnum)( IWbemServices* pNamespace, LPCWSTR wszClass, IWbemRefresher* pRefresher,
  259. long lFlags, IWbemContext* pContext, IWbemHiPerfEnum* pHiPerfEnum, long* plId);
  260. STDMETHOD(GetObjects)( IWbemServices* pNamespace, long lNumObjects, IWbemObjectAccess** apObj,
  261. long lFlags, IWbemContext* pContext);
  262. };
  263. class CWMIHiPerfProvider : public CWMI_Prov
  264. {
  265. STDMETHOD(Initialize)(
  266. /* [in] */ LPWSTR pszUser,
  267. /* [in] */ LONG lFlags,
  268. /* [in] */ LPWSTR pszNamespace,
  269. /* [in] */ LPWSTR pszLocale,
  270. /* [in] */ IWbemServices __RPC_FAR *pNamespace,
  271. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  272. /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink);
  273. };
  274. #endif