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.

4673 lines
103 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 <typeinfo.h>
  10. #include <wbemint.h>
  11. #include <NCObjApi.h>
  12. #include <Guids.h>
  13. #include <Like.h>
  14. #include "Globals.h"
  15. #include "CGlobals.h"
  16. #include "DateTime.h"
  17. #include "ProvSubS.h"
  18. #include "ProvDcAggr.h"
  19. #include "ProvWsvS.h"
  20. #include "ProvFact.h"
  21. #include "ProvObSk.h"
  22. #include "ProvInSk.h"
  23. #include <scopecheck.h>
  24. /******************************************************************************
  25. *
  26. * Name:
  27. *
  28. *
  29. * Description:
  30. *
  31. *
  32. *****************************************************************************/
  33. CDecoupled_ProviderSubsystemRegistrar :: CDecoupled_ProviderSubsystemRegistrar (
  34. WmiAllocator &a_Allocator ,
  35. CServerObject_ProviderSubSystem *a_SubSystem
  36. ) : m_SubSystem ( a_SubSystem ) ,
  37. m_ReferenceCount ( 0 ) ,
  38. m_Allocator ( a_Allocator )
  39. {
  40. m_SubSystem->AddRef () ;
  41. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CDecoupledAggregator_IWbemProvider_ObjectsInProgress ) ;
  42. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  43. }
  44. /******************************************************************************
  45. *
  46. * Name:
  47. *
  48. *
  49. * Description:
  50. *
  51. *
  52. *****************************************************************************/
  53. CDecoupled_ProviderSubsystemRegistrar :: ~CDecoupled_ProviderSubsystemRegistrar ()
  54. {
  55. m_SubSystem->Release () ;
  56. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CDecoupledAggregator_IWbemProvider_ObjectsInProgress ) ;
  57. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  58. }
  59. /******************************************************************************
  60. *
  61. * Name:
  62. *
  63. *
  64. * Description:
  65. *
  66. *
  67. *****************************************************************************/
  68. STDMETHODIMP CDecoupled_ProviderSubsystemRegistrar::QueryInterface (
  69. REFIID iid ,
  70. LPVOID FAR *iplpv
  71. )
  72. {
  73. *iplpv = NULL ;
  74. if ( iid == IID_IUnknown )
  75. {
  76. *iplpv = ( LPVOID ) this ;
  77. }
  78. else if ( iid == IID__IWmiProviderSubsystemRegistrar )
  79. {
  80. *iplpv = ( LPVOID ) ( _IWmiProviderSubsystemRegistrar * ) this ;
  81. }
  82. if ( *iplpv )
  83. {
  84. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  85. return ResultFromScode ( S_OK ) ;
  86. }
  87. else
  88. {
  89. return ResultFromScode ( E_NOINTERFACE ) ;
  90. }
  91. }
  92. /******************************************************************************
  93. *
  94. * Name:
  95. *
  96. *
  97. * Description:
  98. *
  99. *
  100. *****************************************************************************/
  101. STDMETHODIMP_( ULONG ) CDecoupled_ProviderSubsystemRegistrar :: AddRef ()
  102. {
  103. return InterlockedIncrement ( & m_ReferenceCount ) ;
  104. }
  105. /******************************************************************************
  106. *
  107. * Name:
  108. *
  109. *
  110. * Description:
  111. *
  112. *
  113. *****************************************************************************/
  114. STDMETHODIMP_(ULONG) CDecoupled_ProviderSubsystemRegistrar :: Release ()
  115. {
  116. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  117. if ( t_ReferenceCount == 0 )
  118. {
  119. delete this ;
  120. }
  121. return t_ReferenceCount ;
  122. }
  123. /******************************************************************************
  124. *
  125. * Name:
  126. *
  127. *
  128. * Description:
  129. *
  130. *
  131. *****************************************************************************/
  132. HRESULT CDecoupled_ProviderSubsystemRegistrar :: SaveToRegistry (
  133. long a_Flags ,
  134. IWbemContext *a_Context ,
  135. LPCWSTR a_User ,
  136. LPCWSTR a_Locale ,
  137. LPCWSTR a_Scope ,
  138. LPCWSTR a_Registration ,
  139. DWORD a_ProcessIdentifier ,
  140. GUID &a_Identity ,
  141. IUnknown *a_Unknown
  142. )
  143. {
  144. HRESULT t_Result = S_OK ;
  145. HANDLE t_Handle = OpenProcess (
  146. PROCESS_QUERY_INFORMATION ,
  147. FALSE ,
  148. a_ProcessIdentifier
  149. ) ;
  150. if ( t_Handle )
  151. {
  152. wchar_t t_Guid [64] ;
  153. int t_Status = StringFromGUID2 ( a_Identity , t_Guid , sizeof ( t_Guid ) / sizeof ( wchar_t ) ) ;
  154. if ( t_Status )
  155. {
  156. BYTE *t_MarshaledProxy = NULL ;
  157. DWORD t_MarshaledProxyLength = 0 ;
  158. t_Result = ProviderSubSystem_Common_Globals :: MarshalRegistration (
  159. a_Unknown ,
  160. t_MarshaledProxy ,
  161. t_MarshaledProxyLength
  162. ) ;
  163. if ( SUCCEEDED ( t_Result ) )
  164. {
  165. CServerObject_DecoupledClientRegistration_Element t_Element ;
  166. BSTR t_CreationTime = NULL ;
  167. FILETIME t_CreationFileTime ;
  168. FILETIME t_ExitFileTime ;
  169. FILETIME t_KernelFileTime ;
  170. FILETIME t_UserFileTime ;
  171. BOOL t_Status = GetProcessTimes (
  172. t_Handle ,
  173. & t_CreationFileTime,
  174. & t_ExitFileTime,
  175. & t_KernelFileTime,
  176. & t_UserFileTime
  177. );
  178. if ( t_Status )
  179. {
  180. CWbemDateTime t_Time ;
  181. t_Time.SetFileTimeDate ( t_CreationFileTime , VARIANT_FALSE ) ;
  182. t_Result = t_Time.GetValue ( & t_CreationTime ) ;
  183. if ( SUCCEEDED ( t_Result ) )
  184. {
  185. t_Result = t_Element.SetProcessIdentifier ( a_ProcessIdentifier ) ;
  186. if ( SUCCEEDED ( t_Result ) )
  187. {
  188. if ( a_Locale )
  189. {
  190. t_Result = t_Element.SetLocale ( ( BSTR ) a_Locale ) ;
  191. }
  192. }
  193. if ( SUCCEEDED ( t_Result ) )
  194. {
  195. if ( a_User )
  196. {
  197. t_Result = t_Element.SetUser ( ( BSTR ) a_User ) ;
  198. }
  199. }
  200. if ( SUCCEEDED ( t_Result ) )
  201. {
  202. t_Result = t_Element.SetProvider ( ( BSTR ) a_Registration ) ;
  203. }
  204. if ( SUCCEEDED ( t_Result ) )
  205. {
  206. t_Result = t_Element.SetScope ( ( BSTR ) a_Scope ) ;
  207. }
  208. if ( SUCCEEDED ( t_Result ) )
  209. {
  210. t_Result = t_Element.SetCreationTime ( ( BSTR ) t_CreationTime ) ;
  211. }
  212. if ( SUCCEEDED ( t_Result ) )
  213. {
  214. t_Result = t_Element.SetMarshaledProxy ( t_MarshaledProxy , t_MarshaledProxyLength ) ;
  215. }
  216. if ( SUCCEEDED ( t_Result ) )
  217. {
  218. WmiStatusCode t_StatusCode = WmiHelper :: EnterCriticalSection ( ProviderSubSystem_Globals :: GetDecoupledRegistrySection () ) ;
  219. t_Result = t_Element.Save ( t_Guid ) ;
  220. t_StatusCode = WmiHelper :: LeaveCriticalSection ( ProviderSubSystem_Globals :: GetDecoupledRegistrySection () ) ;
  221. }
  222. SysFreeString ( t_CreationTime ) ;
  223. }
  224. else
  225. {
  226. t_Result = WBEM_E_UNEXPECTED ;
  227. }
  228. }
  229. else
  230. {
  231. t_Result = WBEM_E_UNEXPECTED ;
  232. }
  233. delete [] t_MarshaledProxy ;
  234. }
  235. }
  236. else
  237. {
  238. t_Result = WBEM_E_CRITICAL_ERROR ;
  239. }
  240. CloseHandle ( t_Handle ) ;
  241. }
  242. else
  243. {
  244. t_Result = WBEM_E_ACCESS_DENIED ;
  245. }
  246. return t_Result ;
  247. }
  248. /******************************************************************************
  249. *
  250. * Name:
  251. *
  252. *
  253. * Description:
  254. *
  255. *
  256. *****************************************************************************/
  257. HRESULT CDecoupled_ProviderSubsystemRegistrar :: ValidateClientSecurity (
  258. IWbemContext *a_Context ,
  259. LPCWSTR a_Scope ,
  260. LPCWSTR a_Registration ,
  261. IWbemServices *a_Service
  262. )
  263. {
  264. HRESULT t_Result = S_OK ;
  265. IWbemPath *t_Scope = NULL ;
  266. t_Result = CoCreateInstance (
  267. CLSID_WbemDefPath ,
  268. NULL ,
  269. CLSCTX_INPROC_SERVER ,
  270. IID_IWbemPath ,
  271. ( void ** ) & t_Scope
  272. ) ;
  273. if ( SUCCEEDED ( t_Result ) )
  274. {
  275. t_Result = CoImpersonateClient () ;
  276. if ( SUCCEEDED ( t_Result ) )
  277. {
  278. t_Result = t_Scope->SetText ( WBEMPATH_TREAT_SINGLE_IDENT_AS_NS | WBEMPATH_CREATE_ACCEPT_ALL , a_Scope ) ;
  279. if ( SUCCEEDED ( t_Result ) )
  280. {
  281. CServerObject_ProviderRegistrationV1 *t_Registration = new CServerObject_ProviderRegistrationV1 ;
  282. if ( t_Registration )
  283. {
  284. t_Registration->AddRef () ;
  285. t_Result = t_Registration->SetContext (
  286. a_Context ,
  287. t_Scope ,
  288. a_Service
  289. ) ;
  290. if ( SUCCEEDED ( t_Result ) )
  291. {
  292. t_Registration->SetUnloadTimeoutMilliSeconds ( ProviderSubSystem_Globals :: s_InternalCacheTimeout ) ;
  293. t_Result = t_Registration->Load (
  294. e_All ,
  295. NULL ,
  296. a_Registration
  297. ) ;
  298. if ( SUCCEEDED ( t_Result ) )
  299. {
  300. SECURITY_DESCRIPTOR *t_SecurityDescriptor = t_Registration->GetComRegistration ().GetSecurityDescriptor () ;
  301. t_Result = ProviderSubSystem_Common_Globals :: Check_SecurityDescriptor_CallIdentity (
  302. t_SecurityDescriptor ,
  303. MASK_PROVIDER_BINDING_BIND ,
  304. & g_ProviderBindingMapping,
  305. ProviderSubSystem_Common_Globals::GetDefaultDecoupledSD()
  306. ) ;
  307. }
  308. else
  309. {
  310. if ( t_Result == WBEM_E_NOT_FOUND )
  311. {
  312. t_Result = WBEM_E_PROVIDER_NOT_FOUND ;
  313. }
  314. else
  315. {
  316. t_Result = WBEM_E_PROVIDER_LOAD_FAILURE ;
  317. }
  318. }
  319. }
  320. t_Registration->Release () ;
  321. }
  322. else
  323. {
  324. t_Result = WBEM_E_OUT_OF_MEMORY ;
  325. }
  326. }
  327. CoRevertToSelf () ;
  328. }
  329. t_Scope->Release () ;
  330. }
  331. return t_Result ;
  332. }
  333. /******************************************************************************
  334. *
  335. * Name:
  336. *
  337. *
  338. * Description:
  339. *
  340. *
  341. *****************************************************************************/
  342. HRESULT CDecoupled_ProviderSubsystemRegistrar :: Register (
  343. long a_Flags ,
  344. IWbemContext *a_Context ,
  345. LPCWSTR a_User ,
  346. LPCWSTR a_Locale ,
  347. LPCWSTR a_Scope ,
  348. LPCWSTR a_Registration ,
  349. DWORD a_ProcessIdentifier ,
  350. IUnknown *a_Unknown ,
  351. GUID a_Identity
  352. )
  353. {
  354. HRESULT t_Result = S_OK ;
  355. try
  356. {
  357. IWbemContext *t_Context = NULL ;
  358. if ( a_Context )
  359. {
  360. t_Context = a_Context ;
  361. t_Context->AddRef () ;
  362. }
  363. else
  364. {
  365. t_Result = CoCreateInstance (
  366. CLSID_WbemContext ,
  367. NULL ,
  368. CLSCTX_INPROC_SERVER ,
  369. IID_IWbemContext ,
  370. ( void ** ) & t_Context
  371. ) ;
  372. }
  373. if ( SUCCEEDED ( t_Result ) )
  374. {
  375. IWbemServices *t_Service = NULL ;
  376. t_Result = m_SubSystem->GetWmiService (
  377. ( const BSTR ) a_Scope ,
  378. ( const BSTR ) a_User ,
  379. ( const BSTR ) a_Locale ,
  380. t_Service
  381. ) ;
  382. if ( SUCCEEDED ( t_Result ) )
  383. {
  384. t_Result = ValidateClientSecurity (
  385. a_Context ,
  386. a_Scope ,
  387. a_Registration ,
  388. t_Service
  389. ) ;
  390. if ( SUCCEEDED ( t_Result ) )
  391. {
  392. t_Result = SaveToRegistry (
  393. a_Flags ,
  394. a_Context ,
  395. a_User ,
  396. a_Locale ,
  397. a_Scope ,
  398. a_Registration ,
  399. a_ProcessIdentifier ,
  400. a_Identity ,
  401. a_Unknown
  402. ) ;
  403. }
  404. if ( SUCCEEDED ( t_Result ) )
  405. {
  406. _IWmiProviderFactory *t_Factory = NULL ;
  407. t_Result = m_SubSystem->Create (
  408. t_Service ,
  409. 0,
  410. t_Context ,
  411. a_Scope ,
  412. IID__IWmiProviderFactory ,
  413. ( void ** ) & t_Factory
  414. ) ;
  415. if ( SUCCEEDED ( t_Result ) )
  416. {
  417. _IWmiProviderSubsystemRegistrar *t_Registrar = NULL ;
  418. t_Result = t_Factory->GetDecoupledProvider (
  419. 0 ,
  420. t_Context ,
  421. a_User ,
  422. a_Locale ,
  423. a_Scope ,
  424. a_Registration ,
  425. IID__IWmiProviderSubsystemRegistrar ,
  426. ( void ** ) & t_Registrar
  427. ) ;
  428. if ( SUCCEEDED ( t_Result ) )
  429. {
  430. t_Result = t_Registrar->Register (
  431. 0 ,
  432. t_Context ,
  433. a_User ,
  434. a_Locale ,
  435. a_Scope ,
  436. a_Registration ,
  437. a_ProcessIdentifier ,
  438. a_Unknown ,
  439. a_Identity
  440. ) ;
  441. t_Registrar->Release () ;
  442. }
  443. t_Factory->Release () ;
  444. }
  445. }
  446. t_Service->Release () ;
  447. }
  448. }
  449. if ( t_Context )
  450. {
  451. t_Context->Release () ;
  452. }
  453. }
  454. catch ( ... )
  455. {
  456. t_Result = WBEM_E_PROVIDER_FAILURE ;
  457. }
  458. return t_Result ;
  459. }
  460. HRESULT HasDeleteAccess(wchar_t * guid)
  461. {
  462. HRESULT t_Result = S_OK ;
  463. LPWSTR t_HomeClientClsid_String = NULL ;
  464. t_Result = WmiHelper :: ConcatenateStrings (
  465. 3,
  466. & t_HomeClientClsid_String ,
  467. CServerObject_DecoupledClientRegistration::getClientKey() ,
  468. L"\\" ,
  469. guid) ;
  470. if (SUCCEEDED(t_Result))
  471. {
  472. t_Result = CoImpersonateClient();
  473. if ( SUCCEEDED ( t_Result ) )
  474. {
  475. HKEY t_HomeClientClsid_Key ;
  476. if (RegOpenKeyEx (HKEY_LOCAL_MACHINE , t_HomeClientClsid_String , 0 , DELETE , & t_HomeClientClsid_Key )== ERROR_SUCCESS)
  477. {
  478. RegCloseKey(t_HomeClientClsid_Key);
  479. }
  480. else
  481. {
  482. t_Result = E_ACCESSDENIED;
  483. }
  484. CoRevertToSelf();
  485. }
  486. SysFreeString ( t_HomeClientClsid_String ) ;
  487. }
  488. return t_Result;
  489. };
  490. /******************************************************************************
  491. *
  492. * Name:
  493. *
  494. *
  495. * Description:
  496. *
  497. *
  498. *****************************************************************************/
  499. HRESULT CDecoupled_ProviderSubsystemRegistrar :: UnRegister (
  500. long a_Flags ,
  501. IWbemContext *a_Context ,
  502. LPCWSTR a_User ,
  503. LPCWSTR a_Locale ,
  504. LPCWSTR a_Scope ,
  505. LPCWSTR a_Registration ,
  506. GUID a_Identity
  507. )
  508. {
  509. HRESULT t_Result = S_OK ;
  510. wchar_t t_Guid [64] ;
  511. int t_Status = StringFromGUID2 ( a_Identity , t_Guid , sizeof ( t_Guid ) / sizeof ( wchar_t ) ) ;
  512. if ( !t_Status )
  513. {
  514. return E_UNEXPECTED;
  515. }
  516. t_Result = HasDeleteAccess(t_Guid);
  517. if (FAILED(t_Result)) return t_Result;
  518. try
  519. {
  520. IWbemServices *t_Service = NULL ;
  521. t_Result = m_SubSystem->GetWmiService (
  522. ( const BSTR ) a_Scope ,
  523. ( const BSTR ) a_User ,
  524. ( const BSTR ) a_Locale ,
  525. t_Service
  526. ) ;
  527. if (SUCCEEDED ( t_Result ) )
  528. {
  529. _IWmiProviderFactory *t_Factory = NULL ;
  530. t_Result = m_SubSystem->Create (
  531. t_Service ,
  532. 0,
  533. a_Context ,
  534. a_Scope ,
  535. IID__IWmiProviderFactory ,
  536. ( void ** ) & t_Factory
  537. ) ;
  538. if ( SUCCEEDED ( t_Result ) )
  539. {
  540. _IWmiProviderSubsystemRegistrar *t_Registrar = NULL ;
  541. t_Result = t_Factory->GetDecoupledProvider (
  542. 0 ,
  543. a_Context ,
  544. a_User ,
  545. a_Locale ,
  546. a_Scope ,
  547. a_Registration ,
  548. IID__IWmiProviderSubsystemRegistrar ,
  549. ( void ** ) & t_Registrar
  550. ) ;
  551. if ( SUCCEEDED ( t_Result ) )
  552. {
  553. t_Result = t_Registrar->UnRegister (
  554. 0 ,
  555. a_Context ,
  556. a_User ,
  557. a_Locale ,
  558. a_Scope ,
  559. a_Registration ,
  560. a_Identity
  561. ) ;
  562. t_Registrar->Release () ;
  563. }
  564. t_Factory->Release () ;
  565. }
  566. t_Service->Release () ;
  567. }
  568. wchar_t t_Guid [64] ;
  569. int t_Status = StringFromGUID2 ( a_Identity , t_Guid , sizeof ( t_Guid ) / sizeof ( wchar_t ) ) ;
  570. if ( t_Status )
  571. {
  572. CServerObject_DecoupledClientRegistration_Element t_Element ;
  573. WmiStatusCode t_StatusCode = WmiHelper :: EnterCriticalSection ( ProviderSubSystem_Globals :: GetDecoupledRegistrySection () ) ;
  574. t_Result = t_Element.Delete ( t_Guid ) ;
  575. t_StatusCode = WmiHelper :: LeaveCriticalSection ( ProviderSubSystem_Globals :: GetDecoupledRegistrySection () ) ;
  576. }
  577. }
  578. catch ( ... )
  579. {
  580. t_Result = WBEM_E_PROVIDER_FAILURE ;
  581. }
  582. return t_Result ;
  583. }
  584. /******************************************************************************
  585. *
  586. * Name:
  587. *
  588. *
  589. * Description:
  590. *
  591. *
  592. *****************************************************************************/
  593. HRESULT CDecoupled_ProviderSubsystemRegistrar :: CacheProvider (
  594. CServerObject_ProviderSubSystem *a_SubSystem ,
  595. IWbemContext *a_Context ,
  596. CServerObject_DecoupledClientRegistration_Element &a_Element ,
  597. IUnknown *a_Unknown
  598. )
  599. {
  600. HRESULT t_Result = S_OK ;
  601. IWbemServices *t_Service = NULL ;
  602. t_Result = a_SubSystem->GetWmiService (
  603. a_Element.GetScope () ,
  604. ( const BSTR ) a_Element.GetUser () ,
  605. ( const BSTR ) a_Element.GetLocale () ,
  606. t_Service
  607. ) ;
  608. if (SUCCEEDED ( t_Result ) )
  609. {
  610. _IWmiProviderFactory *t_Factory = NULL ;
  611. t_Result = a_SubSystem->Create (
  612. t_Service ,
  613. 0,
  614. a_Context ,
  615. a_Element.GetScope () ,
  616. IID__IWmiProviderFactory ,
  617. ( void ** ) & t_Factory
  618. ) ;
  619. if ( SUCCEEDED ( t_Result ) )
  620. {
  621. _IWmiProviderSubsystemRegistrar *t_Registrar = NULL ;
  622. t_Result = t_Factory->GetDecoupledProvider (
  623. 0 ,
  624. a_Context ,
  625. a_Element.GetUser () ,
  626. a_Element.GetLocale () ,
  627. a_Element.GetScope () ,
  628. a_Element.GetProvider () ,
  629. IID__IWmiProviderSubsystemRegistrar ,
  630. ( void ** ) & t_Registrar
  631. ) ;
  632. if ( SUCCEEDED ( t_Result ) )
  633. {
  634. GUID t_Identity ;
  635. t_Result = CLSIDFromString ( a_Element.GetClsid () , & t_Identity ) ;
  636. if ( SUCCEEDED ( t_Result ) )
  637. {
  638. t_Result = t_Registrar->Register (
  639. 0 ,
  640. a_Context ,
  641. a_Element.GetUser () ,
  642. a_Element.GetLocale () ,
  643. a_Element.GetScope () ,
  644. a_Element.GetProvider () ,
  645. a_Element.GetProcessIdentifier () ,
  646. a_Unknown ,
  647. t_Identity
  648. ) ;
  649. }
  650. t_Registrar->Release () ;
  651. }
  652. t_Factory->Release () ;
  653. }
  654. t_Service->Release () ;
  655. }
  656. return t_Result ;
  657. }
  658. /******************************************************************************
  659. *
  660. * Name:
  661. *
  662. *
  663. * Description:
  664. *
  665. *
  666. *****************************************************************************/
  667. HRESULT CDecoupled_ProviderSubsystemRegistrar :: Load (
  668. CServerObject_ProviderSubSystem *a_SubSystem ,
  669. IWbemContext *a_Context ,
  670. CServerObject_DecoupledClientRegistration_Element &a_Element
  671. )
  672. {
  673. HRESULT t_Result = S_OK ;
  674. BYTE *t_MarshaledProxy = a_Element.GetMarshaledProxy () ;
  675. DWORD t_MarshaledProxyLength = a_Element.GetMarshaledProxyLength () ;
  676. if ( t_MarshaledProxy )
  677. {
  678. IUnknown *t_Unknown = NULL ;
  679. t_Result = ProviderSubSystem_Common_Globals :: UnMarshalRegistration ( & t_Unknown , t_MarshaledProxy , t_MarshaledProxyLength ) ;
  680. if ( SUCCEEDED ( t_Result ) )
  681. {
  682. t_Result = CacheProvider (
  683. a_SubSystem ,
  684. a_Context ,
  685. a_Element ,
  686. t_Unknown
  687. ) ;
  688. t_Unknown->Release () ;
  689. }
  690. }
  691. return t_Result ;
  692. }
  693. /******************************************************************************
  694. *
  695. * Name:
  696. *
  697. *
  698. * Description:
  699. *
  700. *
  701. *****************************************************************************/
  702. HRESULT CDecoupled_ProviderSubsystemRegistrar :: Load (
  703. CServerObject_ProviderSubSystem *a_SubSystem ,
  704. IWbemContext *a_Context
  705. )
  706. {
  707. HRESULT t_Result = S_OK ;
  708. try
  709. {
  710. CServerObject_DecoupledClientRegistration t_Elements ( m_Allocator ) ;
  711. WmiStatusCode t_StatusCode = WmiHelper :: EnterCriticalSection ( ProviderSubSystem_Globals :: GetDecoupledRegistrySection () ) ;
  712. HRESULT t_TempResult = t_Elements.Load () ;
  713. t_StatusCode = WmiHelper :: LeaveCriticalSection ( ProviderSubSystem_Globals :: GetDecoupledRegistrySection () ) ;
  714. if ( SUCCEEDED ( t_TempResult ) )
  715. {
  716. WmiQueue < CServerObject_DecoupledClientRegistration_Element , 8 > &t_Queue = t_Elements.GetQueue () ;
  717. CServerObject_DecoupledClientRegistration_Element t_Top ;
  718. WmiStatusCode t_StatusCode ;
  719. while ( ( t_StatusCode = t_Queue.Top ( t_Top ) ) == e_StatusCode_Success )
  720. {
  721. HRESULT t_TempResult = Load (
  722. a_SubSystem ,
  723. a_Context ,
  724. t_Top
  725. ) ;
  726. t_StatusCode = t_Queue.DeQueue () ;
  727. }
  728. }
  729. else
  730. {
  731. }
  732. }
  733. catch ( ... )
  734. {
  735. t_Result = WBEM_E_PROVIDER_FAILURE ;
  736. }
  737. return t_Result ;
  738. }
  739. /******************************************************************************
  740. *
  741. * Name:
  742. *
  743. *
  744. * Description:
  745. *
  746. *
  747. *****************************************************************************/
  748. HRESULT CDecoupled_ProviderSubsystemRegistrar :: SaveToRegistry (
  749. IUnknown *a_Unknown ,
  750. BYTE *a_MarshaledProxy ,
  751. DWORD a_MarshaledProxyLength
  752. )
  753. {
  754. HRESULT t_Result = S_OK ;
  755. CServerObject_DecoupledServerRegistration t_Element ( m_Allocator ) ;
  756. BSTR t_CreationTime = NULL ;
  757. FILETIME t_CreationFileTime ;
  758. FILETIME t_ExitFileTime ;
  759. FILETIME t_KernelFileTime ;
  760. FILETIME t_UserFileTime ;
  761. BOOL t_Status = GetProcessTimes (
  762. GetCurrentProcess (),
  763. & t_CreationFileTime,
  764. & t_ExitFileTime,
  765. & t_KernelFileTime,
  766. & t_UserFileTime
  767. );
  768. if ( t_Status )
  769. {
  770. CWbemDateTime t_Time ;
  771. t_Time.SetFileTimeDate ( t_CreationFileTime , VARIANT_FALSE ) ;
  772. t_Result = t_Time.GetValue ( & t_CreationTime ) ;
  773. if ( SUCCEEDED ( t_Result ) )
  774. {
  775. t_Result = t_Element.SetProcessIdentifier ( GetCurrentProcessId () ) ;
  776. if ( SUCCEEDED ( t_Result ) )
  777. {
  778. t_Result = t_Element.SetCreationTime ( ( BSTR ) t_CreationTime ) ;
  779. }
  780. if ( SUCCEEDED ( t_Result ) )
  781. {
  782. t_Result = t_Element.SetMarshaledProxy ( a_MarshaledProxy , a_MarshaledProxyLength ) ;
  783. }
  784. if ( SUCCEEDED ( t_Result ) )
  785. {
  786. t_Result = t_Element.Save () ;
  787. }
  788. SysFreeString ( t_CreationTime ) ;
  789. }
  790. else
  791. {
  792. t_Result = WBEM_E_UNEXPECTED ;
  793. }
  794. }
  795. else
  796. {
  797. t_Result = WBEM_E_UNEXPECTED ;
  798. }
  799. return t_Result ;
  800. }
  801. /******************************************************************************
  802. *
  803. * Name:
  804. *
  805. *
  806. * Description:
  807. *
  808. *
  809. *****************************************************************************/
  810. HRESULT CDecoupled_ProviderSubsystemRegistrar :: Save ()
  811. {
  812. HRESULT t_Result = S_OK ;
  813. try
  814. {
  815. /*
  816. * Clear existing stale entries.
  817. */
  818. CServerObject_DecoupledClientRegistration t_Elements ( m_Allocator ) ;
  819. HRESULT t_TempResult = t_Elements.Load () ;
  820. if ( SUCCEEDED ( t_TempResult ) )
  821. {
  822. WmiQueue < CServerObject_DecoupledClientRegistration_Element , 8 > &t_Queue = t_Elements.GetQueue () ;
  823. CServerObject_DecoupledClientRegistration_Element t_Top ;
  824. WmiStatusCode t_StatusCode ;
  825. while ( ( t_StatusCode = t_Queue.Top ( t_Top ) ) == e_StatusCode_Success )
  826. {
  827. t_StatusCode = t_Queue.DeQueue () ;
  828. }
  829. }
  830. else
  831. {
  832. }
  833. BYTE *t_MarshaledProxy = NULL ;
  834. DWORD t_MarshaledProxyLength = 0 ;
  835. IUnknown *t_Unknown = NULL ;
  836. t_Result = this->QueryInterface ( IID_IUnknown, ( void ** ) & t_Unknown ) ;
  837. if ( SUCCEEDED ( t_Result ) )
  838. {
  839. t_Result = ProviderSubSystem_Common_Globals :: MarshalRegistration (
  840. t_Unknown ,
  841. t_MarshaledProxy ,
  842. t_MarshaledProxyLength
  843. ) ;
  844. if ( SUCCEEDED ( t_Result ) )
  845. {
  846. t_Result = SaveToRegistry (
  847. t_Unknown ,
  848. t_MarshaledProxy ,
  849. t_MarshaledProxyLength
  850. ) ;
  851. delete [] t_MarshaledProxy ;
  852. }
  853. t_Unknown->Release () ;
  854. }
  855. }
  856. catch ( ... )
  857. {
  858. t_Result = WBEM_E_PROVIDER_FAILURE ;
  859. }
  860. return t_Result ;
  861. }
  862. /******************************************************************************
  863. *
  864. * Name:
  865. *
  866. *
  867. * Description:
  868. *
  869. *
  870. *****************************************************************************/
  871. HRESULT CDecoupled_ProviderSubsystemRegistrar :: Delete ()
  872. {
  873. HRESULT t_Result = S_OK ;
  874. try
  875. {
  876. CServerObject_DecoupledServerRegistration t_Element ( m_Allocator ) ;
  877. t_Result = t_Element.Delete () ;
  878. }
  879. catch ( ... )
  880. {
  881. t_Result = WBEM_E_PROVIDER_FAILURE ;
  882. }
  883. return t_Result ;
  884. }
  885. /******************************************************************************
  886. *
  887. * Name:
  888. *
  889. *
  890. * Description:
  891. *
  892. *
  893. *****************************************************************************/
  894. CDecoupledAggregator_IWbemProvider :: CDecoupledAggregator_IWbemProvider (
  895. WmiAllocator &a_Allocator ,
  896. CWbemGlobal_IWmiProviderController *a_Controller ,
  897. _IWmiProviderFactory *a_Factory ,
  898. IWbemServices *a_CoreRepositoryStub ,
  899. IWbemServices *a_CoreFullStub ,
  900. const ProviderCacheKey &a_Key ,
  901. const ULONG &a_Period ,
  902. IWbemContext *a_InitializationContext ,
  903. CServerObject_ProviderRegistrationV1 &a_Registration
  904. ) : CWbemGlobal_IWmiObjectSinkController ( a_Allocator ) ,
  905. ServiceCacheElement (
  906. a_Controller ,
  907. a_Key ,
  908. a_Period
  909. ) ,
  910. m_ReferenceCount ( 0 ) ,
  911. m_Allocator ( a_Allocator ) ,
  912. m_Registration ( & a_Registration ) ,
  913. m_ExtendedStatusObject ( NULL ) ,
  914. m_CoreRepositoryStub ( a_CoreRepositoryStub ) ,
  915. m_CoreFullStub ( a_CoreFullStub ) ,
  916. m_Factory ( a_Factory ) ,
  917. m_User ( NULL ) ,
  918. m_Locale ( NULL ) ,
  919. m_Namespace ( NULL ) ,
  920. m_Controller ( NULL ) ,
  921. m_NamespacePath ( NULL ) ,
  922. m_Sink ( NULL ) ,
  923. m_Initialized ( 0 ) ,
  924. m_InitializeResult ( S_OK ) ,
  925. m_InitializedEvent ( NULL ) ,
  926. m_InitializationContext ( a_InitializationContext )
  927. {
  928. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CDecoupledAggregator_IWbemProvider_ObjectsInProgress ) ;
  929. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  930. m_Registration->AddRef () ;
  931. if ( m_Factory )
  932. {
  933. m_Factory->AddRef () ;
  934. }
  935. if ( m_CoreRepositoryStub )
  936. {
  937. m_CoreRepositoryStub->AddRef () ;
  938. }
  939. if ( m_CoreFullStub )
  940. {
  941. m_CoreFullStub->AddRef () ;
  942. }
  943. if ( m_InitializationContext )
  944. {
  945. m_InitializationContext->AddRef () ;
  946. }
  947. }
  948. /******************************************************************************
  949. *
  950. * Name:
  951. *
  952. *
  953. * Description:
  954. *
  955. *
  956. *****************************************************************************/
  957. CDecoupledAggregator_IWbemProvider :: ~CDecoupledAggregator_IWbemProvider ()
  958. {
  959. WmiStatusCode t_StatusCode = CWbemGlobal_IWmiObjectSinkController :: UnInitialize () ;
  960. if ( m_Controller )
  961. {
  962. CWbemGlobal_IWbemSyncProvider_Container *t_Container = NULL ;
  963. WmiStatusCode t_StatusCode = m_Controller->GetContainer ( t_Container ) ;
  964. m_Controller->Lock () ;
  965. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator = t_Container->Begin () ;
  966. while ( ! t_Iterator.Null () )
  967. {
  968. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  969. t_Container->Delete ( t_Element->GetKey () ) ;
  970. m_Controller->UnLock () ;
  971. t_Element->Release () ;
  972. m_Controller->Lock () ;
  973. t_Iterator = t_Container->Begin () ;
  974. }
  975. m_Controller->UnLock () ;
  976. m_Controller->UnInitialize () ;
  977. m_Controller->Release () ;
  978. }
  979. if ( m_NamespacePath )
  980. {
  981. m_NamespacePath->Release () ;
  982. }
  983. if ( m_Factory )
  984. {
  985. m_Factory->Release () ;
  986. }
  987. if ( m_CoreRepositoryStub )
  988. {
  989. m_CoreRepositoryStub->Release () ;
  990. }
  991. if ( m_CoreFullStub )
  992. {
  993. m_CoreFullStub->Release () ;
  994. }
  995. if ( m_User )
  996. {
  997. SysFreeString ( m_User ) ;
  998. }
  999. if ( m_Locale )
  1000. {
  1001. SysFreeString ( m_Locale ) ;
  1002. }
  1003. if ( m_Namespace )
  1004. {
  1005. SysFreeString ( m_Namespace ) ;
  1006. }
  1007. if ( m_Sink )
  1008. {
  1009. m_Sink->AddRef () ;
  1010. }
  1011. if ( m_InitializationContext )
  1012. {
  1013. m_InitializationContext->Release () ;
  1014. }
  1015. if ( m_InitializedEvent )
  1016. {
  1017. CloseHandle ( m_InitializedEvent ) ;
  1018. }
  1019. if ( m_Registration )
  1020. {
  1021. m_Registration->Release () ;
  1022. }
  1023. if ( m_ExtendedStatusObject )
  1024. {
  1025. m_ExtendedStatusObject->Release () ;
  1026. }
  1027. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CDecoupledAggregator_IWbemProvider_ObjectsInProgress ) ;
  1028. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  1029. }
  1030. /******************************************************************************
  1031. *
  1032. * Name:
  1033. *
  1034. *
  1035. * Description:
  1036. *
  1037. *
  1038. *****************************************************************************/
  1039. HRESULT CDecoupledAggregator_IWbemProvider :: Initialize (
  1040. long a_Flags ,
  1041. IWbemContext *a_Context ,
  1042. GUID *a_TransactionIdentifier,
  1043. LPCWSTR a_User,
  1044. LPCWSTR a_Locale,
  1045. LPCWSTR a_Namespace ,
  1046. IWbemServices *a_Repository ,
  1047. IWbemServices *a_Service ,
  1048. IWbemProviderInitSink *a_Sink // For init signals
  1049. )
  1050. {
  1051. HRESULT t_Result = S_OK ;
  1052. WmiStatusCode t_StatusCode = CWbemGlobal_IWmiObjectSinkController :: Initialize () ;
  1053. if ( t_StatusCode != e_StatusCode_Success )
  1054. {
  1055. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1056. }
  1057. if ( SUCCEEDED ( t_Result ) )
  1058. {
  1059. m_Controller = new CWbemGlobal_IWbemSyncProviderController ( m_Allocator ) ;
  1060. if ( m_Controller )
  1061. {
  1062. m_Controller->AddRef () ;
  1063. t_StatusCode = m_Controller->Initialize () ;
  1064. if ( t_StatusCode != e_StatusCode_Success )
  1065. {
  1066. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1067. }
  1068. }
  1069. else
  1070. {
  1071. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1072. }
  1073. }
  1074. if ( SUCCEEDED ( t_Result ) )
  1075. {
  1076. t_Result = CoCreateInstance (
  1077. CLSID_WbemDefPath ,
  1078. NULL ,
  1079. CLSCTX_INPROC_SERVER ,
  1080. IID_IWbemPath ,
  1081. ( void ** ) & m_NamespacePath
  1082. ) ;
  1083. if ( SUCCEEDED ( t_Result ) )
  1084. {
  1085. t_Result = m_NamespacePath->SetText ( WBEMPATH_TREAT_SINGLE_IDENT_AS_NS | WBEMPATH_CREATE_ACCEPT_ALL , a_Namespace ) ;
  1086. }
  1087. }
  1088. if ( SUCCEEDED ( t_Result ) )
  1089. {
  1090. if ( a_User )
  1091. {
  1092. m_User = SysAllocString ( a_User ) ;
  1093. if ( ! m_User )
  1094. {
  1095. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1096. }
  1097. }
  1098. if ( SUCCEEDED ( t_Result ) )
  1099. {
  1100. if ( a_Locale )
  1101. {
  1102. m_Locale = SysAllocString ( a_Locale ) ;
  1103. if ( ! m_Locale )
  1104. {
  1105. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1106. }
  1107. }
  1108. }
  1109. if ( SUCCEEDED ( t_Result ) )
  1110. {
  1111. if ( a_Namespace )
  1112. {
  1113. m_Namespace = SysAllocString ( a_Namespace ) ;
  1114. if ( ! m_Namespace )
  1115. {
  1116. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1117. }
  1118. }
  1119. }
  1120. }
  1121. if ( SUCCEEDED ( t_Result ) )
  1122. {
  1123. m_InitializedEvent = CreateEvent ( NULL , TRUE , FALSE , NULL ) ;
  1124. if ( m_InitializedEvent == NULL )
  1125. {
  1126. t_Result = t_Result = WBEM_E_OUT_OF_MEMORY ;
  1127. }
  1128. }
  1129. if ( SUCCEEDED ( t_Result ) )
  1130. {
  1131. t_Result = a_Repository->GetObject (
  1132. L"__ExtendedStatus" ,
  1133. 0 ,
  1134. a_Context ,
  1135. & m_ExtendedStatusObject ,
  1136. NULL
  1137. ) ;
  1138. }
  1139. a_Sink->SetStatus ( t_Result , 0 ) ;
  1140. return t_Result ;
  1141. }
  1142. /******************************************************************************
  1143. *
  1144. * Name:
  1145. *
  1146. *
  1147. * Description:
  1148. *
  1149. *
  1150. *****************************************************************************/
  1151. HRESULT CDecoupledAggregator_IWbemProvider :: SetStatus (
  1152. LPWSTR a_Operation ,
  1153. LPWSTR a_Parameters ,
  1154. LPWSTR a_Description ,
  1155. HRESULT a_Result ,
  1156. IWbemObjectSink *a_Sink
  1157. )
  1158. {
  1159. if ( m_ExtendedStatusObject )
  1160. {
  1161. IWbemClassObject *t_StatusObject ;
  1162. HRESULT t_Result = m_ExtendedStatusObject->SpawnInstance (
  1163. 0 ,
  1164. & t_StatusObject
  1165. ) ;
  1166. if ( SUCCEEDED ( t_Result ) )
  1167. {
  1168. ProviderSubSystem_Common_Globals :: Set_String ( t_StatusObject , L"Provider" , m_Registration ? m_Registration->GetProviderName () : L"ProviderSubsystem" ) ;
  1169. if ( a_Operation )
  1170. {
  1171. ProviderSubSystem_Common_Globals :: Set_String ( t_StatusObject , L"Operation" , a_Operation ) ;
  1172. }
  1173. if ( a_Parameters )
  1174. {
  1175. ProviderSubSystem_Common_Globals :: Set_String ( t_StatusObject , L"ParameterInfo" , a_Parameters ) ;
  1176. }
  1177. if ( a_Description )
  1178. {
  1179. ProviderSubSystem_Common_Globals :: Set_String ( t_StatusObject , L"Description" , a_Description ) ;
  1180. }
  1181. _IWmiObject *t_FastStatusObject ;
  1182. t_Result = t_StatusObject->QueryInterface ( IID__IWmiObject , ( void ** ) & t_FastStatusObject ) ;
  1183. if ( SUCCEEDED ( t_Result ) )
  1184. {
  1185. ProviderSubSystem_Common_Globals :: Set_Uint32 ( t_FastStatusObject , L"StatusCode" , a_Result ) ;
  1186. t_FastStatusObject->Release () ;
  1187. }
  1188. if ( SUCCEEDED ( a_Result ) )
  1189. {
  1190. t_Result = a_Sink->SetStatus ( 0 , a_Result , NULL , t_StatusObject ) ;
  1191. }
  1192. else
  1193. {
  1194. t_Result = a_Sink->SetStatus ( 0 , a_Result , L"Provider Subsystem Error Report" , t_StatusObject ) ;
  1195. }
  1196. t_StatusObject->Release () ;
  1197. }
  1198. else
  1199. {
  1200. t_Result = a_Sink->SetStatus ( 0 , a_Result , NULL , NULL ) ;
  1201. }
  1202. }
  1203. else
  1204. {
  1205. HRESULT t_Result = a_Sink->SetStatus ( 0 , a_Result , NULL , NULL ) ;
  1206. }
  1207. return S_OK ;
  1208. }
  1209. /******************************************************************************
  1210. *
  1211. * Name:
  1212. *
  1213. *
  1214. * Description:
  1215. *
  1216. *
  1217. *****************************************************************************/
  1218. HRESULT CDecoupledAggregator_IWbemProvider :: IsIndependant ( IWbemContext *a_Context )
  1219. {
  1220. BOOL t_DependantCall = FALSE ;
  1221. HRESULT t_Result = ProviderSubSystem_Common_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  1222. if ( SUCCEEDED ( t_Result ) )
  1223. {
  1224. if ( t_DependantCall == FALSE )
  1225. {
  1226. }
  1227. else
  1228. {
  1229. return S_FALSE ;
  1230. }
  1231. }
  1232. return t_Result ;
  1233. }
  1234. /******************************************************************************
  1235. *
  1236. * Name:
  1237. *
  1238. *
  1239. * Description:
  1240. *
  1241. *
  1242. *****************************************************************************/
  1243. HRESULT CDecoupledAggregator_IWbemProvider :: WaitProvider ( IWbemContext *a_Context , ULONG a_Timeout )
  1244. {
  1245. HRESULT t_Result = WBEM_E_UNEXPECTED ;
  1246. if ( m_Initialized == 0 )
  1247. {
  1248. BOOL t_DependantCall = FALSE ;
  1249. t_Result = ProviderSubSystem_Common_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  1250. if ( SUCCEEDED ( t_Result ) )
  1251. {
  1252. if ( t_DependantCall == FALSE )
  1253. {
  1254. if ( WaitForSingleObject ( m_InitializedEvent , a_Timeout ) == WAIT_TIMEOUT )
  1255. {
  1256. return WBEM_E_PROVIDER_LOAD_FAILURE ;
  1257. }
  1258. }
  1259. else
  1260. {
  1261. if ( WaitForSingleObject ( m_InitializedEvent , 0 ) == WAIT_TIMEOUT )
  1262. {
  1263. return S_FALSE ;
  1264. }
  1265. }
  1266. }
  1267. }
  1268. else
  1269. {
  1270. t_Result = S_OK ;
  1271. }
  1272. return t_Result ;
  1273. }
  1274. /******************************************************************************
  1275. *
  1276. * Name:
  1277. *
  1278. *
  1279. * Description:
  1280. *
  1281. *
  1282. *****************************************************************************/
  1283. HRESULT CDecoupledAggregator_IWbemProvider :: SetInitialized ( HRESULT a_InitializeResult )
  1284. {
  1285. m_InitializeResult = a_InitializeResult ;
  1286. InterlockedExchange ( & m_Initialized , 1 ) ;
  1287. if ( m_InitializedEvent )
  1288. {
  1289. SetEvent ( m_InitializedEvent ) ;
  1290. }
  1291. return S_OK ;
  1292. }
  1293. /******************************************************************************
  1294. *
  1295. * Name:
  1296. *
  1297. *
  1298. * Description:
  1299. *
  1300. *
  1301. *****************************************************************************/
  1302. STDMETHODIMP_(ULONG) CDecoupledAggregator_IWbemProvider :: AddRef ( void )
  1303. {
  1304. return ServiceCacheElement :: AddRef () ;
  1305. }
  1306. /******************************************************************************
  1307. *
  1308. * Name:
  1309. *
  1310. *
  1311. * Description:
  1312. *
  1313. *
  1314. *****************************************************************************/
  1315. STDMETHODIMP_(ULONG) CDecoupledAggregator_IWbemProvider :: Release ( void )
  1316. {
  1317. return ServiceCacheElement :: Release () ;
  1318. }
  1319. /******************************************************************************
  1320. *
  1321. * Name:
  1322. *
  1323. *
  1324. * Description:
  1325. *
  1326. *
  1327. *****************************************************************************/
  1328. STDMETHODIMP CDecoupledAggregator_IWbemProvider :: QueryInterface (
  1329. REFIID iid ,
  1330. LPVOID FAR *iplpv
  1331. )
  1332. {
  1333. *iplpv = NULL ;
  1334. if ( iid == IID_IUnknown )
  1335. {
  1336. *iplpv = ( LPVOID ) this ;
  1337. }
  1338. else if ( iid == IID_IWbemServices )
  1339. {
  1340. *iplpv = ( LPVOID ) ( IWbemServices * ) this ;
  1341. }
  1342. else if ( iid == IID_IWbemEventProvider )
  1343. {
  1344. *iplpv = ( LPVOID ) ( IWbemEventProvider * ) this ;
  1345. }
  1346. else if ( iid == IID_IWbemEventProviderQuerySink )
  1347. {
  1348. *iplpv = ( LPVOID ) ( IWbemEventProviderQuerySink * ) this ;
  1349. }
  1350. else if ( iid == IID_IWbemEventProviderSecurity )
  1351. {
  1352. *iplpv = ( LPVOID ) ( IWbemEventProviderSecurity * ) this ;
  1353. }
  1354. else if ( iid == IID_IWbemProviderIdentity )
  1355. {
  1356. *iplpv = ( LPVOID ) ( IWbemProviderIdentity * ) this ;
  1357. }
  1358. else if ( iid == IID_IWbemEventConsumerProvider )
  1359. {
  1360. *iplpv = ( LPVOID ) ( IWbemEventConsumerProvider * ) this ;
  1361. }
  1362. else if ( iid == IID_IWbemEventConsumerProviderEx )
  1363. {
  1364. *iplpv = ( LPVOID ) ( IWbemEventConsumerProviderEx * ) this ;
  1365. }
  1366. else if ( iid == IID__IWmiProviderSubsystemRegistrar )
  1367. {
  1368. *iplpv = ( LPVOID ) ( _IWmiProviderSubsystemRegistrar * ) this ;
  1369. }
  1370. else if ( iid == IID__IWmiProviderInitialize )
  1371. {
  1372. *iplpv = ( LPVOID ) ( _IWmiProviderInitialize * ) this ;
  1373. }
  1374. else if ( iid == IID_CDecoupledAggregator_IWbemProvider )
  1375. {
  1376. *iplpv = ( LPVOID ) ( CDecoupledAggregator_IWbemProvider * ) this ;
  1377. }
  1378. else if ( iid == IID__IWmiProviderCache )
  1379. {
  1380. *iplpv = ( LPVOID ) ( _IWmiProviderCache * ) this ;
  1381. }
  1382. else if ( iid == IID_IWbemShutdown )
  1383. {
  1384. *iplpv = ( LPVOID ) ( IWbemShutdown * )this ;
  1385. }
  1386. if ( *iplpv )
  1387. {
  1388. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  1389. return ResultFromScode ( S_OK ) ;
  1390. }
  1391. else
  1392. {
  1393. return ResultFromScode ( E_NOINTERFACE ) ;
  1394. }
  1395. }
  1396. /******************************************************************************
  1397. *
  1398. * Name:
  1399. *
  1400. *
  1401. * Description:
  1402. *
  1403. *
  1404. *****************************************************************************/
  1405. template <class TInterface, const IID *TInterface_Id>
  1406. HRESULT GetProviders (
  1407. IWbemContext *a_Context ,
  1408. CWbemGlobal_IWbemSyncProviderController *a_Controller ,
  1409. TInterface **&a_Elements ,
  1410. ULONG &a_ElementCount ,
  1411. ULONG &a_ContainerCount
  1412. )
  1413. {
  1414. HRESULT t_Result = S_OK ;
  1415. CWbemGlobal_IWbemSyncProvider_Container *t_Container = NULL ;
  1416. WmiStatusCode t_StatusCode = a_Controller->GetContainer ( t_Container ) ;
  1417. a_Controller->Lock () ;
  1418. a_ContainerCount = t_Container->Size () ;
  1419. a_Elements = new TInterface * [ t_Container->Size () ] ;
  1420. if ( a_Elements )
  1421. {
  1422. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator = t_Container->Begin () ;
  1423. a_ElementCount = 0 ;
  1424. while ( ! t_Iterator.Null () )
  1425. {
  1426. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  1427. a_Elements [ a_ElementCount ] = NULL ;
  1428. _IWmiProviderInitialize *t_Initializer = NULL ;
  1429. t_Result = t_Element->QueryInterface (
  1430. IID__IWmiProviderInitialize ,
  1431. ( void ** ) & t_Initializer
  1432. ) ;
  1433. if ( SUCCEEDED ( t_Result ) )
  1434. {
  1435. t_Result = t_Initializer->WaitProvider ( a_Context , DEFAULT_PROVIDER_LOAD_TIMEOUT ) ;
  1436. if ( SUCCEEDED ( t_Result ) )
  1437. {
  1438. HRESULT t_Result = t_Element->QueryInterface ( *TInterface_Id , ( void ** ) & a_Elements [ a_ElementCount ] ) ;
  1439. if ( SUCCEEDED ( t_Result ) )
  1440. {
  1441. a_ElementCount ++ ;
  1442. }
  1443. }
  1444. t_Initializer->Release () ;
  1445. }
  1446. t_Iterator.Increment () ;
  1447. }
  1448. }
  1449. else
  1450. {
  1451. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1452. }
  1453. a_Controller->UnLock () ;
  1454. return t_Result ;
  1455. }
  1456. /******************************************************************************
  1457. *
  1458. * Name:
  1459. *
  1460. *
  1461. * Description:
  1462. *
  1463. *
  1464. *****************************************************************************/
  1465. template <class TInterface>
  1466. HRESULT ClearProviders (
  1467. TInterface **a_Elements ,
  1468. ULONG a_ElementCount
  1469. )
  1470. {
  1471. HRESULT t_Result = S_OK ;
  1472. for ( ULONG t_Index = 0 ; t_Index < a_ElementCount ; t_Index ++ )
  1473. {
  1474. a_Elements [ t_Index ]->Release () ;
  1475. }
  1476. delete [] a_Elements ;
  1477. return t_Result ;
  1478. }
  1479. /******************************************************************************
  1480. *
  1481. * Name:
  1482. *
  1483. *
  1484. * Description:
  1485. *
  1486. *
  1487. *****************************************************************************/
  1488. HRESULT CDecoupledAggregator_IWbemProvider::OpenNamespace (
  1489. const BSTR a_ObjectPath,
  1490. long a_Flags,
  1491. IWbemContext *a_Context,
  1492. IWbemServices **a_NamespaceService,
  1493. IWbemCallResult **a_CallResult
  1494. )
  1495. {
  1496. return WBEM_E_NOT_AVAILABLE ;
  1497. }
  1498. /******************************************************************************
  1499. *
  1500. * Name:
  1501. *
  1502. *
  1503. * Description:
  1504. *
  1505. *
  1506. *****************************************************************************/
  1507. HRESULT CDecoupledAggregator_IWbemProvider :: CancelAsyncCall (
  1508. IWbemObjectSink *a_Sink
  1509. )
  1510. {
  1511. HRESULT t_Result = S_OK ;
  1512. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1513. Lock () ;
  1514. WmiStatusCode t_StatusCode = Find (
  1515. a_Sink ,
  1516. t_Iterator
  1517. ) ;
  1518. if ( t_StatusCode == e_StatusCode_Success )
  1519. {
  1520. ObjectSinkContainerElement *t_Element = t_Iterator.GetElement () ;
  1521. UnLock () ;
  1522. IObjectSink_CancelOperation *t_ObjectSink = NULL ;
  1523. t_Result = t_Element->QueryInterface ( IID_IObjectSink_CancelOperation , ( void ** ) & t_ObjectSink ) ;
  1524. if ( SUCCEEDED ( t_Result ) )
  1525. {
  1526. t_Result = t_ObjectSink->Cancel (
  1527. 0
  1528. ) ;
  1529. t_ObjectSink->Release () ;
  1530. }
  1531. IWbemShutdown *t_Shutdown = NULL ;
  1532. HRESULT t_TempResult = t_Element->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  1533. if ( SUCCEEDED ( t_TempResult ) )
  1534. {
  1535. t_TempResult = t_Shutdown->Shutdown (
  1536. 0 ,
  1537. 0 ,
  1538. NULL
  1539. ) ;
  1540. t_Shutdown->Release () ;
  1541. }
  1542. t_Element->Release () ;
  1543. }
  1544. else
  1545. {
  1546. UnLock () ;
  1547. t_Result = WBEM_E_NOT_FOUND ;
  1548. }
  1549. return t_Result ;
  1550. }
  1551. /******************************************************************************
  1552. *
  1553. * Name:
  1554. *
  1555. *
  1556. * Description:
  1557. *
  1558. *
  1559. *****************************************************************************/
  1560. HRESULT CDecoupledAggregator_IWbemProvider :: QueryObjectSink (
  1561. long a_Flags,
  1562. IWbemObjectSink **a_Sink
  1563. )
  1564. {
  1565. return WBEM_E_NOT_AVAILABLE ;
  1566. }
  1567. /******************************************************************************
  1568. *
  1569. * Name:
  1570. *
  1571. *
  1572. * Description:
  1573. *
  1574. *
  1575. *****************************************************************************/
  1576. HRESULT CDecoupledAggregator_IWbemProvider :: GetObject (
  1577. const BSTR a_ObjectPath,
  1578. long a_Flags,
  1579. IWbemContext *a_Context,
  1580. IWbemClassObject **a_Object,
  1581. IWbemCallResult **a_CallResult
  1582. )
  1583. {
  1584. return WBEM_E_NOT_AVAILABLE ;
  1585. }
  1586. /******************************************************************************
  1587. *
  1588. * Name:
  1589. *
  1590. *
  1591. * Description:
  1592. *
  1593. *
  1594. *****************************************************************************/
  1595. HRESULT CDecoupledAggregator_IWbemProvider :: GetObjectAsync (
  1596. const BSTR a_ObjectPath,
  1597. long a_Flags,
  1598. IWbemContext *a_Context,
  1599. IWbemObjectSink *a_Sink
  1600. )
  1601. {
  1602. if ( m_Initialized == 0 )
  1603. {
  1604. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  1605. return WBEM_E_NOT_FOUND ;
  1606. }
  1607. BOOL t_ObjectGot = FALSE ;
  1608. IWbemServices **t_Elements = NULL ;
  1609. ULONG t_ElementsCount = 0 ;
  1610. ULONG t_ContainerCount = 0 ;
  1611. HRESULT t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  1612. if ( SUCCEEDED ( t_Result ) )
  1613. {
  1614. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1615. {
  1616. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1617. CInterceptor_IWbemWaitingObjectSink *t_GettingSink = new CInterceptor_IWbemWaitingObjectSink (
  1618. m_Allocator ,
  1619. t_Provider ,
  1620. a_Sink ,
  1621. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  1622. *m_Registration
  1623. ) ;
  1624. if ( t_GettingSink )
  1625. {
  1626. t_GettingSink->AddRef () ;
  1627. if ( SUCCEEDED ( t_Result ) )
  1628. {
  1629. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1630. Lock () ;
  1631. WmiStatusCode t_StatusCode = Insert (
  1632. *t_GettingSink ,
  1633. t_Iterator
  1634. ) ;
  1635. UnLock () ;
  1636. if ( t_StatusCode == e_StatusCode_Success )
  1637. {
  1638. t_Result = t_Provider->GetObjectAsync (
  1639. a_ObjectPath ,
  1640. 0 ,
  1641. a_Context,
  1642. t_GettingSink
  1643. ) ;
  1644. if ( FAILED ( t_Result ) )
  1645. {
  1646. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  1647. {
  1648. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  1649. }
  1650. }
  1651. if ( SUCCEEDED ( t_Result ) )
  1652. {
  1653. t_Result = t_GettingSink->Wait ( INFINITE ) ;
  1654. if ( SUCCEEDED ( t_Result ) )
  1655. {
  1656. t_Result = t_GettingSink->GetResult () ;
  1657. if ( SUCCEEDED ( t_Result ) )
  1658. {
  1659. t_ObjectGot = TRUE ;
  1660. }
  1661. else
  1662. {
  1663. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1664. {
  1665. t_Result = S_OK ;
  1666. }
  1667. }
  1668. }
  1669. }
  1670. else
  1671. {
  1672. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1673. {
  1674. t_Result = S_OK ;
  1675. }
  1676. }
  1677. }
  1678. else
  1679. {
  1680. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1681. }
  1682. WmiQueue <IWbemClassObject *,8> &t_Queue = t_GettingSink->GetQueue () ;
  1683. IWbemClassObject *t_Object = NULL ;
  1684. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  1685. {
  1686. if ( SUCCEEDED ( t_Result ) )
  1687. {
  1688. t_Result = a_Sink->Indicate ( 1 , & t_Object ) ;
  1689. }
  1690. t_Object->Release () ;
  1691. t_StatusCode = t_Queue.DeQueue () ;
  1692. }
  1693. }
  1694. t_GettingSink->Release () ;
  1695. }
  1696. else
  1697. {
  1698. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1699. }
  1700. }
  1701. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1702. }
  1703. if ( SUCCEEDED ( t_Result ) )
  1704. {
  1705. if ( t_ObjectGot == FALSE )
  1706. {
  1707. if ( t_ElementsCount )
  1708. {
  1709. t_Result = WBEM_E_NOT_FOUND ;
  1710. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1711. }
  1712. else
  1713. {
  1714. SetStatus ( L"GetObjectAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_E_NOT_FOUND , a_Sink ) ;
  1715. }
  1716. }
  1717. else
  1718. {
  1719. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1720. }
  1721. }
  1722. else
  1723. {
  1724. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1725. }
  1726. return t_Result ;
  1727. }
  1728. /******************************************************************************
  1729. *
  1730. * Name:
  1731. *
  1732. *
  1733. * Description:
  1734. *
  1735. *
  1736. *****************************************************************************/
  1737. HRESULT CDecoupledAggregator_IWbemProvider :: PutClass (
  1738. IWbemClassObject *a_Object,
  1739. long a_Flags,
  1740. IWbemContext *a_Context,
  1741. IWbemCallResult **a_CallResult
  1742. )
  1743. {
  1744. return WBEM_E_NOT_AVAILABLE ;
  1745. }
  1746. /******************************************************************************
  1747. *
  1748. * Name:
  1749. *
  1750. *
  1751. * Description:
  1752. *
  1753. *
  1754. *****************************************************************************/
  1755. HRESULT CDecoupledAggregator_IWbemProvider :: PutClassAsync (
  1756. IWbemClassObject *a_Object,
  1757. long a_Flags,
  1758. IWbemContext *a_Context,
  1759. IWbemObjectSink *a_Sink
  1760. )
  1761. {
  1762. if ( m_Initialized == 0 )
  1763. {
  1764. if ( WBEM_FLAG_ADVISORY & a_Flags )
  1765. {
  1766. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1767. return S_OK ;
  1768. }
  1769. else
  1770. {
  1771. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  1772. return WBEM_E_NOT_FOUND ;
  1773. }
  1774. }
  1775. BOOL t_ClassPut = FALSE ;
  1776. IWbemServices **t_Elements = NULL ;
  1777. ULONG t_ElementsCount = 0 ;
  1778. ULONG t_ContainerCount = 0 ;
  1779. HRESULT t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  1780. if ( SUCCEEDED ( t_Result ) )
  1781. {
  1782. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1783. {
  1784. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1785. CInterceptor_IWbemWaitingObjectSink *t_ClassPuttingSink = new CInterceptor_IWbemWaitingObjectSink (
  1786. m_Allocator ,
  1787. t_Provider ,
  1788. a_Sink ,
  1789. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  1790. *m_Registration
  1791. ) ;
  1792. if ( t_ClassPuttingSink )
  1793. {
  1794. t_ClassPuttingSink->AddRef () ;
  1795. if ( SUCCEEDED ( t_Result ) )
  1796. {
  1797. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1798. Lock () ;
  1799. WmiStatusCode t_StatusCode = Insert (
  1800. *t_ClassPuttingSink ,
  1801. t_Iterator
  1802. ) ;
  1803. UnLock () ;
  1804. if ( t_StatusCode == e_StatusCode_Success )
  1805. {
  1806. t_Result = t_Provider->PutClassAsync (
  1807. a_Object ,
  1808. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  1809. a_Context,
  1810. t_ClassPuttingSink
  1811. ) ;
  1812. if ( FAILED ( t_Result ) )
  1813. {
  1814. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  1815. {
  1816. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  1817. }
  1818. }
  1819. if ( SUCCEEDED ( t_Result ) )
  1820. {
  1821. t_Result = t_ClassPuttingSink->Wait ( INFINITE ) ;
  1822. if ( SUCCEEDED ( t_Result ) )
  1823. {
  1824. if ( SUCCEEDED ( t_ClassPuttingSink->GetResult () ) )
  1825. {
  1826. t_ClassPut = TRUE ;
  1827. }
  1828. }
  1829. else
  1830. {
  1831. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1832. {
  1833. t_Result = S_OK ;
  1834. }
  1835. }
  1836. }
  1837. else
  1838. {
  1839. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1840. {
  1841. t_Result = S_OK ;
  1842. }
  1843. }
  1844. }
  1845. else
  1846. {
  1847. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1848. }
  1849. WmiQueue <IWbemClassObject *,8> &t_Queue = t_ClassPuttingSink->GetQueue () ;
  1850. IWbemClassObject *t_Object = NULL ;
  1851. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  1852. {
  1853. t_Object->Release () ;
  1854. t_StatusCode = t_Queue.DeQueue () ;
  1855. }
  1856. }
  1857. t_ClassPuttingSink->Release () ;
  1858. }
  1859. else
  1860. {
  1861. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1862. }
  1863. }
  1864. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  1865. }
  1866. if ( SUCCEEDED ( t_Result ) )
  1867. {
  1868. if ( t_ClassPut == FALSE )
  1869. {
  1870. if ( t_ElementsCount )
  1871. {
  1872. t_Result = WBEM_E_NOT_FOUND ;
  1873. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1874. }
  1875. else
  1876. {
  1877. SetStatus ( L"PutClassAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_E_NOT_FOUND , a_Sink ) ;
  1878. }
  1879. }
  1880. else
  1881. {
  1882. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1883. }
  1884. }
  1885. else
  1886. {
  1887. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1888. }
  1889. return t_Result ;
  1890. }
  1891. /******************************************************************************
  1892. *
  1893. * Name:
  1894. *
  1895. *
  1896. * Description:
  1897. *
  1898. *
  1899. *****************************************************************************/
  1900. HRESULT CDecoupledAggregator_IWbemProvider :: DeleteClass (
  1901. const BSTR a_Class,
  1902. long a_Flags,
  1903. IWbemContext *a_Context,
  1904. IWbemCallResult **a_CallResult
  1905. )
  1906. {
  1907. return WBEM_E_NOT_AVAILABLE ;
  1908. }
  1909. /******************************************************************************
  1910. *
  1911. * Name:
  1912. *
  1913. *
  1914. * Description:
  1915. *
  1916. *
  1917. *****************************************************************************/
  1918. HRESULT CDecoupledAggregator_IWbemProvider :: DeleteClassAsync (
  1919. const BSTR a_Class,
  1920. long a_Flags,
  1921. IWbemContext *a_Context,
  1922. IWbemObjectSink *a_Sink
  1923. )
  1924. {
  1925. if ( m_Initialized == 0 )
  1926. {
  1927. if ( WBEM_FLAG_ADVISORY & a_Flags )
  1928. {
  1929. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1930. return S_OK ;
  1931. }
  1932. else
  1933. {
  1934. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  1935. return WBEM_E_NOT_FOUND ;
  1936. }
  1937. }
  1938. BOOL t_ClassDeleted = FALSE ;
  1939. IWbemServices **t_Elements = NULL ;
  1940. ULONG t_ElementsCount = 0 ;
  1941. ULONG t_ContainerCount = 0 ;
  1942. HRESULT t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  1943. if ( SUCCEEDED ( t_Result ) )
  1944. {
  1945. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  1946. {
  1947. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  1948. CInterceptor_IWbemWaitingObjectSink *t_ClassDeletingSink = new CInterceptor_IWbemWaitingObjectSink (
  1949. m_Allocator ,
  1950. t_Provider ,
  1951. a_Sink ,
  1952. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  1953. *m_Registration
  1954. ) ;
  1955. if ( t_ClassDeletingSink )
  1956. {
  1957. t_ClassDeletingSink->AddRef () ;
  1958. if ( SUCCEEDED ( t_Result ) )
  1959. {
  1960. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1961. Lock () ;
  1962. WmiStatusCode t_StatusCode = Insert (
  1963. *t_ClassDeletingSink ,
  1964. t_Iterator
  1965. ) ;
  1966. UnLock () ;
  1967. if ( t_StatusCode == e_StatusCode_Success )
  1968. {
  1969. t_Result = t_Provider->DeleteClassAsync (
  1970. a_Class ,
  1971. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  1972. a_Context,
  1973. t_ClassDeletingSink
  1974. ) ;
  1975. if ( FAILED ( t_Result ) )
  1976. {
  1977. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  1978. {
  1979. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  1980. }
  1981. }
  1982. if ( SUCCEEDED ( t_Result ) )
  1983. {
  1984. t_Result = t_ClassDeletingSink->Wait ( INFINITE ) ;
  1985. if ( SUCCEEDED ( t_Result ) )
  1986. {
  1987. if ( SUCCEEDED ( t_ClassDeletingSink->GetResult () ) )
  1988. {
  1989. t_ClassDeleted = TRUE ;
  1990. }
  1991. }
  1992. else
  1993. {
  1994. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  1995. {
  1996. t_Result = S_OK ;
  1997. }
  1998. }
  1999. }
  2000. else
  2001. {
  2002. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2003. {
  2004. t_Result = S_OK ;
  2005. }
  2006. }
  2007. }
  2008. else
  2009. {
  2010. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2011. }
  2012. WmiQueue <IWbemClassObject *,8> &t_Queue = t_ClassDeletingSink->GetQueue () ;
  2013. IWbemClassObject *t_Object = NULL ;
  2014. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  2015. {
  2016. t_Object->Release () ;
  2017. t_StatusCode = t_Queue.DeQueue () ;
  2018. }
  2019. }
  2020. t_ClassDeletingSink->Release () ;
  2021. }
  2022. else
  2023. {
  2024. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2025. }
  2026. }
  2027. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2028. }
  2029. if ( SUCCEEDED ( t_Result ) )
  2030. {
  2031. if ( t_ClassDeleted == FALSE )
  2032. {
  2033. if ( t_ElementsCount )
  2034. {
  2035. t_Result = WBEM_E_NOT_FOUND ;
  2036. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2037. }
  2038. else
  2039. {
  2040. SetStatus ( L"DeleteClassAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_E_NOT_FOUND , a_Sink ) ;
  2041. }
  2042. }
  2043. else
  2044. {
  2045. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2046. }
  2047. }
  2048. else
  2049. {
  2050. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2051. }
  2052. return t_Result ;
  2053. }
  2054. /******************************************************************************
  2055. *
  2056. * Name:
  2057. *
  2058. *
  2059. * Description:
  2060. *
  2061. *
  2062. *****************************************************************************/
  2063. HRESULT CDecoupledAggregator_IWbemProvider :: CreateClassEnum (
  2064. const BSTR a_Superclass,
  2065. long a_Flags,
  2066. IWbemContext *a_Context,
  2067. IEnumWbemClassObject **a_Enum
  2068. )
  2069. {
  2070. return WBEM_E_NOT_AVAILABLE ;
  2071. }
  2072. /******************************************************************************
  2073. *
  2074. * Name:
  2075. *
  2076. *
  2077. * Description:
  2078. *
  2079. *
  2080. *****************************************************************************/
  2081. SCODE CDecoupledAggregator_IWbemProvider :: CreateClassEnumAsync (
  2082. const BSTR a_Superclass ,
  2083. long a_Flags,
  2084. IWbemContext *a_Context,
  2085. IWbemObjectSink *a_Sink
  2086. )
  2087. {
  2088. if ( m_Initialized == 0 )
  2089. {
  2090. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2091. return S_OK ;
  2092. }
  2093. HRESULT t_Result = S_OK ;
  2094. CInterceptor_DecoupledIWbemCombiningObjectSink *t_CombiningSink = new CInterceptor_DecoupledIWbemCombiningObjectSink (
  2095. m_Allocator ,
  2096. a_Sink ,
  2097. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2098. ) ;
  2099. if ( t_CombiningSink )
  2100. {
  2101. t_CombiningSink->AddRef () ;
  2102. t_CombiningSink->Suspend () ;
  2103. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2104. Lock () ;
  2105. WmiStatusCode t_StatusCode = Insert (
  2106. *t_CombiningSink ,
  2107. t_Iterator
  2108. ) ;
  2109. UnLock () ;
  2110. if ( t_StatusCode == e_StatusCode_Success )
  2111. {
  2112. IWbemServices **t_Elements = NULL ;
  2113. ULONG t_ElementsCount = 0 ;
  2114. ULONG t_ContainerCount = 0 ;
  2115. t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  2116. if ( SUCCEEDED ( t_Result ) )
  2117. {
  2118. BOOL t_ProviderFound = FALSE ;
  2119. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  2120. {
  2121. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  2122. CInterceptor_DecoupledIWbemObjectSink *t_Sink = new CInterceptor_DecoupledIWbemObjectSink (
  2123. t_Provider ,
  2124. t_CombiningSink ,
  2125. ( IWbemObjectSink * ) t_CombiningSink ,
  2126. ( CWbemGlobal_IWmiObjectSinkController * ) t_CombiningSink
  2127. ) ;
  2128. if ( t_Sink )
  2129. {
  2130. t_Sink->AddRef () ;
  2131. if ( SUCCEEDED ( t_Result ) )
  2132. {
  2133. t_Result = t_CombiningSink->EnQueue ( t_Sink ) ;
  2134. if ( SUCCEEDED ( t_Result ) )
  2135. {
  2136. t_Result = t_Provider->CreateClassEnumAsync (
  2137. a_Superclass ,
  2138. a_Flags,
  2139. a_Context,
  2140. t_Sink
  2141. ) ;
  2142. if ( FAILED ( t_Result ) )
  2143. {
  2144. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  2145. {
  2146. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  2147. }
  2148. }
  2149. if ( SUCCEEDED ( t_Result ) )
  2150. {
  2151. }
  2152. else
  2153. {
  2154. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2155. {
  2156. t_Result = S_OK ;
  2157. }
  2158. }
  2159. }
  2160. }
  2161. t_Sink->Release () ;
  2162. }
  2163. else
  2164. {
  2165. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2166. }
  2167. }
  2168. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2169. }
  2170. if ( SUCCEEDED ( t_Result ) && t_ElementsCount )
  2171. {
  2172. t_CombiningSink->Resume () ;
  2173. t_Result = t_CombiningSink->Wait ( INFINITE ) ;
  2174. }
  2175. else
  2176. {
  2177. SetStatus ( L"CreateClassEnumAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_S_SOURCE_NOT_AVAILABLE , a_Sink ) ;
  2178. }
  2179. }
  2180. else
  2181. {
  2182. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2183. }
  2184. t_CombiningSink->Release () ;
  2185. }
  2186. else
  2187. {
  2188. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2189. }
  2190. return t_Result ;
  2191. }
  2192. /******************************************************************************
  2193. *
  2194. * Name:
  2195. *
  2196. *
  2197. * Description:
  2198. *
  2199. *
  2200. *****************************************************************************/
  2201. HRESULT CDecoupledAggregator_IWbemProvider :: PutInstance (
  2202. IWbemClassObject *a_Instance,
  2203. long a_Flags,
  2204. IWbemContext *a_Context,
  2205. IWbemCallResult **a_CallResult
  2206. )
  2207. {
  2208. return WBEM_E_NOT_AVAILABLE ;
  2209. }
  2210. /******************************************************************************
  2211. *
  2212. * Name:
  2213. *
  2214. *
  2215. * Description:
  2216. *
  2217. *
  2218. *****************************************************************************/
  2219. HRESULT CDecoupledAggregator_IWbemProvider :: PutInstanceAsync (
  2220. IWbemClassObject *a_Instance,
  2221. long a_Flags ,
  2222. IWbemContext *a_Context ,
  2223. IWbemObjectSink *a_Sink
  2224. )
  2225. {
  2226. if ( m_Initialized == 0 )
  2227. {
  2228. if ( WBEM_FLAG_ADVISORY & a_Flags )
  2229. {
  2230. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2231. return S_OK ;
  2232. }
  2233. else
  2234. {
  2235. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2236. return WBEM_E_NOT_FOUND ;
  2237. }
  2238. }
  2239. BOOL t_InstancePut = FALSE ;
  2240. IWbemServices **t_Elements = NULL ;
  2241. ULONG t_ElementsCount = 0 ;
  2242. ULONG t_ContainerCount = 0 ;
  2243. HRESULT t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  2244. if ( SUCCEEDED ( t_Result ) )
  2245. {
  2246. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  2247. {
  2248. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  2249. CInterceptor_IWbemWaitingObjectSink *t_InstancePuttingSink = new CInterceptor_IWbemWaitingObjectSink (
  2250. m_Allocator ,
  2251. t_Provider ,
  2252. a_Sink ,
  2253. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  2254. *m_Registration
  2255. ) ;
  2256. if ( t_InstancePuttingSink )
  2257. {
  2258. t_InstancePuttingSink->AddRef () ;
  2259. if ( SUCCEEDED ( t_Result ) )
  2260. {
  2261. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2262. Lock () ;
  2263. WmiStatusCode t_StatusCode = Insert (
  2264. *t_InstancePuttingSink ,
  2265. t_Iterator
  2266. ) ;
  2267. UnLock () ;
  2268. if ( t_StatusCode == e_StatusCode_Success )
  2269. {
  2270. t_Result = t_Provider->PutInstanceAsync (
  2271. a_Instance ,
  2272. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  2273. a_Context,
  2274. t_InstancePuttingSink
  2275. ) ;
  2276. if ( FAILED ( t_Result ) )
  2277. {
  2278. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  2279. {
  2280. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  2281. }
  2282. }
  2283. if ( SUCCEEDED ( t_Result ) )
  2284. {
  2285. t_Result = t_InstancePuttingSink->Wait ( INFINITE ) ;
  2286. if ( SUCCEEDED ( t_Result ) )
  2287. {
  2288. if ( SUCCEEDED ( t_InstancePuttingSink->GetResult () ) )
  2289. {
  2290. t_InstancePut = TRUE ;
  2291. }
  2292. }
  2293. else
  2294. {
  2295. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2296. {
  2297. t_Result = S_OK ;
  2298. }
  2299. }
  2300. }
  2301. else
  2302. {
  2303. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2304. {
  2305. t_Result = S_OK ;
  2306. }
  2307. }
  2308. }
  2309. else
  2310. {
  2311. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2312. }
  2313. WmiQueue <IWbemClassObject *,8> &t_Queue = t_InstancePuttingSink->GetQueue () ;
  2314. IWbemClassObject *t_Object = NULL ;
  2315. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  2316. {
  2317. t_Object->Release () ;
  2318. t_StatusCode = t_Queue.DeQueue () ;
  2319. }
  2320. }
  2321. t_InstancePuttingSink->Release () ;
  2322. }
  2323. else
  2324. {
  2325. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2326. }
  2327. }
  2328. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2329. }
  2330. if ( SUCCEEDED ( t_Result ) )
  2331. {
  2332. if ( t_InstancePut == FALSE )
  2333. {
  2334. if ( t_ElementsCount )
  2335. {
  2336. t_Result = WBEM_E_NOT_FOUND ;
  2337. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2338. }
  2339. else
  2340. {
  2341. SetStatus ( L"PutInstanceAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_E_NOT_FOUND , a_Sink ) ;
  2342. }
  2343. }
  2344. else
  2345. {
  2346. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2347. }
  2348. }
  2349. else
  2350. {
  2351. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2352. }
  2353. return t_Result ;
  2354. }
  2355. /******************************************************************************
  2356. *
  2357. * Name:
  2358. *
  2359. *
  2360. * Description:
  2361. *
  2362. *
  2363. *****************************************************************************/
  2364. HRESULT CDecoupledAggregator_IWbemProvider :: DeleteInstance (
  2365. const BSTR a_ObjectPath,
  2366. long a_Flags,
  2367. IWbemContext *a_Context,
  2368. IWbemCallResult **a_CallResult
  2369. )
  2370. {
  2371. return WBEM_E_NOT_AVAILABLE ;
  2372. }
  2373. /******************************************************************************
  2374. *
  2375. * Name:
  2376. *
  2377. *
  2378. * Description:
  2379. *
  2380. *
  2381. *****************************************************************************/
  2382. HRESULT CDecoupledAggregator_IWbemProvider :: DeleteInstanceAsync (
  2383. const BSTR a_ObjectPath,
  2384. long a_Flags,
  2385. IWbemContext *a_Context,
  2386. IWbemObjectSink *a_Sink
  2387. )
  2388. {
  2389. if ( m_Initialized == 0 )
  2390. {
  2391. if ( WBEM_FLAG_ADVISORY & a_Flags )
  2392. {
  2393. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2394. return S_OK ;
  2395. }
  2396. else
  2397. {
  2398. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2399. return WBEM_E_NOT_FOUND ;
  2400. }
  2401. }
  2402. BOOL t_InstanceDeleted = FALSE ;
  2403. IWbemServices **t_Elements = NULL ;
  2404. ULONG t_ElementsCount = 0 ;
  2405. ULONG t_ContainerCount = 0 ;
  2406. HRESULT t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  2407. if ( SUCCEEDED ( t_Result ) )
  2408. {
  2409. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  2410. {
  2411. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  2412. CInterceptor_IWbemWaitingObjectSink *t_InstanceDeletingSink = new CInterceptor_IWbemWaitingObjectSink (
  2413. m_Allocator ,
  2414. t_Provider ,
  2415. a_Sink ,
  2416. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  2417. *m_Registration
  2418. ) ;
  2419. if ( t_InstanceDeletingSink )
  2420. {
  2421. t_InstanceDeletingSink->AddRef () ;
  2422. if ( SUCCEEDED ( t_Result ) )
  2423. {
  2424. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2425. Lock () ;
  2426. WmiStatusCode t_StatusCode = Insert (
  2427. *t_InstanceDeletingSink ,
  2428. t_Iterator
  2429. ) ;
  2430. UnLock () ;
  2431. if ( t_StatusCode == e_StatusCode_Success )
  2432. {
  2433. t_Result = t_Provider->DeleteInstanceAsync (
  2434. a_ObjectPath ,
  2435. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  2436. a_Context,
  2437. t_InstanceDeletingSink
  2438. ) ;
  2439. if ( FAILED ( t_Result ) )
  2440. {
  2441. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  2442. {
  2443. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  2444. }
  2445. }
  2446. if ( SUCCEEDED ( t_Result ) )
  2447. {
  2448. t_Result = t_InstanceDeletingSink->Wait ( INFINITE ) ;
  2449. if ( SUCCEEDED ( t_Result ) )
  2450. {
  2451. if ( SUCCEEDED ( t_InstanceDeletingSink->GetResult () ) )
  2452. {
  2453. t_InstanceDeleted = TRUE ;
  2454. }
  2455. }
  2456. else
  2457. {
  2458. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2459. {
  2460. t_Result = S_OK ;
  2461. }
  2462. }
  2463. }
  2464. else
  2465. {
  2466. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2467. {
  2468. t_Result = S_OK ;
  2469. }
  2470. }
  2471. }
  2472. else
  2473. {
  2474. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2475. }
  2476. WmiQueue <IWbemClassObject *,8> &t_Queue = t_InstanceDeletingSink->GetQueue () ;
  2477. IWbemClassObject *t_Object = NULL ;
  2478. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  2479. {
  2480. t_Object->Release () ;
  2481. t_StatusCode = t_Queue.DeQueue () ;
  2482. }
  2483. }
  2484. t_InstanceDeletingSink->Release () ;
  2485. }
  2486. else
  2487. {
  2488. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2489. }
  2490. }
  2491. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2492. }
  2493. if ( SUCCEEDED ( t_Result ) )
  2494. {
  2495. if ( t_InstanceDeleted == FALSE )
  2496. {
  2497. if ( t_ElementsCount )
  2498. {
  2499. t_Result = WBEM_E_NOT_FOUND ;
  2500. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2501. }
  2502. else
  2503. {
  2504. SetStatus ( L"DeleteInstanceAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_E_NOT_FOUND , a_Sink ) ;
  2505. }
  2506. }
  2507. else
  2508. {
  2509. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2510. }
  2511. }
  2512. else
  2513. {
  2514. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2515. }
  2516. return t_Result ;
  2517. }
  2518. /******************************************************************************
  2519. *
  2520. * Name:
  2521. *
  2522. *
  2523. * Description:
  2524. *
  2525. *
  2526. *****************************************************************************/
  2527. HRESULT CDecoupledAggregator_IWbemProvider :: CreateInstanceEnum (
  2528. const BSTR a_Class,
  2529. long a_Flags,
  2530. IWbemContext *a_Context,
  2531. IEnumWbemClassObject **a_Enum
  2532. )
  2533. {
  2534. return WBEM_E_NOT_AVAILABLE ;
  2535. }
  2536. /******************************************************************************
  2537. *
  2538. * Name:
  2539. *
  2540. *
  2541. * Description:
  2542. *
  2543. *
  2544. *****************************************************************************/
  2545. HRESULT CDecoupledAggregator_IWbemProvider :: CreateInstanceEnumAsync (
  2546. const BSTR a_Class ,
  2547. long a_Flags ,
  2548. IWbemContext *a_Context ,
  2549. IWbemObjectSink *a_Sink
  2550. )
  2551. {
  2552. if ( m_Initialized == 0 )
  2553. {
  2554. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2555. return S_OK ;
  2556. }
  2557. HRESULT t_Result = S_OK ;
  2558. CInterceptor_DecoupledIWbemCombiningObjectSink *t_CombiningSink = new CInterceptor_DecoupledIWbemCombiningObjectSink (
  2559. m_Allocator ,
  2560. a_Sink ,
  2561. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2562. ) ;
  2563. if ( t_CombiningSink )
  2564. {
  2565. t_CombiningSink->AddRef () ;
  2566. t_CombiningSink->Suspend () ;
  2567. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2568. Lock () ;
  2569. WmiStatusCode t_StatusCode = Insert (
  2570. *t_CombiningSink ,
  2571. t_Iterator
  2572. ) ;
  2573. UnLock () ;
  2574. if ( t_StatusCode == e_StatusCode_Success )
  2575. {
  2576. IWbemServices **t_Elements = NULL ;
  2577. ULONG t_ElementsCount = 0 ;
  2578. ULONG t_ContainerCount = 0 ;
  2579. t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  2580. if ( SUCCEEDED ( t_Result ) )
  2581. {
  2582. BOOL t_ProviderFound = FALSE ;
  2583. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  2584. {
  2585. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  2586. CInterceptor_DecoupledIWbemObjectSink *t_Sink = new CInterceptor_DecoupledIWbemObjectSink (
  2587. t_Provider ,
  2588. t_CombiningSink ,
  2589. ( IWbemObjectSink * ) t_CombiningSink ,
  2590. ( CWbemGlobal_IWmiObjectSinkController * ) t_CombiningSink
  2591. ) ;
  2592. if ( t_Sink )
  2593. {
  2594. t_Sink->AddRef () ;
  2595. if ( SUCCEEDED ( t_Result ) )
  2596. {
  2597. t_Result = t_CombiningSink->EnQueue ( t_Sink ) ;
  2598. if ( SUCCEEDED ( t_Result ) )
  2599. {
  2600. t_Result = t_Provider->CreateInstanceEnumAsync (
  2601. a_Class,
  2602. a_Flags,
  2603. a_Context,
  2604. t_Sink
  2605. ) ;
  2606. if ( FAILED ( t_Result ) )
  2607. {
  2608. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  2609. {
  2610. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  2611. }
  2612. }
  2613. if ( SUCCEEDED ( t_Result ) )
  2614. {
  2615. }
  2616. else
  2617. {
  2618. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2619. {
  2620. t_Result = S_OK ;
  2621. }
  2622. }
  2623. }
  2624. }
  2625. t_Sink->Release () ;
  2626. }
  2627. else
  2628. {
  2629. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2630. }
  2631. }
  2632. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2633. }
  2634. if ( SUCCEEDED ( t_Result ) && t_ElementsCount )
  2635. {
  2636. t_CombiningSink->Resume () ;
  2637. t_Result = t_CombiningSink->Wait ( INFINITE ) ;
  2638. }
  2639. else
  2640. {
  2641. SetStatus ( L"CreateInstanceEnumAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_S_SOURCE_NOT_AVAILABLE , a_Sink ) ;
  2642. }
  2643. }
  2644. else
  2645. {
  2646. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2647. }
  2648. t_CombiningSink->Release () ;
  2649. }
  2650. else
  2651. {
  2652. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2653. }
  2654. return t_Result ;
  2655. }
  2656. /******************************************************************************
  2657. *
  2658. * Name:
  2659. *
  2660. *
  2661. * Description:
  2662. *
  2663. *
  2664. *****************************************************************************/
  2665. HRESULT CDecoupledAggregator_IWbemProvider :: ExecQuery (
  2666. const BSTR a_QueryLanguage,
  2667. const BSTR a_Query,
  2668. long a_Flags,
  2669. IWbemContext *a_Context,
  2670. IEnumWbemClassObject **a_Enum
  2671. )
  2672. {
  2673. return WBEM_E_NOT_AVAILABLE ;
  2674. }
  2675. /******************************************************************************
  2676. *
  2677. * Name:
  2678. *
  2679. *
  2680. * Description:
  2681. *
  2682. *
  2683. *****************************************************************************/
  2684. HRESULT CDecoupledAggregator_IWbemProvider :: ExecQueryAsync (
  2685. const BSTR a_QueryLanguage,
  2686. const BSTR a_Query,
  2687. long a_Flags,
  2688. IWbemContext *a_Context,
  2689. IWbemObjectSink *a_Sink
  2690. )
  2691. {
  2692. if ( m_Initialized == 0 )
  2693. {
  2694. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2695. return S_OK ;
  2696. }
  2697. HRESULT t_Result = S_OK ;
  2698. CInterceptor_DecoupledIWbemCombiningObjectSink *t_CombiningSink = new CInterceptor_DecoupledIWbemCombiningObjectSink (
  2699. m_Allocator ,
  2700. a_Sink ,
  2701. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2702. ) ;
  2703. if ( t_CombiningSink )
  2704. {
  2705. t_CombiningSink->AddRef () ;
  2706. t_CombiningSink->Suspend () ;
  2707. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2708. Lock () ;
  2709. WmiStatusCode t_StatusCode = Insert (
  2710. *t_CombiningSink ,
  2711. t_Iterator
  2712. ) ;
  2713. UnLock () ;
  2714. if ( t_StatusCode == e_StatusCode_Success )
  2715. {
  2716. IWbemServices **t_Elements = NULL ;
  2717. ULONG t_ElementsCount = 0 ;
  2718. ULONG t_ContainerCount = 0 ;
  2719. t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  2720. if ( SUCCEEDED ( t_Result ) )
  2721. {
  2722. BOOL t_ProviderFound = FALSE ;
  2723. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  2724. {
  2725. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  2726. CInterceptor_DecoupledIWbemObjectSink *t_Sink = new CInterceptor_DecoupledIWbemObjectSink (
  2727. t_Provider ,
  2728. t_CombiningSink ,
  2729. ( IWbemObjectSink * ) t_CombiningSink ,
  2730. ( CWbemGlobal_IWmiObjectSinkController * ) t_CombiningSink
  2731. ) ;
  2732. if ( t_Sink )
  2733. {
  2734. t_Sink->AddRef () ;
  2735. if ( SUCCEEDED ( t_Result ) )
  2736. {
  2737. t_Result = t_CombiningSink->EnQueue ( t_Sink ) ;
  2738. if ( SUCCEEDED ( t_Result ) )
  2739. {
  2740. t_Result = t_Provider->ExecQueryAsync (
  2741. a_QueryLanguage,
  2742. a_Query,
  2743. a_Flags,
  2744. a_Context,
  2745. t_Sink
  2746. ) ;
  2747. if ( FAILED ( t_Result ) )
  2748. {
  2749. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  2750. {
  2751. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  2752. }
  2753. }
  2754. if ( SUCCEEDED ( t_Result ) )
  2755. {
  2756. }
  2757. else
  2758. {
  2759. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2760. {
  2761. t_Result = S_OK ;
  2762. }
  2763. }
  2764. }
  2765. }
  2766. t_Sink->Release () ;
  2767. }
  2768. else
  2769. {
  2770. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2771. }
  2772. }
  2773. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2774. }
  2775. if ( SUCCEEDED ( t_Result ) && t_ElementsCount )
  2776. {
  2777. t_CombiningSink->Resume () ;
  2778. t_Result = t_CombiningSink->Wait ( INFINITE ) ;
  2779. }
  2780. else
  2781. {
  2782. SetStatus ( L"ExecQueryAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_S_SOURCE_NOT_AVAILABLE , a_Sink ) ;
  2783. }
  2784. }
  2785. else
  2786. {
  2787. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2788. }
  2789. t_CombiningSink->Release () ;
  2790. }
  2791. else
  2792. {
  2793. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2794. }
  2795. return t_Result ;
  2796. }
  2797. /******************************************************************************
  2798. *
  2799. * Name:
  2800. *
  2801. *
  2802. * Description:
  2803. *
  2804. *
  2805. *****************************************************************************/
  2806. HRESULT CDecoupledAggregator_IWbemProvider :: ExecNotificationQuery (
  2807. const BSTR a_QueryLanguage,
  2808. const BSTR a_Query,
  2809. long a_Flags,
  2810. IWbemContext *a_Context,
  2811. IEnumWbemClassObject **a_Enum
  2812. )
  2813. {
  2814. return WBEM_E_NOT_AVAILABLE ;
  2815. }
  2816. /******************************************************************************
  2817. *
  2818. * Name:
  2819. *
  2820. *
  2821. * Description:
  2822. *
  2823. *
  2824. *****************************************************************************/
  2825. HRESULT CDecoupledAggregator_IWbemProvider :: ExecNotificationQueryAsync (
  2826. const BSTR a_QueryLanguage ,
  2827. const BSTR a_Query,
  2828. long a_Flags,
  2829. IWbemContext *a_Context,
  2830. IWbemObjectSink *a_Sink
  2831. )
  2832. {
  2833. return WBEM_E_NOT_AVAILABLE ;
  2834. }
  2835. /******************************************************************************
  2836. *
  2837. * Name:
  2838. *
  2839. *
  2840. * Description:
  2841. *
  2842. *
  2843. *****************************************************************************/
  2844. HRESULT STDMETHODCALLTYPE CDecoupledAggregator_IWbemProvider :: ExecMethod (
  2845. const BSTR a_ObjectPath ,
  2846. const BSTR a_MethodName ,
  2847. long a_Flags ,
  2848. IWbemContext *a_Context ,
  2849. IWbemClassObject *a_InParams ,
  2850. IWbemClassObject **a_OutParams ,
  2851. IWbemCallResult **a_CallResult
  2852. )
  2853. {
  2854. return WBEM_E_NOT_AVAILABLE ;
  2855. }
  2856. /******************************************************************************
  2857. *
  2858. * Name:
  2859. *
  2860. *
  2861. * Description:
  2862. *
  2863. *
  2864. *****************************************************************************/
  2865. HRESULT CDecoupledAggregator_IWbemProvider :: ExecMethodAsync (
  2866. const BSTR a_ObjectPath,
  2867. const BSTR a_MethodName,
  2868. long a_Flags,
  2869. IWbemContext *a_Context,
  2870. IWbemClassObject *a_InParams,
  2871. IWbemObjectSink *a_Sink
  2872. )
  2873. {
  2874. if ( m_Initialized == 0 )
  2875. {
  2876. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2877. return WBEM_E_NOT_FOUND ;
  2878. }
  2879. BOOL t_MethodCalled = FALSE ;
  2880. IWbemServices **t_Elements = NULL ;
  2881. ULONG t_ElementsCount = 0 ;
  2882. ULONG t_ContainerCount = 0 ;
  2883. HRESULT t_Result = GetProviders <IWbemServices,&IID_IWbemServices> ( a_Context , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  2884. if ( SUCCEEDED ( t_Result ) )
  2885. {
  2886. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) && !t_MethodCalled ; t_Index ++ )
  2887. {
  2888. IWbemServices *t_Provider = t_Elements [ t_Index ] ;
  2889. CInterceptor_IWbemWaitingObjectSink *t_MethodSink = new CInterceptor_IWbemWaitingObjectSink (
  2890. m_Allocator ,
  2891. t_Provider ,
  2892. a_Sink ,
  2893. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  2894. *m_Registration
  2895. ) ;
  2896. if ( t_MethodSink )
  2897. {
  2898. t_MethodSink->AddRef () ;
  2899. if ( SUCCEEDED ( t_Result ) )
  2900. {
  2901. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2902. Lock () ;
  2903. WmiStatusCode t_StatusCode = Insert (
  2904. *t_MethodSink ,
  2905. t_Iterator
  2906. ) ;
  2907. UnLock () ;
  2908. if ( t_StatusCode == e_StatusCode_Success )
  2909. {
  2910. t_Result = t_Provider->ExecMethodAsync (
  2911. a_ObjectPath,
  2912. a_MethodName,
  2913. a_Flags & ~WBEM_FLAG_USE_AMENDED_QUALIFIERS ,
  2914. a_Context,
  2915. a_InParams,
  2916. t_MethodSink
  2917. ) ;
  2918. if ( FAILED ( t_Result ) )
  2919. {
  2920. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  2921. {
  2922. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  2923. }
  2924. }
  2925. if ( SUCCEEDED ( t_Result ) )
  2926. {
  2927. t_Result = t_MethodSink->Wait ( INFINITE ) ;
  2928. if ( SUCCEEDED ( t_Result ) )
  2929. {
  2930. if ( SUCCEEDED ( t_MethodSink->GetResult () ) )
  2931. {
  2932. t_MethodCalled = TRUE ;
  2933. }
  2934. }
  2935. else
  2936. {
  2937. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2938. {
  2939. t_Result = S_OK ;
  2940. }
  2941. }
  2942. }
  2943. else
  2944. {
  2945. if ( t_Result == WBEM_E_NOT_FOUND || t_Result == WBEM_E_INVALID_CLASS )
  2946. {
  2947. t_Result = S_OK ;
  2948. }
  2949. }
  2950. }
  2951. else
  2952. {
  2953. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2954. }
  2955. WmiQueue <IWbemClassObject *,8> &t_Queue = t_MethodSink->GetQueue () ;
  2956. IWbemClassObject *t_Object = NULL ;
  2957. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  2958. {
  2959. if (SUCCEEDED(t_Result))
  2960. {
  2961. a_Sink->Indicate ( 1 , & t_Object ) ;
  2962. }
  2963. t_Object->Release () ;
  2964. t_StatusCode = t_Queue.DeQueue () ;
  2965. }
  2966. }
  2967. t_MethodSink->Release () ;
  2968. }
  2969. else
  2970. {
  2971. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2972. }
  2973. }
  2974. HRESULT t_TempResult = ClearProviders <IWbemServices> ( t_Elements , t_ElementsCount ) ;
  2975. }
  2976. if ( SUCCEEDED ( t_Result ) )
  2977. {
  2978. if ( t_MethodCalled == FALSE )
  2979. {
  2980. if ( t_ElementsCount )
  2981. {
  2982. t_Result = WBEM_E_NOT_FOUND ;
  2983. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2984. }
  2985. else
  2986. {
  2987. SetStatus ( L"ExecMethodAsync" , NULL , L"No Decoupled Providers Attached" , WBEM_E_NOT_FOUND , a_Sink ) ;
  2988. }
  2989. }
  2990. else
  2991. {
  2992. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2993. }
  2994. }
  2995. else
  2996. {
  2997. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2998. }
  2999. return t_Result ;
  3000. }
  3001. /******************************************************************************
  3002. *
  3003. * Name:
  3004. *
  3005. *
  3006. * Description:
  3007. *
  3008. *
  3009. *****************************************************************************/
  3010. HRESULT CDecoupledAggregator_IWbemProvider :: ProvideEvents (
  3011. IWbemObjectSink *a_Sink ,
  3012. long a_Flags
  3013. )
  3014. {
  3015. #ifdef WMI_PRIVATE_DBG
  3016. #ifdef DBG
  3017. CTestNullTokenOnScope Test(__LINE__,__FILE__);
  3018. #endif
  3019. #endif
  3020. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3021. if ( InterlockedCompareExchangePointer ( ( void ** ) & m_Sink , a_Sink , NULL ) == NULL )
  3022. {
  3023. m_Sink->AddRef () ;
  3024. }
  3025. IWbemEventProvider **t_Elements = NULL ;
  3026. ULONG t_ElementsCount = 0 ;
  3027. ULONG t_ContainerCount = 0 ;
  3028. t_Result = GetProviders <IWbemEventProvider,&IID_IWbemEventProvider> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3029. if ( SUCCEEDED ( t_Result ) )
  3030. {
  3031. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3032. {
  3033. t_Result = t_Elements [ t_Index ]->ProvideEvents (
  3034. a_Sink,
  3035. a_Flags
  3036. ) ;
  3037. if ( FAILED ( t_Result ) )
  3038. {
  3039. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3040. {
  3041. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3042. }
  3043. }
  3044. }
  3045. HRESULT t_TempResult = ClearProviders <IWbemEventProvider> ( t_Elements , t_ElementsCount ) ;
  3046. }
  3047. return t_Result ;
  3048. }
  3049. /******************************************************************************
  3050. *
  3051. * Name:
  3052. *
  3053. *
  3054. * Description:
  3055. *
  3056. *
  3057. *****************************************************************************/
  3058. HRESULT CDecoupledAggregator_IWbemProvider ::NewQuery (
  3059. unsigned long a_Id ,
  3060. WBEM_WSTR a_QueryLanguage ,
  3061. WBEM_WSTR a_Query
  3062. )
  3063. {
  3064. #ifdef WMI_PRIVATE_DBG
  3065. #ifdef DBG
  3066. CTestNullTokenOnScope Test(__LINE__,__FILE__);
  3067. #endif
  3068. #endif
  3069. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3070. IWbemEventProviderQuerySink **t_Elements = NULL ;
  3071. ULONG t_ElementsCount = 0 ;
  3072. ULONG t_ContainerCount = 0 ;
  3073. t_Result = GetProviders <IWbemEventProviderQuerySink,&IID_IWbemEventProviderQuerySink> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3074. if ( SUCCEEDED ( t_Result ) )
  3075. {
  3076. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3077. {
  3078. t_Result = t_Elements [ t_Index ]->NewQuery (
  3079. a_Id,
  3080. a_QueryLanguage ,
  3081. a_Query
  3082. ) ;
  3083. if ( FAILED ( t_Result ) )
  3084. {
  3085. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3086. {
  3087. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3088. }
  3089. }
  3090. }
  3091. HRESULT t_TempResult = ClearProviders <IWbemEventProviderQuerySink> ( t_Elements , t_ElementsCount ) ;
  3092. }
  3093. return t_Result ;
  3094. }
  3095. /******************************************************************************
  3096. *
  3097. * Name:
  3098. *
  3099. *
  3100. * Description:
  3101. *
  3102. *
  3103. *****************************************************************************/
  3104. HRESULT CDecoupledAggregator_IWbemProvider ::CancelQuery (
  3105. unsigned long a_Id
  3106. )
  3107. {
  3108. #ifdef WMI_PRIVATE_DBG
  3109. #ifdef DBG
  3110. CTestNullTokenOnScope Test(__LINE__,__FILE__);
  3111. #endif
  3112. #endif
  3113. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3114. IWbemEventProviderQuerySink **t_Elements = NULL ;
  3115. ULONG t_ElementsCount = 0 ;
  3116. ULONG t_ContainerCount = 0 ;
  3117. t_Result = GetProviders <IWbemEventProviderQuerySink,&IID_IWbemEventProviderQuerySink> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3118. if ( SUCCEEDED ( t_Result ) )
  3119. {
  3120. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3121. {
  3122. t_Result = t_Elements [ t_Index ]->CancelQuery (
  3123. a_Id
  3124. ) ;
  3125. if ( FAILED ( t_Result ) )
  3126. {
  3127. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3128. {
  3129. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3130. }
  3131. }
  3132. }
  3133. HRESULT t_TempResult = ClearProviders <IWbemEventProviderQuerySink> ( t_Elements , t_ElementsCount ) ;
  3134. }
  3135. return t_Result ;
  3136. }
  3137. /******************************************************************************
  3138. *
  3139. * Name:
  3140. *
  3141. *
  3142. * Description:
  3143. *
  3144. *
  3145. *****************************************************************************/
  3146. HRESULT CDecoupledAggregator_IWbemProvider ::AccessCheck (
  3147. WBEM_CWSTR a_QueryLanguage ,
  3148. WBEM_CWSTR a_Query ,
  3149. long a_SidLength ,
  3150. const BYTE *a_Sid
  3151. )
  3152. {
  3153. #ifdef WMI_PRIVATE_DBG
  3154. #ifdef DBG
  3155. CTestNullTokenOnScope Test(__LINE__,__FILE__);
  3156. #endif
  3157. #endif
  3158. HRESULT t_AggregatedResult = S_OK ;
  3159. IWbemEventProviderSecurity **t_Elements = NULL ;
  3160. ULONG t_ElementsCount = 0 ;
  3161. ULONG t_ContainerCount = 0 ;
  3162. HRESULT t_Result = GetProviders <IWbemEventProviderSecurity,&IID_IWbemEventProviderSecurity> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3163. if ( SUCCEEDED ( t_Result ) )
  3164. {
  3165. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3166. {
  3167. t_Result = t_Elements [ t_Index ]->AccessCheck (
  3168. a_QueryLanguage,
  3169. a_Query ,
  3170. a_SidLength ,
  3171. a_Sid
  3172. ) ;
  3173. if ( SUCCEEDED ( t_Result ) )
  3174. {
  3175. if ( t_Result != S_OK )
  3176. {
  3177. t_AggregatedResult = t_Result ;
  3178. }
  3179. }
  3180. else
  3181. {
  3182. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3183. {
  3184. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3185. }
  3186. }
  3187. }
  3188. HRESULT t_TempResult = ClearProviders <IWbemEventProviderSecurity> ( t_Elements , t_ElementsCount ) ;
  3189. }
  3190. if ( SUCCEEDED ( t_Result ) )
  3191. {
  3192. if ( t_ContainerCount )
  3193. {
  3194. if ( t_ElementsCount != t_ContainerCount )
  3195. {
  3196. t_AggregatedResult = WBEM_S_SUBJECT_TO_SDS ;
  3197. }
  3198. }
  3199. t_Result = t_AggregatedResult ;
  3200. }
  3201. return t_Result ;
  3202. }
  3203. /******************************************************************************
  3204. *
  3205. * Name:
  3206. *
  3207. *
  3208. * Description:
  3209. *
  3210. *
  3211. *****************************************************************************/
  3212. HRESULT CDecoupledAggregator_IWbemProvider ::SetRegistrationObject (
  3213. long a_Flags ,
  3214. IWbemClassObject *a_ProviderRegistration
  3215. )
  3216. {
  3217. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3218. IWbemProviderIdentity **t_Elements = NULL ;
  3219. ULONG t_ElementsCount = 0 ;
  3220. ULONG t_ContainerCount = 0 ;
  3221. t_Result = GetProviders <IWbemProviderIdentity,&IID_IWbemProviderIdentity> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3222. if ( SUCCEEDED ( t_Result ) )
  3223. {
  3224. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3225. {
  3226. t_Result = t_Elements [ t_Index ]->SetRegistrationObject (
  3227. a_Flags ,
  3228. a_ProviderRegistration
  3229. ) ;
  3230. if ( FAILED ( t_Result ) )
  3231. {
  3232. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3233. {
  3234. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3235. }
  3236. }
  3237. }
  3238. HRESULT t_TempResult = ClearProviders <IWbemProviderIdentity> ( t_Elements , t_ElementsCount ) ;
  3239. }
  3240. return t_Result ;
  3241. }
  3242. /******************************************************************************
  3243. *
  3244. * Name:
  3245. *
  3246. *
  3247. * Description:
  3248. *
  3249. *
  3250. *****************************************************************************/
  3251. HRESULT CDecoupledAggregator_IWbemProvider ::FindConsumer (
  3252. IWbemClassObject *a_LogicalConsumer ,
  3253. IWbemUnboundObjectSink **a_Consumer
  3254. )
  3255. {
  3256. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3257. IWbemEventConsumerProvider **t_Elements = NULL ;
  3258. ULONG t_ElementsCount = 0 ;
  3259. ULONG t_ContainerCount = 0 ;
  3260. t_Result = GetProviders <IWbemEventConsumerProvider,&IID_IWbemEventConsumerProvider> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3261. if ( SUCCEEDED ( t_Result ) )
  3262. {
  3263. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3264. {
  3265. t_Result = t_Elements [ t_Index ]->FindConsumer (
  3266. a_LogicalConsumer,
  3267. a_Consumer
  3268. ) ;
  3269. if ( FAILED ( t_Result ) )
  3270. {
  3271. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3272. {
  3273. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3274. }
  3275. }
  3276. }
  3277. HRESULT t_TempResult = ClearProviders <IWbemEventConsumerProvider> ( t_Elements , t_ElementsCount ) ;
  3278. }
  3279. return t_Result ;
  3280. }
  3281. /******************************************************************************
  3282. *
  3283. * Name:
  3284. *
  3285. *
  3286. * Description:
  3287. *
  3288. *
  3289. *****************************************************************************/
  3290. HRESULT CDecoupledAggregator_IWbemProvider ::ValidateSubscription (
  3291. IWbemClassObject *a_LogicalConsumer
  3292. )
  3293. {
  3294. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3295. IWbemEventConsumerProviderEx **t_Elements = NULL ;
  3296. ULONG t_ElementsCount = 0 ;
  3297. ULONG t_ContainerCount = 0 ;
  3298. t_Result = GetProviders <IWbemEventConsumerProviderEx,&IID_IWbemEventConsumerProviderEx> ( NULL , m_Controller , t_Elements , t_ElementsCount , t_ContainerCount ) ;
  3299. if ( SUCCEEDED ( t_Result ) )
  3300. {
  3301. for ( ULONG t_Index = 0 ; ( t_Index < t_ElementsCount ) && SUCCEEDED ( t_Result ) ; t_Index ++ )
  3302. {
  3303. t_Result = t_Elements [ t_Index ]->ValidateSubscription (
  3304. a_LogicalConsumer
  3305. ) ;
  3306. if ( FAILED ( t_Result ) )
  3307. {
  3308. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  3309. {
  3310. AbnormalShutdown ( t_Elements [ t_Index ] ) ;
  3311. }
  3312. }
  3313. }
  3314. HRESULT t_TempResult = ClearProviders <IWbemEventConsumerProviderEx> ( t_Elements , t_ElementsCount ) ;
  3315. }
  3316. return t_Result ;
  3317. }
  3318. /******************************************************************************
  3319. *
  3320. * Name:
  3321. *
  3322. *
  3323. * Description:
  3324. *
  3325. *
  3326. *****************************************************************************/
  3327. HRESULT CDecoupledAggregator_IWbemProvider :: AbnormalShutdown ( IUnknown *t_Element )
  3328. {
  3329. SyncProviderContainerElement *t_ContainerElement = NULL ;
  3330. HRESULT t_Result = t_Element->QueryInterface ( IID_CacheElement , ( void ** ) & t_ContainerElement ) ;
  3331. if ( SUCCEEDED ( t_Result ) )
  3332. {
  3333. m_Controller->Lock () ;
  3334. GUID t_Identity = t_ContainerElement->GetKey () ;
  3335. WmiStatusCode t_StatusCode = m_Controller->Delete ( t_Identity ) ;
  3336. if ( t_StatusCode == e_StatusCode_Success )
  3337. {
  3338. m_Controller->UnLock () ;
  3339. t_Element->Release () ;
  3340. }
  3341. else
  3342. {
  3343. m_Controller->UnLock () ;
  3344. }
  3345. t_ContainerElement->Release () ;
  3346. }
  3347. return S_OK ;
  3348. }
  3349. /******************************************************************************
  3350. *
  3351. * Name:
  3352. *
  3353. *
  3354. * Description:
  3355. *
  3356. *
  3357. *****************************************************************************/
  3358. HRESULT CDecoupledAggregator_IWbemProvider :: InitializeProvider (
  3359. IUnknown *a_Unknown ,
  3360. IWbemServices *a_Stub ,
  3361. wchar_t *a_NamespacePath ,
  3362. LONG a_Flags ,
  3363. IWbemContext *a_Context ,
  3364. LPCWSTR a_User ,
  3365. LPCWSTR a_Locale ,
  3366. LPCWSTR a_Scope ,
  3367. CServerObject_ProviderRegistrationV1 &a_Registration
  3368. )
  3369. {
  3370. HRESULT t_Result = S_OK ;
  3371. if ( a_Registration.GetEventProviderRegistration ().Supported () )
  3372. {
  3373. IWbemProviderIdentity *t_ProviderIdentity = NULL ;
  3374. t_Result = a_Unknown->QueryInterface ( IID_IWbemProviderIdentity , ( void ** ) & t_ProviderIdentity ) ;
  3375. if ( SUCCEEDED ( t_Result ) )
  3376. {
  3377. t_Result = t_ProviderIdentity->SetRegistrationObject (
  3378. 0 ,
  3379. a_Registration.GetIdentity ()
  3380. ) ;
  3381. t_ProviderIdentity->Release () ;
  3382. }
  3383. }
  3384. IWbemProviderInit *t_ProviderInit = NULL ;
  3385. t_Result = a_Unknown->QueryInterface ( IID_IWbemProviderInit , ( void ** ) & t_ProviderInit ) ;
  3386. if ( SUCCEEDED ( t_Result ) )
  3387. {
  3388. CServerObject_ProviderInitSink *t_ProviderInitSink = new CServerObject_ProviderInitSink () ;
  3389. if ( t_ProviderInitSink )
  3390. {
  3391. t_ProviderInitSink->AddRef () ;
  3392. t_Result = t_ProviderInitSink->SinkInitialize ( a_Registration.GetComRegistration().GetSecurityDescriptor () ) ;
  3393. if ( SUCCEEDED ( t_Result ) )
  3394. {
  3395. CInterceptor_IWbemProviderInitSink *t_Sink = new CInterceptor_IWbemProviderInitSink ( t_ProviderInitSink ) ;
  3396. if ( t_Sink )
  3397. {
  3398. t_Sink->AddRef () ;
  3399. t_Result = t_ProviderInit->Initialize (
  3400. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  3401. 0 ,
  3402. ( const BSTR ) a_NamespacePath ,
  3403. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  3404. a_Stub ,
  3405. a_Context ,
  3406. t_Sink
  3407. ) ;
  3408. t_Sink->Release () ;
  3409. }
  3410. else
  3411. {
  3412. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3413. }
  3414. if ( SUCCEEDED ( t_Result ) )
  3415. {
  3416. t_ProviderInitSink->Wait () ;
  3417. t_Result = t_ProviderInitSink->GetResult () ;
  3418. }
  3419. if ( SUCCEEDED ( t_Result ) )
  3420. {
  3421. WmiSetAndCommitObject (
  3422. ProviderSubSystem_Globals :: s_EventClassHandles [ Msft_WmiProvider_InitializationOperationEvent ] ,
  3423. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  3424. a_NamespacePath,
  3425. a_Registration.GetProviderName () ,
  3426. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  3427. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  3428. NULL
  3429. ) ;
  3430. }
  3431. else
  3432. {
  3433. WmiSetAndCommitObject (
  3434. ProviderSubSystem_Globals :: s_EventClassHandles [ Msft_WmiProvider_InitializationOperationFailureEvent ] ,
  3435. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  3436. a_NamespacePath,
  3437. a_Registration.GetProviderName () ,
  3438. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  3439. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  3440. NULL ,
  3441. t_Result
  3442. ) ;
  3443. }
  3444. }
  3445. t_ProviderInitSink->Release () ;
  3446. }
  3447. else
  3448. {
  3449. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3450. }
  3451. t_ProviderInit->Release () ;
  3452. }
  3453. else
  3454. {
  3455. t_Result = WBEM_E_ACCESS_DENIED ;
  3456. }
  3457. return t_Result ;
  3458. }
  3459. /******************************************************************************
  3460. *
  3461. * Name:
  3462. *
  3463. *
  3464. * Description:
  3465. *
  3466. *
  3467. *****************************************************************************/
  3468. HRESULT CDecoupledAggregator_IWbemProvider :: CreateSyncProvider (
  3469. IUnknown *a_ServerSideProvider ,
  3470. IWbemServices *a_Stub ,
  3471. wchar_t *a_NamespacePath ,
  3472. LONG a_Flags ,
  3473. IWbemContext *a_Context ,
  3474. LPCWSTR a_User ,
  3475. LPCWSTR a_Locale ,
  3476. LPCWSTR a_Scope ,
  3477. CServerObject_ProviderRegistrationV1 &a_Registration ,
  3478. GUID a_Identity ,
  3479. CInterceptor_IWbemDecoupledProvider *&a_Interceptor
  3480. )
  3481. {
  3482. HRESULT t_Result = S_OK ;
  3483. CInterceptor_IWbemDecoupledProvider *t_Interceptor = new CInterceptor_IWbemDecoupledProvider (
  3484. m_Allocator ,
  3485. a_ServerSideProvider ,
  3486. a_Stub ,
  3487. m_Controller ,
  3488. a_Context ,
  3489. a_Registration ,
  3490. a_Identity
  3491. ) ;
  3492. if ( t_Interceptor )
  3493. {
  3494. /*
  3495. * One for the cache
  3496. */
  3497. t_Interceptor->AddRef () ;
  3498. _IWmiProviderInitialize *t_InterceptorInit = NULL ;
  3499. t_Result = t_Interceptor->QueryInterface ( IID__IWmiProviderInitialize , ( void ** ) & t_InterceptorInit ) ;
  3500. if ( SUCCEEDED ( t_Result ) )
  3501. {
  3502. CServerObject_ProviderInitSink *t_ProviderInitSink = new CServerObject_ProviderInitSink ;
  3503. if ( t_ProviderInitSink )
  3504. {
  3505. t_ProviderInitSink->AddRef () ;
  3506. t_Result = t_ProviderInitSink->SinkInitialize () ;
  3507. if ( SUCCEEDED ( t_Result ) )
  3508. {
  3509. CInterceptor_IWbemProviderInitSink *t_Sink = new CInterceptor_IWbemProviderInitSink ( t_ProviderInitSink ) ;
  3510. if ( t_Sink )
  3511. {
  3512. t_Sink->AddRef () ;
  3513. t_Result = t_InterceptorInit->Initialize (
  3514. 0 ,
  3515. a_Context ,
  3516. NULL ,
  3517. a_Registration.GetComRegistration ().PerUserInitialization () ? ( BSTR ) a_User : NULL ,
  3518. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( BSTR ) a_Locale : NULL ,
  3519. a_NamespacePath ,
  3520. NULL ,
  3521. NULL ,
  3522. t_Sink
  3523. ) ;
  3524. if ( SUCCEEDED ( t_Result ) )
  3525. {
  3526. t_ProviderInitSink->Wait () ;
  3527. t_Result = t_ProviderInitSink->GetResult () ;
  3528. }
  3529. t_Sink->Release () ;
  3530. }
  3531. else
  3532. {
  3533. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3534. }
  3535. }
  3536. t_ProviderInitSink->Release () ;
  3537. }
  3538. else
  3539. {
  3540. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3541. }
  3542. t_InterceptorInit->Release () ;
  3543. }
  3544. if ( SUCCEEDED ( t_Result ) )
  3545. {
  3546. t_Interceptor->AddRef () ;
  3547. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator ;
  3548. WmiStatusCode t_StatusCode = m_Controller->Insert (
  3549. *t_Interceptor ,
  3550. t_Iterator
  3551. ) ;
  3552. if ( t_StatusCode == e_StatusCode_Success )
  3553. {
  3554. }
  3555. else
  3556. {
  3557. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3558. }
  3559. m_Controller->UnLock () ;
  3560. }
  3561. else
  3562. {
  3563. m_Controller->UnLock () ;
  3564. }
  3565. t_Interceptor->SetInitialized ( t_Result ) ;
  3566. if ( SUCCEEDED ( t_Result ) )
  3567. {
  3568. a_Interceptor = t_Interceptor ;
  3569. }
  3570. else
  3571. {
  3572. t_Interceptor->Release () ;
  3573. }
  3574. }
  3575. else
  3576. {
  3577. m_Controller->UnLock () ;
  3578. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3579. }
  3580. return t_Result ;
  3581. }
  3582. /******************************************************************************
  3583. *
  3584. * Name:
  3585. *
  3586. *
  3587. * Description:
  3588. *
  3589. *
  3590. *****************************************************************************/
  3591. HRESULT CDecoupledAggregator_IWbemProvider :: Register (
  3592. long a_Flags ,
  3593. IWbemContext *a_Context ,
  3594. LPCWSTR a_User ,
  3595. LPCWSTR a_Locale ,
  3596. LPCWSTR a_Scope ,
  3597. LPCWSTR a_Registration ,
  3598. DWORD a_ProcessIdentifier ,
  3599. IUnknown *a_Unknown ,
  3600. GUID a_Identity
  3601. )
  3602. {
  3603. HRESULT t_Result = S_OK ;
  3604. try
  3605. {
  3606. m_Controller->Lock () ;
  3607. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator ;
  3608. WmiStatusCode t_StatusCode = m_Controller->Find ( a_Identity , t_Iterator ) ;
  3609. if ( t_StatusCode != e_StatusCode_Success )
  3610. {
  3611. CInterceptor_IWbemServices_Interceptor *t_Stub = new CInterceptor_IWbemServices_Interceptor ( m_Allocator , m_CoreFullStub ) ;
  3612. if ( t_Stub )
  3613. {
  3614. t_Stub->AddRef () ;
  3615. CInterceptor_IWbemDecoupledProvider *t_Interceptor = NULL ;
  3616. t_Result = CreateSyncProvider (
  3617. a_Unknown ,
  3618. t_Stub ,
  3619. ( BSTR ) a_Scope ,
  3620. 0 ,
  3621. a_Context ,
  3622. a_User ,
  3623. a_Locale ,
  3624. NULL ,
  3625. *m_Registration ,
  3626. a_Identity ,
  3627. t_Interceptor
  3628. ) ;
  3629. if ( SUCCEEDED ( t_Result ) )
  3630. {
  3631. IUnknown *t_Unknown = NULL ;
  3632. t_Result = t_Interceptor->QueryInterface ( IID_IUnknown , ( void ** ) & t_Unknown ) ;
  3633. if ( SUCCEEDED ( t_Result ) )
  3634. {
  3635. t_Result = InitializeProvider (
  3636. t_Unknown ,
  3637. t_Stub ,
  3638. ( BSTR ) a_Scope ,
  3639. a_Flags ,
  3640. a_Context ,
  3641. a_User ,
  3642. a_Locale ,
  3643. NULL ,
  3644. *m_Registration
  3645. ) ;
  3646. if ( SUCCEEDED ( t_Result ) )
  3647. {
  3648. if ( InterlockedCompareExchangePointer ( ( void ** ) & m_Sink , NULL , NULL ) )
  3649. {
  3650. IWbemEventProvider *t_Provider = NULL ;
  3651. t_Result = t_Unknown->QueryInterface ( IID_IWbemEventProvider , ( void ** ) & t_Provider ) ;
  3652. if ( SUCCEEDED ( t_Result ) )
  3653. {
  3654. t_Result = t_Provider->ProvideEvents ( m_Sink , 0 ) ;
  3655. t_Provider->Release () ;
  3656. }
  3657. m_Sink->SetStatus (
  3658. WBEM_STATUS_REQUIREMENTS,
  3659. WBEM_REQUIREMENTS_RECHECK_SUBSCRIPTIONS,
  3660. NULL,
  3661. NULL
  3662. ) ;
  3663. }
  3664. }
  3665. t_Unknown->Release () ;
  3666. }
  3667. t_Interceptor->Release () ;
  3668. }
  3669. t_Stub->Release () ;
  3670. }
  3671. else
  3672. {
  3673. m_Controller->UnLock () ;
  3674. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3675. }
  3676. }
  3677. else
  3678. {
  3679. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  3680. m_Controller->UnLock () ;
  3681. t_Element->Release () ;
  3682. t_Result = S_OK ;
  3683. }
  3684. }
  3685. catch ( ... )
  3686. {
  3687. t_Result = WBEM_E_PROVIDER_FAILURE ;
  3688. }
  3689. return t_Result ;
  3690. }
  3691. /******************************************************************************
  3692. *
  3693. * Name:
  3694. *
  3695. *
  3696. * Description:
  3697. *
  3698. *
  3699. *****************************************************************************/
  3700. HRESULT CDecoupledAggregator_IWbemProvider :: UnRegister (
  3701. long a_Flags ,
  3702. IWbemContext *a_Context ,
  3703. LPCWSTR a_User ,
  3704. LPCWSTR a_Locale ,
  3705. LPCWSTR a_Scope ,
  3706. LPCWSTR a_Registration ,
  3707. GUID a_Identity
  3708. )
  3709. {
  3710. HRESULT t_Result = S_OK ;
  3711. try
  3712. {
  3713. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator ;
  3714. IWbemShutdown *t_Shutdown = NULL ;
  3715. m_Controller->Lock () ;
  3716. WmiStatusCode t_StatusCode = m_Controller->Find ( a_Identity , t_Iterator ) ;
  3717. if ( t_StatusCode == e_StatusCode_Success )
  3718. {
  3719. SyncProviderContainerElement *t_Element = t_Iterator.GetElement () ;
  3720. t_Result = t_Element->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  3721. m_Controller->Delete ( a_Identity ) ;
  3722. m_Controller->UnLock () ;
  3723. if ( SUCCEEDED ( t_Result ) && t_Shutdown )
  3724. {
  3725. t_Result = t_Shutdown->Shutdown (
  3726. 0 ,
  3727. 0 ,
  3728. NULL
  3729. ) ;
  3730. t_Shutdown->Release () ;
  3731. }
  3732. /*
  3733. * One for the find.
  3734. */
  3735. t_Element->Release () ;
  3736. /*
  3737. * Removed reference due the cache.
  3738. */
  3739. t_Element->Release () ;
  3740. }
  3741. else
  3742. {
  3743. m_Controller->UnLock () ;
  3744. }
  3745. }
  3746. catch ( ... )
  3747. {
  3748. t_Result = WBEM_E_PROVIDER_FAILURE ;
  3749. }
  3750. return t_Result ;
  3751. }
  3752. /******************************************************************************
  3753. *
  3754. * Name:
  3755. *
  3756. *
  3757. * Description:
  3758. *
  3759. *
  3760. *****************************************************************************/
  3761. HRESULT CDecoupledAggregator_IWbemProvider :: Expel (
  3762. long a_Flags ,
  3763. IWbemContext *a_Context
  3764. )
  3765. {
  3766. HRESULT t_Result = S_OK ;
  3767. CWbemGlobal_IWmiProviderController *t_Controller = ServiceCacheElement :: GetController () ;
  3768. if ( t_Controller )
  3769. {
  3770. t_Controller->Shutdown ( ServiceCacheElement :: GetKey () ) ;
  3771. }
  3772. return t_Result ;
  3773. }
  3774. /******************************************************************************
  3775. *
  3776. * Name:
  3777. *
  3778. *
  3779. * Description:
  3780. *
  3781. *
  3782. *****************************************************************************/
  3783. HRESULT CDecoupledAggregator_IWbemProvider :: ForceReload ()
  3784. {
  3785. HRESULT t_Result = ProviderSubSystem_Globals :: ForwardReload (
  3786. _IWMIPROVSSSINK_FLAGS_RELOAD ,
  3787. NULL ,
  3788. m_Namespace ,
  3789. ServiceCacheElement :: GetKey ().m_Provider
  3790. ) ;
  3791. return t_Result ;
  3792. }
  3793. /******************************************************************************
  3794. *
  3795. * Name:
  3796. *
  3797. *
  3798. * Description:
  3799. *
  3800. *
  3801. *****************************************************************************/
  3802. HRESULT CDecoupledAggregator_IWbemProvider :: Shutdown (
  3803. LONG a_Flags ,
  3804. ULONG a_MaxMilliSeconds ,
  3805. IWbemContext *a_Context
  3806. )
  3807. {
  3808. HRESULT t_Result = S_OK ;
  3809. if ( m_Controller )
  3810. {
  3811. CWbemGlobal_IWbemSyncProvider_Container *t_Container = NULL ;
  3812. m_Controller->GetContainer ( t_Container ) ;
  3813. Lock () ;
  3814. if ( t_Container->Size () )
  3815. {
  3816. IWbemShutdown **t_ShutdownElements = new IWbemShutdown * [ t_Container->Size () ] ;
  3817. if ( t_ShutdownElements )
  3818. {
  3819. CWbemGlobal_IWbemSyncProvider_Container_Iterator t_Iterator = t_Container->Begin ();
  3820. ULONG t_Count = 0 ;
  3821. while ( ! t_Iterator.Null () )
  3822. {
  3823. t_Result = t_Iterator.GetElement ()->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_ShutdownElements [ t_Count ] ) ;
  3824. t_Iterator.Increment () ;
  3825. t_Count ++ ;
  3826. }
  3827. UnLock () ;
  3828. for ( ULONG t_Index = 0 ; t_Index < t_Count ; t_Index ++ )
  3829. {
  3830. if ( t_ShutdownElements [ t_Index ] )
  3831. {
  3832. t_Result = t_ShutdownElements [ t_Index ]->Shutdown (
  3833. a_Flags ,
  3834. a_MaxMilliSeconds ,
  3835. a_Context
  3836. ) ;
  3837. t_ShutdownElements [ t_Index ]->Release () ;
  3838. }
  3839. }
  3840. delete [] t_ShutdownElements ;
  3841. }
  3842. else
  3843. {
  3844. UnLock () ;
  3845. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3846. }
  3847. }
  3848. else
  3849. {
  3850. UnLock () ;
  3851. }
  3852. m_Controller->Shutdown () ;
  3853. }
  3854. CWbemGlobal_IWmiObjectSinkController :: Shutdown () ;
  3855. return t_Result ;
  3856. }