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.

4460 lines
92 KiB

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