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.

329 lines
12 KiB

  1. ////////////////////////////////////////////////////////////////////
  2. //
  3. // WMIProv.h
  4. //
  5. // Purpose: Include file for the WMI_Provider
  6. //
  7. // Copyright (c) 1997-2001 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. CHandleMap m_HandleMap;
  62. CHiPerfHandleMap m_HiPerfHandleMap;
  63. #if defined(_AMD64_) || defined(_IA64_)
  64. CRITICAL_SECTION m_CS;
  65. WmiAllocator *m_Allocator ;
  66. WmiHashTable <LONG, ULONG_PTR, 17> *m_HashTable;
  67. LONG m_ID;
  68. #endif
  69. public:
  70. inline CHiPerfHandleMap * HandleMapPtr() { return &m_HiPerfHandleMap; }
  71. inline IWbemServices * ServicesPtr() { return m_pIWbemServices;}
  72. enum{
  73. SUCCESS = 0,
  74. FAILURE = 1,
  75. NO_DATA_AVAILABLE = 2,
  76. DATA_AVAILABLE
  77. };
  78. CWMI_Prov();
  79. ~CWMI_Prov(void);
  80. //=======================================================
  81. // Non-delegating object IUnknown
  82. //=======================================================
  83. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  84. STDMETHODIMP_(ULONG) AddRef(void);
  85. STDMETHODIMP_(ULONG) Release(void);
  86. //=======================================================
  87. //IWbemServices supported interfaces
  88. //=======================================================
  89. STDMETHOD(OpenNamespace) (
  90. /* [in] */ const BSTR Namespace,
  91. /* [in] */ long lFlags,
  92. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  93. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  94. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult);
  95. STDMETHOD(Initialize)(
  96. /* [in] */ LPWSTR pszUser,
  97. /* [in] */ LONG lFlags,
  98. /* [in] */ LPWSTR pszNamespace,
  99. /* [in] */ LPWSTR pszLocale,
  100. /* [in] */ IWbemServices __RPC_FAR *pNamespace,
  101. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  102. /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink);
  103. STDMETHOD(GetObjectAsync)(
  104. /* [in] */ const BSTR ObjectPath,
  105. /* [in] */ long lFlags,
  106. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  107. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  108. STDMETHOD(CreateInstanceEnumAsync)(
  109. /* [in] */ const BSTR Class,
  110. /* [in] */ long lFlags,
  111. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  112. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  113. STDMETHOD(PutInstanceAsync)(
  114. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  115. /* [in] */ long lFlags,
  116. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  117. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  118. //========================================================
  119. // IWbemServices unsupported interfaces
  120. //========================================================
  121. STDMETHOD(GetTypeInfoCount) (THIS_ UINT * pctinfo)
  122. { return WBEM_E_NOT_SUPPORTED;}
  123. STDMETHOD(GetTypeInfo) (THIS_ UINT itinfo, LCID lcid, ITypeInfo * * pptinfo)
  124. { return WBEM_E_NOT_SUPPORTED;}
  125. STDMETHOD(GetIDsOfNames) (THIS_ REFIID riid, OLECHAR * * rgszNames, UINT cNames,LCID lcid, DISPID * rgdispid)
  126. { return WBEM_E_NOT_SUPPORTED;}
  127. STDMETHOD(Invoke) (THIS_ DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS * pdispparams, VARIANT * pvarResult, EXCEPINFO * pexcepinfo, UINT * puArgErr)
  128. { return WBEM_E_NOT_SUPPORTED;}
  129. STDMETHOD(CreateInstanceEnum)(
  130. /* [in] */ const BSTR Class,
  131. /* [in] */ long lFlags,
  132. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  133. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  134. { return WBEM_E_NOT_SUPPORTED;}
  135. STDMETHOD(GetObject)( /* [in] */ const BSTR ObjectPath,
  136. /* [in] */ long lFlags,
  137. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  138. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  139. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  140. { return WBEM_E_NOT_SUPPORTED;}
  141. STDMETHOD(PutClassAsync)( /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  142. /* [in] */ long lFlags,
  143. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  144. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  145. { return WBEM_E_NOT_SUPPORTED;}
  146. STDMETHOD(CreateClassEnum)(/* [in] */ const BSTR Superclass,
  147. /* [in] */ long lFlags,
  148. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  149. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  150. { return E_NOTIMPL;}
  151. STDMETHOD(CreateClassEnumAsync)(
  152. /* [in] */ const BSTR Superclass,
  153. /* [in] */ long lFlags,
  154. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  155. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  156. { return E_NOTIMPL;}
  157. STDMETHOD(PutInstance) (
  158. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  159. /* [in] */ long lFlags,
  160. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  161. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  162. { return WBEM_E_NOT_SUPPORTED;}
  163. STDMETHOD(DeleteInstance)(
  164. /* [in] */ const BSTR ObjectPath,
  165. /* [in] */ long lFlags,
  166. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  167. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  168. { return WBEM_E_NOT_SUPPORTED;}
  169. STDMETHOD(DeleteInstanceAsync)(
  170. /* [in] */ const BSTR ObjectPath,
  171. /* [in] */ long lFlags,
  172. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  173. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  174. { return WBEM_E_NOT_SUPPORTED;}
  175. STDMETHOD(ExecQuery)(
  176. /* [in] */ const BSTR QueryLanguage,
  177. /* [in] */ const BSTR Query,
  178. /* [in] */ long lFlags,
  179. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  180. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  181. { return WBEM_E_NOT_SUPPORTED;}
  182. STDMETHOD(ExecQueryAsync)(
  183. /* [in] */ const BSTR QueryLanguage,
  184. /* [in] */ const BSTR Query,
  185. /* [in] */ long lFlags,
  186. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  187. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  188. STDMETHOD(CancelAsyncRequest)(THIS_ long lAsyncRequestHandle)
  189. { return WBEM_E_NOT_SUPPORTED;}
  190. STDMETHOD(CancelAsyncCall)(THIS_ IWbemObjectSink __RPC_FAR *pSink)
  191. { return WBEM_E_NOT_SUPPORTED;}
  192. STDMETHOD(QueryObjectSink)(THIS_ /* [in] */ long lFlags,
  193. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler)
  194. { return WBEM_E_NOT_SUPPORTED;}
  195. STDMETHOD(PutClass)( /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  196. /* [in] */ long lFlags,
  197. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  198. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  199. { return WBEM_E_NOT_SUPPORTED;}
  200. STDMETHOD(DeleteClass)( /* [in] */ const BSTR Class,
  201. /* [in] */ long lFlags,
  202. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  203. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  204. { return WBEM_E_NOT_SUPPORTED;}
  205. STDMETHOD(DeleteClassAsync)( /* [in] */ const BSTR Class,
  206. /* [in] */ long lFlags,
  207. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  208. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  209. { return WBEM_E_NOT_SUPPORTED;}
  210. STDMETHOD(ExecNotificationQueryAsync)(
  211. /* [in] */ const BSTR QueryLanguage,
  212. /* [in] */ const BSTR Query,
  213. /* [in] */ long lFlags,
  214. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  215. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  216. { return WBEM_E_NOT_SUPPORTED;}
  217. STDMETHOD(ExecNotificationQuery)(
  218. /* [in] */ const BSTR QueryLanguage,
  219. /* [in] */ const BSTR Query,
  220. /* [in] */ long lFlags,
  221. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  222. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  223. { return WBEM_E_NOT_SUPPORTED;}
  224. STDMETHOD(ExecMethod)(
  225. /* [in] */ const BSTR ObjectPath,
  226. /* [in] */ const BSTR MethodName,
  227. /* [in] */ long lFlags,
  228. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  229. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  230. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  231. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  232. { return WBEM_E_NOT_SUPPORTED;}
  233. STDMETHOD(ExecMethodAsync)( /* [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. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  239. //==========================================================
  240. // IWbemHiPerfProvider COM interfaces
  241. //==========================================================
  242. STDMETHOD(QueryInstances)( IWbemServices __RPC_FAR *pNamespace, WCHAR __RPC_FAR *wszClass,
  243. long lFlags, IWbemContext __RPC_FAR *pCtx, IWbemObjectSink __RPC_FAR *pSink );
  244. STDMETHOD(CreateRefresher)( IWbemServices __RPC_FAR *pNamespace, long lFlags, IWbemRefresher __RPC_FAR *__RPC_FAR *ppRefresher );
  245. STDMETHOD(CreateRefreshableObject)( IWbemServices __RPC_FAR *pNamespace, IWbemObjectAccess __RPC_FAR *pTemplate,
  246. IWbemRefresher __RPC_FAR *pRefresher, long lFlags,
  247. IWbemContext __RPC_FAR *pContext, IWbemObjectAccess __RPC_FAR *__RPC_FAR *ppRefreshable,
  248. long __RPC_FAR *plId );
  249. STDMETHOD(StopRefreshing)( IWbemRefresher __RPC_FAR *pRefresher, long lId, long lFlags );
  250. STDMETHOD(CreateRefreshableEnum)( IWbemServices* pNamespace, LPCWSTR wszClass, IWbemRefresher* pRefresher,
  251. long lFlags, IWbemContext* pContext, IWbemHiPerfEnum* pHiPerfEnum, long* plId);
  252. STDMETHOD(GetObjects)( IWbemServices* pNamespace, long lNumObjects, IWbemObjectAccess** apObj,
  253. long lFlags, IWbemContext* pContext);
  254. };
  255. class CWMIHiPerfProvider : public CWMI_Prov
  256. {
  257. STDMETHOD(Initialize)(
  258. /* [in] */ LPWSTR pszUser,
  259. /* [in] */ LONG lFlags,
  260. /* [in] */ LPWSTR pszNamespace,
  261. /* [in] */ LPWSTR pszLocale,
  262. /* [in] */ IWbemServices __RPC_FAR *pNamespace,
  263. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  264. /* [in] */ IWbemProviderInitSink __RPC_FAR *pInitSink);
  265. };
  266. #endif