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.

440 lines
17 KiB

  1. /*++
  2. Copyright (C) 1995-2001 Microsoft Corporation
  3. Module Name:
  4. IMPDYN.H
  5. Abstract:
  6. Declares the various generic provider classes.
  7. History:
  8. a-davj 27-Sep-95 Created.
  9. --*/
  10. #ifndef _IMPDYN_H_
  11. #define _IMPDYN_H_
  12. #include "indexcac.h"
  13. #include "cvariant.h"
  14. typedef enum {REFRESH,UPDATE} FUNCTYPE;
  15. typedef struct SET_STATUS{
  16. DWORD dwType;
  17. DWORD dwSize;
  18. DWORD dwResult;
  19. } STATSET, * PSETSTAT;
  20. #ifndef PPVOID
  21. typedef LPVOID * PPVOID;
  22. #endif //PPVOID
  23. //***************************************************************************
  24. //
  25. // CLASS NAME:
  26. //
  27. // CEnumInfo
  28. //
  29. // DESCRIPTION:
  30. //
  31. // base class of various collection objects used to keep track of instances
  32. // for enumeration.
  33. //
  34. //***************************************************************************
  35. class CEnumInfo : public CObject{
  36. public:
  37. CEnumInfo(){m_cRef = 1;};
  38. virtual ~CEnumInfo(){return;};
  39. long AddRef(void);
  40. long Release(void);
  41. private:
  42. long m_cRef; //Object reference count
  43. };
  44. //***************************************************************************
  45. //
  46. // CLASS NAME:
  47. //
  48. // CImpDyn
  49. //
  50. // DESCRIPTION:
  51. //
  52. // This is the base class of the instance providers. It does quite a lot
  53. // though the actual getting and putting of data is overriden by derived
  54. // classes.
  55. //
  56. //***************************************************************************
  57. class CImpDyn : public IWbemServices, public IWbemProviderInit
  58. {
  59. protected:
  60. long m_cRef; //Object reference count
  61. IWbemServices * m_pGateway;
  62. WCHAR wcCLSID[42];
  63. IWbemContext * m_pCtx;
  64. public:
  65. CImpDyn();
  66. virtual ~CImpDyn(void);
  67. SCODE ReturnAndSetObj(SCODE sc, IWbemCallResult FAR* FAR* ppCallResult);
  68. virtual SCODE MakeEnum(IWbemClassObject * pClass, CProvObj & ProvObj,
  69. CEnumInfo ** ppInfo) { return E_NOTIMPL;};
  70. virtual SCODE GetKey(CEnumInfo * pInfo, int iIndex, LPWSTR * ppKey)
  71. {return E_NOTIMPL;};
  72. BSTR GetKeyName(IWbemClassObject FAR* pClassInt);
  73. virtual int iGetMinTokens(void) = 0;
  74. virtual SCODE RefreshProperty(long lFlags, IWbemClassObject FAR * pClassInt,
  75. BSTR PropName,CProvObj & ProvObj,CObject * pPackage,
  76. CVariant * pVar, BOOL bTesterDetails) = 0;
  77. virtual SCODE UpdateProperty(long lFlags, IWbemClassObject FAR * pClassInt,
  78. BSTR PropName,CProvObj & ProvObj,CObject * pPackage,
  79. CVariant * pVar) = 0;
  80. virtual SCODE StartBatch(long lFlags, IWbemClassObject FAR * pClassInt,CObject **pObj,BOOL bGet);
  81. virtual void EndBatch(long lFlags, IWbemClassObject FAR * pClassInt,CObject *pObj,BOOL bGet);
  82. SCODE EnumPropDoFunc( long lFlags, IWbemClassObject FAR* pInstance, FUNCTYPE FuncType,
  83. LPWSTR pwcKey = NULL,
  84. CIndexCache * pCache = NULL,
  85. IWbemClassObject * pClass = NULL);
  86. SCODE CImpDyn::GetAttString(IWbemClassObject FAR* pClassInt, LPWSTR pPropName,
  87. LPWSTR pAttName, LPWSTR * ppResult,
  88. CIndexCache * pCache = NULL, int iIndex = -1);
  89. SCODE GetByKey( BSTR ClassRef, long lFlags, SAFEARRAY FAR* FAR* pKeyNames, SAFEARRAY FAR* FAR* pKeyValues, IWbemClassObject FAR* FAR* pObj);
  90. SCODE CreateInst( IWbemServices * pGateway, LPWSTR pwcClass,
  91. LPWSTR pKey, IWbemClassObject ** pNewInst,
  92. LPWSTR pwcKeyName = NULL,
  93. CIndexCache * pCache = NULL,
  94. IWbemContext *pCtx = NULL);
  95. virtual SCODE MethodAsync(BSTR ObjectPath, BSTR MethodName,
  96. long lFlags, IWbemContext* pCtx, IWbemClassObject* pInParams,
  97. IWbemObjectSink* pSink){return WBEM_E_NOT_SUPPORTED;};
  98. virtual SCODE MergeStrings(LPWSTR *ppOut,LPWSTR pClassContext,LPWSTR pKey,LPWSTR pPropContext);
  99. virtual bool NeedsEscapes(){return false;}; // so far, on reg prov needs this
  100. STDMETHOD_(SCODE, RefreshInstance)(THIS_ long lFlags, IWbemClassObject FAR* pObj);
  101. //Non-delegating object IUnknown
  102. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  103. STDMETHODIMP_(ULONG) AddRef(void);
  104. STDMETHODIMP_(ULONG) Release(void);
  105. /* IWbemProviderInit methods */
  106. HRESULT STDMETHODCALLTYPE Initialize(LPWSTR wszUser, long lFlags,
  107. LPWSTR wszNamespace, LPWSTR wszLocale,
  108. IWbemServices* pNamespace, IWbemContext* pContext,
  109. IWbemProviderInitSink* pSink);
  110. /* IWbemServices methods */
  111. HRESULT STDMETHODCALLTYPE OpenNamespace(
  112. /* [in] */ const BSTR Namespace,
  113. /* [in] */ long lFlags,
  114. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  115. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  116. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult){return WBEM_E_NOT_SUPPORTED;};
  117. HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  118. /* [in] */ IWbemObjectSink __RPC_FAR *pSink){return WBEM_E_NOT_SUPPORTED;};
  119. HRESULT STDMETHODCALLTYPE QueryObjectSink(
  120. /* [in] */ long lFlags,
  121. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler){return WBEM_E_NOT_SUPPORTED;};
  122. HRESULT STDMETHODCALLTYPE GetObject(
  123. /* [in] */ const BSTR ObjectPath,
  124. /* [in] */ long lFlags,
  125. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  126. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  127. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  128. HRESULT STDMETHODCALLTYPE GetObjectAsync(
  129. /* [in] */ const BSTR ObjectPath,
  130. /* [in] */ long lFlags,
  131. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  132. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  133. HRESULT STDMETHODCALLTYPE PutClass(
  134. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  135. /* [in] */ long lFlags,
  136. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  137. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult){return WBEM_E_NOT_SUPPORTED;};
  138. HRESULT STDMETHODCALLTYPE PutClassAsync(
  139. /* [in] */ IWbemClassObject __RPC_FAR *pObject,
  140. /* [in] */ long lFlags,
  141. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  142. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;};
  143. HRESULT STDMETHODCALLTYPE DeleteClass(
  144. /* [in] */ const BSTR Class,
  145. /* [in] */ long lFlags,
  146. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  147. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult){return WBEM_E_NOT_SUPPORTED;};
  148. HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  149. /* [in] */ const BSTR Class,
  150. /* [in] */ long lFlags,
  151. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  152. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;};
  153. HRESULT STDMETHODCALLTYPE CreateClassEnum(
  154. /* [in] */ const BSTR Superclass,
  155. /* [in] */ long lFlags,
  156. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  157. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum){return WBEM_E_NOT_SUPPORTED;};
  158. HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  159. /* [in] */ const BSTR Superclass,
  160. /* [in] */ long lFlags,
  161. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  162. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  163. HRESULT STDMETHODCALLTYPE PutInstance(
  164. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  165. /* [in] */ long lFlags,
  166. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  167. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult){return WBEM_E_NOT_SUPPORTED;};
  168. HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  169. /* [in] */ IWbemClassObject __RPC_FAR *pInst,
  170. /* [in] */ long lFlags,
  171. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  172. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  173. HRESULT STDMETHODCALLTYPE DeleteInstance(
  174. /* [in] */ const BSTR ObjectPath,
  175. /* [in] */ long lFlags,
  176. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  177. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult){return WBEM_E_NOT_SUPPORTED;};
  178. HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  179. /* [in] */ const BSTR ObjectPath,
  180. /* [in] */ long lFlags,
  181. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  182. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;};
  183. HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  184. /* [in] */ const BSTR Class,
  185. /* [in] */ long lFlags,
  186. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  187. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  188. HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  189. /* [in] */ const BSTR Class,
  190. /* [in] */ long lFlags,
  191. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  192. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  193. HRESULT STDMETHODCALLTYPE ExecQuery(
  194. /* [in] */ const BSTR QueryLanguage,
  195. /* [in] */ const BSTR Query,
  196. /* [in] */ long lFlags,
  197. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  198. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum){return WBEM_E_NOT_SUPPORTED;};
  199. HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  200. /* [in] */ const BSTR QueryLanguage,
  201. /* [in] */ const BSTR Query,
  202. /* [in] */ long lFlags,
  203. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  204. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler){return WBEM_E_NOT_SUPPORTED;};
  205. HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  206. /* [in] */ const BSTR QueryLanguage,
  207. /* [in] */ const BSTR Query,
  208. /* [in] */ long lFlags,
  209. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  210. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum){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){return WBEM_E_NOT_SUPPORTED;};
  217. HRESULT STDMETHODCALLTYPE ExecMethod(
  218. /* [in] */ const BSTR ObjectPath,
  219. /* [in] */ const BSTR MethodName,
  220. /* [in] */ long lFlags,
  221. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  222. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  223. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  224. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult)
  225. {return WBEM_E_NOT_SUPPORTED;};
  226. HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  227. /* [in] */ const BSTR ObjectPath,
  228. /* [in] */ const BSTR MethodName,
  229. /* [in] */ long lFlags,
  230. /* [in] */ IWbemContext __RPC_FAR *pCtx,
  231. /* [in] */ IWbemClassObject __RPC_FAR *pInParams,
  232. /* [in] */ IWbemObjectSink __RPC_FAR *pResponseHandler);
  233. };
  234. typedef CImpDyn *PCImpDyn;
  235. //***************************************************************************
  236. //
  237. // CLASS NAME:
  238. //
  239. // CImpDynProp
  240. //
  241. // DESCRIPTION:
  242. //
  243. // This is the base class of the property providers. It does quite a lot
  244. // though the actual getting and putting of data is overriden by derived
  245. // classes.
  246. //
  247. //***************************************************************************
  248. class CImpDynProp : public IWbemPropertyProvider
  249. {
  250. protected:
  251. long m_cRef; //Object reference count
  252. WCHAR wcCLSID[42];
  253. CImpDyn * m_pImpDynProv;
  254. WCHAR * BuildString(BSTR ClassMapping, BSTR InstMapping,
  255. BSTR PropMapping);
  256. public:
  257. CImpDynProp();
  258. virtual ~CImpDynProp(void);
  259. virtual bool NeedsEscapes(){return false;}; // so far, on reg prov needs this
  260. //Non-delegating object IUnknown
  261. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  262. STDMETHODIMP_(ULONG) AddRef(void);
  263. STDMETHODIMP_(ULONG) Release(void);
  264. /* IWbemPropertyProvider methods */
  265. virtual HRESULT STDMETHODCALLTYPE GetProperty(
  266. long lFlags,
  267. const BSTR Locale,
  268. const BSTR ClassMapping,
  269. const BSTR InstMapping,
  270. const BSTR PropMapping,
  271. VARIANT *pvValue);
  272. virtual HRESULT STDMETHODCALLTYPE PutProperty(
  273. long lFlags,
  274. const BSTR Locale,
  275. /* [in] */ const BSTR ClassMapping,
  276. /* [in] */ const BSTR InstMapping,
  277. /* [in] */ const BSTR PropMapping,
  278. /* [in] */ const VARIANT __RPC_FAR *pvValue);
  279. };
  280. //***************************************************************************
  281. //
  282. // CLASS NAME:
  283. //
  284. // CEnumInst
  285. //
  286. // DESCRIPTION:
  287. //
  288. // This class is used to enumerate instances
  289. //
  290. //***************************************************************************
  291. class CEnumInst : public IEnumWbemClassObject
  292. {
  293. protected:
  294. int m_iIndex;
  295. CEnumInfo * m_pEnumInfo;
  296. WCHAR * m_pwcClass;
  297. long m_lFlags;
  298. IWbemContext * m_pCtx;
  299. IWbemServices FAR* m_pWBEMGateway;
  300. CImpDyn * m_pProvider;
  301. long m_cRef;
  302. BSTR m_bstrKeyName;
  303. CIndexCache m_PropContextCache;
  304. public:
  305. CEnumInst(CEnumInfo * pEnumInfo,long lFlags,WCHAR * pClass,IWbemServices FAR* pWBEMGateway,
  306. CImpDyn * pProvider, IWbemContext *pCtx);
  307. ~CEnumInst(void);
  308. //IUnknown members
  309. STDMETHODIMP QueryInterface(REFIID, PPVOID);
  310. STDMETHODIMP_(ULONG) AddRef(void);
  311. STDMETHODIMP_(ULONG) Release(void);
  312. STDMETHOD(GetTypeInfoCount)(THIS_ UINT FAR* pctinfo){return WBEM_E_NOT_SUPPORTED;};
  313. STDMETHOD(GetTypeInfo)(
  314. THIS_
  315. UINT itinfo,
  316. LCID lcid,
  317. ITypeInfo FAR* FAR* pptinfo){return WBEM_E_NOT_SUPPORTED;};
  318. STDMETHOD(GetIDsOfNames)(
  319. THIS_
  320. REFIID riid,
  321. OLECHAR FAR* FAR* rgszNames,
  322. UINT cNames,
  323. LCID lcid,
  324. DISPID FAR* rgdispid){return WBEM_E_NOT_SUPPORTED;};
  325. STDMETHOD(Invoke)(
  326. THIS_
  327. DISPID dispidMember,
  328. REFIID riid,
  329. LCID lcid,
  330. WORD wFlags,
  331. DISPPARAMS FAR* pdispparams,
  332. VARIANT FAR* pvarResult,
  333. EXCEPINFO FAR* pexcepinfo,
  334. UINT FAR* puArgErr){return WBEM_E_NOT_SUPPORTED;};
  335. /* IEnumWbemClassObject methods */
  336. HRESULT STDMETHODCALLTYPE Reset( void);
  337. HRESULT STDMETHODCALLTYPE Next(
  338. /* [in] */ long lTimeout,
  339. /* [in] */ unsigned long uCount,
  340. /* [length_is][size_is][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  341. /* [out] */ unsigned long __RPC_FAR *puReturned);
  342. HRESULT STDMETHODCALLTYPE NextAsync(
  343. /* [in] */ unsigned long uCount,
  344. /* [in] */ IWbemObjectSink __RPC_FAR *pSink){return WBEM_E_NOT_SUPPORTED;};
  345. HRESULT STDMETHODCALLTYPE Clone(
  346. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  347. HRESULT STDMETHODCALLTYPE Skip(
  348. /* [in] */ long lTimeout,
  349. /* [in] */ unsigned long nNum);
  350. };
  351. // This structure is passed to async enumerators
  352. typedef struct {
  353. IEnumWbemClassObject FAR* pIEnum;
  354. IWbemObjectSink FAR* pHandler;
  355. } ArgStruct;
  356. // this utility is useful for setting error objects and end of async calls
  357. IWbemClassObject * GetNotifyObj(IWbemServices * pServices, long lRet, IWbemContext * pCtx);
  358. #endif //_IMPDYN_H_