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.

354 lines
12 KiB

  1. #ifndef __provider_lib__
  2. #define __provider_lib__
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif
  6. #include <wbemprov.h>
  7. #include <objbase.h>
  8. typedef LPVOID * PPVOID;
  9. class CWbemServices
  10. {
  11. protected:
  12. IWbemServices* m_pWbemServices;
  13. public:
  14. CWbemServices(IWbemServices* );
  15. virtual ~CWbemServices();
  16. HRESULT STDMETHODCALLTYPE GetObject(
  17. /* [in] */ BSTR ObjectPath,
  18. /* [in] */ long lFlags,
  19. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  20. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  21. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  22. HRESULT STDMETHODCALLTYPE PutClass(
  23. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  24. /* [in] */ long lFlags,
  25. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  26. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  27. HRESULT STDMETHODCALLTYPE DeleteClass(
  28. /* [in] */ BSTR Class,
  29. /* [in] */ long lFlags,
  30. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  31. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  32. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  33. /* [in] */ BSTR Superclass,
  34. /* [in] */ long lFlags,
  35. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  36. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  37. HRESULT STDMETHODCALLTYPE PutInstance(
  38. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  39. /* [in] */ long lFlags,
  40. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  41. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  42. HRESULT STDMETHODCALLTYPE DeleteInstance(
  43. /* [in] */ BSTR ObjectPath,
  44. /* [in] */ long lFlags,
  45. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  46. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult) ;
  47. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  48. /* [in] */ BSTR Class,
  49. /* [in] */ long lFlags,
  50. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  51. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  52. HRESULT STDMETHODCALLTYPE ExecQuery(
  53. /* [in] */ BSTR QueryLanguage,
  54. /* [in] */ BSTR Query,
  55. /* [in] */ long lFlags,
  56. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  57. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  58. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  59. /* [in] */ BSTR QueryLanguage,
  60. /* [in] */ BSTR Query,
  61. /* [in] */ long lFlags,
  62. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  63. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum) ;
  64. HRESULT STDMETHODCALLTYPE ExecMethod(
  65. BSTR,
  66. BSTR,
  67. long,
  68. IWbemContext*,
  69. IWbemClassObject*,
  70. IWbemClassObject**,
  71. IWbemCallResult**) ;
  72. };
  73. class CImpersonatedProvider : public IWbemServices, public IWbemProviderInit
  74. {
  75. protected:
  76. ULONG m_cRef; //Object reference count
  77. CWbemServices* m_pNamespace;
  78. public:
  79. CImpersonatedProvider(BSTR =NULL, BSTR =NULL , BSTR =NULL, IWbemContext* =NULL);
  80. virtual ~CImpersonatedProvider();
  81. //Non-delegating object IUnknown
  82. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  83. STDMETHODIMP_(ULONG) AddRef(void);
  84. STDMETHODIMP_(ULONG) Release(void);
  85. //IWbemProviderInit
  86. HRESULT STDMETHODCALLTYPE Initialize(
  87. /* [in] */ LPWSTR pszUser,
  88. /* [in] */ LONG lFlags,
  89. /* [in] */ LPWSTR pszNamespace,
  90. /* [in] */ LPWSTR pszLocale,
  91. /* [in] */ IWbemServices *pNamespace,
  92. /* [in] */ IWbemContext *pCtx,
  93. /* [in] */ IWbemProviderInitSink *pInitSink
  94. );
  95. //IWbemServices
  96. HRESULT STDMETHODCALLTYPE OpenNamespace(
  97. /* [in] */ const BSTR Namespace,
  98. /* [in] */ long lFlags,
  99. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  100. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  101. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult)
  102. {return WBEM_E_NOT_SUPPORTED;};
  103. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  104. /* [in] */ IWbemObjectSink __RPC_FAR *pSink)
  105. {return WBEM_E_NOT_SUPPORTED;};
  106. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  107. /* [in] */ long lFlags,
  108. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler)
  109. {return WBEM_E_NOT_SUPPORTED;};
  110. HRESULT STDMETHODCALLTYPE GetObject(
  111. /* [in] */ const BSTR ObjectPath,
  112. /* [in] */ long lFlags,
  113. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  114. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  115. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  116. {return WBEM_E_NOT_SUPPORTED;};
  117. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  118. /* [in] */ const BSTR ObjectPath,
  119. /* [in] */ long lFlags,
  120. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  121. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  122. HRESULT STDMETHODCALLTYPE PutClass(
  123. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  124. /* [in] */ long lFlags,
  125. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  126. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  127. {return WBEM_E_NOT_SUPPORTED;};
  128. HRESULT STDMETHODCALLTYPE PutClassAsync(
  129. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  130. /* [in] */ long lFlags,
  131. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  132. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  133. {return WBEM_E_NOT_SUPPORTED;};
  134. HRESULT STDMETHODCALLTYPE DeleteClass(
  135. /* [in] */ const BSTR Class,
  136. /* [in] */ long lFlags,
  137. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  138. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  139. {return WBEM_E_NOT_SUPPORTED;};
  140. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  141. /* [in] */ const BSTR Class,
  142. /* [in] */ long lFlags,
  143. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  144. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  145. {return WBEM_E_NOT_SUPPORTED;};
  146. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  147. /* [in] */ const BSTR Superclass,
  148. /* [in] */ long lFlags,
  149. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  150. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  151. {return WBEM_E_NOT_SUPPORTED;};
  152. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  153. /* [in] */ const BSTR Superclass,
  154. /* [in] */ long lFlags,
  155. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  156. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  157. {return WBEM_E_NOT_SUPPORTED;};
  158. HRESULT STDMETHODCALLTYPE PutInstance(
  159. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  160. /* [in] */ long lFlags,
  161. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  162. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  163. {return WBEM_E_NOT_SUPPORTED;};
  164. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  165. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  166. /* [in] */ long lFlags,
  167. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  168. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  169. HRESULT STDMETHODCALLTYPE DeleteInstance(
  170. /* [in] */ const BSTR ObjectPath,
  171. /* [in] */ long lFlags,
  172. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  173. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  174. {return WBEM_E_NOT_SUPPORTED;};
  175. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  176. /* [in] */ const BSTR ObjectPath,
  177. /* [in] */ long lFlags,
  178. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  179. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  180. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  181. /* [in] */ const BSTR Class,
  182. /* [in] */ long lFlags,
  183. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  184. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  185. {return WBEM_E_NOT_SUPPORTED;};
  186. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  187. /* [in] */ const BSTR Class,
  188. /* [in] */ long lFlags,
  189. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  190. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  191. HRESULT STDMETHODCALLTYPE ExecQuery(
  192. /* [in] */ const BSTR QueryLanguage,
  193. /* [in] */ const BSTR Query,
  194. /* [in] */ long lFlags,
  195. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  196. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  197. {return WBEM_E_NOT_SUPPORTED;};
  198. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  199. /* [in] */ const BSTR QueryLanguage,
  200. /* [in] */ const BSTR Query,
  201. /* [in] */ long lFlags,
  202. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  203. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler) ;
  204. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  205. /* [in] */ const BSTR QueryLanguage,
  206. /* [in] */ const BSTR Query,
  207. /* [in] */ long lFlags,
  208. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  209. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum)
  210. {return WBEM_E_NOT_SUPPORTED;};
  211. HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  212. /* [in] */ const BSTR QueryLanguage,
  213. /* [in] */ const BSTR Query,
  214. /* [in] */ long lFlags,
  215. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  216. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler)
  217. {return WBEM_E_NOT_SUPPORTED;};
  218. HRESULT STDMETHODCALLTYPE ExecMethod(
  219. const BSTR,
  220. const BSTR,
  221. long,
  222. IWbemContext*,
  223. IWbemClassObject*,
  224. IWbemClassObject**,
  225. IWbemCallResult**)
  226. {return WBEM_E_NOT_SUPPORTED;}
  227. virtual HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  228. const BSTR,
  229. const BSTR,
  230. long,
  231. IWbemContext*,
  232. IWbemClassObject*,
  233. IWbemObjectSink*);
  234. protected:
  235. virtual HRESULT STDMETHODCALLTYPE DoCreateInstanceEnumAsync(
  236. /* [in] */ BSTR, // Class,
  237. /* [in] */ long, // lFlags,
  238. /* [in] */ IWbemContext __RPC_FAR *, //pCtx,
  239. /* [in] */ IWbemObjectSink __RPC_FAR * //pResponseHandler
  240. )=0;
  241. virtual HRESULT STDMETHODCALLTYPE DoDeleteInstanceAsync(
  242. /* [in] */ BSTR , //ObjectPath,
  243. /* [in] */ long, // lFlags,
  244. /* [in] */ IWbemContext __RPC_FAR *, //pCtx,
  245. /* [in] */ IWbemObjectSink __RPC_FAR * //pResponseHandler
  246. ) =0;
  247. virtual HRESULT STDMETHODCALLTYPE DoExecMethodAsync(
  248. BSTR,
  249. BSTR,
  250. long,
  251. IWbemContext*,
  252. IWbemClassObject*,
  253. IWbemObjectSink*
  254. )=0;
  255. virtual HRESULT STDMETHODCALLTYPE DoExecQueryAsync(
  256. /* [in] */ BSTR, // QueryLanguage,
  257. /* [in] */ BSTR, // Query,
  258. /* [in] */ long, // lFlags,
  259. /* [in] */ IWbemContext __RPC_FAR *, // pCtx,
  260. /* [in] */ IWbemObjectSink __RPC_FAR * //pResponseHandler
  261. ) =0;
  262. virtual HRESULT STDMETHODCALLTYPE DoGetObjectAsync(
  263. /* [in] */ BSTR ObjectPath,
  264. /* [in] */ long lFlags,
  265. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  266. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler
  267. )=0;
  268. virtual HRESULT STDMETHODCALLTYPE DoPutInstanceAsync(
  269. /* [in] */ IWbemClassObject __RPC_FAR *, //pInst,
  270. /* [in] */ long , // lFlags,
  271. /* [in] */ IWbemContext __RPC_FAR *, //pCtx,
  272. /* [in] */ IWbemObjectSink __RPC_FAR * //pResponseHandler
  273. ) =0;
  274. };
  275. class CWbemInstanceMgr
  276. {
  277. protected:
  278. IWbemObjectSink* m_pSink;
  279. IWbemClassObject **m_ppInst;
  280. DWORD m_dwThreshHold;
  281. DWORD m_dwIndex;
  282. public:
  283. CWbemInstanceMgr(
  284. IWbemObjectSink*,
  285. DWORD =50);
  286. virtual ~CWbemInstanceMgr();
  287. void Indicate(IWbemClassObject*);
  288. void SetStatus(
  289. LONG,
  290. HRESULT,
  291. BSTR,
  292. IWbemClassObject*);
  293. };
  294. #endif // end of provlib