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.

931 lines
30 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. WBEMNAME.H
  5. Abstract:
  6. Implements the COM layer of WINMGMT --- the class representing a namespace.
  7. It is defined in wbemname.h
  8. History:
  9. 23-Jul-96 raymcc Created.
  10. 3/10/97 levn Fully documented (ha ha)
  11. 22-Feb-00 raymcc Whistler revisions/extensions
  12. --*/
  13. #ifndef _WBEM_NAME_H_
  14. #define _WBEM_NAME_H_
  15. #include <winntsec.h>
  16. #include <statsync.h>
  17. #include <sinks.h>
  18. extern DWORD g_IdentifierLimit;
  19. extern DWORD g_QueryLimit;
  20. extern DWORD g_PathLimit;
  21. #define WBEM_FLAG_NO_STATIC 0x80000000
  22. #define WBEM_FLAG_ONLY_STATIC 0x40000000
  23. #ifdef DBG
  24. class OperationStat
  25. {
  26. enum { HistoryLength = 122 };
  27. DWORD signature;
  28. DWORD historycData_[HistoryLength];
  29. DWORD historyIndex_;
  30. DWORD opCount_;
  31. DWORD avgTime_;
  32. DWORD maxTime_;
  33. LONG zeroTime_;
  34. public:
  35. static CStaticCritSec lock_;
  36. OperationStat() :
  37. historyIndex_(0), opCount_(0), avgTime_(0), maxTime_(0),signature((DWORD)'nCpO')
  38. {
  39. memset(historycData_, 0, sizeof(historycData_)); // SEC:REVIEWED 2002-03-22 : OK, debug code only
  40. };
  41. void addTime(DWORD duration)
  42. {
  43. if (duration==0)
  44. {
  45. InterlockedIncrement(&zeroTime_);
  46. return;
  47. }
  48. if (CStaticCritSec::anyFailure()) return ;
  49. lock_.Enter();
  50. historycData_[historyIndex_++]=duration;
  51. historyIndex_%=HistoryLength;
  52. if (++opCount_ == 0) ++opCount_;
  53. double avg = (double)avgTime_ + ((double)duration-avgTime_)/opCount_;
  54. avgTime_ = (DWORD)avg;
  55. if (duration > maxTime_)
  56. {
  57. maxTime_ = duration;
  58. };
  59. lock_.Leave();
  60. };
  61. };
  62. class TimeTraces
  63. {
  64. public:
  65. typedef enum{ GetObject=0, GetObjectByPath, ExecQuery, ExecMethod, DeleteInstance, DeleteClass, CreateInstanceEnum, CreateClassEnum, PutClass, PutInstance, Invalid } tracedOp;
  66. TimeTraces() :zeroTime_(0) {};
  67. void addTime(tracedOp operation, DWORD duration)
  68. {
  69. if (duration==0) InterlockedIncrement(&zeroTime_);
  70. _DBG_ASSERT(operation >= GetObject);
  71. _DBG_ASSERT(operation < Invalid);
  72. allCounters[operation].addTime(duration);
  73. }
  74. private:
  75. OperationStat allCounters[Invalid];
  76. LONG zeroTime_;
  77. };
  78. extern TimeTraces gTimeTraceHistory;
  79. class TimeTrace
  80. {
  81. TimeTraces::tracedOp operation_;
  82. DWORD start_;
  83. public:
  84. TimeTrace(TimeTraces::tracedOp operation ):
  85. operation_(operation), start_(GetTickCount())
  86. { }
  87. ~TimeTrace()
  88. {
  89. gTimeTraceHistory.addTime(operation_, GetTickCount()-start_);
  90. }
  91. };
  92. #define TIMETRACE(x) TimeTrace timeTrace(x);
  93. #else
  94. #define TIMETRACE(x)
  95. #endif
  96. class CFlexAceArray;
  97. class CBasicObjectSink;
  98. class CComplexProjectionSink;
  99. class CDynasty;
  100. class CAsyncReq;
  101. class CWmiMerger;
  102. struct SAssocTriad
  103. {
  104. IWbemClassObject *m_pEp1;
  105. IWbemClassObject *m_pEp2;
  106. IWbemClassObject *m_pAssoc;
  107. SAssocTriad() { m_pEp1 = 0; m_pEp2 = 0; m_pAssoc = 0; }
  108. ~SAssocTriad() { ReleaseIfNotNULL(m_pEp1); ReleaseIfNotNULL(m_pEp2); ReleaseIfNotNULL(m_pAssoc); }
  109. static void ArrayCleanup(CFlexArray &Array)
  110. {
  111. for (int i = 0; i < Array.Size(); i++)
  112. delete (SAssocTriad *) Array[i];
  113. Array.Empty();
  114. }
  115. };
  116. //******************************************************************************
  117. //******************************************************************************
  118. //
  119. // class CWbemNamespace
  120. //
  121. // This class represents the COM layer of WINMGMT --- what the client sees. An
  122. // instance of this class is created whenever a namespace is opened by a client
  123. // (at the moment, we don't cache namespace pointers, so if a client opens the
  124. // same namespace twice, we will create to of these).
  125. //
  126. //******************************************************************************
  127. //
  128. // Constructor
  129. //
  130. // Enumerates all the class providers in this namespace (instances of
  131. // __Win32Provider with the method mask indicating a class provider), loads
  132. // them all and initializes them by calling ConnectServer.
  133. //
  134. //******************************************************************************
  135. //*************************** interface IWbemServices **************************
  136. //
  137. // See help for documentation of the IWbemServices interface.
  138. //
  139. //******************************************************************************
  140. //************************** helper functions **********************************
  141. //
  142. // Are documented in the wbemname.cpp file.
  143. //
  144. //******************************************************************************
  145. typedef void * IWbemServicesEx;
  146. typedef void * IWbemCallResultEx;
  147. class CWbemNamespace :
  148. public IWbemServices,
  149. public IWbemInternalServices
  150. {
  151. public:
  152. protected:
  153. friend class CQueryEngine;
  154. ULONG m_uSecondaryRefCount;
  155. BOOL m_bShutDown;
  156. //
  157. DWORD Status;
  158. IWmiDbSession *m_pSession;
  159. IWmiDbController *m_pDriver;
  160. IWmiDbHandle *m_pNsHandle;
  161. IWmiDbHandle *m_pScopeHandle;
  162. _IWmiArbitrator *m_pArb;
  163. BOOL m_bSubscope;
  164. LPWSTR m_pThisNamespaceFull;
  165. LPWSTR m_pThisNamespace;
  166. DWORD m_dwPermission;
  167. DWORD m_dwSecurityFlags;
  168. LPWSTR m_wszUserName;
  169. BOOL m_bProvider;
  170. BOOL m_bESS;
  171. BOOL m_bForClient;
  172. CCritSec m_cs;
  173. WString m_wsLocale;
  174. CNtSecurityDescriptor m_sd;
  175. CNtSecurityDescriptor m_sdCheckAdmin;
  176. BOOL m_bSecurityInitialized;
  177. _IWmiProviderFactory *m_pProvFact;
  178. _IWmiCoreServices *m_pCoreSvc;
  179. BOOL m_bRepositOnly;
  180. IUnknown *m_pRefreshingSvc;
  181. LPWSTR m_pszClientMachineName;
  182. DWORD m_dwClientProcessID;
  183. LIST_ENTRY m_Entry; // for the Global Counter
  184. public:
  185. LIST_ENTRY m_EntryArb; // for the arbitrator
  186. protected:
  187. // No access
  188. CWbemNamespace();
  189. ~CWbemNamespace();
  190. // Async impl entry points
  191. virtual HRESULT STDMETHODCALLTYPE _GetObjectAsync(
  192. IN ULONG uInternalFlags,
  193. IN _IWmiFinalizer *p,
  194. IN _IWmiCoreHandle *phTask,
  195. IN const BSTR strObjectPath,
  196. IN long lFlags,
  197. IN IWbemContext __RPC_FAR *pCtx,
  198. IN IWbemObjectSink __RPC_FAR *pResponseHandler
  199. );
  200. virtual HRESULT STDMETHODCALLTYPE _PutClassAsync(
  201. IN ULONG uInternalFlags,
  202. IN _IWmiFinalizer *p,
  203. IN _IWmiCoreHandle *phTask,
  204. IN IWbemClassObject __RPC_FAR *pObject,
  205. IN long lFlags,
  206. IN IWbemContext __RPC_FAR *pCtx,
  207. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  208. virtual HRESULT STDMETHODCALLTYPE _DeleteClassAsync(
  209. IN ULONG uInternalFlags,
  210. IN _IWmiFinalizer *p,
  211. IN _IWmiCoreHandle *phTask,
  212. IN const BSTR strClass,
  213. IN long lFlags,
  214. IN IWbemContext __RPC_FAR *pCtx,
  215. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  216. virtual HRESULT STDMETHODCALLTYPE _CreateClassEnumAsync(
  217. IN ULONG uInternalFlags,
  218. IN _IWmiFinalizer *p,
  219. IN _IWmiCoreHandle *phTask,
  220. IN const BSTR strSuperclass,
  221. IN long lFlags,
  222. IN IWbemContext __RPC_FAR *pCtx,
  223. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  224. virtual HRESULT STDMETHODCALLTYPE _PutInstanceAsync(
  225. IN ULONG uInternalFlags,
  226. IN _IWmiFinalizer *p,
  227. IN _IWmiCoreHandle *phTask,
  228. IN IWbemClassObject __RPC_FAR *pInst,
  229. IN long lFlags,
  230. IN IWbemContext __RPC_FAR *pCtx,
  231. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  232. virtual HRESULT STDMETHODCALLTYPE _DeleteInstanceAsync(
  233. IN ULONG uInternalFlags,
  234. IN _IWmiFinalizer *p,
  235. IN _IWmiCoreHandle *phTask,
  236. IN const BSTR strObjectPath,
  237. IN long lFlags,
  238. IN IWbemContext __RPC_FAR *pCtx,
  239. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  240. virtual HRESULT STDMETHODCALLTYPE _CreateInstanceEnumAsync(
  241. IN ULONG uInternalFlags,
  242. IN _IWmiFinalizer *p,
  243. IN _IWmiCoreHandle *phTask,
  244. IN const BSTR strFilter,
  245. IN long lFlags,
  246. IN IWbemContext __RPC_FAR *pCtx,
  247. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  248. virtual HRESULT STDMETHODCALLTYPE _ExecQueryAsync(
  249. IN ULONG uInternalFlags,
  250. IN _IWmiFinalizer *p,
  251. IN _IWmiCoreHandle *phTask,
  252. IN const BSTR strQueryLanguage,
  253. IN const BSTR strQuery,
  254. IN long lFlags,
  255. IN IWbemContext __RPC_FAR *pCtx,
  256. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  257. virtual HRESULT STDMETHODCALLTYPE _ExecNotificationQueryAsync(
  258. IN ULONG uInternalFlags,
  259. IN _IWmiFinalizer *p,
  260. IN _IWmiCoreHandle *phTask,
  261. IN const BSTR strQueryLanguage,
  262. IN const BSTR strQuery,
  263. IN long lFlags,
  264. IN IWbemContext __RPC_FAR *pCtx,
  265. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  266. virtual HRESULT STDMETHODCALLTYPE _ExecMethodAsync(
  267. IN ULONG uInternalFlags,
  268. IN _IWmiFinalizer *p,
  269. IN _IWmiCoreHandle *phTask,
  270. IN const BSTR strObjectPath,
  271. IN const BSTR strMethodName,
  272. IN long lFlags,
  273. IN IWbemContext __RPC_FAR *pCtx,
  274. IN IWbemClassObject __RPC_FAR *pInParams,
  275. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  276. HRESULT CreateNamespace(CWbemInstance *pNewInst);
  277. public:
  278. /* IUnknown methods */
  279. STDMETHOD(QueryInterface)(REFIID riid, LPVOID FAR* ppvObj);
  280. STDMETHOD_(ULONG, AddRef)(THIS);
  281. STDMETHOD_(ULONG, Release)(THIS);
  282. // Real entry points
  283. // IWbemServices
  284. virtual HRESULT STDMETHODCALLTYPE OpenNamespace(
  285. IN const BSTR strNamespace,
  286. IN long lFlags,
  287. IN IWbemContext __RPC_FAR *pCtx,
  288. /* [unique][in][out] */ IWbemServices __RPC_FAR *__RPC_FAR *ppWorkingNamespace,
  289. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppResult);
  290. virtual HRESULT STDMETHODCALLTYPE CancelAsyncCall(
  291. IN IWbemObjectSink __RPC_FAR *pSink);
  292. virtual HRESULT STDMETHODCALLTYPE QueryObjectSink(
  293. IN long lFlags,
  294. /* [out] */ IWbemObjectSink __RPC_FAR *__RPC_FAR *ppResponseHandler);
  295. virtual HRESULT STDMETHODCALLTYPE GetObject(
  296. IN const BSTR strObjectPath,
  297. IN long lFlags,
  298. IN IWbemContext __RPC_FAR *pCtx,
  299. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppObject,
  300. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  301. virtual HRESULT STDMETHODCALLTYPE GetObjectAsync(
  302. IN const BSTR strObjectPath,
  303. IN long lFlags,
  304. IN IWbemContext __RPC_FAR *pCtx,
  305. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  306. virtual HRESULT STDMETHODCALLTYPE PutClass(
  307. IN IWbemClassObject __RPC_FAR *pObject,
  308. IN long lFlags,
  309. IN IWbemContext __RPC_FAR *pCtx,
  310. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  311. virtual HRESULT STDMETHODCALLTYPE PutClassAsync(
  312. IN IWbemClassObject __RPC_FAR *pObject,
  313. IN long lFlags,
  314. IN IWbemContext __RPC_FAR *pCtx,
  315. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  316. virtual HRESULT STDMETHODCALLTYPE DeleteClass(
  317. IN const BSTR strClass,
  318. IN long lFlags,
  319. IN IWbemContext __RPC_FAR *pCtx,
  320. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  321. virtual HRESULT STDMETHODCALLTYPE DeleteClassAsync(
  322. IN const BSTR strClass,
  323. IN long lFlags,
  324. IN IWbemContext __RPC_FAR *pCtx,
  325. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  326. virtual HRESULT STDMETHODCALLTYPE CreateClassEnum(
  327. IN const BSTR strSuperclass,
  328. IN long lFlags,
  329. IN IWbemContext __RPC_FAR *pCtx,
  330. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  331. virtual HRESULT STDMETHODCALLTYPE CreateClassEnumAsync(
  332. IN const BSTR strSuperclass,
  333. IN long lFlags,
  334. IN IWbemContext __RPC_FAR *pCtx,
  335. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  336. virtual HRESULT STDMETHODCALLTYPE PutInstance(
  337. IN IWbemClassObject __RPC_FAR *pInst,
  338. IN long lFlags,
  339. IN IWbemContext __RPC_FAR *pCtx,
  340. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  341. virtual HRESULT STDMETHODCALLTYPE PutInstanceAsync(
  342. IN IWbemClassObject __RPC_FAR *pInst,
  343. IN long lFlags,
  344. IN IWbemContext __RPC_FAR *pCtx,
  345. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  346. virtual HRESULT STDMETHODCALLTYPE DeleteInstance(
  347. IN const BSTR strObjectPath,
  348. IN long lFlags,
  349. IN IWbemContext __RPC_FAR *pCtx,
  350. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  351. virtual HRESULT STDMETHODCALLTYPE DeleteInstanceAsync(
  352. IN const BSTR strObjectPath,
  353. IN long lFlags,
  354. IN IWbemContext __RPC_FAR *pCtx,
  355. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  356. virtual HRESULT STDMETHODCALLTYPE CreateInstanceEnum(
  357. IN const BSTR strFilter,
  358. IN long lFlags,
  359. IN IWbemContext __RPC_FAR *pCtx,
  360. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  361. virtual HRESULT STDMETHODCALLTYPE CreateInstanceEnumAsync(
  362. IN const BSTR strFilter,
  363. IN long lFlags,
  364. IN IWbemContext __RPC_FAR *pCtx,
  365. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  366. virtual HRESULT STDMETHODCALLTYPE ExecQuery(
  367. IN const BSTR strQueryLanguage,
  368. IN const BSTR strQuery,
  369. IN long lFlags,
  370. IN IWbemContext __RPC_FAR *pCtx,
  371. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  372. virtual HRESULT STDMETHODCALLTYPE ExecQueryAsync(
  373. IN const BSTR strQueryLanguage,
  374. IN const BSTR strQuery,
  375. IN long lFlags,
  376. IN IWbemContext __RPC_FAR *pCtx,
  377. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  378. virtual HRESULT STDMETHODCALLTYPE ExecNotificationQuery(
  379. IN const BSTR strQueryLanguage,
  380. IN const BSTR strQuery,
  381. IN long lFlags,
  382. IN IWbemContext __RPC_FAR *pCtx,
  383. /* [out] */ IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum);
  384. virtual HRESULT STDMETHODCALLTYPE ExecNotificationQueryAsync(
  385. IN const BSTR strQueryLanguage,
  386. IN const BSTR strQuery,
  387. IN long lFlags,
  388. IN IWbemContext __RPC_FAR *pCtx,
  389. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  390. virtual HRESULT STDMETHODCALLTYPE ExecMethod(
  391. IN const BSTR strObjectPath,
  392. IN const BSTR strMethodName,
  393. IN long lFlags,
  394. IN IWbemContext __RPC_FAR *pCtx,
  395. IN IWbemClassObject __RPC_FAR *pInParams,
  396. /* [unique][in][out] */ IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  397. /* [unique][in][out] */ IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult);
  398. virtual HRESULT STDMETHODCALLTYPE ExecMethodAsync(
  399. IN const BSTR strObjectPath,
  400. IN const BSTR strMethodName,
  401. IN long lFlags,
  402. IN IWbemContext __RPC_FAR *pCtx,
  403. IN IWbemClassObject __RPC_FAR *pInParams,
  404. IN IWbemObjectSink __RPC_FAR *pResponseHandler);
  405. // IWbemInternalServices
  406. STDMETHOD(FindKeyRoot)(LPCWSTR wszClassName,
  407. IWbemClassObject** ppKeyRootClass);
  408. STDMETHOD(InternalGetClass)(
  409. LPCWSTR wszClassName,
  410. IWbemClassObject** ppClass);
  411. STDMETHOD(InternalGetInstance)(
  412. LPCWSTR wszPath,
  413. IWbemClassObject** ppInstance);
  414. STDMETHOD(InternalExecQuery)(
  415. LPCWSTR wszQueryLanguage,
  416. LPCWSTR wszQuery,
  417. long lFlags,
  418. IWbemObjectSink* pSink);
  419. STDMETHOD(InternalCreateInstanceEnum)(
  420. LPCWSTR wszClassName,
  421. long lFlags,
  422. IWbemObjectSink* pSink);
  423. STDMETHOD(GetDbInstance)(
  424. LPCWSTR wszDbKey,
  425. IWbemClassObject** ppInstance);
  426. STDMETHOD(GetDbReferences)(
  427. IWbemClassObject* pEndpoint,
  428. IWbemObjectSink* pSink);
  429. STDMETHOD(InternalPutInstance)(
  430. IWbemClassObject* pInst);
  431. // Other
  432. STDMETHOD(GetNormalizedPath)( BSTR pstrPath, BSTR* pstrStandardPath );
  433. static CWbemNamespace* CreateInstance();
  434. HRESULT Initialize(
  435. LPWSTR pName,
  436. LPWSTR wszUserName,
  437. DWORD dwSecFlags,
  438. DWORD dwPermission,
  439. BOOL bForClient,
  440. BOOL bRepositOnly,
  441. LPCWSTR pszClientMachineName,
  442. DWORD dwClientProcessID,
  443. BOOL bSkipSDInitialize,
  444. IWmiDbSession *pParentSession
  445. );
  446. public:
  447. IWmiDbHandle *GetNsHandle() { return m_pNsHandle; }
  448. IWmiDbSession *GetNsSession() { return m_pSession; }
  449. IWmiDbHandle *GetScope() { return m_pScopeHandle; }
  450. BOOL IsSubscope() { return m_bSubscope; }
  451. INTERNAL LPWSTR GetName() {return m_pThisNamespace;}
  452. INTERNAL LPWSTR GetNameFull() {return m_pThisNamespaceFull;}
  453. DWORD& GetStatus() {return Status;}
  454. INTERNAL LPWSTR GetUserName() {return m_wszUserName;} // SEC:REVIEWED 2002-03-22 : OK
  455. //INTERNAL void SetUserName(LPWSTR wName);
  456. DWORD GetSecurityFlags() {return m_dwSecurityFlags;}
  457. bool Allowed(DWORD dwRequired);
  458. void SetIsProvider(BOOL bProvider)
  459. {m_bProvider = bProvider;}
  460. void SetIsESS ( BOOL bESS )
  461. { m_bESS = bESS; }
  462. BOOL GetIsESS ( ) { return m_bESS; }
  463. BOOL GetIsProvider ( ) { return m_bProvider ; }
  464. void SetLocale(LPCWSTR wszLocale) {m_wsLocale = wszLocale;}
  465. LPCWSTR GetLocale() {return m_wsLocale;}
  466. LPWSTR GetClientMachine(){return m_pszClientMachineName;};
  467. DWORD GetClientProcID(){return m_dwClientProcessID;};
  468. HRESULT AdjustPutContext(IWbemContext *pCtx);
  469. HRESULT MergeGetKeysCtx(IN IWbemContext *pCtx);
  470. HRESULT SplitLocalized (CWbemObject *pOriginal, CWbemObject *pStoredObj = NULL);
  471. HRESULT FixAmendedQualifiers(IWbemQualifierSet *pOriginal, IWbemQualifierSet *pNew);
  472. // Worker functions for sync/async
  473. // ===============================
  474. HRESULT Exec_DeleteClass(LPWSTR wszClass, long lFlags,
  475. IWbemContext* pContext, CBasicObjectSink* pSink);
  476. HRESULT Exec_GetObjectByPath(READONLY LPWSTR wszObjectPath, long lFlags,
  477. IWbemContext* pContext, IWbemClassObject** ppObj,
  478. IWbemClassObject** ppErrorObj);
  479. HRESULT Exec_GetObject(READONLY LPWSTR wszObjectPath, long lFlags,
  480. IWbemContext* pContext, CBasicObjectSink* pSink);
  481. HRESULT Exec_DeleteInstance(LPWSTR wszObjectPath, long lFlags,
  482. IWbemContext* pContext, CBasicObjectSink* pSink);
  483. HRESULT Exec_PutClass(IWbemClassObject* pClass, long lFlags,
  484. IWbemContext* pContext, CBasicObjectSink* pSink, BOOL fIsInternal = FALSE);
  485. HRESULT Exec_PutInstance(IWbemClassObject* pInstance, long lFlags,
  486. IWbemContext* pContext, CBasicObjectSink* pSink);
  487. HRESULT Exec_CreateClassEnum(LPWSTR wszParent, long lFlags,
  488. IWbemContext* pContext, CBasicObjectSink* pSink);
  489. HRESULT Exec_CreateInstanceEnum(LPWSTR wszClass, long lFlags,
  490. IWbemContext* pContext, CBasicObjectSink* pSink);
  491. HRESULT Exec_ExecMethod(LPWSTR wszObjectPath, LPWSTR wszMethodName,
  492. long lFlags, IWbemClassObject *pInParams, IWbemContext *pCtx,
  493. CBasicObjectSink* pSink);
  494. static HRESULT Exec_CancelAsyncCall(IWbemObjectSink* pSink);
  495. static HRESULT Exec_CancelProvAsyncCall( IWbemServices* pProv, IWbemObjectSink* pSink );
  496. HRESULT GetImplementationClass(IWbemClassObject *pTestObj,
  497. LPWSTR wszMethodName, IWbemContext* pCtx,
  498. IWbemClassObject **pClassObj);
  499. HRESULT Exec_GetInstance(LPCWSTR wszObjectPath,
  500. IWbemPath* pParsedPath, long lFlags, IWbemContext* Context,
  501. CBasicObjectSink* pSink);
  502. HRESULT Exec_GetClass(LPCWSTR wszClassName,
  503. long lFlags, IWbemContext* Context, CBasicObjectSink* pSink);
  504. // HRESULT SetErrorObj(IWbemClassObject* pErrorObj);
  505. HRESULT RecursivePutInstance(CWbemInstance* pInst,
  506. CWbemClass* pClassDef, long lFlags, IWbemContext* pContext,
  507. CBasicObjectSink* pSink, BOOL bLast);
  508. HRESULT DeleteSingleInstance(
  509. READONLY LPWSTR wszObjectPath, long lFlags, IWbemContext* pContext,
  510. CBasicObjectSink* pSink);
  511. HRESULT InternalPutStaticClass( IWbemClassObject* pClass );
  512. HRESULT DeleteObject(const BSTR strObjectPath,
  513. long lFlags,
  514. IWbemContext *pCtx,IWbemCallResult **ppCallResult);
  515. // Assoc-by-rule helpers
  516. // =====================
  517. HRESULT ManufactureAssocs(
  518. IN IWbemClassObject *pAssocClass,
  519. IN IWbemClassObject *pEp, // Optional
  520. IN IWbemContext *pCtx,
  521. IN LPWSTR pszJoinQuery,
  522. OUT CFlexArray &aTriads
  523. );
  524. HRESULT BuildAssocTriads(
  525. IN IWbemClassObject *pAssocClass,
  526. IN IWbemClassObject *pClsDef1,
  527. IN IWbemClassObject *pClsDef2,
  528. IN LPWSTR pszJoinProp1,
  529. IN LPWSTR pszJoinProp2,
  530. IN LPWSTR pszAssocRef1, // Prop which points to EP1
  531. IN LPWSTR pszAssocRef2, // Prop which points to EP2
  532. IN CFlexArray &aEp1,
  533. IN CFlexArray &aEp2,
  534. IN OUT CFlexArray &aTriads
  535. );
  536. HRESULT BuildRuleBasedPathToInst(
  537. IN IWbemClassObject *pEp,
  538. IN LPWSTR pszJoinProp1,
  539. IN IWbemClassObject *pEp2,
  540. IN LPWSTR pszJoinProp2,
  541. OUT WString &wsNewPath);
  542. HRESULT ExtractEpInfoFromQuery(
  543. IWbemQuery *pQuery,
  544. wmilib::auto_buffer<WCHAR> & pszClass1,
  545. wmilib::auto_buffer<WCHAR> & pszProp1,
  546. wmilib::auto_buffer<WCHAR> & pClass2,
  547. wmilib::auto_buffer<WCHAR> & pszProp2);
  548. HRESULT MapAssocRefsToClasses(
  549. IN IWbemClassObject *pAssocClass,
  550. IN IWbemClassObject *pClsDef1,
  551. IN IWbemClassObject *pClsDef2,
  552. wmilib::auto_buffer<WCHAR> & pszAssocRef1,
  553. wmilib::auto_buffer<WCHAR> & pszAssocRef2);
  554. // Property provider access.
  555. // =========================
  556. typedef enum {GET, PUT} Operation;
  557. HRESULT GetOrPutDynProps (
  558. IWbemClassObject *pObj,
  559. Operation op,
  560. BOOL bIsDynamic = false
  561. );
  562. HRESULT Exec_DynAux_GetInstances (
  563. READONLY CWbemObject *pClassDef,
  564. long lFlags,
  565. IWbemContext* pCtx,
  566. CBasicObjectSink* pSink
  567. ) ;
  568. HRESULT DynAux_GetInstances (
  569. CWbemObject *pClassDef,
  570. long lFlags,
  571. IWbemContext* pContext,
  572. CBasicObjectSink* pSink,
  573. BOOL bComplexQuery
  574. ) ;
  575. HRESULT DynAux_GetInstance (
  576. LPWSTR pObjPath,
  577. long lFlags,
  578. IWbemContext* pContext,
  579. CBasicObjectSink* pSink
  580. );
  581. HRESULT DynAux_AskRecursively (
  582. CDynasty* pDynasty,
  583. long lFlags,
  584. LPWSTR wszObjectPath,
  585. IWbemContext* pContext,
  586. CBasicObjectSink* pSink
  587. );
  588. HRESULT DynAux_GetSingleInstance (
  589. CWbemClass* pClassDef,
  590. long lFlags,
  591. LPWSTR wszObjectPath,
  592. IWbemContext* pContext,
  593. CBasicObjectSink* pSink
  594. );
  595. HRESULT Exec_DynAux_ExecQueryAsync (
  596. CWbemObject* pClassDef,
  597. LPWSTR Query,
  598. LPWSTR QueryFormat,
  599. long lFlags,
  600. IWbemContext* pCtx,
  601. CBasicObjectSink* pSink
  602. ) ;
  603. HRESULT DynAux_ExecQueryAsync (
  604. CWbemObject* pClassDef,
  605. LPWSTR Query,
  606. LPWSTR QueryFormat,
  607. long lFlags,
  608. IWbemContext* pContext,
  609. CBasicObjectSink* pSink,
  610. BOOL bComplexQuery
  611. );
  612. HRESULT DynAux_ExecQueryExtendedAsync(
  613. LPWSTR wsProvider,
  614. LPWSTR Query,
  615. LPWSTR QueryFormat,
  616. long lFlags,
  617. IWbemContext* pCtx,
  618. CComplexProjectionSink* pSink
  619. ) ;
  620. HRESULT GetObjectByFullPath(
  621. READONLY LPWSTR wszObjectPath,
  622. IWbemPath * pOutput,
  623. long lFlags,
  624. IWbemContext* pContext,
  625. CBasicObjectSink* pSink
  626. );
  627. HRESULT DynAux_BuildClassHierarchy(IN LPWSTR wszClassName,
  628. IN LONG lFlags,
  629. IN IWbemContext* pContext,
  630. OUT wmilib::auto_ptr<CDynasty> & pDynasty,
  631. OUT IWbemClassObject** ppErrorObj);
  632. HRESULT DynAux_BuildChainUp(IN IWbemContext* pContext,
  633. OUT wmilib::auto_ptr<CDynasty> & ppTop,
  634. OUT IWbemClassObject** ppErrorObj);
  635. HRESULT DecorateObject(IWbemClassObject* pObject);
  636. static HRESULT IsPutRequiredForClass(CWbemClass* pClass,
  637. CWbemInstance* pInst, IWbemContext* pContext,
  638. BOOL bParentTakenCareOf);
  639. static HRESULT DoesNeedToBePut(LPCWSTR wszName, CWbemInstance* pInst,
  640. BOOL bRestrictedPut, BOOL bStrictNulls, BOOL bPropertyList,
  641. CWStringArray& awsProperties);
  642. static HRESULT GetContextPutExtensions(IWbemContext* pContext,
  643. BOOL& bRestrictedPut, BOOL& bStrictNulls, BOOL& bPropertyList,
  644. CWStringArray& awsProperties);
  645. static HRESULT GetContextBoolean(IWbemContext* pContext,
  646. LPCWSTR wszName, BOOL* pbValue);
  647. HRESULT GetAceList(CFlexAceArray **);
  648. HRESULT PutAceList(CFlexAceArray *);
  649. HRESULT InitializeSD(IWmiDbSession *pSession);
  650. CNtSecurityDescriptor & GetSDRef(){return m_sd;};
  651. DWORD GetUserAccess();
  652. DWORD GetNTUserAccess();
  653. HRESULT EnsureSecurity();
  654. void SetPermissions(DWORD dwPerm){m_dwPermission = dwPerm;};
  655. HRESULT InitializeUserLists(CFlexAceArray & AllowList,CFlexAceArray & DenyList);
  656. HRESULT SecurityMethod(LPWSTR wszMethodName, long lFlags,
  657. IWbemClassObject *pInParams, IWbemContext *pCtx, IWbemObjectSink* pSink);
  658. HRESULT GetSDMethod(IWbemClassObject* pOutParams);
  659. HRESULT RecursiveSDMerge();
  660. BOOL IsNamespaceSDProtected();
  661. HRESULT GetParentsInheritableAces(CNtSecurityDescriptor &sd);
  662. HRESULT SetSDMethod(IWbemClassObject* pInParams);
  663. HRESULT GetCallerAccessRightsMethod(IWbemClassObject* pOutParams);
  664. BOOL IsForClient(){return m_bForClient;};
  665. HRESULT EnumerateSecurityClassInstances(LPWSTR wszClassName,
  666. IWbemObjectSink* pOwnSink, IWbemContext* pContext, long lFlags);
  667. HRESULT PutSecurityClassInstances(LPWSTR wszClassName, IWbemClassObject * pClass,
  668. IWbemObjectSink* pSink, IWbemContext* pContext, long lFlags);
  669. HRESULT DeleteSecurityClassInstances(ParsedObjectPath* pParsedPath,
  670. IWbemObjectSink* pSink, IWbemContext* pContext, long lFlags);
  671. HRESULT GetSecurityClassInstances(ParsedObjectPath* pParsedPath, CBasicObjectSink* pSink,
  672. IWbemContext* pContext,long lFlags);
  673. HRESULT CheckNs();
  674. HRESULT InitNewTask(
  675. IN CAsyncReq *pReq,
  676. IN _IWmiFinalizer *pFnz,
  677. IN ULONG uTaskType,
  678. IN IWbemContext *pCtx,
  679. IN IWbemObjectSink *pAsyncClientSink
  680. );
  681. HRESULT CreateAsyncFinalizer(
  682. IN IWbemContext *pContext,
  683. IN IWbemObjectSink *pStartingSink,
  684. IN _IWmiFinalizer **pFnz,
  685. OUT IWbemObjectSink **pResultSinkEx
  686. );
  687. HRESULT CreateSyncFinalizer(
  688. IN IWbemContext *pContext,
  689. IN _IWmiFinalizer **pFnz
  690. );
  691. HRESULT ExecSyncQuery(
  692. IN LPWSTR pszQuery,
  693. IN IWbemContext *pCtx,
  694. IN LONG lFlags,
  695. OUT CFlexArray &aDest
  696. );
  697. // Helper function to shell db queries out to different threads as appropriate
  698. HRESULT Static_QueryRepository(
  699. READONLY CWbemObject *pClassDef,
  700. long lFlags,
  701. IWbemContext* pCtx,
  702. CBasicObjectSink* pSink ,
  703. QL_LEVEL_1_RPN_EXPRESSION* pParsedQuery,
  704. LPCWSTR pwszClassName,
  705. CWmiMerger* pWmiMerger
  706. );
  707. // Two primary connect functions.
  708. // ==============================
  709. static HRESULT UniversalConnect(
  710. IN CWbemNamespace *pParent,
  711. IN IWbemContext *pCtx,
  712. IN LPCWSTR pszNewScope,
  713. IN LPCWSTR pszAssocSelector,
  714. IN LPCWSTR pszUserName,
  715. IN _IWmiCallSec *pCallSec,
  716. IN _IWmiUserHandle *pUser,
  717. IN DWORD dwUserFlags,
  718. IN DWORD dwInternalFlags,
  719. IN DWORD dwSecFlags,
  720. IN DWORD dwPermission,
  721. IN BOOL bForClient,
  722. IN BOOL bRepositOnly,
  723. IN LPCWSTR pszClientMachineName,
  724. IN DWORD dwClientProcessID,
  725. IN REFIID riid,
  726. OUT LPVOID *pConnection
  727. );
  728. static HRESULT PathBasedConnect(
  729. IN LPCWSTR pszPath,
  730. IN LPCWSTR pszUser,
  731. IN IWbemContext __RPC_FAR *pCtx,
  732. IN ULONG uClientFlags,
  733. IN DWORD dwSecFlags,
  734. IN DWORD dwPermissions,
  735. IN ULONG uInternalFlags,
  736. IN LPCWSTR pszClientMachineName,
  737. IN DWORD dwClientProcessID,
  738. IN REFIID riid,
  739. /* [iid_is][out] */ void __RPC_FAR *__RPC_FAR *pServices
  740. );
  741. void StopClientCalls(){m_bShutDown = TRUE;};
  742. HRESULT Dump(FILE *f); // Debug only
  743. _IWmiCoreServices* GetCoreServices( void ) { return m_pCoreSvc; }
  744. HRESULT GetDynamicReferenceClasses( long lFlags, IWbemContext* pCtx, IWbemObjectSink* pSink );
  745. };
  746. #endif