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.

2413 lines
56 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. XXXX
  5. Abstract:
  6. History:
  7. --*/
  8. #include "precomp.h"
  9. #include <wbemint.h>
  10. #include <wmiutils.h>
  11. #include <strsafe.h>
  12. #include "Globals.h"
  13. #include "ProvRegDeCoupled.h"
  14. #include "CGlobals.h"
  15. #include "provcache.h"
  16. #include "aggregator.h"
  17. #include "ProvWsvS.h"
  18. #include "ProvWsv.h"
  19. #include "ProvInSk.h"
  20. #include "ProvobSk.h"
  21. /******************************************************************************
  22. *
  23. * Name:
  24. *
  25. *
  26. * Description:
  27. *
  28. *
  29. *****************************************************************************/
  30. DCProxyAggr :: DCProxyAggr ( ) :
  31. m_ReferenceCount ( 0 ) ,
  32. m_UnRegistered( -1 ),
  33. m_Allocator ( *DecoupledProviderSubSystem_Globals :: s_Allocator ),
  34. CWbemGlobal_IWmiObjectSinkController ( *DecoupledProviderSubSystem_Globals :: s_Allocator ),
  35. m_Sink(NULL),
  36. initialized_(false),
  37. m_Controller(0),
  38. m_CriticalSection(NOTHROW_LOCK)
  39. {
  40. }
  41. /******************************************************************************
  42. *
  43. * Name:
  44. *
  45. *
  46. * Description:
  47. *
  48. *
  49. *****************************************************************************/
  50. DCProxyAggr :: ~DCProxyAggr ()
  51. {
  52. #ifdef _DBG
  53. if (m_UnRegistered != -1) DebugBreak();
  54. #endif
  55. CWbemGlobal_IWmiObjectSinkController :: UnInitialize () ;
  56. if ( m_Controller )
  57. {
  58. CWbemGlobal_IWbemSyncProvider_Container *t_Container = NULL ;
  59. m_Controller->GetContainer ( t_Container ) ;
  60. m_Controller->Lock () ;
  61. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator = t_Container->Begin () ;
  62. while ( ! t_Iterator.Null () )
  63. {
  64. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  65. t_Container->Delete ( t_Element->GetKey () ) ;
  66. m_Controller->UnLock () ;
  67. t_Element->Release () ;
  68. m_Controller->Lock () ;
  69. t_Iterator = t_Container->Begin () ;
  70. }
  71. m_Controller->UnLock () ;
  72. m_Controller->UnInitialize () ;
  73. m_Controller->Release () ;
  74. }
  75. }
  76. void DCProxyAggr::activate()
  77. {
  78. LONG registerCount = InterlockedIncrement(&m_UnRegistered);
  79. if (registerCount == 0) // is the first aggregator
  80. {
  81. const DC_DBkey key( m_User, m_Locale, m_Namespace, m_ProviderName);
  82. DC_registrar::instance()->RegisterAggregator(key, auto_ref<DCProxyAggr>(this));
  83. }
  84. };
  85. void DCProxyAggr::deActivate()
  86. {
  87. LONG registerCount = InterlockedDecrement(&m_UnRegistered);
  88. if ( registerCount < 0 ) DC_registrar::instance()->UnRegisterAggregator (auto_ref<DCProxyAggr>(this));
  89. };
  90. /******************************************************************************
  91. *
  92. * Name:
  93. *
  94. *
  95. * Description:
  96. *
  97. *
  98. *****************************************************************************/
  99. STDMETHODIMP_(ULONG) DCProxyAggr :: AddRef ( void )
  100. {
  101. return InterlockedIncrement(&m_ReferenceCount) ;
  102. }
  103. /******************************************************************************
  104. *
  105. * Name:
  106. *
  107. *
  108. * Description:
  109. *
  110. *
  111. *****************************************************************************/
  112. STDMETHODIMP_(ULONG) DCProxyAggr :: Release ( void )
  113. {
  114. LONG t_Reference = InterlockedDecrement(&m_ReferenceCount);
  115. if ( 0 == t_Reference )
  116. {
  117. delete this ;
  118. return 0 ;
  119. }
  120. else
  121. {
  122. return t_Reference ;
  123. }
  124. }
  125. // IWbemServices
  126. /******************************************************************************
  127. *
  128. * Name:
  129. *
  130. *
  131. * Description:
  132. *
  133. *
  134. *****************************************************************************/
  135. template <class TInterface, const IID *TInterface_Id>
  136. HRESULT GetProviders (
  137. IWbemContext *a_Context ,
  138. CWbemGlobal_IWbemSyncProviderController *a_Controller ,
  139. TInterface **&a_Elements ,
  140. ULONG &a_ElementCount ,
  141. ULONG &a_ContainerCount
  142. )
  143. {
  144. HRESULT t_Result = S_OK ;
  145. CWbemGlobal_IWbemSyncProvider_Container *t_Container = NULL ;
  146. WmiStatusCode t_StatusCode = a_Controller->GetContainer ( t_Container ) ;
  147. a_Controller->Lock () ;
  148. a_ContainerCount = t_Container->Size () ;
  149. a_Elements = new TInterface * [ t_Container->Size () ] ;
  150. if ( a_Elements )
  151. {
  152. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator = t_Container->Begin () ;
  153. a_ElementCount = 0 ;
  154. while ( ! t_Iterator.Null () )
  155. {
  156. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  157. a_Elements [ a_ElementCount ] = NULL ;
  158. _IWmiProviderInitialize *t_Initializer = NULL ;
  159. t_Result = t_Element->QueryInterface (
  160. IID__IWmiProviderInitialize ,
  161. ( void ** ) & t_Initializer
  162. ) ;
  163. if ( SUCCEEDED ( t_Result ) )
  164. {
  165. t_Result = t_Initializer->WaitProvider ( a_Context , DEFAULT_PROVIDER_LOAD_TIMEOUT ) ;
  166. if ( SUCCEEDED ( t_Result ) )
  167. {
  168. HRESULT t_Result = t_Element->QueryInterface ( *TInterface_Id , ( void ** ) & a_Elements [ a_ElementCount ] ) ;
  169. if ( SUCCEEDED ( t_Result ) )
  170. {
  171. a_ElementCount ++ ;
  172. }
  173. }
  174. t_Initializer->Release () ;
  175. }
  176. t_Iterator.Increment () ;
  177. }
  178. }
  179. else
  180. {
  181. t_Result = WBEM_E_OUT_OF_MEMORY ;
  182. }
  183. a_Controller->UnLock () ;
  184. return t_Result ;
  185. }
  186. /******************************************************************************
  187. *
  188. * Name:
  189. *
  190. *
  191. * Description:
  192. *
  193. *
  194. *****************************************************************************/
  195. template <class TInterface >
  196. HRESULT GetProviders (
  197. CWbemGlobal_IWbemSyncProviderController *a_Controller ,
  198. TInterface **&a_Elements ,
  199. ULONG &a_ElementCount
  200. )
  201. {
  202. HRESULT t_Result = S_OK ;
  203. CWbemGlobal_IWbemSyncProvider_Container *t_Container = NULL ;
  204. WmiStatusCode t_StatusCode = a_Controller->GetContainer ( t_Container ) ;
  205. a_Controller->Lock () ;
  206. a_Elements = new TInterface * [ t_Container->Size () ] ;
  207. if ( a_Elements )
  208. {
  209. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator = t_Container->Begin () ;
  210. a_ElementCount = 0 ;
  211. while ( ! t_Iterator.Null () )
  212. {
  213. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  214. a_Elements [ a_ElementCount ] = NULL ;
  215. HRESULT t_TempResult = t_Element->QueryInterface ( __uuidof(TInterface) , ( void ** ) & a_Elements [ a_ElementCount ] ) ;
  216. if ( SUCCEEDED ( t_TempResult ) )
  217. {
  218. a_ElementCount ++ ;
  219. }
  220. t_Iterator.Increment () ;
  221. }
  222. }
  223. else
  224. {
  225. t_Result = WBEM_E_OUT_OF_MEMORY ;
  226. }
  227. a_Controller->UnLock () ;
  228. return t_Result ;
  229. }
  230. /******************************************************************************
  231. *
  232. * Name:
  233. *
  234. *
  235. * Description:
  236. *
  237. *
  238. *****************************************************************************/
  239. template <class TInterface>
  240. HRESULT ClearProviders (
  241. TInterface **a_Elements ,
  242. ULONG a_ElementCount
  243. )
  244. {
  245. HRESULT t_Result = S_OK ;
  246. for ( ULONG t_Index = 0 ; t_Index < a_ElementCount ; t_Index ++ )
  247. {
  248. a_Elements [ t_Index ]->Release () ;
  249. }
  250. delete [] a_Elements ;
  251. return t_Result ;
  252. }
  253. /******************************************************************************
  254. *
  255. * Name:
  256. *
  257. *
  258. * Description:
  259. *
  260. *
  261. *****************************************************************************/
  262. HRESULT DCProxyAggr :: Initialize (
  263. LPWSTR a_User,
  264. LONG a_Flags,
  265. LPWSTR a_Namespace,
  266. LPWSTR a_Locale,
  267. LPWSTR a_ProviderName,
  268. IWbemServices *a_CoreService, // For anybody
  269. IWbemContext *a_Context,
  270. IWbemProviderInitSink *a_Sink // For init signals
  271. )
  272. {
  273. if ( initialized() )
  274. return a_Sink->SetStatus ( WBEM_S_NO_ERROR , 0 ) ;
  275. if( !a_Sink)
  276. return WBEM_E_INVALID_PARAMETER;
  277. if(!a_CoreService )
  278. return a_Sink->SetStatus ( WBEM_E_INVALID_PARAMETER , 0 ) ;
  279. m_context = a_Context;
  280. if (m_context == 0) // Create a default context or the test provider will fail !
  281. m_context.CreateInstance(CLSID_WbemContext);
  282. if (m_context == 0)
  283. return a_Sink->SetStatus ( WBEM_E_OUT_OF_MEMORY , 0 ) ;
  284. m_CoreService = a_CoreService;
  285. m_Flags = a_Flags;
  286. try{
  287. m_User = a_User;
  288. m_Locale = a_Locale;
  289. m_Namespace = a_Namespace;
  290. m_ProviderName = a_ProviderName;
  291. }
  292. catch( _com_error& err){
  293. return a_Sink->SetStatus ( WBEM_E_OUT_OF_MEMORY , 0 ) ;
  294. }
  295. HRESULT t_Result = S_OK ;
  296. WmiStatusCode t_StatusCode = CWbemGlobal_IWmiObjectSinkController :: Initialize () ;
  297. if ( t_StatusCode != e_StatusCode_Success )
  298. {
  299. t_Result = WBEM_E_OUT_OF_MEMORY ;
  300. }
  301. t_Result = m_NamespacePath.CreateInstance(CLSID_WbemDefPath, NULL, CLSCTX_INPROC_SERVER);
  302. if ( SUCCEEDED ( t_Result ) )
  303. {
  304. t_Result = m_NamespacePath->SetText ( WBEMPATH_TREAT_SINGLE_IDENT_AS_NS | WBEMPATH_CREATE_ACCEPT_ALL , a_Namespace ) ;
  305. }
  306. if ( SUCCEEDED ( t_Result ) )
  307. {
  308. m_Controller = new CWbemGlobal_IWbemSyncProviderController ( m_Allocator ) ;
  309. if ( m_Controller )
  310. {
  311. m_Controller->AddRef () ;
  312. t_StatusCode = m_Controller->Initialize () ;
  313. if ( t_StatusCode != e_StatusCode_Success )
  314. {
  315. t_Result = WBEM_E_OUT_OF_MEMORY ;
  316. }
  317. }
  318. else
  319. {
  320. t_Result = WBEM_E_OUT_OF_MEMORY ;
  321. }
  322. }
  323. LoadAll();
  324. a_Sink->SetStatus ( t_Result , 0 ) ;
  325. return t_Result ;
  326. }
  327. /******************************************************************************
  328. *
  329. * Name:
  330. *
  331. *
  332. * Description:
  333. *
  334. *
  335. *****************************************************************************/
  336. HRESULT DCProxyAggr :: CreateSyncProvider (
  337. IUnknown *a_ServerSideProvider ,
  338. IWbemServices *a_Stub ,
  339. wchar_t *a_NamespacePath ,
  340. LONG a_Flags ,
  341. IWbemContext *a_Context ,
  342. LPCWSTR a_User ,
  343. LPCWSTR a_Locale ,
  344. LPCWSTR a_Scope ,
  345. CServerObject_ProviderRegistrationV1 &a_Registration ,
  346. GUID a_Identity ,
  347. CInterceptor_IWbemDecoupledProvider *&a_Interceptor
  348. )
  349. {
  350. HRESULT t_Result = S_OK ;
  351. CInterceptor_IWbemDecoupledProvider *t_Interceptor = new CInterceptor_IWbemDecoupledProvider (
  352. m_Allocator ,
  353. a_ServerSideProvider ,
  354. a_Stub ,
  355. m_Controller ,
  356. a_Context ,
  357. a_Registration ,
  358. a_Identity
  359. ) ;
  360. if ( t_Interceptor )
  361. {
  362. /*
  363. * One for the cache
  364. */
  365. t_Interceptor->AddRef () ;
  366. _IWmiProviderInitialize *t_InterceptorInit = NULL ;
  367. t_Result = t_Interceptor->QueryInterface ( IID__IWmiProviderInitialize , ( void ** ) & t_InterceptorInit ) ;
  368. if ( SUCCEEDED ( t_Result ) )
  369. {
  370. CServerObject_ProviderInitSink *t_ProviderInitSink = new CServerObject_ProviderInitSink ;
  371. if ( t_ProviderInitSink )
  372. {
  373. t_ProviderInitSink->AddRef () ;
  374. t_Result = t_ProviderInitSink->SinkInitialize () ;
  375. if ( SUCCEEDED ( t_Result ) )
  376. {
  377. CInterceptor_IWbemProviderInitSink *t_Sink = new CInterceptor_IWbemProviderInitSink ( t_ProviderInitSink ) ;
  378. if ( t_Sink )
  379. {
  380. t_Sink->AddRef () ;
  381. t_Result = t_InterceptorInit->Initialize (
  382. 0 ,
  383. a_Context ,
  384. NULL ,
  385. a_Registration.GetComRegistration ().PerUserInitialization () ? ( BSTR ) a_User : NULL ,
  386. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( BSTR ) a_Locale : NULL ,
  387. a_NamespacePath ,
  388. NULL ,
  389. NULL ,
  390. t_Sink
  391. ) ;
  392. if ( SUCCEEDED ( t_Result ) )
  393. {
  394. t_ProviderInitSink->Wait () ;
  395. t_Result = t_ProviderInitSink->GetResult () ;
  396. }
  397. t_Sink->Release () ;
  398. }
  399. else
  400. {
  401. t_Result = WBEM_E_OUT_OF_MEMORY ;
  402. }
  403. }
  404. t_ProviderInitSink->Release () ;
  405. }
  406. else
  407. {
  408. t_Result = WBEM_E_OUT_OF_MEMORY ;
  409. }
  410. t_InterceptorInit->Release () ;
  411. }
  412. if ( SUCCEEDED ( t_Result ) )
  413. {
  414. t_Interceptor->AddRef () ;
  415. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator ;
  416. WmiStatusCode t_StatusCode = m_Controller->Insert (
  417. *t_Interceptor ,
  418. t_Iterator
  419. ) ;
  420. if ( t_StatusCode == e_StatusCode_Success )
  421. {
  422. }
  423. else
  424. {
  425. t_Result = WBEM_E_OUT_OF_MEMORY ;
  426. }
  427. m_Controller->UnLock () ;
  428. }
  429. else
  430. {
  431. m_Controller->UnLock () ;
  432. }
  433. t_Interceptor->SetInitialized ( t_Result ) ;
  434. if ( SUCCEEDED ( t_Result ) )
  435. {
  436. a_Interceptor = t_Interceptor ;
  437. }
  438. else
  439. {
  440. t_Interceptor->Release () ;
  441. }
  442. }
  443. else
  444. {
  445. m_Controller->UnLock () ;
  446. t_Result = WBEM_E_OUT_OF_MEMORY ;
  447. }
  448. return t_Result ;
  449. }
  450. /******************************************************************************
  451. *
  452. * Name:
  453. *
  454. *
  455. * Description:
  456. *
  457. *
  458. *****************************************************************************/
  459. HRESULT
  460. DCProxyAggr :: Register ( DC_reg& reg, bool validate )
  461. {
  462. DC_DBkey key( m_User, m_Locale, m_Namespace, m_ProviderName);
  463. if( !key.equal(reg) )
  464. return S_OK;
  465. HRESULT t_Result = S_OK ;
  466. // Check the client pointer
  467. IUnknown * pUnk = reg.service();
  468. if (pUnk == 0)
  469. return WBEM_E_PROVIDER_FAILURE;
  470. try
  471. {
  472. CServerObject_ProviderRegistrationV1 *t_Registration = new CServerObject_ProviderRegistrationV1 ;
  473. if ( t_Registration )
  474. {
  475. t_Registration->AddRef () ;
  476. t_Result = t_Registration->SetContext (
  477. m_context ,
  478. m_NamespacePath ,
  479. m_CoreService
  480. ) ;
  481. if ( SUCCEEDED ( t_Result ) )
  482. {
  483. t_Result = t_Registration->Load (
  484. e_All ,
  485. m_NamespacePath ,
  486. reg.GetProvider()
  487. ) ;
  488. if ( SUCCEEDED ( t_Result ) )
  489. {
  490. if (validate)
  491. {
  492. t_Result = OS::CoImpersonateClient();
  493. if (SUCCEEDED(t_Result))
  494. {
  495. t_Result = ProviderSubSystem_Common_Globals::ValidateClientSecurity (*t_Registration);
  496. CoRevertToSelf();
  497. }
  498. }
  499. if ( SUCCEEDED ( t_Result ) )
  500. {
  501. m_Controller->Lock () ;
  502. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator ;
  503. WmiStatusCode t_StatusCode = m_Controller->Find ( reg.identity() , t_Iterator ) ;
  504. if ( t_StatusCode != e_StatusCode_Success )
  505. {
  506. CInterceptor_IWbemServices_Stub *t_Stub = new CInterceptor_IWbemServices_Stub ( m_Allocator , m_CoreService.GetInterfacePtr() ) ;
  507. CInterceptor_IWbemDecoupledProvider * t_Provider = NULL;
  508. if ( t_Stub )
  509. {
  510. t_Stub->AddRef () ;
  511. CInterceptor_IWbemDecoupledProvider *t_Interceptor = NULL ;
  512. t_Result = CreateSyncProvider (
  513. pUnk ,
  514. t_Stub ,
  515. reg.GetScope() ,
  516. 0 ,
  517. m_context ,
  518. reg.GetUser() ,
  519. reg.GetLocale() ,
  520. NULL ,
  521. *t_Registration ,
  522. reg.identity(),
  523. t_Interceptor
  524. ) ;
  525. if ( SUCCEEDED ( t_Result ) )
  526. {
  527. IUnknown *t_Unknown = NULL ;
  528. t_Result = t_Interceptor->QueryInterface ( IID_IUnknown , ( void ** ) & t_Unknown ) ;
  529. if ( SUCCEEDED ( t_Result ) )
  530. {
  531. t_Result = InitializeProvider (
  532. t_Unknown ,
  533. t_Stub ,
  534. reg.GetScope() ,
  535. m_Flags ,
  536. m_context ,
  537. reg.GetUser() ,
  538. reg.GetLocale() ,
  539. NULL ,
  540. *t_Registration
  541. ) ;
  542. if ( SUCCEEDED ( t_Result ) )
  543. {
  544. if ( m_Sink )
  545. {
  546. IWbemEventProvider *t_EvProvider = NULL ;
  547. t_Result = t_Unknown->QueryInterface ( IID_IWbemEventProvider , ( void ** ) & t_EvProvider ) ;
  548. if ( SUCCEEDED ( t_Result ) )
  549. {
  550. t_Result = t_EvProvider->ProvideEvents ( (IWbemObjectSink *)m_Sink , 0 ) ;
  551. t_EvProvider->Release () ;
  552. }
  553. m_Sink->SetStatus (
  554. WBEM_STATUS_REQUIREMENTS,
  555. WBEM_REQUIREMENTS_RECHECK_SUBSCRIPTIONS,
  556. NULL,
  557. NULL
  558. ) ;
  559. }
  560. }
  561. t_Unknown->Release () ;
  562. }
  563. t_Interceptor->Release () ;
  564. }
  565. t_Stub->Release () ;
  566. }
  567. else
  568. {
  569. m_Controller->UnLock () ;
  570. t_Result = WBEM_E_OUT_OF_MEMORY ;
  571. }
  572. }
  573. else
  574. {
  575. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  576. m_Controller->UnLock () ;
  577. t_Element->Release () ;
  578. t_Result = S_OK ;
  579. }
  580. }
  581. }
  582. }
  583. t_Registration->Release () ;
  584. }
  585. else
  586. {
  587. t_Result = WBEM_E_OUT_OF_MEMORY ;
  588. }
  589. }
  590. catch ( ... )
  591. {
  592. t_Result = WBEM_E_PROVIDER_FAILURE ;
  593. }
  594. return t_Result ;
  595. }
  596. /******************************************************************************
  597. *
  598. * Name:
  599. *
  600. *
  601. * Description:
  602. *
  603. *
  604. *****************************************************************************/
  605. HRESULT
  606. DCProxyAggr :: UnRegister ( GUID a_Identity )
  607. {
  608. HRESULT t_Result = S_OK ;
  609. try
  610. {
  611. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator ;
  612. IWbemShutdown *t_Shutdown = NULL ;
  613. m_Controller->Lock () ;
  614. WmiStatusCode t_StatusCode = m_Controller->Find ( a_Identity , t_Iterator ) ;
  615. if ( t_StatusCode == e_StatusCode_Success )
  616. {
  617. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  618. t_Result = t_Element->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  619. m_Controller->Delete ( a_Identity ) ;
  620. m_Controller->UnLock () ;
  621. if ( SUCCEEDED ( t_Result ) && t_Shutdown )
  622. {
  623. t_Result = t_Shutdown->Shutdown (
  624. 0 ,
  625. 0 ,
  626. NULL
  627. ) ;
  628. t_Shutdown->Release () ;
  629. }
  630. /*
  631. * One for the find.
  632. */
  633. t_Element->Release () ;
  634. /*
  635. * Removed reference due the cache.
  636. */
  637. t_Element->Release () ;
  638. }
  639. else
  640. {
  641. m_Controller->UnLock () ;
  642. }
  643. }
  644. catch ( ... )
  645. {
  646. t_Result = WBEM_E_PROVIDER_FAILURE ;
  647. }
  648. return t_Result ;
  649. }
  650. /******************************************************************************
  651. *
  652. * Name:
  653. *
  654. *
  655. * Description:
  656. *
  657. *
  658. *****************************************************************************/
  659. HRESULT
  660. DCProxyAggr :: UnRegister ( const CInterceptor_IWbemDecoupledProvider& provider )
  661. {
  662. CInterceptor_IWbemDecoupledProvider& prov = const_cast<CInterceptor_IWbemDecoupledProvider&>(provider);
  663. return UnRegister(prov.GetKey());
  664. }
  665. /******************************************************************************
  666. *
  667. * Name:
  668. *
  669. *
  670. * Description:
  671. *
  672. *
  673. *****************************************************************************/
  674. HRESULT
  675. DCProxyAggr :: InitializeProvider (
  676. IUnknown *a_Unknown ,
  677. IWbemServices *a_Stub ,
  678. wchar_t *a_NamespacePath ,
  679. LONG a_Flags ,
  680. IWbemContext *a_Context ,
  681. LPCWSTR a_User ,
  682. LPCWSTR a_Locale ,
  683. LPCWSTR a_Scope ,
  684. CServerObject_ProviderRegistrationV1 &a_Registration
  685. )
  686. {
  687. HRESULT t_Result = S_OK ;
  688. IWbemProviderInit *t_ProviderInit = NULL ;
  689. t_Result = a_Unknown->QueryInterface ( IID_IWbemProviderInit , ( void ** ) & t_ProviderInit ) ;
  690. if ( SUCCEEDED ( t_Result ) )
  691. {
  692. CServerObject_ProviderInitSink *t_ProviderInitSink = new CServerObject_ProviderInitSink ;
  693. if ( t_ProviderInitSink )
  694. {
  695. t_ProviderInitSink->AddRef () ;
  696. t_Result = t_ProviderInitSink->SinkInitialize (a_Registration.GetComRegistration ().GetSecurityDescriptor ()) ;
  697. CInterceptor_IWbemProviderInitSink *t_Sink = new CInterceptor_IWbemProviderInitSink ( t_ProviderInitSink ) ;
  698. if ( t_Sink )
  699. {
  700. t_Sink->AddRef () ;
  701. try
  702. {
  703. BOOL t_Impersonating = FALSE ;
  704. IUnknown *t_OldContext = NULL ;
  705. IServerSecurity *t_OldSecurity = NULL ;
  706. t_Result = DecoupledProviderSubSystem_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  707. if ( SUCCEEDED ( t_Result ) )
  708. {
  709. t_Result = t_ProviderInit->Initialize (
  710. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  711. 0 ,
  712. ( const BSTR ) a_NamespacePath ,
  713. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  714. a_Stub ,
  715. a_Context ,
  716. t_Sink
  717. ) ;
  718. if ( SUCCEEDED ( t_Result ) )
  719. {
  720. t_ProviderInitSink->Wait () ;
  721. t_Result = t_ProviderInitSink->GetResult () ;
  722. }
  723. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  724. }
  725. }
  726. catch ( ... )
  727. {
  728. t_Result = WBEM_E_PROVIDER_FAILURE ;
  729. }
  730. t_Sink->Release();
  731. }
  732. else
  733. {
  734. t_Result = WBEM_E_OUT_OF_MEMORY ;
  735. }
  736. t_ProviderInitSink->Release () ;
  737. }
  738. else
  739. {
  740. t_Result = WBEM_E_OUT_OF_MEMORY ;
  741. }
  742. t_ProviderInit->Release () ;
  743. }
  744. return t_Result ;
  745. }
  746. /******************************************************************************
  747. *
  748. * Name:
  749. *
  750. *
  751. * Description:
  752. *
  753. *
  754. *****************************************************************************/
  755. HRESULT DCProxyAggr :: GetObjectAsync (
  756. const BSTR a_ObjectPath,
  757. long a_Flags,
  758. IWbemContext *a_Context,
  759. IWbemObjectSink *a_Sink
  760. )
  761. {
  762. BOOL t_ObjectGot = FALSE ;
  763. IWbemServices **t_Elements = NULL ;
  764. ULONG t_ElementsCount = 0 ;
  765. HRESULT t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  766. if ( SUCCEEDED ( t_Result ) )
  767. {
  768. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  769. {
  770. CInterceptor_IWbemWaitingObjectSink *t_GettingSink = new CInterceptor_IWbemWaitingObjectSink (
  771. m_Allocator ,
  772. ( CWbemGlobal_IWmiObjectSinkController * ) this
  773. ) ;
  774. if ( t_GettingSink )
  775. {
  776. t_GettingSink->AddRef () ;
  777. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  778. Lock () ;
  779. WmiStatusCode t_StatusCode = Insert (
  780. *t_GettingSink ,
  781. t_Iterator
  782. ) ;
  783. UnLock () ;
  784. if ( t_StatusCode == e_StatusCode_Success )
  785. {
  786. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  787. t_Result = t_Provider->GetObjectAsync (
  788. a_ObjectPath ,
  789. 0 ,
  790. a_Context,
  791. t_GettingSink
  792. ) ;
  793. if ( SUCCEEDED ( t_Result ) )
  794. {
  795. t_Result = t_GettingSink->Wait ( INFINITE ) ;
  796. if ( SUCCEEDED ( t_Result ) )
  797. {
  798. t_Result = t_GettingSink->GetResult () ;
  799. if ( SUCCEEDED ( t_Result ) )
  800. {
  801. t_ObjectGot = TRUE ;
  802. }
  803. else
  804. {
  805. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  806. {
  807. t_Result = S_OK ;
  808. }
  809. }
  810. }
  811. }
  812. else if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  813. {
  814. t_Result = S_OK ;
  815. }
  816. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  817. {
  818. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  819. UnRegister(*last_interceptor);
  820. t_Result = S_OK ;
  821. }
  822. }
  823. else
  824. {
  825. t_Result = WBEM_E_OUT_OF_MEMORY ;
  826. }
  827. WmiQueue <IWbemClassObject *,8> &t_Queue = t_GettingSink->GetQueue () ;
  828. IWbemClassObject *t_Object = NULL ;
  829. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  830. {
  831. if ( SUCCEEDED ( t_Result ) )
  832. {
  833. t_Result = a_Sink->Indicate ( 1 , & t_Object ) ;
  834. }
  835. t_Object->Release () ;
  836. t_StatusCode = t_Queue.DeQueue () ;
  837. }
  838. t_GettingSink->Release () ;
  839. }
  840. else
  841. {
  842. t_Result = WBEM_E_OUT_OF_MEMORY ;
  843. }
  844. }
  845. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  846. }
  847. if ( SUCCEEDED ( t_Result ) )
  848. {
  849. if ( t_ObjectGot == FALSE )
  850. {
  851. t_Result = WBEM_E_NOT_FOUND ;
  852. }
  853. }
  854. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  855. return t_Result ;
  856. }
  857. /******************************************************************************
  858. *
  859. * Name:
  860. *
  861. *
  862. * Description:
  863. *
  864. *
  865. *****************************************************************************/
  866. HRESULT DCProxyAggr :: PutClassAsync (
  867. IWbemClassObject *a_Object,
  868. long a_Flags,
  869. IWbemContext *a_Context,
  870. IWbemObjectSink *a_Sink
  871. )
  872. {
  873. BOOL t_ClassPut = FALSE ;
  874. IWbemServices **t_Elements = NULL ;
  875. ULONG t_ElementsCount = 0 ;
  876. HRESULT t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  877. if ( SUCCEEDED ( t_Result ) )
  878. {
  879. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  880. {
  881. CInterceptor_IWbemWaitingObjectSink *t_ClassPuttingSink = new CInterceptor_IWbemWaitingObjectSink (
  882. m_Allocator ,
  883. ( CWbemGlobal_IWmiObjectSinkController * ) this
  884. ) ;
  885. if ( t_ClassPuttingSink )
  886. {
  887. t_ClassPuttingSink->AddRef () ;
  888. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  889. Lock () ;
  890. WmiStatusCode t_StatusCode = Insert (
  891. *t_ClassPuttingSink ,
  892. t_Iterator
  893. ) ;
  894. UnLock () ;
  895. if ( t_StatusCode == e_StatusCode_Success )
  896. {
  897. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  898. t_Result = t_Provider->PutClassAsync (
  899. a_Object ,
  900. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  901. a_Context,
  902. t_ClassPuttingSink
  903. ) ;
  904. if ( SUCCEEDED ( t_Result ) )
  905. {
  906. t_Result = t_ClassPuttingSink->Wait ( INFINITE ) ;
  907. if ( SUCCEEDED ( t_Result ) )
  908. {
  909. if ( SUCCEEDED ( t_ClassPuttingSink->GetResult () ) )
  910. {
  911. t_ClassPut = TRUE ;
  912. }
  913. }
  914. else
  915. {
  916. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  917. {
  918. t_Result = S_OK ;
  919. }
  920. }
  921. }
  922. else
  923. {
  924. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  925. {
  926. t_Result = S_OK ;
  927. }
  928. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  929. {
  930. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  931. UnRegister(*last_interceptor);
  932. t_Result = S_OK ;
  933. }
  934. }
  935. }
  936. else
  937. {
  938. t_Result = WBEM_E_OUT_OF_MEMORY ;
  939. }
  940. WmiQueue <IWbemClassObject *,8> &t_Queue = t_ClassPuttingSink->GetQueue () ;
  941. IWbemClassObject *t_Object = NULL ;
  942. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  943. {
  944. t_Object->Release () ;
  945. t_StatusCode = t_Queue.DeQueue () ;
  946. }
  947. t_ClassPuttingSink->Release () ;
  948. }
  949. else
  950. {
  951. t_Result = WBEM_E_OUT_OF_MEMORY ;
  952. }
  953. }
  954. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  955. }
  956. if ( SUCCEEDED ( t_Result ) )
  957. {
  958. if ( t_ClassPut == FALSE )
  959. {
  960. t_Result = WBEM_E_NOT_FOUND ;
  961. }
  962. }
  963. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  964. return t_Result ;
  965. }
  966. /******************************************************************************
  967. *
  968. * Name:
  969. *
  970. *
  971. * Description:
  972. *
  973. *
  974. *****************************************************************************/
  975. HRESULT DCProxyAggr :: DeleteClassAsync (
  976. const BSTR a_Class,
  977. long a_Flags,
  978. IWbemContext *a_Context,
  979. IWbemObjectSink *a_Sink
  980. )
  981. {
  982. BOOL t_ClassDeleted = FALSE ;
  983. IWbemServices **t_Elements = NULL ;
  984. ULONG t_ElementsCount = 0 ;
  985. HRESULT t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  986. if ( SUCCEEDED ( t_Result ) )
  987. {
  988. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  989. {
  990. CInterceptor_IWbemWaitingObjectSink *t_ClassDeletingSink = new CInterceptor_IWbemWaitingObjectSink (
  991. m_Allocator ,
  992. ( CWbemGlobal_IWmiObjectSinkController * ) this
  993. ) ;
  994. if ( t_ClassDeletingSink )
  995. {
  996. t_ClassDeletingSink->AddRef () ;
  997. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  998. Lock () ;
  999. WmiStatusCode t_StatusCode = Insert (
  1000. *t_ClassDeletingSink ,
  1001. t_Iterator
  1002. ) ;
  1003. UnLock () ;
  1004. if ( t_StatusCode == e_StatusCode_Success )
  1005. {
  1006. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1007. t_Result = t_Provider->DeleteClassAsync (
  1008. a_Class ,
  1009. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  1010. a_Context,
  1011. t_ClassDeletingSink
  1012. ) ;
  1013. if ( SUCCEEDED ( t_Result ) )
  1014. {
  1015. t_Result = t_ClassDeletingSink->Wait ( INFINITE ) ;
  1016. if ( SUCCEEDED ( t_Result ) )
  1017. {
  1018. if ( SUCCEEDED ( t_ClassDeletingSink->GetResult () ) )
  1019. {
  1020. t_ClassDeleted = TRUE ;
  1021. }
  1022. }
  1023. else
  1024. {
  1025. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1026. {
  1027. t_Result = S_OK ;
  1028. }
  1029. }
  1030. }
  1031. else
  1032. {
  1033. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1034. {
  1035. t_Result = S_OK ;
  1036. }
  1037. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1038. {
  1039. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1040. UnRegister(*last_interceptor);
  1041. t_Result = S_OK ;
  1042. }
  1043. }
  1044. }
  1045. else
  1046. {
  1047. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1048. }
  1049. WmiQueue <IWbemClassObject *,8> &t_Queue = t_ClassDeletingSink->GetQueue () ;
  1050. IWbemClassObject *t_Object = NULL ;
  1051. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  1052. {
  1053. t_Object->Release () ;
  1054. t_StatusCode = t_Queue.DeQueue () ;
  1055. }
  1056. t_ClassDeletingSink->Release () ;
  1057. }
  1058. else
  1059. {
  1060. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1061. }
  1062. }
  1063. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1064. }
  1065. if ( SUCCEEDED ( t_Result ) )
  1066. {
  1067. if ( t_ClassDeleted == FALSE )
  1068. {
  1069. t_Result = WBEM_E_NOT_FOUND ;
  1070. }
  1071. }
  1072. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1073. return t_Result ;
  1074. }
  1075. /******************************************************************************
  1076. *
  1077. * Name:
  1078. *
  1079. *
  1080. * Description:
  1081. *
  1082. *
  1083. *****************************************************************************/
  1084. SCODE DCProxyAggr :: CreateClassEnumAsync (
  1085. const BSTR a_Superclass ,
  1086. long a_Flags,
  1087. IWbemContext *a_Context,
  1088. IWbemObjectSink *a_Sink
  1089. )
  1090. {
  1091. HRESULT t_Result = S_OK ;
  1092. CInterceptor_DecoupledIWbemCombiningObjectSink *t_CombiningSink = new CInterceptor_DecoupledIWbemCombiningObjectSink (
  1093. m_Allocator ,
  1094. a_Sink ,
  1095. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1096. ) ;
  1097. if ( t_CombiningSink )
  1098. {
  1099. t_CombiningSink->AddRef () ;
  1100. t_CombiningSink->Suspend () ;
  1101. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1102. Lock () ;
  1103. WmiStatusCode t_StatusCode = Insert (
  1104. *t_CombiningSink ,
  1105. t_Iterator
  1106. ) ;
  1107. UnLock () ;
  1108. if ( t_StatusCode == e_StatusCode_Success )
  1109. {
  1110. IWbemServices **t_Elements = NULL ;
  1111. ULONG t_ElementsCount = 0 ;
  1112. t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1113. if ( SUCCEEDED ( t_Result ) )
  1114. {
  1115. BOOL t_ProviderFound = FALSE ;
  1116. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1117. {
  1118. CInterceptor_DecoupledIWbemObjectSink *t_Sink = new CInterceptor_DecoupledIWbemObjectSink (
  1119. t_CombiningSink ,
  1120. ( IWbemObjectSink * ) t_CombiningSink ,
  1121. ( CWbemGlobal_IWmiObjectSinkController * ) t_CombiningSink
  1122. ) ;
  1123. if ( t_Sink )
  1124. {
  1125. t_Sink->AddRef () ;
  1126. t_Result = t_CombiningSink->EnQueue ( t_Sink ) ;
  1127. if ( SUCCEEDED ( t_Result ) )
  1128. {
  1129. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1130. t_Result = t_Provider->CreateClassEnumAsync (
  1131. a_Superclass ,
  1132. a_Flags,
  1133. a_Context,
  1134. t_Sink
  1135. ) ;
  1136. if ( SUCCEEDED ( t_Result ) )
  1137. {
  1138. }
  1139. else
  1140. {
  1141. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1142. {
  1143. t_Result = S_OK ;
  1144. }
  1145. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1146. {
  1147. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1148. UnRegister(*last_interceptor);
  1149. t_Result = S_OK ;
  1150. }
  1151. }
  1152. }
  1153. t_Sink->Release () ;
  1154. }
  1155. else
  1156. {
  1157. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1158. }
  1159. }
  1160. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1161. }
  1162. if ( SUCCEEDED ( t_Result ) && t_ElementsCount )
  1163. {
  1164. t_CombiningSink->Resume () ;
  1165. t_Result = t_CombiningSink->Wait ( INFINITE ) ;
  1166. }
  1167. else
  1168. {
  1169. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1170. }
  1171. }
  1172. else
  1173. {
  1174. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1175. }
  1176. t_CombiningSink->Release () ;
  1177. }
  1178. else
  1179. {
  1180. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1181. }
  1182. return t_Result ;
  1183. }
  1184. /******************************************************************************
  1185. *
  1186. * Name:
  1187. *
  1188. *
  1189. * Description:
  1190. *
  1191. *
  1192. *****************************************************************************/
  1193. HRESULT DCProxyAggr :: PutInstanceAsync (
  1194. IWbemClassObject *a_Instance,
  1195. long a_Flags ,
  1196. IWbemContext *a_Context ,
  1197. IWbemObjectSink *a_Sink
  1198. )
  1199. {
  1200. BOOL t_InstancePut = FALSE ;
  1201. IWbemServices **t_Elements = NULL ;
  1202. ULONG t_ElementsCount = 0 ;
  1203. HRESULT t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1204. if ( SUCCEEDED ( t_Result ) )
  1205. {
  1206. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1207. {
  1208. CInterceptor_IWbemWaitingObjectSink *t_InstancePuttingSink = new CInterceptor_IWbemWaitingObjectSink (
  1209. m_Allocator ,
  1210. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1211. ) ;
  1212. if ( t_InstancePuttingSink )
  1213. {
  1214. t_InstancePuttingSink->AddRef () ;
  1215. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1216. Lock () ;
  1217. WmiStatusCode t_StatusCode = Insert (
  1218. *t_InstancePuttingSink ,
  1219. t_Iterator
  1220. ) ;
  1221. UnLock () ;
  1222. if ( t_StatusCode == e_StatusCode_Success )
  1223. {
  1224. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1225. t_Result = t_Provider->PutInstanceAsync (
  1226. a_Instance ,
  1227. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  1228. a_Context,
  1229. t_InstancePuttingSink
  1230. ) ;
  1231. if ( SUCCEEDED ( t_Result ) )
  1232. {
  1233. t_Result = t_InstancePuttingSink->Wait ( INFINITE ) ;
  1234. if ( SUCCEEDED ( t_Result ) )
  1235. {
  1236. if ( SUCCEEDED ( t_InstancePuttingSink->GetResult () ) )
  1237. {
  1238. t_InstancePut = TRUE ;
  1239. }
  1240. }
  1241. else
  1242. {
  1243. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1244. {
  1245. t_Result = S_OK ;
  1246. }
  1247. }
  1248. }
  1249. else
  1250. {
  1251. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1252. {
  1253. t_Result = S_OK ;
  1254. }
  1255. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1256. {
  1257. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1258. UnRegister(*last_interceptor);
  1259. t_Result = S_OK ;
  1260. }
  1261. }
  1262. }
  1263. else
  1264. {
  1265. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1266. }
  1267. WmiQueue <IWbemClassObject *,8> &t_Queue = t_InstancePuttingSink->GetQueue () ;
  1268. IWbemClassObject *t_Object = NULL ;
  1269. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  1270. {
  1271. t_Object->Release () ;
  1272. t_StatusCode = t_Queue.DeQueue () ;
  1273. }
  1274. t_InstancePuttingSink->Release () ;
  1275. }
  1276. else
  1277. {
  1278. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1279. }
  1280. }
  1281. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1282. }
  1283. if ( SUCCEEDED ( t_Result ) )
  1284. {
  1285. if ( t_InstancePut == FALSE )
  1286. {
  1287. t_Result = WBEM_E_NOT_FOUND ;
  1288. }
  1289. }
  1290. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1291. return t_Result ;
  1292. }
  1293. /******************************************************************************
  1294. *
  1295. * Name:
  1296. *
  1297. *
  1298. * Description:
  1299. *
  1300. *
  1301. *****************************************************************************/
  1302. HRESULT DCProxyAggr :: DeleteInstanceAsync (
  1303. const BSTR a_ObjectPath,
  1304. long a_Flags,
  1305. IWbemContext *a_Context,
  1306. IWbemObjectSink *a_Sink
  1307. )
  1308. {
  1309. BOOL t_InstanceDeleted = FALSE ;
  1310. IWbemServices **t_Elements = NULL ;
  1311. ULONG t_ElementsCount = 0 ;
  1312. HRESULT t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1313. if ( SUCCEEDED ( t_Result ) )
  1314. {
  1315. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1316. {
  1317. CInterceptor_IWbemWaitingObjectSink *t_InstanceDeletingSink = new CInterceptor_IWbemWaitingObjectSink (
  1318. m_Allocator ,
  1319. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1320. ) ;
  1321. if ( t_InstanceDeletingSink )
  1322. {
  1323. t_InstanceDeletingSink->AddRef () ;
  1324. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1325. Lock () ;
  1326. WmiStatusCode t_StatusCode = Insert (
  1327. *t_InstanceDeletingSink ,
  1328. t_Iterator
  1329. ) ;
  1330. UnLock () ;
  1331. if ( t_StatusCode == e_StatusCode_Success )
  1332. {
  1333. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1334. t_Result = t_Provider->DeleteInstanceAsync (
  1335. a_ObjectPath ,
  1336. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  1337. a_Context,
  1338. t_InstanceDeletingSink
  1339. ) ;
  1340. if ( SUCCEEDED ( t_Result ) )
  1341. {
  1342. t_Result = t_InstanceDeletingSink->Wait ( INFINITE ) ;
  1343. if ( SUCCEEDED ( t_Result ) )
  1344. {
  1345. if ( SUCCEEDED ( t_InstanceDeletingSink->GetResult () ) )
  1346. {
  1347. t_InstanceDeleted = TRUE ;
  1348. }
  1349. }
  1350. else
  1351. {
  1352. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1353. {
  1354. t_Result = S_OK ;
  1355. }
  1356. }
  1357. }
  1358. else
  1359. {
  1360. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1361. {
  1362. t_Result = S_OK ;
  1363. }
  1364. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  1365. {
  1366. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1367. UnRegister(*last_interceptor);
  1368. t_Result = S_OK ;
  1369. }
  1370. }
  1371. }
  1372. else
  1373. {
  1374. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1375. }
  1376. WmiQueue <IWbemClassObject *,8> &t_Queue = t_InstanceDeletingSink->GetQueue () ;
  1377. IWbemClassObject *t_Object = NULL ;
  1378. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  1379. {
  1380. t_Object->Release () ;
  1381. t_StatusCode = t_Queue.DeQueue () ;
  1382. }
  1383. t_InstanceDeletingSink->Release () ;
  1384. }
  1385. else
  1386. {
  1387. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1388. }
  1389. }
  1390. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1391. }
  1392. if ( SUCCEEDED ( t_Result ) )
  1393. {
  1394. if ( t_InstanceDeleted == FALSE )
  1395. {
  1396. t_Result = WBEM_E_NOT_FOUND ;
  1397. }
  1398. }
  1399. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1400. return t_Result ;
  1401. }
  1402. /******************************************************************************
  1403. *
  1404. * Name:
  1405. *
  1406. *
  1407. * Description:
  1408. *
  1409. *
  1410. *****************************************************************************/
  1411. HRESULT DCProxyAggr :: CreateInstanceEnumAsync (
  1412. const BSTR a_Class ,
  1413. long a_Flags ,
  1414. IWbemContext *a_Context ,
  1415. IWbemObjectSink *a_Sink
  1416. )
  1417. {
  1418. HRESULT t_Result = S_OK ;
  1419. CInterceptor_DecoupledIWbemCombiningObjectSink *t_CombiningSink = new CInterceptor_DecoupledIWbemCombiningObjectSink (
  1420. m_Allocator ,
  1421. a_Sink ,
  1422. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1423. ) ;
  1424. if ( t_CombiningSink )
  1425. {
  1426. t_CombiningSink->AddRef () ;
  1427. t_CombiningSink->Suspend () ;
  1428. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1429. Lock () ;
  1430. WmiStatusCode t_StatusCode = Insert (
  1431. *t_CombiningSink ,
  1432. t_Iterator
  1433. ) ;
  1434. UnLock () ;
  1435. if ( t_StatusCode == e_StatusCode_Success )
  1436. {
  1437. IWbemServices **t_Elements = NULL ;
  1438. ULONG t_ElementsCount = 0 ;
  1439. t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1440. if ( SUCCEEDED ( t_Result ) )
  1441. {
  1442. BOOL t_ProviderFound = FALSE ;
  1443. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1444. {
  1445. CInterceptor_DecoupledIWbemObjectSink *t_Sink = new CInterceptor_DecoupledIWbemObjectSink (
  1446. t_CombiningSink ,
  1447. ( IWbemObjectSink * ) t_CombiningSink ,
  1448. ( CWbemGlobal_IWmiObjectSinkController * ) t_CombiningSink
  1449. ) ;
  1450. if ( t_Sink )
  1451. {
  1452. t_Sink->AddRef () ;
  1453. t_Result = t_CombiningSink->EnQueue ( t_Sink ) ;
  1454. if ( SUCCEEDED ( t_Result ) )
  1455. {
  1456. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1457. t_Result = t_Provider->CreateInstanceEnumAsync (
  1458. a_Class,
  1459. a_Flags,
  1460. a_Context,
  1461. t_Sink
  1462. ) ;
  1463. if ( SUCCEEDED ( t_Result ) )
  1464. {
  1465. }
  1466. else
  1467. {
  1468. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1469. {
  1470. t_Result = S_OK ;
  1471. }
  1472. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1473. {
  1474. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1475. UnRegister(*last_interceptor);
  1476. t_Result = S_OK ;
  1477. }
  1478. }
  1479. }
  1480. t_Sink->Release () ;
  1481. }
  1482. else
  1483. {
  1484. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1485. }
  1486. }
  1487. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1488. }
  1489. if ( SUCCEEDED ( t_Result ) && t_ElementsCount )
  1490. {
  1491. t_CombiningSink->Resume () ;
  1492. t_Result = t_CombiningSink->Wait ( INFINITE ) ;
  1493. }
  1494. else
  1495. {
  1496. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1497. }
  1498. }
  1499. else
  1500. {
  1501. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1502. }
  1503. t_CombiningSink->Release () ;
  1504. }
  1505. else
  1506. {
  1507. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1508. }
  1509. return t_Result ;
  1510. }
  1511. /******************************************************************************
  1512. *
  1513. * Name:
  1514. *
  1515. *
  1516. * Description:
  1517. *
  1518. *
  1519. *****************************************************************************/
  1520. HRESULT DCProxyAggr :: ExecQueryAsync (
  1521. const BSTR a_QueryLanguage,
  1522. const BSTR a_Query,
  1523. long a_Flags,
  1524. IWbemContext *a_Context,
  1525. IWbemObjectSink *a_Sink
  1526. )
  1527. {
  1528. HRESULT t_Result = S_OK ;
  1529. CInterceptor_DecoupledIWbemCombiningObjectSink *t_CombiningSink = new CInterceptor_DecoupledIWbemCombiningObjectSink (
  1530. m_Allocator ,
  1531. a_Sink ,
  1532. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1533. ) ;
  1534. if ( t_CombiningSink )
  1535. {
  1536. t_CombiningSink->AddRef () ;
  1537. t_CombiningSink->Suspend () ;
  1538. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1539. Lock () ;
  1540. WmiStatusCode t_StatusCode = Insert (
  1541. *t_CombiningSink ,
  1542. t_Iterator
  1543. ) ;
  1544. UnLock () ;
  1545. if ( t_StatusCode == e_StatusCode_Success )
  1546. {
  1547. IWbemServices **t_Elements = NULL ;
  1548. ULONG t_ElementsCount = 0 ;
  1549. t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1550. if ( SUCCEEDED ( t_Result ) )
  1551. {
  1552. BOOL t_ProviderFound = FALSE ;
  1553. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1554. {
  1555. CInterceptor_DecoupledIWbemObjectSink *t_Sink = new CInterceptor_DecoupledIWbemObjectSink (
  1556. t_CombiningSink ,
  1557. ( IWbemObjectSink * ) t_CombiningSink ,
  1558. ( CWbemGlobal_IWmiObjectSinkController * ) t_CombiningSink
  1559. ) ;
  1560. if ( t_Sink )
  1561. {
  1562. t_Sink->AddRef () ;
  1563. t_Result = t_CombiningSink->EnQueue ( t_Sink ) ;
  1564. if ( SUCCEEDED ( t_Result ) )
  1565. {
  1566. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1567. t_Result = t_Provider->ExecQueryAsync (
  1568. a_QueryLanguage,
  1569. a_Query,
  1570. a_Flags,
  1571. a_Context,
  1572. t_Sink
  1573. ) ;
  1574. if ( SUCCEEDED ( t_Result ) )
  1575. {
  1576. }
  1577. else
  1578. {
  1579. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1580. {
  1581. t_Result = S_OK ;
  1582. }
  1583. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1584. {
  1585. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1586. UnRegister(*last_interceptor);
  1587. t_Result = S_OK ;
  1588. }
  1589. }
  1590. }
  1591. t_Sink->Release () ;
  1592. }
  1593. else
  1594. {
  1595. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1596. }
  1597. }
  1598. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1599. }
  1600. if ( SUCCEEDED ( t_Result ) && t_ElementsCount )
  1601. {
  1602. t_CombiningSink->Resume () ;
  1603. t_Result = t_CombiningSink->Wait ( INFINITE ) ;
  1604. }
  1605. else
  1606. {
  1607. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1608. }
  1609. }
  1610. else
  1611. {
  1612. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1613. }
  1614. t_CombiningSink->Release () ;
  1615. }
  1616. else
  1617. {
  1618. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1619. }
  1620. return t_Result ;
  1621. }
  1622. /******************************************************************************
  1623. *
  1624. * Name:
  1625. *
  1626. *
  1627. * Description:
  1628. *
  1629. *
  1630. *****************************************************************************/
  1631. HRESULT DCProxyAggr :: ExecMethodAsync (
  1632. const BSTR a_ObjectPath,
  1633. const BSTR a_MethodName,
  1634. long a_Flags,
  1635. IWbemContext *a_Context,
  1636. IWbemClassObject *a_InParams,
  1637. IWbemObjectSink *a_Sink
  1638. )
  1639. {
  1640. BOOL t_MethodCalled = FALSE ;
  1641. IWbemServices **t_Elements = NULL ;
  1642. ULONG t_ElementsCount = 0 ;
  1643. HRESULT t_Result = GetProviders <IWbemServices> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1644. if ( SUCCEEDED ( t_Result ) )
  1645. {
  1646. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) && !t_MethodCalled ; t_Index ++ )
  1647. {
  1648. CInterceptor_IWbemWaitingObjectSink *t_MethodSink = new CInterceptor_IWbemWaitingObjectSink (
  1649. m_Allocator ,
  1650. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1651. ) ;
  1652. if ( t_MethodSink )
  1653. {
  1654. t_MethodSink->AddRef () ;
  1655. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1656. Lock () ;
  1657. WmiStatusCode t_StatusCode = Insert (
  1658. *t_MethodSink ,
  1659. t_Iterator
  1660. ) ;
  1661. UnLock () ;
  1662. if ( t_StatusCode == e_StatusCode_Success )
  1663. {
  1664. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1665. t_Result = t_Provider->ExecMethodAsync (
  1666. a_ObjectPath,
  1667. a_MethodName,
  1668. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  1669. a_Context,
  1670. a_InParams,
  1671. t_MethodSink
  1672. ) ;
  1673. if ( SUCCEEDED ( t_Result ) )
  1674. {
  1675. t_Result = t_MethodSink->Wait ( INFINITE ) ;
  1676. if ( SUCCEEDED ( t_Result ) )
  1677. {
  1678. if ( SUCCEEDED ( t_MethodSink->GetResult () ) )
  1679. {
  1680. t_MethodCalled = TRUE ;
  1681. }
  1682. }
  1683. else
  1684. {
  1685. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1686. {
  1687. t_Result = S_OK ;
  1688. }
  1689. }
  1690. }
  1691. else
  1692. {
  1693. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1694. {
  1695. t_Result = S_OK ;
  1696. }
  1697. else if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1698. {
  1699. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Provider);
  1700. UnRegister(*last_interceptor);
  1701. t_Result = S_OK ;
  1702. }
  1703. }
  1704. }
  1705. else
  1706. {
  1707. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1708. }
  1709. WmiQueue <IWbemClassObject *,8> &t_Queue = t_MethodSink->GetQueue () ;
  1710. IWbemClassObject *t_Object = NULL ;
  1711. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  1712. {
  1713. if (SUCCEEDED(t_Result))
  1714. {
  1715. a_Sink->Indicate ( 1 , & t_Object ) ;
  1716. }
  1717. t_Object->Release () ;
  1718. t_StatusCode = t_Queue.DeQueue () ;
  1719. }
  1720. t_MethodSink->Release () ;
  1721. }
  1722. else
  1723. {
  1724. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1725. }
  1726. }
  1727. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1728. }
  1729. if ( SUCCEEDED ( t_Result ) )
  1730. {
  1731. if ( t_MethodCalled == FALSE )
  1732. {
  1733. t_Result = WBEM_E_NOT_FOUND ;
  1734. }
  1735. }
  1736. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1737. return t_Result ;
  1738. }
  1739. /******************************************************************************
  1740. *
  1741. * Name:
  1742. *
  1743. *
  1744. * Description:
  1745. *
  1746. *
  1747. *****************************************************************************/
  1748. HRESULT DCProxyAggr ::ProvideEvents (
  1749. IWbemObjectSink *a_Sink ,
  1750. long a_Flags
  1751. )
  1752. {
  1753. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  1754. m_Sink = a_Sink;
  1755. IWbemEventProvider **t_Elements = NULL ;
  1756. ULONG t_ElementsCount = 0 ;
  1757. t_Result = GetProviders <IWbemEventProvider> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1758. if ( SUCCEEDED ( t_Result ) )
  1759. {
  1760. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1761. {
  1762. t_Result = t_Elements [ t_Index ]->ProvideEvents (
  1763. a_Sink,
  1764. a_Flags
  1765. ) ;
  1766. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1767. {
  1768. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Elements [ t_Index ]);
  1769. UnRegister(*last_interceptor);
  1770. t_Result = S_OK ;
  1771. }
  1772. }
  1773. HRESULT t_TempResult = ClearProviders <IWbemEventProvider> ( t_Elements , t_ElementsCount ) ;
  1774. }
  1775. return t_Result ;
  1776. }
  1777. HRESULT DCProxyAggr ::AccessCheck (
  1778. WBEM_CWSTR a_QueryLanguage ,
  1779. WBEM_CWSTR a_Query ,
  1780. long a_SidLength ,
  1781. const BYTE *a_Sid
  1782. )
  1783. {
  1784. HRESULT t_AggregatedResult = S_OK ;
  1785. IWbemEventProviderSecurity **t_Elements = NULL ;
  1786. ULONG t_ElementsCount = 0 ;
  1787. ULONG t_ContainerCount = 0 ;
  1788. HRESULT t_Result = GetProviders <IWbemEventProviderSecurity,&IID_IWbemEventProviderSecurity> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  1789. if ( SUCCEEDED ( t_Result ) )
  1790. {
  1791. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1792. {
  1793. t_Result = t_Elements [ t_Index ]->AccessCheck (
  1794. a_QueryLanguage,
  1795. a_Query ,
  1796. a_SidLength ,
  1797. a_Sid
  1798. ) ;
  1799. if ( SUCCEEDED ( t_Result ) )
  1800. {
  1801. if ( t_Result != S_OK )
  1802. {
  1803. t_AggregatedResult = t_Result ;
  1804. }
  1805. }
  1806. else
  1807. {
  1808. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1809. {
  1810. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Elements [ t_Index ]);
  1811. UnRegister(*last_interceptor);
  1812. t_Result = S_OK ;
  1813. }
  1814. }
  1815. }
  1816. HRESULT t_TempResult = ClearProviders <IWbemEventProviderSecurity> ( t_Elements , t_ElementsCount ) ;
  1817. }
  1818. if ( SUCCEEDED ( t_Result ) )
  1819. {
  1820. if ( t_ContainerCount )
  1821. {
  1822. if ( t_ElementsCount != t_ContainerCount )
  1823. {
  1824. t_AggregatedResult = WBEM_S_SUBJECT_TO_SDS ;
  1825. }
  1826. }
  1827. t_Result = t_AggregatedResult ;
  1828. }
  1829. return t_Result ;
  1830. }
  1831. HRESULT
  1832. DCProxyAggr::LoadAll ( void )
  1833. {
  1834. HRESULT t_Result = S_OK ;
  1835. try
  1836. {
  1837. CServerObject_DecoupledClientRegistration t_Elements ( m_Allocator ) ;
  1838. HRESULT t_TempResult = t_Elements.Load () ;
  1839. if ( SUCCEEDED ( t_TempResult ) )
  1840. {
  1841. WmiQueue < CServerObject_DecoupledClientRegistration_Element , 8 > &t_Queue = t_Elements.GetQueue () ;
  1842. CServerObject_DecoupledClientRegistration_Element t_Top ;
  1843. WmiStatusCode t_StatusCode ;
  1844. while ( ( t_StatusCode = t_Queue.Top ( t_Top ) ) == e_StatusCode_Success )
  1845. {
  1846. HRESULT t_TempResult = Register( DC_reg (t_Top ), false );
  1847. if (FAILED(t_TempResult) && t_TempResult == WBEM_E_PROVIDER_FAILURE)
  1848. t_Top.Delete(t_Top.GetClsid());
  1849. t_StatusCode = t_Queue.DeQueue () ;
  1850. }
  1851. }
  1852. else
  1853. {
  1854. }
  1855. }
  1856. catch ( ... )
  1857. {
  1858. t_Result = WBEM_E_PROVIDER_FAILURE ;
  1859. }
  1860. initialized_ = true;
  1861. return t_Result ;
  1862. }
  1863. /******************************************************************************
  1864. *
  1865. * Name:
  1866. *
  1867. *
  1868. * Description:
  1869. *
  1870. *
  1871. *****************************************************************************/
  1872. HRESULT DCProxyAggr ::NewQuery (
  1873. unsigned long a_Id ,
  1874. WBEM_WSTR a_QueryLanguage ,
  1875. WBEM_WSTR a_Query
  1876. )
  1877. {
  1878. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  1879. IWbemEventProviderQuerySink **t_Elements = NULL ;
  1880. ULONG t_ElementsCount = 0 ;
  1881. t_Result = GetProviders <IWbemEventProviderQuerySink> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1882. if ( SUCCEEDED ( t_Result ) )
  1883. {
  1884. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1885. {
  1886. t_Result = t_Elements [ t_Index ]->NewQuery (
  1887. a_Id,
  1888. a_QueryLanguage ,
  1889. a_Query
  1890. ) ;
  1891. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1892. {
  1893. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Elements [ t_Index ]);
  1894. UnRegister(*last_interceptor);
  1895. t_Result = S_OK ;
  1896. }
  1897. }
  1898. HRESULT t_TempResult = ClearProviders <IWbemEventProviderQuerySink> ( t_Elements , t_ElementsCount ) ;
  1899. }
  1900. return t_Result ;
  1901. }
  1902. /******************************************************************************
  1903. *
  1904. * Name:
  1905. *
  1906. *
  1907. * Description:
  1908. *
  1909. *
  1910. *****************************************************************************/
  1911. HRESULT DCProxyAggr ::CancelQuery (
  1912. unsigned long a_Id
  1913. )
  1914. {
  1915. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  1916. IWbemEventProviderQuerySink **t_Elements = NULL ;
  1917. ULONG t_ElementsCount = 0 ;
  1918. t_Result = GetProviders <IWbemEventProviderQuerySink> ( m_Controller , t_Elements , t_ElementsCount ) ;
  1919. if ( SUCCEEDED ( t_Result ) )
  1920. {
  1921. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1922. {
  1923. t_Result = t_Elements [ t_Index ]->CancelQuery ( a_Id ) ;
  1924. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) || (t_Result == WBEM_E_TRANSPORT_FAILURE))
  1925. {
  1926. const CInterceptor_IWbemDecoupledProvider* last_interceptor = static_cast<CInterceptor_IWbemDecoupledProvider*>(t_Elements [ t_Index ]);
  1927. UnRegister(*last_interceptor);
  1928. t_Result = S_OK ;
  1929. }
  1930. }
  1931. HRESULT t_TempResult = ClearProviders <IWbemEventProviderQuerySink> ( t_Elements , t_ElementsCount ) ;
  1932. }
  1933. return t_Result ;
  1934. }