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.

7028 lines
167 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. XXXX
  5. Abstract:
  6. History:
  7. --*/
  8. #include "PreComp.h"
  9. #include <wbemint.h>
  10. #include <stdio.h>
  11. #include <NCObjApi.h>
  12. #include "Globals.h"
  13. #include "CGlobals.h"
  14. #include "ProvSubs.h"
  15. #include "ProvFact.h"
  16. #include "ProvObSk.h"
  17. #include "ProvInSk.h"
  18. #include "ProvWsv.h"
  19. #include "ProvCache.h"
  20. #include "arrtempl.h"
  21. #include "Guids.h"
  22. #include <helper.h>
  23. /******************************************************************************
  24. *
  25. * Name:
  26. *
  27. *
  28. * Description:
  29. *
  30. *
  31. *****************************************************************************/
  32. #pragma warning( disable : 4355 )
  33. CInterceptor_IWbemUnboundObjectSink :: CInterceptor_IWbemUnboundObjectSink (
  34. WmiAllocator &a_Allocator ,
  35. IUnknown *a_ServerSideProvider ,
  36. CWbemGlobal_IWmiObjectSinkController *a_Controller ,
  37. CServerObject_ProviderRegistrationV1 &a_Registration
  38. ) : VoidPointerContainerElement (
  39. a_Controller ,
  40. this
  41. ) ,
  42. m_Allocator ( a_Allocator ) ,
  43. m_Controller ( NULL ) ,
  44. m_Unknown ( NULL ) ,
  45. m_Provider_IWbemUnboundObjectSink ( NULL ) ,
  46. m_Provider_Internal_IWbemUnboundObjectSink ( NULL ) ,
  47. m_Registration ( & a_Registration ) ,
  48. m_ProxyContainer ( a_Allocator , ProxyIndex_UnBound_Size , MAX_PROXIES ) ,
  49. m_InitializeResult ( S_OK ) ,
  50. m_ProcessIdentifier ( 0 )
  51. {
  52. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CInterceptor_IWbemUnboundObjectSink_ObjectsInProgress ) ;
  53. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  54. if ( m_Registration )
  55. {
  56. m_Registration->AddRef () ;
  57. }
  58. m_InitializeResult = a_Controller->QueryInterface ( IID__IWmiProviderAbnormalShutdown , ( void ** ) & m_Controller ) ;
  59. if ( SUCCEEDED ( m_InitializeResult ) )
  60. {
  61. if ( a_ServerSideProvider )
  62. {
  63. m_Unknown = a_ServerSideProvider ;
  64. m_Unknown->AddRef () ;
  65. m_InitializeResult = a_ServerSideProvider->QueryInterface ( IID_IWbemUnboundObjectSink , ( void ** ) & m_Provider_IWbemUnboundObjectSink ) ;
  66. if ( SUCCEEDED ( m_InitializeResult ) )
  67. {
  68. m_InitializeResult = a_ServerSideProvider->QueryInterface ( IID_Internal_IWbemUnboundObjectSink , ( void ** ) & m_Provider_Internal_IWbemUnboundObjectSink ) ;
  69. }
  70. }
  71. }
  72. }
  73. #pragma warning( default : 4355 )
  74. /******************************************************************************
  75. *
  76. * Name:
  77. *
  78. *
  79. * Description:
  80. *
  81. *
  82. *****************************************************************************/
  83. CInterceptor_IWbemUnboundObjectSink :: ~CInterceptor_IWbemUnboundObjectSink ()
  84. {
  85. if ( m_Controller )
  86. {
  87. m_Controller->Release () ;
  88. }
  89. if ( m_Unknown )
  90. {
  91. m_Unknown->Release () ;
  92. }
  93. if ( m_Provider_IWbemUnboundObjectSink )
  94. {
  95. m_Provider_IWbemUnboundObjectSink->Release () ;
  96. }
  97. if ( m_Provider_Internal_IWbemUnboundObjectSink )
  98. {
  99. m_Provider_Internal_IWbemUnboundObjectSink->Release () ;
  100. }
  101. if ( m_Registration )
  102. {
  103. m_Registration->Release () ;
  104. }
  105. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CInterceptor_IWbemUnboundObjectSink_ObjectsInProgress ) ;
  106. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  107. }
  108. /******************************************************************************
  109. *
  110. * Name:
  111. *
  112. *
  113. * Description:
  114. *
  115. *
  116. *****************************************************************************/
  117. HRESULT CInterceptor_IWbemUnboundObjectSink :: Initialize ()
  118. {
  119. if ( SUCCEEDED ( m_InitializeResult ) )
  120. {
  121. WmiStatusCode t_StatusCode = m_ProxyContainer.Initialize () ;
  122. if ( t_StatusCode != e_StatusCode_Success )
  123. {
  124. m_InitializeResult = WBEM_E_OUT_OF_MEMORY ;
  125. }
  126. }
  127. if ( SUCCEEDED ( m_InitializeResult ) )
  128. {
  129. _IWmiProviderSite *t_Site = NULL ;
  130. m_InitializeResult = m_Unknown->QueryInterface ( IID__IWmiProviderSite , ( void ** ) & t_Site ) ;
  131. if ( SUCCEEDED ( m_InitializeResult ) )
  132. {
  133. m_InitializeResult = t_Site->GetSite ( & m_ProcessIdentifier ) ;
  134. t_Site->Release () ;
  135. }
  136. }
  137. return m_InitializeResult ;
  138. }
  139. /******************************************************************************
  140. *
  141. * Name:
  142. *
  143. *
  144. * Description:
  145. *
  146. *
  147. *****************************************************************************/
  148. STDMETHODIMP_( ULONG ) CInterceptor_IWbemUnboundObjectSink :: AddRef ()
  149. {
  150. return VoidPointerContainerElement :: AddRef () ;
  151. }
  152. /******************************************************************************
  153. *
  154. * Name:
  155. *
  156. *
  157. * Description:
  158. *
  159. *
  160. *****************************************************************************/
  161. STDMETHODIMP_(ULONG) CInterceptor_IWbemUnboundObjectSink :: Release ()
  162. {
  163. return VoidPointerContainerElement :: Release () ;
  164. }
  165. /******************************************************************************
  166. *
  167. * Name:
  168. *
  169. *
  170. * Description:
  171. *
  172. *
  173. *****************************************************************************/
  174. STDMETHODIMP CInterceptor_IWbemUnboundObjectSink :: QueryInterface (
  175. REFIID iid ,
  176. LPVOID FAR *iplpv
  177. )
  178. {
  179. *iplpv = NULL ;
  180. if ( iid == IID_IUnknown )
  181. {
  182. *iplpv = ( LPVOID ) this ;
  183. }
  184. else if ( iid == IID_IWbemUnboundObjectSink )
  185. {
  186. if ( m_Provider_IWbemUnboundObjectSink )
  187. {
  188. *iplpv = ( LPVOID ) ( IWbemUnboundObjectSink * ) this ;
  189. }
  190. }
  191. else if ( iid == IID_IWbemShutdown )
  192. {
  193. *iplpv = ( LPVOID ) ( IWbemShutdown * ) this ;
  194. }
  195. if ( *iplpv )
  196. {
  197. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  198. return ResultFromScode ( S_OK ) ;
  199. }
  200. else
  201. {
  202. return ResultFromScode ( E_NOINTERFACE ) ;
  203. }
  204. }
  205. /******************************************************************************
  206. *
  207. * Name:
  208. *
  209. *
  210. * Description:
  211. *
  212. *
  213. *****************************************************************************/
  214. HRESULT CInterceptor_IWbemUnboundObjectSink :: Begin_Interface (
  215. IUnknown *a_ServerInterface ,
  216. REFIID a_InterfaceIdentifier ,
  217. DWORD a_ProxyIndex ,
  218. IUnknown *a_InternalServerInterface ,
  219. REFIID a_InternalInterfaceIdentifier ,
  220. DWORD a_InternalProxyIndex ,
  221. DWORD a_ProcessIdentifier ,
  222. HANDLE &a_IdentifyToken ,
  223. BOOL &a_Impersonating ,
  224. IUnknown *&a_OldContext ,
  225. IServerSecurity *&a_OldSecurity ,
  226. BOOL &a_IsProxy ,
  227. IUnknown *&a_Interface ,
  228. BOOL &a_Revert ,
  229. IUnknown *&a_Proxy ,
  230. IWbemContext *a_Context
  231. )
  232. {
  233. HRESULT t_Result = S_OK ;
  234. a_IdentifyToken = NULL ;
  235. a_Revert = FALSE ;
  236. a_Proxy = NULL ;
  237. a_Impersonating = FALSE ;
  238. a_OldContext = NULL ;
  239. a_OldSecurity = NULL ;
  240. switch ( m_Registration->GetHosting () )
  241. {
  242. case e_Hosting_WmiCore:
  243. case e_Hosting_WmiCoreOrSelfHost:
  244. case e_Hosting_SelfHost:
  245. {
  246. a_Interface = a_ServerInterface ;
  247. a_IsProxy = FALSE ;
  248. }
  249. break ;
  250. default:
  251. {
  252. DWORD t_AuthenticationLevel = RPC_C_AUTHN_LEVEL_DEFAULT ;
  253. IUnknown *t_CallContext ;
  254. t_Result = CoGetCallContext ( IID_IUnknown , ( void ** ) & t_CallContext ) ;
  255. if ( SUCCEEDED ( t_Result ) )
  256. {
  257. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating , & t_AuthenticationLevel ) ;
  258. if ( SUCCEEDED ( t_Result ) )
  259. {
  260. if ( a_ProcessIdentifier )
  261. {
  262. t_Result = CoImpersonateClient () ;
  263. if ( SUCCEEDED ( t_Result ) )
  264. {
  265. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  266. CoRevertToSelf () ;
  267. if ( t_ImpersonationLevel == RPC_C_IMP_LEVEL_IMPERSONATE || t_ImpersonationLevel == RPC_C_IMP_LEVEL_DELEGATE )
  268. {
  269. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState (
  270. m_ProxyContainer ,
  271. a_ProxyIndex ,
  272. a_InterfaceIdentifier ,
  273. a_ServerInterface ,
  274. a_Proxy ,
  275. a_Revert
  276. ) ;
  277. }
  278. else
  279. {
  280. switch ( m_Registration->GetHosting () )
  281. {
  282. case e_Hosting_SharedLocalSystemHost:
  283. case e_Hosting_SharedLocalSystemHostOrSelfHost:
  284. {
  285. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  286. m_ProxyContainer ,
  287. a_InternalProxyIndex ,
  288. a_InterfaceIdentifier ,
  289. a_InternalServerInterface ,
  290. a_Proxy ,
  291. a_Revert ,
  292. a_ProcessIdentifier ,
  293. a_IdentifyToken ,
  294. ProviderSubSystem_Common_Globals :: s_Token_All_Access_System_ACE ,
  295. ProviderSubSystem_Common_Globals :: s_System_ACESize
  296. ) ;
  297. }
  298. break ;
  299. case e_Hosting_SharedLocalServiceHost:
  300. {
  301. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  302. m_ProxyContainer ,
  303. a_InternalProxyIndex ,
  304. a_InterfaceIdentifier ,
  305. a_InternalServerInterface ,
  306. a_Proxy ,
  307. a_Revert ,
  308. a_ProcessIdentifier ,
  309. a_IdentifyToken ,
  310. ProviderSubSystem_Common_Globals :: s_Token_All_Access_LocalService_ACE ,
  311. ProviderSubSystem_Common_Globals :: s_LocalService_ACESize
  312. ) ;
  313. }
  314. break ;
  315. case e_Hosting_SharedNetworkServiceHost:
  316. {
  317. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  318. m_ProxyContainer ,
  319. a_InternalProxyIndex ,
  320. a_InterfaceIdentifier ,
  321. a_InternalServerInterface ,
  322. a_Proxy ,
  323. a_Revert ,
  324. a_ProcessIdentifier ,
  325. a_IdentifyToken ,
  326. ProviderSubSystem_Common_Globals :: s_Token_All_Access_NetworkService_ACE ,
  327. ProviderSubSystem_Common_Globals :: s_NetworkService_ACESize
  328. ) ;
  329. }
  330. break ;
  331. default:
  332. {
  333. t_Result = WBEM_E_UNEXPECTED ;
  334. }
  335. break ;
  336. }
  337. }
  338. }
  339. }
  340. else
  341. {
  342. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState (
  343. m_ProxyContainer ,
  344. a_ProxyIndex ,
  345. a_InterfaceIdentifier ,
  346. a_ServerInterface ,
  347. a_Proxy ,
  348. a_Revert
  349. ) ;
  350. }
  351. }
  352. if ( FAILED ( t_Result ) && t_Result != WBEM_E_NOT_FOUND )
  353. {
  354. ProviderSubSystem_Common_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  355. }
  356. t_CallContext->Release () ;
  357. }
  358. else
  359. {
  360. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_NoImpersonation (
  361. m_ProxyContainer ,
  362. a_ProxyIndex ,
  363. a_InterfaceIdentifier ,
  364. a_ServerInterface ,
  365. a_Proxy ,
  366. a_Revert
  367. ) ;
  368. }
  369. if ( t_Result == WBEM_E_NOT_FOUND )
  370. {
  371. a_Interface = a_ServerInterface ;
  372. a_IsProxy = FALSE ;
  373. t_Result = S_OK ;
  374. }
  375. else
  376. {
  377. if ( SUCCEEDED ( t_Result ) )
  378. {
  379. a_IsProxy = TRUE ;
  380. a_Interface = ( IUnknown * ) a_Proxy ;
  381. // Set cloaking on the proxy
  382. // =========================
  383. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  384. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  385. a_Interface ,
  386. RPC_C_AUTHN_LEVEL_DEFAULT ,
  387. t_ImpersonationLevel
  388. ) ;
  389. if ( SUCCEEDED ( t_Result ) )
  390. {
  391. if ( a_Context )
  392. {
  393. VARIANT t_Variant ;
  394. VariantInit ( & t_Variant ) ;
  395. t_Variant.lVal = t_AuthenticationLevel ;
  396. t_Variant.vt = VT_I4 ;
  397. t_Result = a_Context->SetValue ( L"__WBEM_CLIENT_AUTHENTICATION_LEVEL" , 0, & t_Variant ) ;
  398. }
  399. }
  400. if ( FAILED ( t_Result ) )
  401. {
  402. if ( a_IdentifyToken )
  403. {
  404. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState_SvcHost (
  405. m_ProxyContainer ,
  406. a_InternalProxyIndex ,
  407. a_Proxy ,
  408. a_Revert ,
  409. a_ProcessIdentifier ,
  410. a_IdentifyToken
  411. ) ;
  412. }
  413. else
  414. {
  415. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState (
  416. m_ProxyContainer ,
  417. a_ProxyIndex ,
  418. a_Proxy ,
  419. a_Revert
  420. ) ;
  421. }
  422. }
  423. }
  424. }
  425. }
  426. break ;
  427. }
  428. return t_Result ;
  429. }
  430. /******************************************************************************
  431. *
  432. * Name:
  433. *
  434. *
  435. * Description:
  436. *
  437. *
  438. *****************************************************************************/
  439. HRESULT CInterceptor_IWbemUnboundObjectSink :: End_Interface (
  440. IUnknown *a_ServerInterface ,
  441. REFIID a_InterfaceIdentifier ,
  442. DWORD a_ProxyIndex ,
  443. IUnknown *a_InternalServerInterface ,
  444. REFIID a_InternalInterfaceIdentifier ,
  445. DWORD a_InternalProxyIndex ,
  446. DWORD a_ProcessIdentifier ,
  447. HANDLE a_IdentifyToken ,
  448. BOOL a_Impersonating ,
  449. IUnknown *a_OldContext ,
  450. IServerSecurity *a_OldSecurity ,
  451. BOOL a_IsProxy ,
  452. IUnknown *a_Interface ,
  453. BOOL a_Revert ,
  454. IUnknown *a_Proxy
  455. )
  456. {
  457. CoRevertToSelf () ;
  458. if ( a_Proxy )
  459. {
  460. if ( a_IdentifyToken )
  461. {
  462. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState_SvcHost (
  463. m_ProxyContainer ,
  464. a_InternalProxyIndex ,
  465. a_Proxy ,
  466. a_Revert ,
  467. a_ProcessIdentifier ,
  468. a_IdentifyToken
  469. ) ;
  470. }
  471. else
  472. {
  473. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState (
  474. m_ProxyContainer ,
  475. a_ProxyIndex ,
  476. a_Proxy ,
  477. a_Revert
  478. ) ;
  479. }
  480. }
  481. ProviderSubSystem_Common_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  482. return S_OK ;
  483. }
  484. /******************************************************************************
  485. *
  486. * Name:
  487. *
  488. *
  489. * Description:
  490. *
  491. *
  492. *****************************************************************************/
  493. HRESULT CInterceptor_IWbemUnboundObjectSink :: IndicateToConsumer (
  494. IWbemClassObject *a_LogicalConsumer ,
  495. long a_ObjectCount ,
  496. IWbemClassObject **a_Objects
  497. )
  498. {
  499. if ( m_Provider_IWbemUnboundObjectSink )
  500. {
  501. IUnknown *t_ServerInterface = m_Provider_IWbemUnboundObjectSink ;
  502. REFIID t_InterfaceIdentifier = IID_IWbemUnboundObjectSink ;
  503. DWORD t_ProxyIndex = ProxyIndex_UnBound_IWbemUnboundObjectSink ;
  504. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemUnboundObjectSink ;
  505. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemUnboundObjectSink ;
  506. DWORD t_InternalProxyIndex = ProxyIndex_UnBound_Internal_IWbemUnboundObjectSink ;
  507. BOOL t_Impersonating ;
  508. IUnknown *t_OldContext ;
  509. IServerSecurity *t_OldSecurity ;
  510. BOOL t_IsProxy ;
  511. IUnknown *t_Interface ;
  512. BOOL t_Revert ;
  513. IUnknown *t_Proxy ;
  514. DWORD t_ProcessIdentifier = m_ProcessIdentifier ;
  515. HANDLE t_IdentifyToken = NULL ;
  516. HRESULT t_Result = Begin_Interface (
  517. t_ServerInterface ,
  518. t_InterfaceIdentifier ,
  519. t_ProxyIndex ,
  520. t_InternalServerInterface ,
  521. t_InternalInterfaceIdentifier ,
  522. t_InternalProxyIndex ,
  523. t_ProcessIdentifier ,
  524. t_IdentifyToken ,
  525. t_Impersonating ,
  526. t_OldContext ,
  527. t_OldSecurity ,
  528. t_IsProxy ,
  529. t_Interface ,
  530. t_Revert ,
  531. t_Proxy
  532. ) ;
  533. if ( SUCCEEDED ( t_Result ) )
  534. {
  535. if ( t_IdentifyToken )
  536. {
  537. WmiInternalContext t_InternalContext ;
  538. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  539. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  540. t_Result = ( ( Internal_IWbemUnboundObjectSink * ) t_Interface )->Internal_IndicateToConsumer (
  541. t_InternalContext ,
  542. a_LogicalConsumer ,
  543. a_ObjectCount ,
  544. a_Objects
  545. ) ;
  546. }
  547. else
  548. {
  549. t_Result = ( ( IWbemUnboundObjectSink * ) t_Interface )->IndicateToConsumer (
  550. a_LogicalConsumer ,
  551. a_ObjectCount ,
  552. a_Objects
  553. ) ;
  554. }
  555. End_Interface (
  556. t_ServerInterface ,
  557. t_InterfaceIdentifier ,
  558. t_ProxyIndex ,
  559. t_InternalServerInterface ,
  560. t_InternalInterfaceIdentifier ,
  561. t_InternalProxyIndex ,
  562. t_ProcessIdentifier ,
  563. t_IdentifyToken ,
  564. t_Impersonating ,
  565. t_OldContext ,
  566. t_OldSecurity ,
  567. t_IsProxy ,
  568. t_Interface ,
  569. t_Revert ,
  570. t_Proxy
  571. ) ;
  572. }
  573. if ( FAILED ( t_Result ) )
  574. {
  575. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  576. {
  577. if ( m_Controller )
  578. {
  579. m_Controller->AbnormalShutdown () ;
  580. }
  581. }
  582. }
  583. return t_Result ;
  584. }
  585. return WBEM_E_PROVIDER_NOT_CAPABLE;
  586. }
  587. /******************************************************************************
  588. *
  589. * Name:
  590. *
  591. *
  592. * Description:
  593. *
  594. *
  595. *****************************************************************************/
  596. HRESULT CInterceptor_IWbemUnboundObjectSink :: Shutdown (
  597. LONG a_Flags ,
  598. ULONG a_MaxMilliSeconds ,
  599. IWbemContext *a_Context
  600. )
  601. {
  602. return S_OK ;
  603. }
  604. /******************************************************************************
  605. *
  606. * Name:
  607. *
  608. *
  609. * Description:
  610. *
  611. *
  612. *****************************************************************************/
  613. InternalQuotaInterface :: InternalQuotaInterface ( CInterceptor_IWbemProvider *a_Owner ) : m_Owner ( NULL ) , m_ReferenceCount ( 0 )
  614. {
  615. a_Owner->QueryInterface ( IID__IWmiProviderQuota , ( void ** ) & m_Owner ) ;
  616. }
  617. /******************************************************************************
  618. *
  619. * Name:
  620. *
  621. *
  622. * Description:
  623. *
  624. *
  625. *****************************************************************************/
  626. InternalQuotaInterface :: ~InternalQuotaInterface ()
  627. {
  628. if ( m_Owner )
  629. {
  630. m_Owner->Release () ;
  631. }
  632. }
  633. /******************************************************************************
  634. *
  635. * Name:
  636. *
  637. *
  638. * Description:
  639. *
  640. *
  641. *****************************************************************************/
  642. HRESULT InternalQuotaInterface :: Initialize ()
  643. {
  644. return m_Owner ? S_OK : WBEM_E_CRITICAL_ERROR ;
  645. }
  646. /******************************************************************************
  647. *
  648. * Name:
  649. *
  650. *
  651. * Description:
  652. *
  653. *
  654. *****************************************************************************/
  655. STDMETHODIMP InternalQuotaInterface :: QueryInterface (
  656. REFIID iid ,
  657. LPVOID FAR *iplpv
  658. )
  659. {
  660. *iplpv = NULL ;
  661. if ( iid == IID_IUnknown )
  662. {
  663. *iplpv = ( LPVOID ) this ;
  664. }
  665. else if ( iid == IID__IWmiProviderQuota )
  666. {
  667. *iplpv = ( LPVOID ) ( _IWmiProviderQuota * ) this ;
  668. }
  669. if ( *iplpv )
  670. {
  671. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  672. return ResultFromScode ( S_OK ) ;
  673. }
  674. else
  675. {
  676. return ResultFromScode ( E_NOINTERFACE ) ;
  677. }
  678. }
  679. /******************************************************************************
  680. *
  681. * Name:
  682. *
  683. *
  684. * Description:
  685. *
  686. *
  687. *****************************************************************************/
  688. STDMETHODIMP_(ULONG) InternalQuotaInterface :: AddRef ( void )
  689. {
  690. return InterlockedIncrement ( & m_ReferenceCount ) ;
  691. }
  692. /******************************************************************************
  693. *
  694. * Name:
  695. *
  696. *
  697. * Description:
  698. *
  699. *
  700. *****************************************************************************/
  701. STDMETHODIMP_(ULONG) InternalQuotaInterface :: Release ( void )
  702. {
  703. LONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  704. if ( t_ReferenceCount == 0 )
  705. {
  706. delete this ;
  707. }
  708. return t_ReferenceCount ;
  709. }
  710. /******************************************************************************
  711. *
  712. * Name:
  713. *
  714. *
  715. * Description:
  716. *
  717. *
  718. *****************************************************************************/
  719. HRESULT InternalQuotaInterface :: Violation (
  720. long a_Flags ,
  721. IWbemContext *a_Context ,
  722. IWbemClassObject *a_Object
  723. )
  724. {
  725. return m_Owner->Violation (
  726. a_Flags ,
  727. a_Context ,
  728. a_Object
  729. ) ;
  730. }
  731. /******************************************************************************
  732. *
  733. * Name:
  734. *
  735. *
  736. * Description:
  737. *
  738. *
  739. *****************************************************************************/
  740. #pragma warning( disable : 4355 )
  741. CInterceptor_IWbemProvider :: CInterceptor_IWbemProvider (
  742. WmiAllocator &a_Allocator ,
  743. CWbemGlobal_IWmiProviderController *a_Controller ,
  744. const ProviderCacheKey &a_Key ,
  745. const ULONG &a_Period ,
  746. IWbemContext *a_InitializationContext ,
  747. CServerObject_ProviderRegistrationV1 &a_Registration
  748. ) : CWbemGlobal_IWmiObjectSinkController ( a_Allocator ) ,
  749. ServiceCacheElement (
  750. a_Controller ,
  751. a_Key ,
  752. a_Period
  753. ) ,
  754. m_Allocator ( a_Allocator ) ,
  755. m_Unknown ( NULL ) ,
  756. m_Registration ( & a_Registration ) ,
  757. m_Host ( NULL ) ,
  758. m_Quota ( NULL ) ,
  759. m_Internal ( this ) ,
  760. m_User ( NULL ) ,
  761. m_Locale ( NULL ) ,
  762. m_Namespace ( NULL ) ,
  763. m_Provider_IWbemServices ( NULL ) ,
  764. m_Provider_IWbemPropertyProvider ( NULL ) ,
  765. m_Provider_IWbemHiPerfProvider ( NULL ) ,
  766. m_Provider_IWbemEventProvider ( NULL ) ,
  767. m_Provider_IWbemEventProviderQuerySink ( NULL ) ,
  768. m_Provider_IWbemEventProviderSecurity ( NULL ) ,
  769. m_Provider_IWbemEventConsumerProvider ( NULL ) ,
  770. m_Provider_IWbemEventConsumerProviderEx ( NULL ) ,
  771. m_Provider_IWbemUnboundObjectSink ( NULL ) ,
  772. m_Provider_Internal_IWbemServices ( NULL ) ,
  773. m_Provider_Internal_IWbemPropertyProvider ( NULL ) ,
  774. m_Provider_Internal_IWbemEventProvider ( NULL ) ,
  775. m_Provider_Internal_IWbemEventProviderQuerySink ( NULL ) ,
  776. m_Provider_Internal_IWbemEventProviderSecurity ( NULL ) ,
  777. m_Provider_Internal_IWbemEventConsumerProvider ( NULL ) ,
  778. m_Provider_Internal_IWbemEventConsumerProviderEx ( NULL ) ,
  779. m_Provider_Internal_IWbemUnboundObjectSink ( NULL ) ,
  780. m_Provider_Internal_IWmiProviderConfiguration ( NULL ) ,
  781. m_ProxyContainer ( a_Allocator , ProxyIndex_Provider_Size , MAX_PROXIES ) ,
  782. m_ProcessIdentifier ( 0 ) ,
  783. m_Resumed ( 1 ) ,
  784. m_UnInitialized ( 0 ) ,
  785. m_Initialized ( 0 ) ,
  786. m_InitializeResult ( S_OK ) ,
  787. m_InitializedEvent ( NULL ) ,
  788. m_InitializationContext ( a_InitializationContext )
  789. {
  790. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CInterceptor_IWbemProvider_ObjectsInProgress ) ;
  791. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  792. if ( m_InitializationContext )
  793. {
  794. m_InitializationContext->AddRef () ;
  795. }
  796. if ( m_Registration )
  797. {
  798. m_Registration->AddRef () ;
  799. }
  800. }
  801. #pragma warning( default : 4355 )
  802. /******************************************************************************
  803. *
  804. * Name:
  805. *
  806. *
  807. * Description:
  808. *
  809. *
  810. *****************************************************************************/
  811. CInterceptor_IWbemProvider :: ~CInterceptor_IWbemProvider ()
  812. {
  813. CWbemGlobal_IWmiObjectSinkController :: UnInitialize () ;
  814. if ( m_InitializationContext )
  815. {
  816. m_InitializationContext->Release () ;
  817. }
  818. if ( m_InitializedEvent )
  819. {
  820. CloseHandle ( m_InitializedEvent ) ;
  821. }
  822. if ( m_Registration )
  823. {
  824. m_Registration->Release () ;
  825. }
  826. if ( m_Namespace )
  827. {
  828. SysFreeString ( m_Namespace ) ;
  829. }
  830. if ( m_Locale )
  831. {
  832. SysFreeString ( m_Locale ) ;
  833. }
  834. if ( m_User )
  835. {
  836. SysFreeString ( m_User ) ;
  837. }
  838. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CInterceptor_IWbemProvider_ObjectsInProgress ) ;
  839. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  840. }
  841. /******************************************************************************
  842. *
  843. * Name:
  844. *
  845. *
  846. * Description:
  847. *
  848. *
  849. *****************************************************************************/
  850. HRESULT CInterceptor_IWbemProvider :: Initialize (
  851. LPWSTR a_User,
  852. LONG a_Flags,
  853. LPWSTR a_Namespace,
  854. LPWSTR a_Locale,
  855. IWbemServices *a_Core , // For anybody
  856. IWbemContext *a_Context ,
  857. IWbemProviderInitSink *a_Sink // For init signals
  858. )
  859. {
  860. HRESULT t_Result = S_OK ;
  861. WmiStatusCode t_StatusCode = CWbemGlobal_IWmiObjectSinkController :: Initialize () ;
  862. if ( t_StatusCode != e_StatusCode_Success )
  863. {
  864. t_Result = WBEM_E_OUT_OF_MEMORY ;
  865. }
  866. if ( SUCCEEDED ( t_Result ) )
  867. {
  868. t_StatusCode = m_ProxyContainer.Initialize () ;
  869. if ( t_StatusCode != e_StatusCode_Success )
  870. {
  871. t_Result = WBEM_E_OUT_OF_MEMORY ;
  872. }
  873. }
  874. if ( SUCCEEDED ( t_Result ) )
  875. {
  876. m_InitializedEvent = CreateEvent ( NULL , TRUE , FALSE , NULL ) ;
  877. if ( m_InitializedEvent == NULL )
  878. {
  879. t_Result = t_Result = WBEM_E_OUT_OF_MEMORY ;
  880. }
  881. }
  882. if ( SUCCEEDED ( t_Result ) )
  883. {
  884. m_Quota = new InternalQuotaInterface ( this ) ;
  885. if ( m_Quota )
  886. {
  887. m_Quota->AddRef () ;
  888. t_Result = m_Quota->Initialize () ;
  889. }
  890. else
  891. {
  892. t_Result = WBEM_E_OUT_OF_MEMORY ;
  893. }
  894. }
  895. if ( SUCCEEDED ( t_Result ) )
  896. {
  897. if ( a_User )
  898. {
  899. m_User = SysAllocString ( a_User ) ;
  900. if ( m_User == NULL )
  901. {
  902. t_Result = WBEM_E_OUT_OF_MEMORY ;
  903. }
  904. }
  905. }
  906. if ( SUCCEEDED ( t_Result ) )
  907. {
  908. if ( a_Locale )
  909. {
  910. m_Locale = SysAllocString ( a_Locale ) ;
  911. if ( m_Locale == NULL )
  912. {
  913. t_Result = WBEM_E_OUT_OF_MEMORY ;
  914. }
  915. }
  916. }
  917. if ( SUCCEEDED ( t_Result ) )
  918. {
  919. if ( a_Namespace )
  920. {
  921. m_Namespace = SysAllocString ( a_Namespace ) ;
  922. if ( m_Namespace == NULL )
  923. {
  924. t_Result = WBEM_E_OUT_OF_MEMORY ;
  925. }
  926. }
  927. }
  928. if ( SUCCEEDED ( t_Result ) )
  929. {
  930. t_Result = m_InitializeResult ;
  931. }
  932. a_Sink->SetStatus ( t_Result , 0 ) ;
  933. return t_Result ;
  934. }
  935. /******************************************************************************
  936. *
  937. * Name:
  938. *
  939. *
  940. * Description:
  941. *
  942. *
  943. *****************************************************************************/
  944. HRESULT CInterceptor_IWbemProvider :: GetInitializeResult ()
  945. {
  946. return m_InitializeResult ;
  947. }
  948. HRESULT CInterceptor_IWbemProvider :: SetProvider ( _IWmiProviderHost *a_Host , IUnknown *a_Unknown )
  949. {
  950. if ( a_Host )
  951. {
  952. m_Host = a_Host ;
  953. m_Host->AddRef () ;
  954. HRESULT t_Result = m_Host->GetProcessIdentifier ( & m_ProcessIdentifier ) ;
  955. if ( FAILED ( t_Result ) )
  956. {
  957. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  958. }
  959. }
  960. else
  961. {
  962. m_ProcessIdentifier = GetCurrentProcessId ();
  963. }
  964. m_Unknown = a_Unknown ;
  965. m_Unknown->AddRef () ;
  966. HRESULT t_TempResult = m_Unknown->QueryInterface ( IID_IWbemServices , ( void ** ) & m_Provider_IWbemServices ) ;
  967. if ( SUCCEEDED ( t_TempResult ) )
  968. {
  969. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemServices , ( void ** ) & m_Provider_Internal_IWbemServices ) ;
  970. if ( FAILED ( t_TempResult ) )
  971. {
  972. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  973. }
  974. }
  975. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemPropertyProvider , ( void ** ) & m_Provider_IWbemPropertyProvider ) ;
  976. if ( SUCCEEDED ( t_TempResult ) )
  977. {
  978. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemPropertyProvider , ( void ** ) & m_Provider_Internal_IWbemPropertyProvider ) ;
  979. if ( FAILED ( t_TempResult ) )
  980. {
  981. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  982. }
  983. }
  984. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemHiPerfProvider , ( void ** ) & m_Provider_IWbemHiPerfProvider ) ;
  985. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventProvider , ( void ** ) & m_Provider_IWbemEventProvider ) ;
  986. if ( SUCCEEDED ( t_TempResult ) )
  987. {
  988. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventProvider , ( void ** ) & m_Provider_Internal_IWbemEventProvider ) ;
  989. if ( FAILED ( t_TempResult ) )
  990. {
  991. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  992. }
  993. }
  994. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventProviderQuerySink , ( void ** ) & m_Provider_IWbemEventProviderQuerySink ) ;
  995. if ( SUCCEEDED ( t_TempResult ) )
  996. {
  997. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventProviderQuerySink , ( void ** ) & m_Provider_Internal_IWbemEventProviderQuerySink ) ;
  998. if ( FAILED ( t_TempResult ) )
  999. {
  1000. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1001. }
  1002. }
  1003. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventProviderSecurity , ( void ** ) & m_Provider_IWbemEventProviderSecurity ) ;
  1004. if ( SUCCEEDED ( t_TempResult ) )
  1005. {
  1006. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventProviderSecurity , ( void ** ) & m_Provider_Internal_IWbemEventProviderSecurity ) ;
  1007. if ( FAILED ( t_TempResult ) )
  1008. {
  1009. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1010. }
  1011. }
  1012. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemUnboundObjectSink , ( void ** ) & m_Provider_IWbemUnboundObjectSink ) ;
  1013. if ( SUCCEEDED ( t_TempResult ) )
  1014. {
  1015. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemUnboundObjectSink , ( void ** ) & m_Provider_Internal_IWbemUnboundObjectSink ) ;
  1016. if ( FAILED ( t_TempResult ) )
  1017. {
  1018. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1019. }
  1020. }
  1021. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventConsumerProvider , ( void ** ) & m_Provider_IWbemEventConsumerProvider ) ;
  1022. if ( SUCCEEDED ( t_TempResult ) )
  1023. {
  1024. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventConsumerProvider , ( void ** ) & m_Provider_Internal_IWbemEventConsumerProvider ) ;
  1025. if ( FAILED ( t_TempResult ) )
  1026. {
  1027. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1028. }
  1029. }
  1030. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventConsumerProviderEx , ( void ** ) & m_Provider_IWbemEventConsumerProviderEx ) ;
  1031. if ( SUCCEEDED ( t_TempResult ) )
  1032. {
  1033. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventConsumerProviderEx , ( void ** ) & m_Provider_Internal_IWbemEventConsumerProviderEx ) ;
  1034. if ( FAILED ( t_TempResult ) )
  1035. {
  1036. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1037. }
  1038. }
  1039. t_TempResult = m_Unknown->QueryInterface ( IID__IWmiProviderConfiguration , ( void ** ) & m_Provider__IWmiProviderConfiguration ) ;
  1040. if ( FAILED ( t_TempResult ) )
  1041. {
  1042. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1043. }
  1044. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWmiProviderConfiguration , ( void ** ) & m_Provider_Internal_IWmiProviderConfiguration ) ;
  1045. if ( FAILED ( t_TempResult ) )
  1046. {
  1047. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  1048. }
  1049. return m_InitializeResult ;
  1050. }
  1051. /******************************************************************************
  1052. *
  1053. * Name:
  1054. *
  1055. *
  1056. * Description:
  1057. *
  1058. *
  1059. *****************************************************************************/
  1060. HRESULT CInterceptor_IWbemProvider :: DownLevel (
  1061. long a_Flags ,
  1062. IWbemContext *a_Context ,
  1063. REFIID a_Riid,
  1064. void **a_Interface
  1065. )
  1066. {
  1067. return m_Unknown->QueryInterface ( a_Riid , a_Interface ) ;
  1068. }
  1069. /******************************************************************************
  1070. *
  1071. * Name:
  1072. *
  1073. *
  1074. * Description:
  1075. *
  1076. *
  1077. *****************************************************************************/
  1078. HRESULT CInterceptor_IWbemProvider :: SetInitialized ( HRESULT a_InitializeResult )
  1079. {
  1080. m_InitializeResult = a_InitializeResult ;
  1081. InterlockedExchange ( & m_Initialized , 1 ) ;
  1082. if ( m_InitializedEvent )
  1083. {
  1084. SetEvent ( m_InitializedEvent ) ;
  1085. }
  1086. return S_OK ;
  1087. }
  1088. /******************************************************************************
  1089. *
  1090. * Name:
  1091. *
  1092. *
  1093. * Description:
  1094. *
  1095. *
  1096. *****************************************************************************/
  1097. HRESULT CInterceptor_IWbemProvider :: IsIndependant ( IWbemContext *a_Context )
  1098. {
  1099. BOOL t_DependantCall = FALSE ;
  1100. HRESULT t_Result = ProviderSubSystem_Common_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  1101. if ( SUCCEEDED ( t_Result ) )
  1102. {
  1103. if ( t_DependantCall == FALSE )
  1104. {
  1105. }
  1106. else
  1107. {
  1108. return S_FALSE ;
  1109. }
  1110. }
  1111. return t_Result ;
  1112. }
  1113. /******************************************************************************
  1114. *
  1115. * Name:
  1116. *
  1117. *
  1118. * Description:
  1119. *
  1120. *
  1121. *****************************************************************************/
  1122. HRESULT CInterceptor_IWbemProvider :: WaitProvider ( IWbemContext *a_Context , ULONG a_Timeout )
  1123. {
  1124. HRESULT t_Result = WBEM_E_UNEXPECTED ;
  1125. if ( m_Initialized == 0 )
  1126. {
  1127. BOOL t_DependantCall = FALSE ;
  1128. t_Result = ProviderSubSystem_Common_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  1129. if ( SUCCEEDED ( t_Result ) )
  1130. {
  1131. if ( t_DependantCall == FALSE )
  1132. {
  1133. if ( WaitForSingleObject ( m_InitializedEvent , a_Timeout ) == WAIT_TIMEOUT )
  1134. {
  1135. return WBEM_E_PROVIDER_LOAD_FAILURE ;
  1136. }
  1137. }
  1138. else
  1139. {
  1140. if ( WaitForSingleObject ( m_InitializedEvent , 0 ) == WAIT_TIMEOUT )
  1141. {
  1142. return S_FALSE ;
  1143. }
  1144. }
  1145. }
  1146. }
  1147. else
  1148. {
  1149. t_Result = S_OK ;
  1150. }
  1151. return t_Result ;
  1152. }
  1153. /******************************************************************************
  1154. *
  1155. * Name:
  1156. *
  1157. *
  1158. * Description:
  1159. *
  1160. *
  1161. *****************************************************************************/
  1162. STDMETHODIMP_(ULONG) CInterceptor_IWbemProvider :: AddRef ( void )
  1163. {
  1164. return ServiceCacheElement :: AddRef () ;
  1165. }
  1166. /******************************************************************************
  1167. *
  1168. * Name:
  1169. *
  1170. *
  1171. * Description:
  1172. *
  1173. *
  1174. *****************************************************************************/
  1175. STDMETHODIMP_(ULONG) CInterceptor_IWbemProvider :: Release ( void )
  1176. {
  1177. return ServiceCacheElement :: Release () ;
  1178. }
  1179. /******************************************************************************
  1180. *
  1181. * Name:
  1182. *
  1183. *
  1184. * Description:
  1185. *
  1186. *
  1187. *****************************************************************************/
  1188. void CInterceptor_IWbemProvider :: CallBackInternalRelease ()
  1189. {
  1190. if ( InterlockedCompareExchange ( & m_UnInitialized , 1 , 0 ) == 0 )
  1191. {
  1192. WmiStatusCode t_StatusCode = m_ProxyContainer.UnInitialize () ;
  1193. CWbemGlobal_HostedProviderController *t_Controller = ProviderSubSystem_Globals :: GetHostedProviderController () ;
  1194. CWbemGlobal_HostedProviderController_Container_Iterator t_Iterator ;
  1195. t_Controller->Lock () ;
  1196. t_StatusCode = t_Controller->Find ( m_ProcessIdentifier , t_Iterator ) ;
  1197. if ( t_StatusCode == e_StatusCode_Success )
  1198. {
  1199. ProviderController *t_ProviderController = NULL ;
  1200. HRESULT t_Result = t_Iterator.GetElement ()->QueryInterface ( IID_ProviderController , ( void ** ) & t_ProviderController ) ;
  1201. if ( SUCCEEDED ( t_Result ) )
  1202. {
  1203. t_StatusCode = t_ProviderController->Delete ( this ) ;
  1204. if ( t_StatusCode == e_StatusCode_Success )
  1205. {
  1206. NonCyclicRelease () ;
  1207. }
  1208. t_ProviderController->Release () ;
  1209. }
  1210. }
  1211. t_Controller->UnLock () ;
  1212. if ( m_Quota )
  1213. {
  1214. m_Quota->Release () ;
  1215. }
  1216. if ( m_Unknown )
  1217. {
  1218. m_Unknown->Release () ;
  1219. }
  1220. if ( m_Provider_IWbemServices )
  1221. {
  1222. m_Provider_IWbemServices->Release () ;
  1223. }
  1224. if ( m_Provider_IWbemPropertyProvider )
  1225. {
  1226. m_Provider_IWbemPropertyProvider->Release () ;
  1227. }
  1228. if ( m_Provider_IWbemHiPerfProvider )
  1229. {
  1230. m_Provider_IWbemHiPerfProvider->Release () ;
  1231. }
  1232. if ( m_Provider_IWbemEventProvider )
  1233. {
  1234. m_Provider_IWbemEventProvider->Release () ;
  1235. }
  1236. if ( m_Provider_IWbemEventProviderQuerySink )
  1237. {
  1238. m_Provider_IWbemEventProviderQuerySink->Release () ;
  1239. }
  1240. if ( m_Provider_IWbemEventProviderSecurity )
  1241. {
  1242. m_Provider_IWbemEventProviderSecurity->Release () ;
  1243. }
  1244. if ( m_Provider_IWbemEventConsumerProviderEx )
  1245. {
  1246. m_Provider_IWbemEventConsumerProviderEx->Release () ;
  1247. }
  1248. if ( m_Provider_IWbemEventConsumerProvider )
  1249. {
  1250. m_Provider_IWbemEventConsumerProvider->Release () ;
  1251. }
  1252. if ( m_Provider__IWmiProviderConfiguration )
  1253. {
  1254. m_Provider__IWmiProviderConfiguration->Release () ;
  1255. }
  1256. if ( m_Provider_IWbemUnboundObjectSink )
  1257. {
  1258. m_Provider_IWbemUnboundObjectSink->Release () ;
  1259. }
  1260. if ( m_Provider_Internal_IWbemServices )
  1261. {
  1262. m_Provider_Internal_IWbemServices->Release () ;
  1263. }
  1264. if ( m_Provider_Internal_IWbemPropertyProvider )
  1265. {
  1266. m_Provider_Internal_IWbemPropertyProvider->Release () ;
  1267. }
  1268. if ( m_Provider_Internal_IWbemEventProvider )
  1269. {
  1270. m_Provider_Internal_IWbemEventProvider->Release () ;
  1271. }
  1272. if ( m_Provider_Internal_IWbemEventProviderQuerySink )
  1273. {
  1274. m_Provider_Internal_IWbemEventProviderQuerySink->Release () ;
  1275. }
  1276. if ( m_Provider_Internal_IWbemEventProviderSecurity )
  1277. {
  1278. m_Provider_Internal_IWbemEventProviderSecurity->Release () ;
  1279. }
  1280. if ( m_Provider_Internal_IWbemEventConsumerProvider )
  1281. {
  1282. m_Provider_Internal_IWbemEventConsumerProvider->Release () ;
  1283. }
  1284. if ( m_Provider_Internal_IWbemEventConsumerProviderEx )
  1285. {
  1286. m_Provider_Internal_IWbemEventConsumerProviderEx->Release () ;
  1287. }
  1288. if ( m_Provider_Internal_IWbemUnboundObjectSink )
  1289. {
  1290. m_Provider_Internal_IWbemUnboundObjectSink->Release () ;
  1291. }
  1292. if ( m_Provider_Internal_IWmiProviderConfiguration )
  1293. {
  1294. m_Provider_Internal_IWmiProviderConfiguration->Release () ;
  1295. }
  1296. if ( m_Host )
  1297. {
  1298. m_Host->Release () ;
  1299. }
  1300. SetEvent ( ProviderSubSystem_Globals :: s_CoFreeUnusedLibrariesEvent ) ;
  1301. }
  1302. }
  1303. /******************************************************************************
  1304. *
  1305. * Name:
  1306. *
  1307. *
  1308. * Description:
  1309. *
  1310. *
  1311. *****************************************************************************/
  1312. STDMETHODIMP CInterceptor_IWbemProvider :: QueryInterface (
  1313. REFIID iid ,
  1314. LPVOID FAR *iplpv
  1315. )
  1316. {
  1317. *iplpv = NULL ;
  1318. if ( m_Initialized == 0 )
  1319. {
  1320. if ( iid == IID_IUnknown )
  1321. {
  1322. *iplpv = ( LPVOID ) this ;
  1323. }
  1324. else if ( iid == IID_IWbemServices )
  1325. {
  1326. *iplpv = ( LPVOID ) ( IWbemServices * ) this ;
  1327. }
  1328. else if ( iid == IID_IWbemPropertyProvider )
  1329. {
  1330. *iplpv = ( LPVOID ) ( IWbemPropertyProvider * ) this ;
  1331. }
  1332. else if ( iid == IID_IWbemHiPerfProvider )
  1333. {
  1334. *iplpv = ( LPVOID ) ( IWbemHiPerfProvider * ) this ;
  1335. }
  1336. else if ( iid == IID_IWbemEventProvider )
  1337. {
  1338. *iplpv = ( LPVOID ) ( IWbemEventProvider * ) this ;
  1339. }
  1340. else if ( iid == IID_IWbemEventProviderQuerySink )
  1341. {
  1342. *iplpv = ( LPVOID ) ( IWbemEventProviderQuerySink * ) this ;
  1343. }
  1344. else if ( iid == IID_IWbemEventProviderSecurity )
  1345. {
  1346. *iplpv = ( LPVOID ) ( IWbemEventProviderSecurity * ) this ;
  1347. }
  1348. else if ( iid == IID_IWbemEventConsumerProvider )
  1349. {
  1350. *iplpv = ( LPVOID ) ( IWbemEventConsumerProvider * ) this ;
  1351. }
  1352. else if ( iid == IID_IWbemEventConsumerProviderEx )
  1353. {
  1354. *iplpv = ( LPVOID ) ( IWbemEventConsumerProviderEx * ) this ;
  1355. }
  1356. else if ( iid == IID_IWbemUnboundObjectSink )
  1357. {
  1358. *iplpv = ( LPVOID ) ( IWbemUnboundObjectSink * ) this ;
  1359. }
  1360. else if ( iid == IID_IWbemProviderInit )
  1361. {
  1362. *iplpv = ( LPVOID ) ( IWbemProviderInit * ) this ;
  1363. }
  1364. else if ( iid == IID__IWmiProviderInitialize )
  1365. {
  1366. *iplpv = ( LPVOID ) ( _IWmiProviderInitialize * ) this ;
  1367. }
  1368. else if ( iid == IID_IWbemShutdown )
  1369. {
  1370. *iplpv = ( LPVOID ) ( IWbemShutdown * ) this ;
  1371. }
  1372. else if ( iid == IID__IWmiProviderLoad )
  1373. {
  1374. *iplpv = ( LPVOID ) ( _IWmiProviderLoad * )this ;
  1375. }
  1376. else if ( iid == IID__IWmiProviderConfiguration )
  1377. {
  1378. *iplpv = ( LPVOID ) ( _IWmiProviderConfiguration * ) this ;
  1379. }
  1380. else if ( iid == IID__IWmiProviderQuota )
  1381. {
  1382. *iplpv = ( LPVOID ) & ( this->m_Internal ) ;
  1383. }
  1384. else if ( iid == IID__IWmiProviderStack )
  1385. {
  1386. *iplpv = ( LPVOID ) ( _IWmiProviderStack * ) this ;
  1387. }
  1388. else if ( iid == IID__IWmiProviderCache )
  1389. {
  1390. *iplpv = ( LPVOID ) ( _IWmiProviderCache * ) this ;
  1391. }
  1392. else if ( iid == IID_CWbemGlobal_IWmiObjectSinkController )
  1393. {
  1394. *iplpv = ( LPVOID ) ( CWbemGlobal_IWmiObjectSinkController * ) this ;
  1395. }
  1396. else if ( iid == IID_CInterceptor_IWbemProvider )
  1397. {
  1398. *iplpv = ( LPVOID ) ( CInterceptor_IWbemProvider * ) this ;
  1399. }
  1400. }
  1401. else
  1402. {
  1403. if ( iid == IID_IUnknown )
  1404. {
  1405. *iplpv = ( LPVOID ) this ;
  1406. }
  1407. else if ( iid == IID_IWbemServices )
  1408. {
  1409. if ( m_Provider_IWbemServices )
  1410. {
  1411. *iplpv = ( LPVOID ) ( IWbemServices * ) this ;
  1412. }
  1413. }
  1414. else if ( iid == IID_IWbemPropertyProvider )
  1415. {
  1416. if ( m_Provider_IWbemPropertyProvider )
  1417. {
  1418. *iplpv = ( LPVOID ) ( IWbemPropertyProvider * ) this ;
  1419. }
  1420. }
  1421. else if ( iid == IID_IWbemHiPerfProvider )
  1422. {
  1423. if ( m_Provider_IWbemHiPerfProvider )
  1424. {
  1425. *iplpv = ( LPVOID ) ( IWbemHiPerfProvider * ) this ;
  1426. }
  1427. }
  1428. else if ( iid == IID_IWbemEventProvider )
  1429. {
  1430. if ( m_Provider_IWbemEventProvider )
  1431. {
  1432. *iplpv = ( LPVOID ) ( IWbemEventProvider * ) this ;
  1433. }
  1434. }
  1435. else if ( iid == IID_IWbemEventProviderQuerySink )
  1436. {
  1437. if ( m_Provider_IWbemEventProviderQuerySink )
  1438. {
  1439. *iplpv = ( LPVOID ) ( IWbemEventProviderQuerySink * ) this ;
  1440. }
  1441. }
  1442. else if ( iid == IID_IWbemEventProviderSecurity )
  1443. {
  1444. if ( m_Provider_IWbemEventProviderSecurity )
  1445. {
  1446. *iplpv = ( LPVOID ) ( IWbemEventProviderSecurity * ) this ;
  1447. }
  1448. }
  1449. else if ( iid == IID_IWbemEventConsumerProvider )
  1450. {
  1451. if ( m_Provider_IWbemEventConsumerProvider )
  1452. {
  1453. *iplpv = ( LPVOID ) ( IWbemEventConsumerProvider * ) this ;
  1454. }
  1455. }
  1456. else if ( iid == IID_IWbemEventConsumerProviderEx )
  1457. {
  1458. if ( m_Provider_IWbemEventConsumerProviderEx )
  1459. {
  1460. *iplpv = ( LPVOID ) ( IWbemEventConsumerProviderEx * ) this ;
  1461. }
  1462. }
  1463. else if ( iid == IID_IWbemUnboundObjectSink )
  1464. {
  1465. if ( m_Provider_IWbemUnboundObjectSink )
  1466. {
  1467. *iplpv = ( LPVOID ) ( IWbemUnboundObjectSink * ) this ;
  1468. }
  1469. }
  1470. else if ( iid == IID_IWbemProviderInit )
  1471. {
  1472. *iplpv = ( LPVOID ) ( IWbemProviderInit * ) this ;
  1473. }
  1474. else if ( iid == IID__IWmiProviderInitialize )
  1475. {
  1476. *iplpv = ( LPVOID ) ( _IWmiProviderInitialize * ) this ;
  1477. }
  1478. else if ( iid == IID_IWbemShutdown )
  1479. {
  1480. *iplpv = ( LPVOID ) ( IWbemShutdown * ) this ;
  1481. }
  1482. else if ( iid == IID__IWmiProviderLoad )
  1483. {
  1484. *iplpv = ( LPVOID ) ( _IWmiProviderLoad * )this ;
  1485. }
  1486. else if ( iid == IID__IWmiProviderConfiguration )
  1487. {
  1488. *iplpv = ( LPVOID ) ( _IWmiProviderConfiguration * ) this ;
  1489. }
  1490. else if ( iid == IID__IWmiProviderQuota )
  1491. {
  1492. *iplpv = ( LPVOID ) & ( this->m_Internal ) ;
  1493. }
  1494. else if ( iid == IID__IWmiProviderStack )
  1495. {
  1496. *iplpv = ( LPVOID ) ( _IWmiProviderStack * ) this ;
  1497. }
  1498. else if ( iid == IID__IWmiProviderCache )
  1499. {
  1500. *iplpv = ( LPVOID ) ( _IWmiProviderCache * ) this ;
  1501. }
  1502. else if ( iid == IID__IWmiProviderAbnormalShutdown )
  1503. {
  1504. *iplpv = ( LPVOID ) ( _IWmiProviderAbnormalShutdown * ) this ;
  1505. }
  1506. else if ( iid == IID_CWbemGlobal_IWmiObjectSinkController )
  1507. {
  1508. *iplpv = ( LPVOID ) ( CWbemGlobal_IWmiObjectSinkController * ) this ;
  1509. }
  1510. else if ( iid == IID_CInterceptor_IWbemProvider )
  1511. {
  1512. *iplpv = ( LPVOID ) ( CInterceptor_IWbemProvider * ) this ;
  1513. }
  1514. }
  1515. if ( *iplpv )
  1516. {
  1517. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  1518. return ResultFromScode ( S_OK ) ;
  1519. }
  1520. else
  1521. {
  1522. return ResultFromScode ( E_NOINTERFACE ) ;
  1523. }
  1524. }
  1525. /******************************************************************************
  1526. *
  1527. * Name:
  1528. *
  1529. *
  1530. * Description:
  1531. *
  1532. *
  1533. *****************************************************************************/
  1534. HRESULT CInterceptor_IWbemProvider :: Begin_Interface (
  1535. IUnknown *a_ServerInterface ,
  1536. REFIID a_InterfaceIdentifier ,
  1537. DWORD a_ProxyIndex ,
  1538. IUnknown *a_InternalServerInterface ,
  1539. REFIID a_InternalInterfaceIdentifier ,
  1540. DWORD a_InternalProxyIndex ,
  1541. DWORD a_ProcessIdentifier ,
  1542. HANDLE &a_IdentifyToken ,
  1543. BOOL &a_Impersonating ,
  1544. IUnknown *&a_OldContext ,
  1545. IServerSecurity *&a_OldSecurity ,
  1546. BOOL &a_IsProxy ,
  1547. IUnknown *&a_Interface ,
  1548. BOOL &a_Revert ,
  1549. IUnknown *&a_Proxy ,
  1550. IWbemContext *a_Context
  1551. )
  1552. {
  1553. HRESULT t_Result = S_OK ;
  1554. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  1555. a_IdentifyToken = NULL ;
  1556. a_Revert = FALSE ;
  1557. a_Proxy = NULL ;
  1558. a_Impersonating = FALSE ;
  1559. a_OldContext = NULL ;
  1560. a_OldSecurity = NULL ;
  1561. switch ( m_Registration->GetHosting () )
  1562. {
  1563. case e_Hosting_WmiCore:
  1564. case e_Hosting_WmiCoreOrSelfHost:
  1565. case e_Hosting_SelfHost:
  1566. {
  1567. a_Interface = a_ServerInterface ;
  1568. a_IsProxy = FALSE ;
  1569. }
  1570. break ;
  1571. default:
  1572. {
  1573. DWORD t_AuthenticationLevel = 0 ;
  1574. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation (
  1575. a_OldContext ,
  1576. a_OldSecurity ,
  1577. a_Impersonating ,
  1578. & t_AuthenticationLevel
  1579. ) ;
  1580. if ( SUCCEEDED ( t_Result ) )
  1581. {
  1582. if ( a_ProcessIdentifier )
  1583. {
  1584. DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE ;
  1585. IServerSecurity *t_ServerSecurity = NULL ;
  1586. HRESULT t_TempResult = CoGetCallContext ( IID_IUnknown , ( void ** ) & t_ServerSecurity ) ;
  1587. if ( SUCCEEDED ( t_TempResult ) )
  1588. {
  1589. t_Result = CoImpersonateClient () ;
  1590. if ( SUCCEEDED ( t_Result ) )
  1591. {
  1592. t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1593. CoRevertToSelf () ;
  1594. }
  1595. t_ServerSecurity->Release () ;
  1596. }
  1597. if ( t_ImpersonationLevel == RPC_C_IMP_LEVEL_IMPERSONATE || t_ImpersonationLevel == RPC_C_IMP_LEVEL_DELEGATE )
  1598. {
  1599. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState (
  1600. m_ProxyContainer ,
  1601. a_ProxyIndex ,
  1602. a_InterfaceIdentifier ,
  1603. a_ServerInterface ,
  1604. a_Proxy ,
  1605. a_Revert
  1606. ) ;
  1607. }
  1608. else
  1609. {
  1610. switch ( m_Registration->GetHosting () )
  1611. {
  1612. case e_Hosting_SharedLocalSystemHost:
  1613. case e_Hosting_SharedLocalSystemHostOrSelfHost:
  1614. {
  1615. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  1616. m_ProxyContainer ,
  1617. a_InternalProxyIndex ,
  1618. a_InterfaceIdentifier ,
  1619. a_InternalServerInterface ,
  1620. a_Proxy ,
  1621. a_Revert ,
  1622. a_ProcessIdentifier ,
  1623. a_IdentifyToken ,
  1624. ProviderSubSystem_Common_Globals :: s_Token_All_Access_System_ACE ,
  1625. ProviderSubSystem_Common_Globals :: s_System_ACESize
  1626. ) ;
  1627. }
  1628. break ;
  1629. case e_Hosting_SharedLocalServiceHost:
  1630. {
  1631. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  1632. m_ProxyContainer ,
  1633. a_InternalProxyIndex ,
  1634. a_InterfaceIdentifier ,
  1635. a_InternalServerInterface ,
  1636. a_Proxy ,
  1637. a_Revert ,
  1638. a_ProcessIdentifier ,
  1639. a_IdentifyToken ,
  1640. ProviderSubSystem_Common_Globals :: s_Token_All_Access_LocalService_ACE ,
  1641. ProviderSubSystem_Common_Globals :: s_LocalService_ACESize
  1642. ) ;
  1643. }
  1644. break ;
  1645. case e_Hosting_SharedNetworkServiceHost:
  1646. {
  1647. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  1648. m_ProxyContainer ,
  1649. a_InternalProxyIndex ,
  1650. a_InterfaceIdentifier ,
  1651. a_InternalServerInterface ,
  1652. a_Proxy ,
  1653. a_Revert ,
  1654. a_ProcessIdentifier ,
  1655. a_IdentifyToken ,
  1656. ProviderSubSystem_Common_Globals :: s_Token_All_Access_NetworkService_ACE ,
  1657. ProviderSubSystem_Common_Globals :: s_NetworkService_ACESize
  1658. ) ;
  1659. }
  1660. break ;
  1661. default:
  1662. {
  1663. t_Result = WBEM_E_UNEXPECTED ;
  1664. }
  1665. break ;
  1666. }
  1667. }
  1668. }
  1669. else
  1670. {
  1671. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState (
  1672. m_ProxyContainer ,
  1673. a_ProxyIndex ,
  1674. a_InterfaceIdentifier ,
  1675. a_ServerInterface ,
  1676. a_Proxy ,
  1677. a_Revert
  1678. ) ;
  1679. }
  1680. if ( t_Result == WBEM_E_NOT_FOUND )
  1681. {
  1682. a_Interface = a_ServerInterface ;
  1683. a_IsProxy = FALSE ;
  1684. t_Result = S_OK ;
  1685. }
  1686. else
  1687. {
  1688. if ( SUCCEEDED ( t_Result ) )
  1689. {
  1690. a_IsProxy = TRUE ;
  1691. a_Interface = ( IUnknown * ) a_Proxy ;
  1692. // Set cloaking on the proxy
  1693. // =========================
  1694. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1695. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1696. a_Interface ,
  1697. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1698. t_ImpersonationLevel
  1699. ) ;
  1700. if ( SUCCEEDED ( t_Result ) )
  1701. {
  1702. if ( a_Context )
  1703. {
  1704. VARIANT t_Variant ;
  1705. VariantInit ( & t_Variant ) ;
  1706. t_Variant.lVal = t_AuthenticationLevel ;
  1707. t_Variant.vt = VT_I4 ;
  1708. t_Result = a_Context->SetValue ( L"__WBEM_CLIENT_AUTHENTICATION_LEVEL" , 0, & t_Variant ) ;
  1709. }
  1710. }
  1711. if ( FAILED ( t_Result ) )
  1712. {
  1713. if ( a_IdentifyToken )
  1714. {
  1715. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState_SvcHost (
  1716. m_ProxyContainer ,
  1717. a_InternalProxyIndex ,
  1718. a_Proxy ,
  1719. a_Revert ,
  1720. a_ProcessIdentifier ,
  1721. a_IdentifyToken
  1722. ) ;
  1723. }
  1724. else
  1725. {
  1726. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState (
  1727. m_ProxyContainer ,
  1728. a_ProxyIndex ,
  1729. a_Proxy ,
  1730. a_Revert
  1731. ) ;
  1732. }
  1733. }
  1734. }
  1735. }
  1736. if ( FAILED ( t_Result ) && t_Result != WBEM_E_NOT_FOUND )
  1737. {
  1738. ProviderSubSystem_Common_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  1739. }
  1740. }
  1741. }
  1742. break ;
  1743. }
  1744. return t_Result ;
  1745. }
  1746. /******************************************************************************
  1747. *
  1748. * Name:
  1749. *
  1750. *
  1751. * Description:
  1752. *
  1753. *
  1754. *****************************************************************************/
  1755. HRESULT CInterceptor_IWbemProvider :: End_Interface (
  1756. IUnknown *a_ServerInterface ,
  1757. REFIID a_InterfaceIdentifier ,
  1758. DWORD a_ProxyIndex ,
  1759. IUnknown *a_InternalServerInterface ,
  1760. REFIID a_InternalInterfaceIdentifier ,
  1761. DWORD a_InternalProxyIndex ,
  1762. DWORD a_ProcessIdentifier ,
  1763. HANDLE a_IdentifyToken ,
  1764. BOOL a_Impersonating ,
  1765. IUnknown *a_OldContext ,
  1766. IServerSecurity *a_OldSecurity ,
  1767. BOOL a_IsProxy ,
  1768. IUnknown *a_Interface ,
  1769. BOOL a_Revert ,
  1770. IUnknown *a_Proxy
  1771. )
  1772. {
  1773. CoRevertToSelf () ;
  1774. if ( a_Proxy )
  1775. {
  1776. if ( a_IdentifyToken )
  1777. {
  1778. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState_SvcHost (
  1779. m_ProxyContainer ,
  1780. a_InternalProxyIndex ,
  1781. a_Proxy ,
  1782. a_Revert ,
  1783. a_ProcessIdentifier ,
  1784. a_IdentifyToken
  1785. ) ;
  1786. }
  1787. else
  1788. {
  1789. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState (
  1790. m_ProxyContainer ,
  1791. a_ProxyIndex ,
  1792. a_Proxy ,
  1793. a_Revert
  1794. ) ;
  1795. }
  1796. }
  1797. switch ( m_Registration->GetHosting () )
  1798. {
  1799. case e_Hosting_WmiCore:
  1800. case e_Hosting_WmiCoreOrSelfHost:
  1801. case e_Hosting_SelfHost:
  1802. {
  1803. }
  1804. break ;
  1805. default:
  1806. {
  1807. ProviderSubSystem_Common_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  1808. }
  1809. break ;
  1810. }
  1811. return S_OK ;
  1812. }
  1813. /******************************************************************************
  1814. *
  1815. * Name:
  1816. *
  1817. *
  1818. * Description:
  1819. *
  1820. *
  1821. *****************************************************************************/
  1822. HRESULT CInterceptor_IWbemProvider :: Begin_Interface_Context (
  1823. IUnknown *a_ServerInterface ,
  1824. REFIID a_InterfaceIdentifier ,
  1825. DWORD a_ProxyIndex ,
  1826. IUnknown *a_InternalServerInterface ,
  1827. REFIID a_InternalInterfaceIdentifier ,
  1828. DWORD a_InternalProxyIndex ,
  1829. DWORD a_ProcessIdentifier ,
  1830. HANDLE &a_IdentifyToken ,
  1831. BOOL &a_Impersonating ,
  1832. IUnknown *&a_OldContext ,
  1833. IServerSecurity *&a_OldSecurity ,
  1834. BOOL &a_IsProxy ,
  1835. IUnknown *&a_Interface ,
  1836. BOOL &a_Revert ,
  1837. IUnknown *&a_Proxy ,
  1838. IWbemContext *a_Context
  1839. )
  1840. {
  1841. HRESULT t_Result = S_OK ;
  1842. a_IdentifyToken = NULL ;
  1843. a_Revert = FALSE ;
  1844. a_Proxy = NULL ;
  1845. a_Impersonating = FALSE ;
  1846. a_OldContext = NULL ;
  1847. a_OldSecurity = NULL ;
  1848. switch ( m_Registration->GetHosting () )
  1849. {
  1850. case e_Hosting_WmiCore:
  1851. case e_Hosting_WmiCoreOrSelfHost:
  1852. case e_Hosting_SelfHost:
  1853. {
  1854. a_Interface = a_ServerInterface ;
  1855. a_IsProxy = FALSE ;
  1856. }
  1857. break ;
  1858. default:
  1859. {
  1860. DWORD t_AuthenticationLevel = 0 ;
  1861. IServerSecurity *t_Security = NULL ;
  1862. t_Result = CoGetCallContext ( IID_IServerSecurity , ( void ** ) & t_Security ) ;
  1863. if ( SUCCEEDED ( t_Result ) )
  1864. {
  1865. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation (
  1866. a_OldContext ,
  1867. a_OldSecurity ,
  1868. a_Impersonating ,
  1869. & t_AuthenticationLevel
  1870. ) ;
  1871. if ( SUCCEEDED ( t_Result ) )
  1872. {
  1873. if ( a_ProcessIdentifier )
  1874. {
  1875. DWORD t_ImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE ;
  1876. IServerSecurity *t_ServerSecurity = NULL ;
  1877. HRESULT t_TempResult = CoGetCallContext ( IID_IUnknown , ( void ** ) & t_ServerSecurity ) ;
  1878. if ( SUCCEEDED ( t_TempResult ) )
  1879. {
  1880. t_Result = CoImpersonateClient () ;
  1881. if ( SUCCEEDED ( t_Result ) )
  1882. {
  1883. t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1884. CoRevertToSelf () ;
  1885. }
  1886. t_ServerSecurity->Release () ;
  1887. }
  1888. if ( t_ImpersonationLevel == RPC_C_IMP_LEVEL_IMPERSONATE || t_ImpersonationLevel == RPC_C_IMP_LEVEL_DELEGATE )
  1889. {
  1890. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState (
  1891. m_ProxyContainer ,
  1892. a_ProxyIndex ,
  1893. a_InterfaceIdentifier ,
  1894. a_ServerInterface ,
  1895. a_Proxy ,
  1896. a_Revert
  1897. ) ;
  1898. }
  1899. else
  1900. {
  1901. switch ( m_Registration->GetHosting () )
  1902. {
  1903. case e_Hosting_SharedLocalSystemHost:
  1904. case e_Hosting_SharedLocalSystemHostOrSelfHost:
  1905. {
  1906. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  1907. m_ProxyContainer ,
  1908. a_InternalProxyIndex ,
  1909. a_InterfaceIdentifier ,
  1910. a_InternalServerInterface ,
  1911. a_Proxy ,
  1912. a_Revert ,
  1913. a_ProcessIdentifier ,
  1914. a_IdentifyToken ,
  1915. ProviderSubSystem_Common_Globals :: s_Token_All_Access_System_ACE ,
  1916. ProviderSubSystem_Common_Globals :: s_System_ACESize
  1917. ) ;
  1918. }
  1919. break ;
  1920. case e_Hosting_SharedLocalServiceHost:
  1921. {
  1922. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  1923. m_ProxyContainer ,
  1924. a_InternalProxyIndex ,
  1925. a_InterfaceIdentifier ,
  1926. a_InternalServerInterface ,
  1927. a_Proxy ,
  1928. a_Revert ,
  1929. a_ProcessIdentifier ,
  1930. a_IdentifyToken ,
  1931. ProviderSubSystem_Common_Globals :: s_Token_All_Access_LocalService_ACE ,
  1932. ProviderSubSystem_Common_Globals :: s_LocalService_ACESize
  1933. ) ;
  1934. }
  1935. break ;
  1936. case e_Hosting_SharedNetworkServiceHost:
  1937. {
  1938. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_SvcHost (
  1939. m_ProxyContainer ,
  1940. a_InternalProxyIndex ,
  1941. a_InterfaceIdentifier ,
  1942. a_InternalServerInterface ,
  1943. a_Proxy ,
  1944. a_Revert ,
  1945. a_ProcessIdentifier ,
  1946. a_IdentifyToken ,
  1947. ProviderSubSystem_Common_Globals :: s_Token_All_Access_NetworkService_ACE ,
  1948. ProviderSubSystem_Common_Globals :: s_NetworkService_ACESize
  1949. ) ;
  1950. }
  1951. break ;
  1952. default:
  1953. {
  1954. t_Result = WBEM_E_UNEXPECTED ;
  1955. }
  1956. break ;
  1957. }
  1958. }
  1959. }
  1960. else
  1961. {
  1962. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState (
  1963. m_ProxyContainer ,
  1964. a_ProxyIndex ,
  1965. a_InterfaceIdentifier ,
  1966. a_ServerInterface ,
  1967. a_Proxy ,
  1968. a_Revert
  1969. ) ;
  1970. }
  1971. if ( t_Result == WBEM_E_NOT_FOUND )
  1972. {
  1973. a_Interface = a_ServerInterface ;
  1974. a_IsProxy = FALSE ;
  1975. t_Result = S_OK ;
  1976. }
  1977. else
  1978. {
  1979. if ( SUCCEEDED ( t_Result ) )
  1980. {
  1981. a_IsProxy = TRUE ;
  1982. a_Interface = ( IUnknown * ) a_Proxy ;
  1983. // Set cloaking on the proxy
  1984. // =========================
  1985. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1986. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1987. a_Interface ,
  1988. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1989. t_ImpersonationLevel
  1990. ) ;
  1991. if ( SUCCEEDED ( t_Result ) )
  1992. {
  1993. if ( a_Context )
  1994. {
  1995. VARIANT t_Variant ;
  1996. VariantInit ( & t_Variant ) ;
  1997. t_Variant.lVal = t_AuthenticationLevel ;
  1998. t_Variant.vt = VT_I4 ;
  1999. t_Result = a_Context->SetValue ( L"__WBEM_CLIENT_AUTHENTICATION_LEVEL" , 0, & t_Variant ) ;
  2000. }
  2001. }
  2002. if ( FAILED ( t_Result ) )
  2003. {
  2004. if ( a_IdentifyToken )
  2005. {
  2006. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState_SvcHost (
  2007. m_ProxyContainer ,
  2008. a_InternalProxyIndex ,
  2009. a_Proxy ,
  2010. a_Revert ,
  2011. a_ProcessIdentifier ,
  2012. a_IdentifyToken
  2013. ) ;
  2014. }
  2015. else
  2016. {
  2017. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState (
  2018. m_ProxyContainer ,
  2019. a_ProxyIndex ,
  2020. a_Proxy ,
  2021. a_Revert
  2022. ) ;
  2023. }
  2024. }
  2025. }
  2026. }
  2027. if ( FAILED ( t_Result ) && t_Result != WBEM_E_NOT_FOUND )
  2028. {
  2029. ProviderSubSystem_Common_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  2030. }
  2031. }
  2032. t_Security->Release () ;
  2033. }
  2034. else
  2035. {
  2036. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState_NoImpersonation (
  2037. m_ProxyContainer ,
  2038. a_ProxyIndex ,
  2039. a_InterfaceIdentifier ,
  2040. a_ServerInterface ,
  2041. a_Proxy ,
  2042. a_Revert
  2043. ) ;
  2044. if ( t_Result == WBEM_E_NOT_FOUND )
  2045. {
  2046. a_Interface = a_ServerInterface ;
  2047. a_IsProxy = FALSE ;
  2048. t_Result = S_OK ;
  2049. }
  2050. else
  2051. {
  2052. a_Interface = a_Proxy ;
  2053. a_IsProxy = TRUE ;
  2054. t_Result = S_OK ;
  2055. }
  2056. }
  2057. }
  2058. break ;
  2059. }
  2060. return t_Result ;
  2061. }
  2062. /******************************************************************************
  2063. *
  2064. * Name:
  2065. *
  2066. *
  2067. * Description:
  2068. *
  2069. *
  2070. *****************************************************************************/
  2071. HRESULT CInterceptor_IWbemProvider :: End_Interface_Context (
  2072. IUnknown *a_ServerInterface ,
  2073. REFIID a_InterfaceIdentifier ,
  2074. DWORD a_ProxyIndex ,
  2075. IUnknown *a_InternalServerInterface ,
  2076. REFIID a_InternalInterfaceIdentifier ,
  2077. DWORD a_InternalProxyIndex ,
  2078. DWORD a_ProcessIdentifier ,
  2079. HANDLE a_IdentifyToken ,
  2080. BOOL a_Impersonating ,
  2081. IUnknown *a_OldContext ,
  2082. IServerSecurity *a_OldSecurity ,
  2083. BOOL a_IsProxy ,
  2084. IUnknown *a_Interface ,
  2085. BOOL a_Revert ,
  2086. IUnknown *a_Proxy
  2087. )
  2088. {
  2089. CoRevertToSelf () ;
  2090. if ( a_Proxy )
  2091. {
  2092. if ( a_IdentifyToken )
  2093. {
  2094. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState_SvcHost (
  2095. m_ProxyContainer ,
  2096. a_InternalProxyIndex ,
  2097. a_Proxy ,
  2098. a_Revert ,
  2099. a_ProcessIdentifier ,
  2100. a_IdentifyToken
  2101. ) ;
  2102. }
  2103. else
  2104. {
  2105. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState (
  2106. m_ProxyContainer ,
  2107. a_ProxyIndex ,
  2108. a_Proxy ,
  2109. a_Revert
  2110. ) ;
  2111. }
  2112. }
  2113. switch ( m_Registration->GetHosting () )
  2114. {
  2115. case e_Hosting_WmiCore:
  2116. case e_Hosting_WmiCoreOrSelfHost:
  2117. case e_Hosting_SelfHost:
  2118. {
  2119. }
  2120. break ;
  2121. default:
  2122. {
  2123. ProviderSubSystem_Common_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  2124. }
  2125. break ;
  2126. }
  2127. return S_OK ;
  2128. }
  2129. /******************************************************************************
  2130. *
  2131. * Name:
  2132. *
  2133. *
  2134. * Description:
  2135. *
  2136. *
  2137. *****************************************************************************/
  2138. HRESULT CInterceptor_IWbemProvider::OpenNamespace (
  2139. const BSTR a_ObjectPath ,
  2140. long a_Flags ,
  2141. IWbemContext *a_Context ,
  2142. IWbemServices **a_NamespaceService ,
  2143. IWbemCallResult **a_CallResult
  2144. )
  2145. {
  2146. return WBEM_E_NOT_AVAILABLE ;
  2147. }
  2148. /******************************************************************************
  2149. *
  2150. * Name:
  2151. *
  2152. *
  2153. * Description:
  2154. *
  2155. *
  2156. *****************************************************************************/
  2157. HRESULT CInterceptor_IWbemProvider :: CancelAsyncCall (
  2158. IWbemObjectSink *a_Sink
  2159. )
  2160. {
  2161. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2162. if ( GetResumed () )
  2163. {
  2164. if ( m_Provider_IWbemServices )
  2165. {
  2166. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2167. Lock () ;
  2168. WmiStatusCode t_StatusCode = Find (
  2169. a_Sink ,
  2170. t_Iterator
  2171. ) ;
  2172. if ( t_StatusCode == e_StatusCode_Success )
  2173. {
  2174. ObjectSinkContainerElement *t_Element = t_Iterator.GetElement () ;
  2175. UnLock () ;
  2176. IWbemObjectSink *t_ObjectSink = NULL ;
  2177. t_Result = t_Element->QueryInterface ( IID_IWbemObjectSink , ( void ** ) & t_ObjectSink ) ;
  2178. if ( SUCCEEDED ( t_Result ) )
  2179. {
  2180. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2181. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2182. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2183. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2184. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2185. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2186. BOOL t_Impersonating ;
  2187. IUnknown *t_OldContext ;
  2188. IServerSecurity *t_OldSecurity ;
  2189. BOOL t_IsProxy ;
  2190. IUnknown *t_Interface ;
  2191. BOOL t_Revert ;
  2192. IUnknown *t_Proxy ;
  2193. HANDLE t_IdentifyToken = NULL ;
  2194. t_Result = Begin_Interface (
  2195. t_ServerInterface ,
  2196. t_InterfaceIdentifier ,
  2197. t_ProxyIndex ,
  2198. t_InternalServerInterface ,
  2199. t_InternalInterfaceIdentifier ,
  2200. t_InternalProxyIndex ,
  2201. m_ProcessIdentifier ,
  2202. t_IdentifyToken ,
  2203. t_Impersonating ,
  2204. t_OldContext ,
  2205. t_OldSecurity ,
  2206. t_IsProxy ,
  2207. t_Interface ,
  2208. t_Revert ,
  2209. t_Proxy
  2210. ) ;
  2211. if ( SUCCEEDED ( t_Result ) )
  2212. {
  2213. if ( t_IdentifyToken )
  2214. {
  2215. WmiInternalContext t_InternalContext ;
  2216. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2217. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2218. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_CancelAsyncCall (
  2219. t_InternalContext ,
  2220. t_ObjectSink
  2221. ) ;
  2222. }
  2223. else
  2224. {
  2225. t_Result = ( ( IWbemServices * ) t_Interface )->CancelAsyncCall (
  2226. t_ObjectSink
  2227. ) ;
  2228. }
  2229. End_Interface (
  2230. t_ServerInterface ,
  2231. t_InterfaceIdentifier ,
  2232. t_ProxyIndex ,
  2233. t_InternalServerInterface ,
  2234. t_InternalInterfaceIdentifier ,
  2235. t_InternalProxyIndex ,
  2236. m_ProcessIdentifier ,
  2237. t_IdentifyToken ,
  2238. t_Impersonating ,
  2239. t_OldContext ,
  2240. t_OldSecurity ,
  2241. t_IsProxy ,
  2242. t_Interface ,
  2243. t_Revert ,
  2244. t_Proxy
  2245. ) ;
  2246. }
  2247. t_ObjectSink->Release () ;
  2248. }
  2249. IWbemShutdown *t_Shutdown = NULL ;
  2250. HRESULT t_TempResult = t_Element->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  2251. if ( SUCCEEDED ( t_TempResult ) )
  2252. {
  2253. t_TempResult = t_Shutdown->Shutdown (
  2254. 0 ,
  2255. 0 ,
  2256. NULL
  2257. ) ;
  2258. t_Shutdown->Release () ;
  2259. }
  2260. t_Element->Release () ;
  2261. }
  2262. else
  2263. {
  2264. UnLock () ;
  2265. t_Result = WBEM_E_NOT_FOUND ;
  2266. }
  2267. }
  2268. }
  2269. else
  2270. {
  2271. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  2272. }
  2273. if ( FAILED ( t_Result ) )
  2274. {
  2275. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  2276. {
  2277. AbnormalShutdown () ;
  2278. }
  2279. }
  2280. return t_Result ;
  2281. }
  2282. /******************************************************************************
  2283. *
  2284. * Name:
  2285. *
  2286. *
  2287. * Description:
  2288. *
  2289. *
  2290. *****************************************************************************/
  2291. HRESULT CInterceptor_IWbemProvider :: QueryObjectSink (
  2292. long a_Flags ,
  2293. IWbemObjectSink **a_Sink
  2294. )
  2295. {
  2296. return WBEM_E_NOT_AVAILABLE ;
  2297. }
  2298. /******************************************************************************
  2299. *
  2300. * Name:
  2301. *
  2302. *
  2303. * Description:
  2304. *
  2305. *
  2306. *****************************************************************************/
  2307. HRESULT CInterceptor_IWbemProvider :: GetObject (
  2308. const BSTR a_ObjectPath ,
  2309. long a_Flags ,
  2310. IWbemContext *a_Context ,
  2311. IWbemClassObject **a_Object ,
  2312. IWbemCallResult **a_CallResult
  2313. )
  2314. {
  2315. return WBEM_E_NOT_AVAILABLE ;
  2316. }
  2317. /******************************************************************************
  2318. *
  2319. * Name:
  2320. *
  2321. *
  2322. * Description:
  2323. *
  2324. *
  2325. *****************************************************************************/
  2326. HRESULT CInterceptor_IWbemProvider :: GetObjectAsync (
  2327. const BSTR a_ObjectPath ,
  2328. long a_Flags ,
  2329. IWbemContext *a_Context ,
  2330. IWbemObjectSink *a_Sink
  2331. )
  2332. {
  2333. if ( m_Initialized == 0 )
  2334. {
  2335. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2336. return WBEM_E_NOT_FOUND ;
  2337. }
  2338. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  2339. BOOL t_DependantCall = FALSE ;
  2340. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2341. if ( GetResumed () )
  2342. {
  2343. if ( m_Provider_IWbemServices )
  2344. {
  2345. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2346. a_Sink ,
  2347. ( IWbemServices * ) this ,
  2348. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2349. ) ;
  2350. if ( t_Sink )
  2351. {
  2352. t_Sink->AddRef () ;
  2353. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2354. if ( SUCCEEDED ( t_Result ) )
  2355. {
  2356. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2357. Lock () ;
  2358. WmiStatusCode t_StatusCode = Insert (
  2359. *t_Sink ,
  2360. t_Iterator
  2361. ) ;
  2362. if ( t_StatusCode == e_StatusCode_Success )
  2363. {
  2364. UnLock () ;
  2365. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2366. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2367. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2368. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2369. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2370. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2371. BOOL t_Impersonating ;
  2372. IUnknown *t_OldContext ;
  2373. IServerSecurity *t_OldSecurity ;
  2374. BOOL t_IsProxy ;
  2375. IUnknown *t_Interface ;
  2376. BOOL t_Revert ;
  2377. IUnknown *t_Proxy ;
  2378. HANDLE t_IdentifyToken = NULL ;
  2379. t_Result = Begin_Interface (
  2380. t_ServerInterface ,
  2381. t_InterfaceIdentifier ,
  2382. t_ProxyIndex ,
  2383. t_InternalServerInterface ,
  2384. t_InternalInterfaceIdentifier ,
  2385. t_InternalProxyIndex ,
  2386. m_ProcessIdentifier ,
  2387. t_IdentifyToken ,
  2388. t_Impersonating ,
  2389. t_OldContext ,
  2390. t_OldSecurity ,
  2391. t_IsProxy ,
  2392. t_Interface ,
  2393. t_Revert ,
  2394. t_Proxy
  2395. ) ;
  2396. if ( SUCCEEDED ( t_Result ) )
  2397. {
  2398. if ( t_IdentifyToken )
  2399. {
  2400. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  2401. if ( t_ObjectPath )
  2402. {
  2403. WmiInternalContext t_InternalContext ;
  2404. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2405. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2406. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_GetObjectAsync (
  2407. t_InternalContext ,
  2408. t_ObjectPath,
  2409. a_Flags,
  2410. a_Context ,
  2411. t_Sink
  2412. ) ;
  2413. SysFreeString ( t_ObjectPath ) ;
  2414. }
  2415. else
  2416. {
  2417. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2418. }
  2419. }
  2420. else
  2421. {
  2422. t_Result = ( ( IWbemServices * ) t_Interface )->GetObjectAsync (
  2423. a_ObjectPath,
  2424. a_Flags,
  2425. a_Context ,
  2426. t_Sink
  2427. ) ;
  2428. }
  2429. End_Interface (
  2430. t_ServerInterface ,
  2431. t_InterfaceIdentifier ,
  2432. t_ProxyIndex ,
  2433. t_InternalServerInterface ,
  2434. t_InternalInterfaceIdentifier ,
  2435. t_InternalProxyIndex ,
  2436. m_ProcessIdentifier ,
  2437. t_IdentifyToken ,
  2438. t_Impersonating ,
  2439. t_OldContext ,
  2440. t_OldSecurity ,
  2441. t_IsProxy ,
  2442. t_Interface ,
  2443. t_Revert ,
  2444. t_Proxy
  2445. ) ;
  2446. }
  2447. }
  2448. else
  2449. {
  2450. UnLock () ;
  2451. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2452. }
  2453. }
  2454. if ( FAILED ( t_Result ) )
  2455. {
  2456. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2457. }
  2458. t_Sink->Release () ;
  2459. }
  2460. else
  2461. {
  2462. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2463. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2464. }
  2465. }
  2466. else
  2467. {
  2468. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2469. }
  2470. }
  2471. else
  2472. {
  2473. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  2474. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2475. }
  2476. if ( FAILED ( t_Result ) )
  2477. {
  2478. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  2479. {
  2480. AbnormalShutdown () ;
  2481. }
  2482. }
  2483. return t_Result ;
  2484. }
  2485. /******************************************************************************
  2486. *
  2487. * Name:
  2488. *
  2489. *
  2490. * Description:
  2491. *
  2492. *
  2493. *****************************************************************************/
  2494. HRESULT CInterceptor_IWbemProvider :: PutClass (
  2495. IWbemClassObject *a_Object ,
  2496. long a_Flags ,
  2497. IWbemContext *a_Context ,
  2498. IWbemCallResult **a_CallResult
  2499. )
  2500. {
  2501. return WBEM_E_NOT_AVAILABLE ;
  2502. }
  2503. /******************************************************************************
  2504. *
  2505. * Name:
  2506. *
  2507. *
  2508. * Description:
  2509. *
  2510. *
  2511. *****************************************************************************/
  2512. HRESULT CInterceptor_IWbemProvider :: PutClassAsync (
  2513. IWbemClassObject *a_Object ,
  2514. long a_Flags ,
  2515. IWbemContext FAR *a_Context ,
  2516. IWbemObjectSink *a_Sink
  2517. )
  2518. {
  2519. if ( m_Initialized == 0 )
  2520. {
  2521. if ( WBEM_FLAG_ADVISORY & a_Flags )
  2522. {
  2523. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2524. return S_OK ;
  2525. }
  2526. else
  2527. {
  2528. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2529. return WBEM_E_NOT_FOUND ;
  2530. }
  2531. }
  2532. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  2533. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2534. if ( GetResumed () )
  2535. {
  2536. if ( m_Provider_IWbemServices )
  2537. {
  2538. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2539. a_Sink ,
  2540. ( IWbemServices * ) this ,
  2541. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2542. ) ;
  2543. if ( t_Sink )
  2544. {
  2545. t_Sink->AddRef () ;
  2546. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2547. if ( SUCCEEDED ( t_Result ) )
  2548. {
  2549. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2550. Lock () ;
  2551. WmiStatusCode t_StatusCode = Insert (
  2552. *t_Sink ,
  2553. t_Iterator
  2554. ) ;
  2555. if ( t_StatusCode == e_StatusCode_Success )
  2556. {
  2557. UnLock () ;
  2558. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2559. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2560. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2561. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2562. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2563. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2564. BOOL t_Impersonating ;
  2565. IUnknown *t_OldContext ;
  2566. IServerSecurity *t_OldSecurity ;
  2567. BOOL t_IsProxy ;
  2568. IUnknown *t_Interface ;
  2569. BOOL t_Revert ;
  2570. IUnknown *t_Proxy ;
  2571. HANDLE t_IdentifyToken = NULL ;
  2572. t_Result = Begin_Interface (
  2573. t_ServerInterface ,
  2574. t_InterfaceIdentifier ,
  2575. t_ProxyIndex ,
  2576. t_InternalServerInterface ,
  2577. t_InternalInterfaceIdentifier ,
  2578. t_InternalProxyIndex ,
  2579. m_ProcessIdentifier ,
  2580. t_IdentifyToken ,
  2581. t_Impersonating ,
  2582. t_OldContext ,
  2583. t_OldSecurity ,
  2584. t_IsProxy ,
  2585. t_Interface ,
  2586. t_Revert ,
  2587. t_Proxy
  2588. ) ;
  2589. if ( SUCCEEDED ( t_Result ) )
  2590. {
  2591. if ( t_IdentifyToken )
  2592. {
  2593. WmiInternalContext t_InternalContext ;
  2594. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2595. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2596. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_PutClassAsync (
  2597. t_InternalContext ,
  2598. a_Object ,
  2599. a_Flags,
  2600. a_Context ,
  2601. t_Sink
  2602. ) ;
  2603. }
  2604. else
  2605. {
  2606. t_Result = ( ( IWbemServices * ) t_Interface )->PutClassAsync (
  2607. a_Object ,
  2608. a_Flags,
  2609. a_Context ,
  2610. t_Sink
  2611. ) ;
  2612. }
  2613. End_Interface (
  2614. t_ServerInterface ,
  2615. t_InterfaceIdentifier ,
  2616. t_ProxyIndex ,
  2617. t_InternalServerInterface ,
  2618. t_InternalInterfaceIdentifier ,
  2619. t_InternalProxyIndex ,
  2620. m_ProcessIdentifier ,
  2621. t_IdentifyToken ,
  2622. t_Impersonating ,
  2623. t_OldContext ,
  2624. t_OldSecurity ,
  2625. t_IsProxy ,
  2626. t_Interface ,
  2627. t_Revert ,
  2628. t_Proxy
  2629. ) ;
  2630. }
  2631. }
  2632. else
  2633. {
  2634. UnLock () ;
  2635. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2636. }
  2637. }
  2638. if ( FAILED ( t_Result ) )
  2639. {
  2640. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2641. }
  2642. t_Sink->Release () ;
  2643. }
  2644. else
  2645. {
  2646. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2647. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2648. }
  2649. }
  2650. else
  2651. {
  2652. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2653. }
  2654. }
  2655. else
  2656. {
  2657. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  2658. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2659. }
  2660. if ( FAILED ( t_Result ) )
  2661. {
  2662. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  2663. {
  2664. AbnormalShutdown () ;
  2665. }
  2666. }
  2667. return t_Result ;
  2668. }
  2669. /******************************************************************************
  2670. *
  2671. * Name:
  2672. *
  2673. *
  2674. * Description:
  2675. *
  2676. *
  2677. *****************************************************************************/
  2678. HRESULT CInterceptor_IWbemProvider :: DeleteClass (
  2679. const BSTR a_Class ,
  2680. long a_Flags ,
  2681. IWbemContext *a_Context ,
  2682. IWbemCallResult **a_CallResult
  2683. )
  2684. {
  2685. return WBEM_E_NOT_AVAILABLE ;
  2686. }
  2687. /******************************************************************************
  2688. *
  2689. * Name:
  2690. *
  2691. *
  2692. * Description:
  2693. *
  2694. *
  2695. *****************************************************************************/
  2696. HRESULT CInterceptor_IWbemProvider :: DeleteClassAsync (
  2697. const BSTR a_Class ,
  2698. long a_Flags,
  2699. IWbemContext *a_Context ,
  2700. IWbemObjectSink *a_Sink
  2701. )
  2702. {
  2703. if ( m_Initialized == 0 )
  2704. {
  2705. if ( WBEM_FLAG_ADVISORY & a_Flags )
  2706. {
  2707. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2708. return S_OK ;
  2709. }
  2710. else
  2711. {
  2712. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2713. return WBEM_E_NOT_FOUND ;
  2714. }
  2715. }
  2716. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  2717. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2718. if ( GetResumed () )
  2719. {
  2720. if ( m_Provider_IWbemServices )
  2721. {
  2722. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2723. a_Sink ,
  2724. ( IWbemServices * ) this ,
  2725. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2726. ) ;
  2727. if ( t_Sink )
  2728. {
  2729. t_Sink->AddRef () ;
  2730. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2731. if ( SUCCEEDED ( t_Result ) )
  2732. {
  2733. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2734. Lock () ;
  2735. WmiStatusCode t_StatusCode = Insert (
  2736. *t_Sink ,
  2737. t_Iterator
  2738. ) ;
  2739. if ( t_StatusCode == e_StatusCode_Success )
  2740. {
  2741. UnLock () ;
  2742. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2743. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2744. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2745. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2746. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2747. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2748. BOOL t_Impersonating ;
  2749. IUnknown *t_OldContext ;
  2750. IServerSecurity *t_OldSecurity ;
  2751. BOOL t_IsProxy ;
  2752. IUnknown *t_Interface ;
  2753. BOOL t_Revert ;
  2754. IUnknown *t_Proxy ;
  2755. HANDLE t_IdentifyToken = NULL ;
  2756. t_Result = Begin_Interface (
  2757. t_ServerInterface ,
  2758. t_InterfaceIdentifier ,
  2759. t_ProxyIndex ,
  2760. t_InternalServerInterface ,
  2761. t_InternalInterfaceIdentifier ,
  2762. t_InternalProxyIndex ,
  2763. m_ProcessIdentifier ,
  2764. t_IdentifyToken ,
  2765. t_Impersonating ,
  2766. t_OldContext ,
  2767. t_OldSecurity ,
  2768. t_IsProxy ,
  2769. t_Interface ,
  2770. t_Revert ,
  2771. t_Proxy
  2772. ) ;
  2773. if ( SUCCEEDED ( t_Result ) )
  2774. {
  2775. if ( t_IdentifyToken )
  2776. {
  2777. BSTR t_Class = SysAllocString ( a_Class ) ;
  2778. if ( t_Class )
  2779. {
  2780. WmiInternalContext t_InternalContext ;
  2781. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2782. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2783. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_DeleteClassAsync (
  2784. t_InternalContext ,
  2785. t_Class ,
  2786. a_Flags,
  2787. a_Context ,
  2788. t_Sink
  2789. ) ;
  2790. SysFreeString ( t_Class ) ;
  2791. }
  2792. else
  2793. {
  2794. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2795. }
  2796. }
  2797. else
  2798. {
  2799. t_Result = ( ( IWbemServices * ) t_Interface )->DeleteClassAsync (
  2800. a_Class ,
  2801. a_Flags,
  2802. a_Context ,
  2803. t_Sink
  2804. ) ;
  2805. }
  2806. End_Interface (
  2807. t_ServerInterface ,
  2808. t_InterfaceIdentifier ,
  2809. t_ProxyIndex ,
  2810. t_InternalServerInterface ,
  2811. t_InternalInterfaceIdentifier ,
  2812. t_InternalProxyIndex ,
  2813. m_ProcessIdentifier ,
  2814. t_IdentifyToken ,
  2815. t_Impersonating ,
  2816. t_OldContext ,
  2817. t_OldSecurity ,
  2818. t_IsProxy ,
  2819. t_Interface ,
  2820. t_Revert ,
  2821. t_Proxy
  2822. ) ;
  2823. }
  2824. }
  2825. else
  2826. {
  2827. UnLock () ;
  2828. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2829. }
  2830. }
  2831. if ( FAILED ( t_Result ) )
  2832. {
  2833. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2834. }
  2835. t_Sink->Release () ;
  2836. }
  2837. else
  2838. {
  2839. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2840. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2841. }
  2842. }
  2843. else
  2844. {
  2845. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2846. }
  2847. }
  2848. else
  2849. {
  2850. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  2851. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2852. }
  2853. if ( FAILED ( t_Result ) )
  2854. {
  2855. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  2856. {
  2857. AbnormalShutdown () ;
  2858. }
  2859. }
  2860. return t_Result ;
  2861. }
  2862. /******************************************************************************
  2863. *
  2864. * Name:
  2865. *
  2866. *
  2867. * Description:
  2868. *
  2869. *
  2870. *****************************************************************************/
  2871. HRESULT CInterceptor_IWbemProvider :: CreateClassEnum (
  2872. const BSTR a_Superclass ,
  2873. long a_Flags,
  2874. IWbemContext *a_Context ,
  2875. IEnumWbemClassObject **a_Enum
  2876. )
  2877. {
  2878. return WBEM_E_NOT_AVAILABLE ;
  2879. }
  2880. /******************************************************************************
  2881. *
  2882. * Name:
  2883. *
  2884. *
  2885. * Description:
  2886. *
  2887. *
  2888. *****************************************************************************/
  2889. SCODE CInterceptor_IWbemProvider :: CreateClassEnumAsync (
  2890. const BSTR a_Superclass ,
  2891. long a_Flags ,
  2892. IWbemContext *a_Context ,
  2893. IWbemObjectSink *a_Sink
  2894. )
  2895. {
  2896. if ( m_Initialized == 0 )
  2897. {
  2898. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2899. return S_OK ;
  2900. }
  2901. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  2902. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2903. if ( GetResumed () )
  2904. {
  2905. if ( m_Provider_IWbemServices )
  2906. {
  2907. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2908. a_Sink ,
  2909. ( IWbemServices * ) this ,
  2910. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2911. ) ;
  2912. if ( t_Sink )
  2913. {
  2914. t_Sink->AddRef () ;
  2915. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2916. if ( SUCCEEDED ( t_Result ) )
  2917. {
  2918. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2919. Lock () ;
  2920. WmiStatusCode t_StatusCode = Insert (
  2921. *t_Sink ,
  2922. t_Iterator
  2923. ) ;
  2924. if ( t_StatusCode == e_StatusCode_Success )
  2925. {
  2926. UnLock () ;
  2927. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2928. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2929. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2930. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2931. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2932. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2933. BOOL t_Impersonating ;
  2934. IUnknown *t_OldContext ;
  2935. IServerSecurity *t_OldSecurity ;
  2936. BOOL t_IsProxy ;
  2937. IUnknown *t_Interface ;
  2938. BOOL t_Revert ;
  2939. IUnknown *t_Proxy ;
  2940. HANDLE t_IdentifyToken = NULL ;
  2941. t_Result = Begin_Interface (
  2942. t_ServerInterface ,
  2943. t_InterfaceIdentifier ,
  2944. t_ProxyIndex ,
  2945. t_InternalServerInterface ,
  2946. t_InternalInterfaceIdentifier ,
  2947. t_InternalProxyIndex ,
  2948. m_ProcessIdentifier ,
  2949. t_IdentifyToken ,
  2950. t_Impersonating ,
  2951. t_OldContext ,
  2952. t_OldSecurity ,
  2953. t_IsProxy ,
  2954. t_Interface ,
  2955. t_Revert ,
  2956. t_Proxy
  2957. ) ;
  2958. if ( SUCCEEDED ( t_Result ) )
  2959. {
  2960. if ( t_IdentifyToken )
  2961. {
  2962. BSTR t_Superclass = SysAllocString ( a_Superclass ) ;
  2963. if ( t_Superclass )
  2964. {
  2965. WmiInternalContext t_InternalContext ;
  2966. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2967. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2968. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_CreateClassEnumAsync (
  2969. t_InternalContext ,
  2970. t_Superclass ,
  2971. a_Flags,
  2972. a_Context ,
  2973. t_Sink
  2974. ) ;
  2975. SysFreeString ( t_Superclass ) ;
  2976. }
  2977. else
  2978. {
  2979. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2980. }
  2981. }
  2982. else
  2983. {
  2984. t_Result = ( ( IWbemServices * ) t_Interface )->CreateClassEnumAsync (
  2985. a_Superclass ,
  2986. a_Flags,
  2987. a_Context ,
  2988. t_Sink
  2989. ) ;
  2990. }
  2991. End_Interface (
  2992. t_ServerInterface ,
  2993. t_InterfaceIdentifier ,
  2994. t_ProxyIndex ,
  2995. t_InternalServerInterface ,
  2996. t_InternalInterfaceIdentifier ,
  2997. t_InternalProxyIndex ,
  2998. m_ProcessIdentifier ,
  2999. t_IdentifyToken ,
  3000. t_Impersonating ,
  3001. t_OldContext ,
  3002. t_OldSecurity ,
  3003. t_IsProxy ,
  3004. t_Interface ,
  3005. t_Revert ,
  3006. t_Proxy
  3007. ) ;
  3008. }
  3009. }
  3010. else
  3011. {
  3012. UnLock () ;
  3013. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3014. }
  3015. }
  3016. if ( FAILED ( t_Result ) )
  3017. {
  3018. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3019. }
  3020. t_Sink->Release () ;
  3021. }
  3022. else
  3023. {
  3024. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3025. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3026. }
  3027. }
  3028. else
  3029. {
  3030. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3031. }
  3032. }
  3033. else
  3034. {
  3035. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  3036. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3037. }
  3038. if ( FAILED ( t_Result ) )
  3039. {
  3040. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  3041. {
  3042. AbnormalShutdown () ;
  3043. }
  3044. }
  3045. return t_Result ;
  3046. }
  3047. /******************************************************************************
  3048. *
  3049. * Name:
  3050. *
  3051. *
  3052. * Description:
  3053. *
  3054. *
  3055. *****************************************************************************/
  3056. HRESULT CInterceptor_IWbemProvider :: PutInstance (
  3057. IWbemClassObject *a_Instance ,
  3058. long a_Flags ,
  3059. IWbemContext *a_Context ,
  3060. IWbemCallResult **a_CallResult
  3061. )
  3062. {
  3063. return WBEM_E_NOT_AVAILABLE ;
  3064. }
  3065. /******************************************************************************
  3066. *
  3067. * Name:
  3068. *
  3069. *
  3070. * Description:
  3071. *
  3072. *
  3073. *****************************************************************************/
  3074. HRESULT CInterceptor_IWbemProvider :: PutInstanceAsync (
  3075. IWbemClassObject *a_Instance ,
  3076. long a_Flags ,
  3077. IWbemContext *a_Context ,
  3078. IWbemObjectSink *a_Sink
  3079. )
  3080. {
  3081. if ( m_Initialized == 0 )
  3082. {
  3083. if ( WBEM_FLAG_ADVISORY & a_Flags )
  3084. {
  3085. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  3086. return S_OK ;
  3087. }
  3088. else
  3089. {
  3090. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  3091. return WBEM_E_NOT_FOUND ;
  3092. }
  3093. }
  3094. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  3095. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  3096. if ( GetResumed () )
  3097. {
  3098. if ( m_Provider_IWbemServices )
  3099. {
  3100. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  3101. a_Sink ,
  3102. ( IWbemServices * ) this ,
  3103. ( CWbemGlobal_IWmiObjectSinkController * ) this
  3104. ) ;
  3105. if ( t_Sink )
  3106. {
  3107. t_Sink->AddRef () ;
  3108. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  3109. if ( SUCCEEDED ( t_Result ) )
  3110. {
  3111. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  3112. Lock () ;
  3113. WmiStatusCode t_StatusCode = Insert (
  3114. *t_Sink ,
  3115. t_Iterator
  3116. ) ;
  3117. if ( t_StatusCode == e_StatusCode_Success )
  3118. {
  3119. UnLock () ;
  3120. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  3121. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  3122. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  3123. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  3124. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  3125. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  3126. BOOL t_Impersonating ;
  3127. IUnknown *t_OldContext ;
  3128. IServerSecurity *t_OldSecurity ;
  3129. BOOL t_IsProxy ;
  3130. IUnknown *t_Interface ;
  3131. BOOL t_Revert ;
  3132. IUnknown *t_Proxy ;
  3133. HANDLE t_IdentifyToken = NULL ;
  3134. t_Result = Begin_Interface (
  3135. t_ServerInterface ,
  3136. t_InterfaceIdentifier ,
  3137. t_ProxyIndex ,
  3138. t_InternalServerInterface ,
  3139. t_InternalInterfaceIdentifier ,
  3140. t_InternalProxyIndex ,
  3141. m_ProcessIdentifier ,
  3142. t_IdentifyToken ,
  3143. t_Impersonating ,
  3144. t_OldContext ,
  3145. t_OldSecurity ,
  3146. t_IsProxy ,
  3147. t_Interface ,
  3148. t_Revert ,
  3149. t_Proxy
  3150. ) ;
  3151. if ( SUCCEEDED ( t_Result ) )
  3152. {
  3153. if ( t_IdentifyToken )
  3154. {
  3155. WmiInternalContext t_InternalContext ;
  3156. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3157. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3158. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_PutInstanceAsync (
  3159. t_InternalContext ,
  3160. a_Instance ,
  3161. a_Flags,
  3162. a_Context ,
  3163. t_Sink
  3164. ) ;
  3165. }
  3166. else
  3167. {
  3168. t_Result = ( ( IWbemServices * ) t_Interface )->PutInstanceAsync (
  3169. a_Instance ,
  3170. a_Flags,
  3171. a_Context ,
  3172. t_Sink
  3173. ) ;
  3174. }
  3175. End_Interface (
  3176. t_ServerInterface ,
  3177. t_InterfaceIdentifier ,
  3178. t_ProxyIndex ,
  3179. t_InternalServerInterface ,
  3180. t_InternalInterfaceIdentifier ,
  3181. t_InternalProxyIndex ,
  3182. m_ProcessIdentifier ,
  3183. t_IdentifyToken ,
  3184. t_Impersonating ,
  3185. t_OldContext ,
  3186. t_OldSecurity ,
  3187. t_IsProxy ,
  3188. t_Interface ,
  3189. t_Revert ,
  3190. t_Proxy
  3191. ) ;
  3192. }
  3193. }
  3194. else
  3195. {
  3196. UnLock () ;
  3197. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3198. }
  3199. }
  3200. if ( FAILED ( t_Result ) )
  3201. {
  3202. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3203. }
  3204. t_Sink->Release () ;
  3205. }
  3206. else
  3207. {
  3208. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3209. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3210. }
  3211. }
  3212. else
  3213. {
  3214. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3215. }
  3216. }
  3217. else
  3218. {
  3219. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  3220. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3221. }
  3222. if ( FAILED ( t_Result ) )
  3223. {
  3224. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  3225. {
  3226. AbnormalShutdown () ;
  3227. }
  3228. }
  3229. return t_Result ;
  3230. }
  3231. /******************************************************************************
  3232. *
  3233. * Name:
  3234. *
  3235. *
  3236. * Description:
  3237. *
  3238. *
  3239. *****************************************************************************/
  3240. HRESULT CInterceptor_IWbemProvider :: DeleteInstance (
  3241. const BSTR a_ObjectPath ,
  3242. long a_Flags ,
  3243. IWbemContext *a_Context ,
  3244. IWbemCallResult **a_CallResult
  3245. )
  3246. {
  3247. return WBEM_E_NOT_AVAILABLE ;
  3248. }
  3249. /******************************************************************************
  3250. *
  3251. * Name:
  3252. *
  3253. *
  3254. * Description:
  3255. *
  3256. *
  3257. *****************************************************************************/
  3258. HRESULT CInterceptor_IWbemProvider :: DeleteInstanceAsync (
  3259. const BSTR a_ObjectPath ,
  3260. long a_Flags ,
  3261. IWbemContext *a_Context ,
  3262. IWbemObjectSink *a_Sink
  3263. )
  3264. {
  3265. if ( m_Initialized == 0 )
  3266. {
  3267. if ( WBEM_FLAG_ADVISORY & a_Flags )
  3268. {
  3269. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  3270. return S_OK ;
  3271. }
  3272. else
  3273. {
  3274. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  3275. return WBEM_E_NOT_FOUND ;
  3276. }
  3277. }
  3278. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  3279. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  3280. if ( GetResumed () )
  3281. {
  3282. if ( m_Provider_IWbemServices )
  3283. {
  3284. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  3285. a_Sink ,
  3286. ( IWbemServices * ) this ,
  3287. ( CWbemGlobal_IWmiObjectSinkController * ) this
  3288. ) ;
  3289. if ( t_Sink )
  3290. {
  3291. t_Sink->AddRef () ;
  3292. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  3293. if ( SUCCEEDED ( t_Result ) )
  3294. {
  3295. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  3296. Lock () ;
  3297. WmiStatusCode t_StatusCode = Insert (
  3298. *t_Sink ,
  3299. t_Iterator
  3300. ) ;
  3301. if ( t_StatusCode == e_StatusCode_Success )
  3302. {
  3303. UnLock () ;
  3304. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  3305. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  3306. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  3307. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  3308. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  3309. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  3310. BOOL t_Impersonating ;
  3311. IUnknown *t_OldContext ;
  3312. IServerSecurity *t_OldSecurity ;
  3313. BOOL t_IsProxy ;
  3314. IUnknown *t_Interface ;
  3315. BOOL t_Revert ;
  3316. IUnknown *t_Proxy ;
  3317. HANDLE t_IdentifyToken = NULL ;
  3318. t_Result = Begin_Interface (
  3319. t_ServerInterface ,
  3320. t_InterfaceIdentifier ,
  3321. t_ProxyIndex ,
  3322. t_InternalServerInterface ,
  3323. t_InternalInterfaceIdentifier ,
  3324. t_InternalProxyIndex ,
  3325. m_ProcessIdentifier ,
  3326. t_IdentifyToken ,
  3327. t_Impersonating ,
  3328. t_OldContext ,
  3329. t_OldSecurity ,
  3330. t_IsProxy ,
  3331. t_Interface ,
  3332. t_Revert ,
  3333. t_Proxy
  3334. ) ;
  3335. if ( SUCCEEDED ( t_Result ) )
  3336. {
  3337. if ( t_IdentifyToken )
  3338. {
  3339. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  3340. if ( t_ObjectPath )
  3341. {
  3342. WmiInternalContext t_InternalContext ;
  3343. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3344. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3345. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_DeleteInstanceAsync (
  3346. t_InternalContext ,
  3347. t_ObjectPath ,
  3348. a_Flags ,
  3349. a_Context ,
  3350. t_Sink
  3351. ) ;
  3352. SysFreeString ( t_ObjectPath ) ;
  3353. }
  3354. else
  3355. {
  3356. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3357. }
  3358. }
  3359. else
  3360. {
  3361. t_Result = ( ( IWbemServices * ) t_Interface )->DeleteInstanceAsync (
  3362. a_ObjectPath ,
  3363. a_Flags ,
  3364. a_Context ,
  3365. t_Sink
  3366. ) ;
  3367. }
  3368. End_Interface (
  3369. t_ServerInterface ,
  3370. t_InterfaceIdentifier ,
  3371. t_ProxyIndex ,
  3372. t_InternalServerInterface ,
  3373. t_InternalInterfaceIdentifier ,
  3374. t_InternalProxyIndex ,
  3375. m_ProcessIdentifier ,
  3376. t_IdentifyToken ,
  3377. t_Impersonating ,
  3378. t_OldContext ,
  3379. t_OldSecurity ,
  3380. t_IsProxy ,
  3381. t_Interface ,
  3382. t_Revert ,
  3383. t_Proxy
  3384. ) ;
  3385. }
  3386. }
  3387. else
  3388. {
  3389. UnLock () ;
  3390. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3391. }
  3392. }
  3393. if ( FAILED ( t_Result ) )
  3394. {
  3395. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3396. }
  3397. t_Sink->Release () ;
  3398. }
  3399. else
  3400. {
  3401. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3402. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3403. }
  3404. }
  3405. else
  3406. {
  3407. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3408. }
  3409. }
  3410. else
  3411. {
  3412. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  3413. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3414. }
  3415. if ( FAILED ( t_Result ) )
  3416. {
  3417. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  3418. {
  3419. AbnormalShutdown () ;
  3420. }
  3421. }
  3422. return t_Result ;
  3423. }
  3424. /******************************************************************************
  3425. *
  3426. * Name:
  3427. *
  3428. *
  3429. * Description:
  3430. *
  3431. *
  3432. *****************************************************************************/
  3433. HRESULT CInterceptor_IWbemProvider :: CreateInstanceEnum (
  3434. const BSTR a_Class ,
  3435. long a_Flags ,
  3436. IWbemContext *a_Context ,
  3437. IEnumWbemClassObject **a_Enum
  3438. )
  3439. {
  3440. return WBEM_E_NOT_AVAILABLE ;
  3441. }
  3442. /******************************************************************************
  3443. *
  3444. * Name:
  3445. *
  3446. *
  3447. * Description:
  3448. *
  3449. *
  3450. *****************************************************************************/
  3451. HRESULT CInterceptor_IWbemProvider :: CreateInstanceEnumAsync (
  3452. const BSTR a_Class ,
  3453. long a_Flags ,
  3454. IWbemContext *a_Context ,
  3455. IWbemObjectSink *a_Sink
  3456. )
  3457. {
  3458. if ( m_Initialized == 0 )
  3459. {
  3460. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  3461. return S_OK ;
  3462. }
  3463. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  3464. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  3465. if ( GetResumed () )
  3466. {
  3467. if ( m_Provider_IWbemServices )
  3468. {
  3469. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  3470. a_Sink ,
  3471. ( IWbemServices * ) this ,
  3472. ( CWbemGlobal_IWmiObjectSinkController * ) this
  3473. ) ;
  3474. if ( t_Sink )
  3475. {
  3476. t_Sink->AddRef () ;
  3477. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  3478. if ( SUCCEEDED ( t_Result ) )
  3479. {
  3480. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  3481. Lock () ;
  3482. WmiStatusCode t_StatusCode = Insert (
  3483. *t_Sink ,
  3484. t_Iterator
  3485. ) ;
  3486. if ( t_StatusCode == e_StatusCode_Success )
  3487. {
  3488. UnLock () ;
  3489. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  3490. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  3491. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  3492. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  3493. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  3494. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  3495. BOOL t_Impersonating ;
  3496. IUnknown *t_OldContext ;
  3497. IServerSecurity *t_OldSecurity ;
  3498. BOOL t_IsProxy ;
  3499. IUnknown *t_Interface ;
  3500. BOOL t_Revert ;
  3501. IUnknown *t_Proxy ;
  3502. HANDLE t_IdentifyToken = NULL ;
  3503. t_Result = Begin_Interface (
  3504. t_ServerInterface ,
  3505. t_InterfaceIdentifier ,
  3506. t_ProxyIndex ,
  3507. t_InternalServerInterface ,
  3508. t_InternalInterfaceIdentifier ,
  3509. t_InternalProxyIndex ,
  3510. m_ProcessIdentifier ,
  3511. t_IdentifyToken ,
  3512. t_Impersonating ,
  3513. t_OldContext ,
  3514. t_OldSecurity ,
  3515. t_IsProxy ,
  3516. t_Interface ,
  3517. t_Revert ,
  3518. t_Proxy
  3519. ) ;
  3520. if ( SUCCEEDED ( t_Result ) )
  3521. {
  3522. if ( t_IdentifyToken )
  3523. {
  3524. WmiInternalContext t_InternalContext ;
  3525. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3526. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3527. BSTR t_Class = SysAllocString ( a_Class ) ;
  3528. if ( t_Class )
  3529. {
  3530. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_CreateInstanceEnumAsync (
  3531. t_InternalContext ,
  3532. t_Class ,
  3533. a_Flags ,
  3534. a_Context ,
  3535. t_Sink
  3536. ) ;
  3537. SysFreeString ( t_Class ) ;
  3538. }
  3539. else
  3540. {
  3541. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3542. }
  3543. }
  3544. else
  3545. {
  3546. t_Result = ( ( IWbemServices * ) t_Interface )->CreateInstanceEnumAsync (
  3547. a_Class ,
  3548. a_Flags ,
  3549. a_Context ,
  3550. t_Sink
  3551. ) ;
  3552. }
  3553. End_Interface (
  3554. t_ServerInterface ,
  3555. t_InterfaceIdentifier ,
  3556. t_ProxyIndex ,
  3557. t_InternalServerInterface ,
  3558. t_InternalInterfaceIdentifier ,
  3559. t_InternalProxyIndex ,
  3560. m_ProcessIdentifier ,
  3561. t_IdentifyToken ,
  3562. t_Impersonating ,
  3563. t_OldContext ,
  3564. t_OldSecurity ,
  3565. t_IsProxy ,
  3566. t_Interface ,
  3567. t_Revert ,
  3568. t_Proxy
  3569. ) ;
  3570. }
  3571. }
  3572. else
  3573. {
  3574. UnLock () ;
  3575. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3576. }
  3577. }
  3578. if ( FAILED ( t_Result ) )
  3579. {
  3580. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3581. }
  3582. t_Sink->Release () ;
  3583. }
  3584. else
  3585. {
  3586. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3587. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3588. }
  3589. }
  3590. else
  3591. {
  3592. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3593. }
  3594. }
  3595. else
  3596. {
  3597. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  3598. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3599. }
  3600. if ( FAILED ( t_Result ) )
  3601. {
  3602. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  3603. {
  3604. AbnormalShutdown () ;
  3605. }
  3606. }
  3607. return t_Result ;
  3608. }
  3609. /******************************************************************************
  3610. *
  3611. * Name:
  3612. *
  3613. *
  3614. * Description:
  3615. *
  3616. *
  3617. *****************************************************************************/
  3618. HRESULT CInterceptor_IWbemProvider :: ExecQuery (
  3619. const BSTR a_QueryLanguage ,
  3620. const BSTR a_Query ,
  3621. long a_Flags ,
  3622. IWbemContext *a_Context ,
  3623. IEnumWbemClassObject **a_Enum
  3624. )
  3625. {
  3626. return WBEM_E_NOT_AVAILABLE ;
  3627. }
  3628. /******************************************************************************
  3629. *
  3630. * Name:
  3631. *
  3632. *
  3633. * Description:
  3634. *
  3635. *
  3636. *****************************************************************************/
  3637. HRESULT CInterceptor_IWbemProvider :: ExecQueryAsync (
  3638. const BSTR a_QueryLanguage ,
  3639. const BSTR a_Query,
  3640. long a_Flags,
  3641. IWbemContext *a_Context ,
  3642. IWbemObjectSink *a_Sink
  3643. )
  3644. {
  3645. if ( m_Initialized == 0 )
  3646. {
  3647. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  3648. return S_OK ;
  3649. }
  3650. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  3651. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  3652. if ( GetResumed () )
  3653. {
  3654. if ( m_Provider_IWbemServices )
  3655. {
  3656. CInterceptor_IWbemFilteringObjectSink *t_Sink = new CInterceptor_IWbemFilteringObjectSink (
  3657. a_Sink ,
  3658. ( IWbemServices * ) this ,
  3659. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  3660. a_QueryLanguage ,
  3661. a_Query
  3662. ) ;
  3663. if ( t_Sink )
  3664. {
  3665. t_Sink->AddRef () ;
  3666. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  3667. if ( SUCCEEDED ( t_Result ) )
  3668. {
  3669. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  3670. Lock () ;
  3671. WmiStatusCode t_StatusCode = Insert (
  3672. *t_Sink ,
  3673. t_Iterator
  3674. ) ;
  3675. if ( t_StatusCode == e_StatusCode_Success )
  3676. {
  3677. UnLock () ;
  3678. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  3679. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  3680. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  3681. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  3682. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  3683. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  3684. BOOL t_Impersonating ;
  3685. IUnknown *t_OldContext ;
  3686. IServerSecurity *t_OldSecurity ;
  3687. BOOL t_IsProxy ;
  3688. IUnknown *t_Interface ;
  3689. BOOL t_Revert ;
  3690. IUnknown *t_Proxy ;
  3691. HANDLE t_IdentifyToken = NULL ;
  3692. t_Result = Begin_Interface (
  3693. t_ServerInterface ,
  3694. t_InterfaceIdentifier ,
  3695. t_ProxyIndex ,
  3696. t_InternalServerInterface ,
  3697. t_InternalInterfaceIdentifier ,
  3698. t_InternalProxyIndex ,
  3699. m_ProcessIdentifier ,
  3700. t_IdentifyToken ,
  3701. t_Impersonating ,
  3702. t_OldContext ,
  3703. t_OldSecurity ,
  3704. t_IsProxy ,
  3705. t_Interface ,
  3706. t_Revert ,
  3707. t_Proxy
  3708. ) ;
  3709. if ( SUCCEEDED ( t_Result ) )
  3710. {
  3711. if ( t_IdentifyToken )
  3712. {
  3713. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  3714. BSTR t_Query = SysAllocString ( a_Query ) ;
  3715. if ( t_QueryLanguage && t_Query )
  3716. {
  3717. WmiInternalContext t_InternalContext ;
  3718. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3719. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3720. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_ExecQueryAsync (
  3721. t_InternalContext ,
  3722. t_QueryLanguage ,
  3723. t_Query,
  3724. a_Flags,
  3725. a_Context ,
  3726. t_Sink
  3727. ) ;
  3728. }
  3729. else
  3730. {
  3731. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3732. }
  3733. SysFreeString ( t_QueryLanguage ) ;
  3734. SysFreeString ( t_Query ) ;
  3735. }
  3736. else
  3737. {
  3738. t_Result = ( ( IWbemServices * ) t_Interface )->ExecQueryAsync (
  3739. a_QueryLanguage ,
  3740. a_Query,
  3741. a_Flags,
  3742. a_Context ,
  3743. t_Sink
  3744. ) ;
  3745. }
  3746. End_Interface (
  3747. t_ServerInterface ,
  3748. t_InterfaceIdentifier ,
  3749. t_ProxyIndex ,
  3750. t_InternalServerInterface ,
  3751. t_InternalInterfaceIdentifier ,
  3752. t_InternalProxyIndex ,
  3753. m_ProcessIdentifier ,
  3754. t_IdentifyToken ,
  3755. t_Impersonating ,
  3756. t_OldContext ,
  3757. t_OldSecurity ,
  3758. t_IsProxy ,
  3759. t_Interface ,
  3760. t_Revert ,
  3761. t_Proxy
  3762. ) ;
  3763. }
  3764. }
  3765. else
  3766. {
  3767. UnLock () ;
  3768. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3769. }
  3770. }
  3771. if ( FAILED ( t_Result ) )
  3772. {
  3773. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3774. }
  3775. t_Sink->Release () ;
  3776. }
  3777. else
  3778. {
  3779. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3780. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3781. }
  3782. }
  3783. else
  3784. {
  3785. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3786. }
  3787. }
  3788. else
  3789. {
  3790. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  3791. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3792. }
  3793. if ( FAILED ( t_Result ) )
  3794. {
  3795. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  3796. {
  3797. AbnormalShutdown () ;
  3798. }
  3799. }
  3800. return t_Result ;
  3801. }
  3802. /******************************************************************************
  3803. *
  3804. * Name:
  3805. *
  3806. *
  3807. * Description:
  3808. *
  3809. *
  3810. *****************************************************************************/
  3811. HRESULT CInterceptor_IWbemProvider :: ExecNotificationQuery (
  3812. const BSTR a_QueryLanguage ,
  3813. const BSTR a_Query ,
  3814. long a_Flags ,
  3815. IWbemContext *a_Context ,
  3816. IEnumWbemClassObject **a_Enum
  3817. )
  3818. {
  3819. return WBEM_E_NOT_AVAILABLE ;
  3820. }
  3821. /******************************************************************************
  3822. *
  3823. * Name:
  3824. *
  3825. *
  3826. * Description:
  3827. *
  3828. *
  3829. *****************************************************************************/
  3830. HRESULT CInterceptor_IWbemProvider :: ExecNotificationQueryAsync (
  3831. const BSTR a_QueryLanguage ,
  3832. const BSTR a_Query ,
  3833. long a_Flags ,
  3834. IWbemContext *a_Context ,
  3835. IWbemObjectSink *a_Sink
  3836. )
  3837. {
  3838. return WBEM_E_NOT_AVAILABLE ;
  3839. }
  3840. /******************************************************************************
  3841. *
  3842. * Name:
  3843. *
  3844. *
  3845. * Description:
  3846. *
  3847. *
  3848. *****************************************************************************/
  3849. HRESULT CInterceptor_IWbemProvider :: ExecMethod (
  3850. const BSTR a_ObjectPath ,
  3851. const BSTR a_MethodName ,
  3852. long a_Flags ,
  3853. IWbemContext *a_Context ,
  3854. IWbemClassObject *a_InParams ,
  3855. IWbemClassObject **a_OutParams ,
  3856. IWbemCallResult **a_CallResult
  3857. )
  3858. {
  3859. return WBEM_E_NOT_AVAILABLE ;
  3860. }
  3861. /******************************************************************************
  3862. *
  3863. * Name:
  3864. *
  3865. *
  3866. * Description:
  3867. *
  3868. *
  3869. *****************************************************************************/
  3870. HRESULT CInterceptor_IWbemProvider :: ExecMethodAsync (
  3871. const BSTR a_ObjectPath ,
  3872. const BSTR a_MethodName ,
  3873. long a_Flags ,
  3874. IWbemContext *a_Context ,
  3875. IWbemClassObject *a_InParams ,
  3876. IWbemObjectSink *a_Sink
  3877. )
  3878. {
  3879. if ( m_Initialized == 0 )
  3880. {
  3881. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  3882. return WBEM_E_NOT_FOUND ;
  3883. }
  3884. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  3885. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  3886. if ( GetResumed () )
  3887. {
  3888. if ( m_Provider_IWbemServices )
  3889. {
  3890. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  3891. a_Sink ,
  3892. ( IWbemServices * ) this ,
  3893. ( CWbemGlobal_IWmiObjectSinkController * ) this
  3894. ) ;
  3895. if ( t_Sink )
  3896. {
  3897. t_Sink->AddRef () ;
  3898. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  3899. if ( SUCCEEDED ( t_Result ) )
  3900. {
  3901. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  3902. Lock () ;
  3903. WmiStatusCode t_StatusCode = Insert (
  3904. *t_Sink ,
  3905. t_Iterator
  3906. ) ;
  3907. if ( t_StatusCode == e_StatusCode_Success )
  3908. {
  3909. UnLock () ;
  3910. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  3911. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  3912. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  3913. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  3914. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  3915. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  3916. BOOL t_Impersonating ;
  3917. IUnknown *t_OldContext ;
  3918. IServerSecurity *t_OldSecurity ;
  3919. BOOL t_IsProxy ;
  3920. IUnknown *t_Interface ;
  3921. BOOL t_Revert ;
  3922. IUnknown *t_Proxy ;
  3923. HANDLE t_IdentifyToken = NULL ;
  3924. t_Result = Begin_Interface (
  3925. t_ServerInterface ,
  3926. t_InterfaceIdentifier ,
  3927. t_ProxyIndex ,
  3928. t_InternalServerInterface ,
  3929. t_InternalInterfaceIdentifier ,
  3930. t_InternalProxyIndex ,
  3931. m_ProcessIdentifier ,
  3932. t_IdentifyToken ,
  3933. t_Impersonating ,
  3934. t_OldContext ,
  3935. t_OldSecurity ,
  3936. t_IsProxy ,
  3937. t_Interface ,
  3938. t_Revert ,
  3939. t_Proxy ,
  3940. a_Context
  3941. ) ;
  3942. if ( SUCCEEDED ( t_Result ) )
  3943. {
  3944. if ( t_IdentifyToken )
  3945. {
  3946. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  3947. BSTR t_MethodName = SysAllocString ( a_MethodName ) ;
  3948. if ( t_ObjectPath && t_MethodName )
  3949. {
  3950. WmiInternalContext t_InternalContext ;
  3951. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3952. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3953. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_ExecMethodAsync (
  3954. t_InternalContext ,
  3955. t_ObjectPath ,
  3956. t_MethodName ,
  3957. a_Flags ,
  3958. a_Context ,
  3959. a_InParams ,
  3960. t_Sink
  3961. ) ;
  3962. }
  3963. else
  3964. {
  3965. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3966. }
  3967. SysFreeString ( t_ObjectPath ) ;
  3968. SysFreeString ( t_MethodName ) ;
  3969. }
  3970. else
  3971. {
  3972. t_Result = ( ( IWbemServices * ) t_Interface )->ExecMethodAsync (
  3973. a_ObjectPath ,
  3974. a_MethodName ,
  3975. a_Flags ,
  3976. a_Context ,
  3977. a_InParams ,
  3978. t_Sink
  3979. ) ;
  3980. }
  3981. End_Interface (
  3982. t_ServerInterface ,
  3983. t_InterfaceIdentifier ,
  3984. t_ProxyIndex ,
  3985. t_InternalServerInterface ,
  3986. t_InternalInterfaceIdentifier ,
  3987. t_InternalProxyIndex ,
  3988. m_ProcessIdentifier ,
  3989. t_IdentifyToken ,
  3990. t_Impersonating ,
  3991. t_OldContext ,
  3992. t_OldSecurity ,
  3993. t_IsProxy ,
  3994. t_Interface ,
  3995. t_Revert ,
  3996. t_Proxy
  3997. ) ;
  3998. }
  3999. }
  4000. else
  4001. {
  4002. UnLock () ;
  4003. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4004. }
  4005. }
  4006. if ( FAILED ( t_Result ) )
  4007. {
  4008. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  4009. }
  4010. t_Sink->Release () ;
  4011. }
  4012. else
  4013. {
  4014. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4015. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  4016. }
  4017. }
  4018. else
  4019. {
  4020. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  4021. }
  4022. }
  4023. else
  4024. {
  4025. t_Result = WBEM_E_PROVIDER_SUSPENDED ;
  4026. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  4027. }
  4028. if ( FAILED ( t_Result ) )
  4029. {
  4030. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4031. {
  4032. AbnormalShutdown () ;
  4033. }
  4034. }
  4035. return t_Result ;
  4036. }
  4037. /******************************************************************************
  4038. *
  4039. * Name:
  4040. *
  4041. *
  4042. * Description:
  4043. *
  4044. *
  4045. *****************************************************************************/
  4046. HRESULT CInterceptor_IWbemProvider :: GetProperty (
  4047. long a_Flags ,
  4048. const BSTR a_Locale ,
  4049. const BSTR a_ClassMapping ,
  4050. const BSTR a_InstanceMapping ,
  4051. const BSTR a_PropertyMapping ,
  4052. VARIANT *a_Value
  4053. )
  4054. {
  4055. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4056. if ( GetResumed () )
  4057. {
  4058. if ( m_Provider_IWbemPropertyProvider )
  4059. {
  4060. IUnknown *t_ServerInterface = m_Provider_IWbemPropertyProvider ;
  4061. REFIID t_InterfaceIdentifier = IID_IWbemPropertyProvider ;
  4062. DWORD t_ProxyIndex = ProxyIndex_IWbemPropertyProvider ;
  4063. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemPropertyProvider ;
  4064. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemPropertyProvider ;
  4065. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemPropertyProvider ;
  4066. BOOL t_Impersonating ;
  4067. IUnknown *t_OldContext ;
  4068. IServerSecurity *t_OldSecurity ;
  4069. BOOL t_IsProxy ;
  4070. IUnknown *t_Interface ;
  4071. BOOL t_Revert ;
  4072. IUnknown *t_Proxy ;
  4073. HANDLE t_IdentifyToken = NULL ;
  4074. HRESULT t_Result = Begin_Interface (
  4075. t_ServerInterface ,
  4076. t_InterfaceIdentifier ,
  4077. t_ProxyIndex ,
  4078. t_InternalServerInterface ,
  4079. t_InternalInterfaceIdentifier ,
  4080. t_InternalProxyIndex ,
  4081. m_ProcessIdentifier ,
  4082. t_IdentifyToken ,
  4083. t_Impersonating ,
  4084. t_OldContext ,
  4085. t_OldSecurity ,
  4086. t_IsProxy ,
  4087. t_Interface ,
  4088. t_Revert ,
  4089. t_Proxy
  4090. ) ;
  4091. if ( SUCCEEDED ( t_Result ) )
  4092. {
  4093. if ( t_IdentifyToken )
  4094. {
  4095. BSTR t_ClassMapping = NULL ;
  4096. BSTR t_InstanceMapping = NULL ;
  4097. BSTR t_PropertyMapping = NULL ;
  4098. if ( a_ClassMapping )
  4099. {
  4100. t_ClassMapping = SysAllocString ( a_ClassMapping ) ;
  4101. if ( t_ClassMapping == NULL )
  4102. {
  4103. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4104. }
  4105. }
  4106. if ( a_InstanceMapping )
  4107. {
  4108. t_InstanceMapping = SysAllocString ( a_InstanceMapping ) ;
  4109. if ( t_InstanceMapping == NULL )
  4110. {
  4111. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4112. }
  4113. }
  4114. if ( a_PropertyMapping )
  4115. {
  4116. t_PropertyMapping = SysAllocString ( a_PropertyMapping ) ;
  4117. if ( t_PropertyMapping == NULL )
  4118. {
  4119. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4120. }
  4121. }
  4122. if ( SUCCEEDED ( t_Result ) )
  4123. {
  4124. WmiInternalContext t_InternalContext ;
  4125. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4126. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4127. ( ( Internal_IWbemPropertyProvider * ) t_Interface )->Internal_GetProperty (
  4128. t_InternalContext ,
  4129. a_Flags ,
  4130. a_Locale ,
  4131. t_ClassMapping ,
  4132. t_InstanceMapping ,
  4133. t_PropertyMapping ,
  4134. a_Value
  4135. ) ;
  4136. }
  4137. else
  4138. {
  4139. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4140. }
  4141. SysFreeString ( t_ClassMapping ) ;
  4142. SysFreeString ( t_InstanceMapping ) ;
  4143. SysFreeString ( t_PropertyMapping ) ;
  4144. }
  4145. else
  4146. {
  4147. t_Result = ( ( IWbemPropertyProvider * ) t_Interface )->GetProperty (
  4148. a_Flags ,
  4149. a_Locale ,
  4150. a_ClassMapping ,
  4151. a_InstanceMapping ,
  4152. a_PropertyMapping ,
  4153. a_Value
  4154. ) ;
  4155. }
  4156. End_Interface (
  4157. t_ServerInterface ,
  4158. t_InterfaceIdentifier ,
  4159. t_ProxyIndex ,
  4160. t_InternalServerInterface ,
  4161. t_InternalInterfaceIdentifier ,
  4162. t_InternalProxyIndex ,
  4163. m_ProcessIdentifier ,
  4164. t_IdentifyToken ,
  4165. t_Impersonating ,
  4166. t_OldContext ,
  4167. t_OldSecurity ,
  4168. t_IsProxy ,
  4169. t_Interface ,
  4170. t_Revert ,
  4171. t_Proxy
  4172. ) ;
  4173. }
  4174. if ( FAILED ( t_Result ) )
  4175. {
  4176. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4177. {
  4178. AbnormalShutdown () ;
  4179. }
  4180. }
  4181. return t_Result ;
  4182. }
  4183. else
  4184. {
  4185. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4186. }
  4187. }
  4188. return WBEM_E_PROVIDER_SUSPENDED ;
  4189. }
  4190. /******************************************************************************
  4191. *
  4192. * Name:
  4193. *
  4194. *
  4195. * Description:
  4196. *
  4197. *
  4198. *****************************************************************************/
  4199. HRESULT CInterceptor_IWbemProvider :: PutProperty (
  4200. long a_Flags ,
  4201. const BSTR a_Locale ,
  4202. const BSTR a_ClassMapping ,
  4203. const BSTR a_InstanceMapping ,
  4204. const BSTR a_PropertyMapping ,
  4205. const VARIANT *a_Value
  4206. )
  4207. {
  4208. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4209. if ( GetResumed () )
  4210. {
  4211. if ( m_Provider_IWbemPropertyProvider )
  4212. {
  4213. IUnknown *t_ServerInterface = m_Provider_IWbemPropertyProvider ;
  4214. REFIID t_InterfaceIdentifier = IID_IWbemPropertyProvider ;
  4215. DWORD t_ProxyIndex = ProxyIndex_IWbemPropertyProvider ;
  4216. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemPropertyProvider ;
  4217. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemPropertyProvider ;
  4218. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemPropertyProvider ;
  4219. BOOL t_Impersonating ;
  4220. IUnknown *t_OldContext ;
  4221. IServerSecurity *t_OldSecurity ;
  4222. BOOL t_IsProxy ;
  4223. IUnknown *t_Interface ;
  4224. BOOL t_Revert ;
  4225. IUnknown *t_Proxy ;
  4226. HANDLE t_IdentifyToken = NULL ;
  4227. HRESULT t_Result = Begin_Interface (
  4228. t_ServerInterface ,
  4229. t_InterfaceIdentifier ,
  4230. t_ProxyIndex ,
  4231. t_InternalServerInterface ,
  4232. t_InternalInterfaceIdentifier ,
  4233. t_InternalProxyIndex ,
  4234. m_ProcessIdentifier ,
  4235. t_IdentifyToken ,
  4236. t_Impersonating ,
  4237. t_OldContext ,
  4238. t_OldSecurity ,
  4239. t_IsProxy ,
  4240. t_Interface ,
  4241. t_Revert ,
  4242. t_Proxy
  4243. ) ;
  4244. if ( SUCCEEDED ( t_Result ) )
  4245. {
  4246. if ( t_IdentifyToken )
  4247. {
  4248. BSTR t_ClassMapping = NULL ;
  4249. BSTR t_InstanceMapping = NULL ;
  4250. BSTR t_PropertyMapping = NULL ;
  4251. if ( a_ClassMapping )
  4252. {
  4253. t_ClassMapping = SysAllocString ( a_ClassMapping ) ;
  4254. if ( t_ClassMapping == NULL )
  4255. {
  4256. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4257. }
  4258. }
  4259. if ( a_InstanceMapping )
  4260. {
  4261. t_InstanceMapping = SysAllocString ( a_InstanceMapping ) ;
  4262. if ( t_InstanceMapping == NULL )
  4263. {
  4264. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4265. }
  4266. }
  4267. if ( a_PropertyMapping )
  4268. {
  4269. t_PropertyMapping = SysAllocString ( a_PropertyMapping ) ;
  4270. if ( t_PropertyMapping == NULL )
  4271. {
  4272. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4273. }
  4274. }
  4275. if ( SUCCEEDED ( t_Result ) )
  4276. {
  4277. WmiInternalContext t_InternalContext ;
  4278. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4279. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4280. ( ( Internal_IWbemPropertyProvider * ) t_Interface )->Internal_PutProperty (
  4281. t_InternalContext ,
  4282. a_Flags ,
  4283. a_Locale ,
  4284. t_ClassMapping ,
  4285. t_InstanceMapping ,
  4286. t_PropertyMapping ,
  4287. a_Value
  4288. ) ;
  4289. }
  4290. else
  4291. {
  4292. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4293. }
  4294. SysFreeString ( t_ClassMapping ) ;
  4295. SysFreeString ( t_InstanceMapping ) ;
  4296. SysFreeString ( t_PropertyMapping ) ;
  4297. }
  4298. else
  4299. {
  4300. t_Result = ( ( IWbemPropertyProvider * ) t_Interface )->PutProperty (
  4301. a_Flags ,
  4302. a_Locale ,
  4303. a_ClassMapping ,
  4304. a_InstanceMapping ,
  4305. a_PropertyMapping ,
  4306. a_Value
  4307. ) ;
  4308. }
  4309. End_Interface (
  4310. t_ServerInterface ,
  4311. t_InterfaceIdentifier ,
  4312. t_ProxyIndex ,
  4313. t_InternalServerInterface ,
  4314. t_InternalInterfaceIdentifier ,
  4315. t_InternalProxyIndex ,
  4316. m_ProcessIdentifier ,
  4317. t_IdentifyToken ,
  4318. t_Impersonating ,
  4319. t_OldContext ,
  4320. t_OldSecurity ,
  4321. t_IsProxy ,
  4322. t_Interface ,
  4323. t_Revert ,
  4324. t_Proxy
  4325. ) ;
  4326. }
  4327. if ( FAILED ( t_Result ) )
  4328. {
  4329. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4330. {
  4331. AbnormalShutdown () ;
  4332. }
  4333. }
  4334. return t_Result ;
  4335. }
  4336. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4337. }
  4338. return WBEM_E_PROVIDER_SUSPENDED ;
  4339. }
  4340. /******************************************************************************
  4341. *
  4342. * Name:
  4343. *
  4344. *
  4345. * Description:
  4346. *
  4347. *
  4348. *****************************************************************************/
  4349. HRESULT CInterceptor_IWbemProvider ::ProvideEvents (
  4350. IWbemObjectSink *a_Sink ,
  4351. long a_Flags
  4352. )
  4353. {
  4354. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4355. if ( GetResumed () )
  4356. {
  4357. if ( m_Provider_IWbemEventProvider )
  4358. {
  4359. IUnknown *t_ServerInterface = m_Provider_IWbemEventProvider ;
  4360. REFIID t_InterfaceIdentifier = IID_IWbemEventProvider ;
  4361. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProvider ;
  4362. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProvider ;
  4363. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProvider ;
  4364. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProvider ;
  4365. BOOL t_Impersonating ;
  4366. IUnknown *t_OldContext ;
  4367. IServerSecurity *t_OldSecurity ;
  4368. BOOL t_IsProxy ;
  4369. IUnknown *t_Interface ;
  4370. BOOL t_Revert ;
  4371. IUnknown *t_Proxy ;
  4372. HANDLE t_IdentifyToken = NULL ;
  4373. HRESULT t_Result = Begin_Interface (
  4374. t_ServerInterface ,
  4375. t_InterfaceIdentifier ,
  4376. t_ProxyIndex ,
  4377. t_InternalServerInterface ,
  4378. t_InternalInterfaceIdentifier ,
  4379. t_InternalProxyIndex ,
  4380. m_ProcessIdentifier ,
  4381. t_IdentifyToken ,
  4382. t_Impersonating ,
  4383. t_OldContext ,
  4384. t_OldSecurity ,
  4385. t_IsProxy ,
  4386. t_Interface ,
  4387. t_Revert ,
  4388. t_Proxy
  4389. ) ;
  4390. if ( SUCCEEDED ( t_Result ) )
  4391. {
  4392. if ( t_IdentifyToken )
  4393. {
  4394. WmiInternalContext t_InternalContext ;
  4395. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4396. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4397. t_Result = ( ( Internal_IWbemEventProvider * ) t_Interface )->Internal_ProvideEvents (
  4398. t_InternalContext ,
  4399. a_Sink ,
  4400. a_Flags
  4401. ) ;
  4402. }
  4403. else
  4404. {
  4405. t_Result = ( ( IWbemEventProvider * ) t_Interface )->ProvideEvents (
  4406. a_Sink ,
  4407. a_Flags
  4408. ) ;
  4409. }
  4410. End_Interface (
  4411. t_ServerInterface ,
  4412. t_InterfaceIdentifier ,
  4413. t_ProxyIndex ,
  4414. t_InternalServerInterface ,
  4415. t_InternalInterfaceIdentifier ,
  4416. t_InternalProxyIndex ,
  4417. m_ProcessIdentifier ,
  4418. t_IdentifyToken ,
  4419. t_Impersonating ,
  4420. t_OldContext ,
  4421. t_OldSecurity ,
  4422. t_IsProxy ,
  4423. t_Interface ,
  4424. t_Revert ,
  4425. t_Proxy
  4426. ) ;
  4427. }
  4428. if ( FAILED ( t_Result ) )
  4429. {
  4430. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4431. {
  4432. AbnormalShutdown () ;
  4433. }
  4434. }
  4435. return t_Result ;
  4436. }
  4437. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4438. }
  4439. return WBEM_E_PROVIDER_SUSPENDED ;
  4440. }
  4441. /******************************************************************************
  4442. *
  4443. * Name:
  4444. *
  4445. *
  4446. * Description:
  4447. *
  4448. *
  4449. *****************************************************************************/
  4450. HRESULT CInterceptor_IWbemProvider ::NewQuery (
  4451. unsigned long a_Id ,
  4452. WBEM_WSTR a_QueryLanguage ,
  4453. WBEM_WSTR a_Query
  4454. )
  4455. {
  4456. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4457. if ( GetResumed () )
  4458. {
  4459. if ( m_Provider_IWbemEventProviderQuerySink )
  4460. {
  4461. IUnknown *t_ServerInterface = m_Provider_IWbemEventProviderQuerySink ;
  4462. REFIID t_InterfaceIdentifier = IID_IWbemEventProviderQuerySink ;
  4463. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProviderQuerySink ;
  4464. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProviderQuerySink ;
  4465. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProviderQuerySink ;
  4466. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProviderQuerySink ;
  4467. BOOL t_Impersonating ;
  4468. IUnknown *t_OldContext ;
  4469. IServerSecurity *t_OldSecurity ;
  4470. BOOL t_IsProxy ;
  4471. IUnknown *t_Interface ;
  4472. BOOL t_Revert ;
  4473. IUnknown *t_Proxy ;
  4474. HANDLE t_IdentifyToken = NULL ;
  4475. HRESULT t_Result = Begin_Interface (
  4476. t_ServerInterface ,
  4477. t_InterfaceIdentifier ,
  4478. t_ProxyIndex ,
  4479. t_InternalServerInterface ,
  4480. t_InternalInterfaceIdentifier ,
  4481. t_InternalProxyIndex ,
  4482. m_ProcessIdentifier ,
  4483. t_IdentifyToken ,
  4484. t_Impersonating ,
  4485. t_OldContext ,
  4486. t_OldSecurity ,
  4487. t_IsProxy ,
  4488. t_Interface ,
  4489. t_Revert ,
  4490. t_Proxy
  4491. ) ;
  4492. if ( SUCCEEDED ( t_Result ) )
  4493. {
  4494. if ( t_IdentifyToken )
  4495. {
  4496. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  4497. BSTR t_Query = SysAllocString ( a_Query ) ;
  4498. if ( t_QueryLanguage && t_Query )
  4499. {
  4500. WmiInternalContext t_InternalContext ;
  4501. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4502. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4503. t_Result = ( ( Internal_IWbemEventProviderQuerySink * ) t_Interface )->Internal_NewQuery (
  4504. t_InternalContext ,
  4505. a_Id ,
  4506. t_QueryLanguage ,
  4507. t_Query
  4508. ) ;
  4509. }
  4510. else
  4511. {
  4512. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4513. }
  4514. SysFreeString ( t_QueryLanguage ) ;
  4515. SysFreeString ( t_Query ) ;
  4516. }
  4517. else
  4518. {
  4519. t_Result = ( ( IWbemEventProviderQuerySink * ) t_Interface )->NewQuery (
  4520. a_Id ,
  4521. a_QueryLanguage ,
  4522. a_Query
  4523. ) ;
  4524. }
  4525. End_Interface (
  4526. t_ServerInterface ,
  4527. t_InterfaceIdentifier ,
  4528. t_ProxyIndex ,
  4529. t_InternalServerInterface ,
  4530. t_InternalInterfaceIdentifier ,
  4531. t_InternalProxyIndex ,
  4532. m_ProcessIdentifier ,
  4533. t_IdentifyToken ,
  4534. t_Impersonating ,
  4535. t_OldContext ,
  4536. t_OldSecurity ,
  4537. t_IsProxy ,
  4538. t_Interface ,
  4539. t_Revert ,
  4540. t_Proxy
  4541. ) ;
  4542. }
  4543. if ( FAILED ( t_Result ) )
  4544. {
  4545. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4546. {
  4547. AbnormalShutdown () ;
  4548. }
  4549. }
  4550. return t_Result ;
  4551. }
  4552. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4553. }
  4554. return WBEM_E_PROVIDER_SUSPENDED ;
  4555. }
  4556. /******************************************************************************
  4557. *
  4558. * Name:
  4559. *
  4560. *
  4561. * Description:
  4562. *
  4563. *
  4564. *****************************************************************************/
  4565. HRESULT CInterceptor_IWbemProvider ::CancelQuery (
  4566. unsigned long a_Id
  4567. )
  4568. {
  4569. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4570. if ( GetResumed () )
  4571. {
  4572. if ( m_Provider_IWbemEventProviderQuerySink )
  4573. {
  4574. IUnknown *t_ServerInterface = m_Provider_IWbemEventProviderQuerySink ;
  4575. REFIID t_InterfaceIdentifier = IID_IWbemEventProviderQuerySink ;
  4576. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProviderQuerySink ;
  4577. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProviderQuerySink ;
  4578. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProviderQuerySink ;
  4579. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProviderQuerySink ;
  4580. BOOL t_Impersonating ;
  4581. IUnknown *t_OldContext ;
  4582. IServerSecurity *t_OldSecurity ;
  4583. BOOL t_IsProxy ;
  4584. IUnknown *t_Interface ;
  4585. BOOL t_Revert ;
  4586. IUnknown *t_Proxy ;
  4587. HANDLE t_IdentifyToken = NULL ;
  4588. HRESULT t_Result = Begin_Interface (
  4589. t_ServerInterface ,
  4590. t_InterfaceIdentifier ,
  4591. t_ProxyIndex ,
  4592. t_InternalServerInterface ,
  4593. t_InternalInterfaceIdentifier ,
  4594. t_InternalProxyIndex ,
  4595. m_ProcessIdentifier ,
  4596. t_IdentifyToken ,
  4597. t_Impersonating ,
  4598. t_OldContext ,
  4599. t_OldSecurity ,
  4600. t_IsProxy ,
  4601. t_Interface ,
  4602. t_Revert ,
  4603. t_Proxy
  4604. ) ;
  4605. if ( SUCCEEDED ( t_Result ) )
  4606. {
  4607. if ( t_IdentifyToken )
  4608. {
  4609. WmiInternalContext t_InternalContext ;
  4610. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4611. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4612. t_Result = ( ( Internal_IWbemEventProviderQuerySink * ) t_Interface )->Internal_CancelQuery (
  4613. t_InternalContext ,
  4614. a_Id
  4615. ) ;
  4616. }
  4617. else
  4618. {
  4619. t_Result = ( ( IWbemEventProviderQuerySink * ) t_Interface )->CancelQuery (
  4620. a_Id
  4621. ) ;
  4622. }
  4623. End_Interface (
  4624. t_ServerInterface ,
  4625. t_InterfaceIdentifier ,
  4626. t_ProxyIndex ,
  4627. t_InternalServerInterface ,
  4628. t_InternalInterfaceIdentifier ,
  4629. t_InternalProxyIndex ,
  4630. m_ProcessIdentifier ,
  4631. t_IdentifyToken ,
  4632. t_Impersonating ,
  4633. t_OldContext ,
  4634. t_OldSecurity ,
  4635. t_IsProxy ,
  4636. t_Interface ,
  4637. t_Revert ,
  4638. t_Proxy
  4639. ) ;
  4640. }
  4641. if ( FAILED ( t_Result ) )
  4642. {
  4643. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4644. {
  4645. AbnormalShutdown () ;
  4646. }
  4647. }
  4648. return t_Result ;
  4649. }
  4650. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4651. }
  4652. return WBEM_E_PROVIDER_SUSPENDED ;
  4653. }
  4654. /******************************************************************************
  4655. *
  4656. * Name:
  4657. *
  4658. *
  4659. * Description:
  4660. *
  4661. *
  4662. *****************************************************************************/
  4663. HRESULT CInterceptor_IWbemProvider ::AccessCheck (
  4664. WBEM_CWSTR a_QueryLanguage ,
  4665. WBEM_CWSTR a_Query ,
  4666. long a_SidLength ,
  4667. const BYTE *a_Sid
  4668. )
  4669. {
  4670. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4671. if ( GetResumed () )
  4672. {
  4673. if ( m_Provider_IWbemEventProviderSecurity )
  4674. {
  4675. IUnknown *t_ServerInterface = m_Provider_IWbemEventProviderSecurity ;
  4676. REFIID t_InterfaceIdentifier = IID_IWbemEventProviderSecurity ;
  4677. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProviderSecurity ;
  4678. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProviderSecurity ;
  4679. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProviderSecurity ;
  4680. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProviderSecurity;
  4681. BOOL t_Impersonating ;
  4682. IUnknown *t_OldContext ;
  4683. IServerSecurity *t_OldSecurity ;
  4684. BOOL t_IsProxy ;
  4685. IUnknown *t_Interface ;
  4686. BOOL t_Revert ;
  4687. IUnknown *t_Proxy ;
  4688. HANDLE t_IdentifyToken = NULL ;
  4689. HRESULT t_Result ;
  4690. if ( a_Sid )
  4691. {
  4692. t_Result = Begin_Interface (
  4693. t_ServerInterface ,
  4694. t_InterfaceIdentifier ,
  4695. t_ProxyIndex ,
  4696. t_InternalServerInterface ,
  4697. t_InternalInterfaceIdentifier ,
  4698. t_InternalProxyIndex ,
  4699. m_ProcessIdentifier ,
  4700. t_IdentifyToken ,
  4701. t_Impersonating ,
  4702. t_OldContext ,
  4703. t_OldSecurity ,
  4704. t_IsProxy ,
  4705. t_Interface ,
  4706. t_Revert ,
  4707. t_Proxy
  4708. ) ;
  4709. }
  4710. else
  4711. {
  4712. t_Result = Begin_Interface (
  4713. t_ServerInterface ,
  4714. t_InterfaceIdentifier ,
  4715. t_ProxyIndex ,
  4716. t_InternalServerInterface ,
  4717. t_InternalInterfaceIdentifier ,
  4718. t_InternalProxyIndex ,
  4719. m_ProcessIdentifier ,
  4720. t_IdentifyToken ,
  4721. t_Impersonating ,
  4722. t_OldContext ,
  4723. t_OldSecurity ,
  4724. t_IsProxy ,
  4725. t_Interface ,
  4726. t_Revert ,
  4727. t_Proxy
  4728. ) ;
  4729. }
  4730. if ( SUCCEEDED ( t_Result ) )
  4731. {
  4732. if ( t_IdentifyToken )
  4733. {
  4734. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  4735. BSTR t_Query = SysAllocString ( a_Query ) ;
  4736. if ( t_QueryLanguage && t_Query )
  4737. {
  4738. WmiInternalContext t_InternalContext ;
  4739. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4740. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4741. t_Result = ( ( Internal_IWbemEventProviderSecurity * ) t_Interface )->Internal_AccessCheck (
  4742. t_InternalContext ,
  4743. t_QueryLanguage ,
  4744. t_Query ,
  4745. a_SidLength ,
  4746. a_Sid
  4747. ) ;
  4748. }
  4749. else
  4750. {
  4751. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4752. }
  4753. SysFreeString ( t_QueryLanguage ) ;
  4754. SysFreeString ( t_Query ) ;
  4755. }
  4756. else
  4757. {
  4758. t_Result = ( ( IWbemEventProviderSecurity * ) t_Interface )->AccessCheck (
  4759. a_QueryLanguage ,
  4760. a_Query ,
  4761. a_SidLength ,
  4762. a_Sid
  4763. ) ;
  4764. }
  4765. End_Interface (
  4766. t_ServerInterface ,
  4767. t_InterfaceIdentifier ,
  4768. t_ProxyIndex ,
  4769. t_InternalServerInterface ,
  4770. t_InternalInterfaceIdentifier ,
  4771. t_InternalProxyIndex ,
  4772. m_ProcessIdentifier ,
  4773. t_IdentifyToken ,
  4774. t_Impersonating ,
  4775. t_OldContext ,
  4776. t_OldSecurity ,
  4777. t_IsProxy ,
  4778. t_Interface ,
  4779. t_Revert ,
  4780. t_Proxy
  4781. ) ;
  4782. if ( FAILED ( t_Result ) )
  4783. {
  4784. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4785. {
  4786. AbnormalShutdown () ;
  4787. }
  4788. }
  4789. }
  4790. return t_Result ;
  4791. }
  4792. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4793. }
  4794. return WBEM_E_PROVIDER_SUSPENDED ;
  4795. }
  4796. /******************************************************************************
  4797. *
  4798. * Name:
  4799. *
  4800. *
  4801. * Description:
  4802. *
  4803. *
  4804. *****************************************************************************/
  4805. HRESULT CInterceptor_IWbemProvider ::FindConsumer (
  4806. IWbemClassObject *a_LogicalConsumer ,
  4807. IWbemUnboundObjectSink **a_Consumer
  4808. )
  4809. {
  4810. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4811. if ( GetResumed () )
  4812. {
  4813. if ( m_Provider_IWbemEventConsumerProvider )
  4814. {
  4815. IWbemUnboundObjectSink *t_Consumer = NULL ;
  4816. IUnknown *t_ServerInterface = m_Provider_IWbemEventConsumerProvider ;
  4817. REFIID t_InterfaceIdentifier = IID_IWbemEventConsumerProvider ;
  4818. DWORD t_ProxyIndex = ProxyIndex_IWbemEventConsumerProvider ;
  4819. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventConsumerProvider ;
  4820. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventConsumerProvider ;
  4821. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventConsumerProvider ;
  4822. BOOL t_Impersonating ;
  4823. IUnknown *t_OldContext ;
  4824. IServerSecurity *t_OldSecurity ;
  4825. BOOL t_IsProxy ;
  4826. IUnknown *t_Interface ;
  4827. BOOL t_Revert ;
  4828. IUnknown *t_Proxy ;
  4829. HANDLE t_IdentifyToken = NULL ;
  4830. HRESULT t_Result = Begin_Interface (
  4831. t_ServerInterface ,
  4832. t_InterfaceIdentifier ,
  4833. t_ProxyIndex ,
  4834. t_InternalServerInterface ,
  4835. t_InternalInterfaceIdentifier ,
  4836. t_InternalProxyIndex ,
  4837. m_ProcessIdentifier ,
  4838. t_IdentifyToken ,
  4839. t_Impersonating ,
  4840. t_OldContext ,
  4841. t_OldSecurity ,
  4842. t_IsProxy ,
  4843. t_Interface ,
  4844. t_Revert ,
  4845. t_Proxy
  4846. ) ;
  4847. if ( SUCCEEDED ( t_Result ) )
  4848. {
  4849. if ( t_IdentifyToken )
  4850. {
  4851. WmiInternalContext t_InternalContext ;
  4852. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4853. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4854. t_Result = ( ( Internal_IWbemEventConsumerProvider * ) t_Interface )->Internal_FindConsumer (
  4855. t_InternalContext ,
  4856. a_LogicalConsumer ,
  4857. & t_Consumer
  4858. ) ;
  4859. }
  4860. else
  4861. {
  4862. t_Result = ( ( IWbemEventConsumerProvider * ) t_Interface )->FindConsumer (
  4863. a_LogicalConsumer ,
  4864. & t_Consumer
  4865. ) ;
  4866. }
  4867. End_Interface (
  4868. t_ServerInterface ,
  4869. t_InterfaceIdentifier ,
  4870. t_ProxyIndex ,
  4871. t_InternalServerInterface ,
  4872. t_InternalInterfaceIdentifier ,
  4873. t_InternalProxyIndex ,
  4874. m_ProcessIdentifier ,
  4875. t_IdentifyToken ,
  4876. t_Impersonating ,
  4877. t_OldContext ,
  4878. t_OldSecurity ,
  4879. t_IsProxy ,
  4880. t_Interface ,
  4881. t_Revert ,
  4882. t_Proxy
  4883. ) ;
  4884. }
  4885. if ( SUCCEEDED ( t_Result ) )
  4886. {
  4887. if ( a_Consumer )
  4888. {
  4889. CInterceptor_IWbemUnboundObjectSink *t_UnboundObjectSink = new CInterceptor_IWbemUnboundObjectSink (
  4890. m_Allocator ,
  4891. t_Consumer ,
  4892. this ,
  4893. *m_Registration
  4894. ) ;
  4895. if ( t_UnboundObjectSink )
  4896. {
  4897. t_UnboundObjectSink->AddRef () ;
  4898. t_Result = t_UnboundObjectSink->Initialize () ;
  4899. if ( SUCCEEDED ( t_Result ) )
  4900. {
  4901. CWbemGlobal_VoidPointerController_Container_Iterator t_Iterator ;
  4902. Lock () ;
  4903. WmiStatusCode t_StatusCode = Insert (
  4904. *t_UnboundObjectSink ,
  4905. t_Iterator
  4906. ) ;
  4907. if ( t_StatusCode == e_StatusCode_Success )
  4908. {
  4909. UnLock () ;
  4910. *a_Consumer = t_UnboundObjectSink ;
  4911. t_UnboundObjectSink->AddRef () ;
  4912. }
  4913. else
  4914. {
  4915. UnLock () ;
  4916. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4917. }
  4918. }
  4919. t_UnboundObjectSink->Release () ;
  4920. }
  4921. }
  4922. }
  4923. else
  4924. {
  4925. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  4926. {
  4927. AbnormalShutdown () ;
  4928. }
  4929. }
  4930. if ( t_Consumer )
  4931. {
  4932. t_Consumer->Release () ;
  4933. }
  4934. return t_Result ;
  4935. }
  4936. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4937. }
  4938. return WBEM_E_PROVIDER_SUSPENDED ;
  4939. }
  4940. /******************************************************************************
  4941. *
  4942. * Name:
  4943. *
  4944. *
  4945. * Description:
  4946. *
  4947. *
  4948. *****************************************************************************/
  4949. HRESULT CInterceptor_IWbemProvider ::ValidateSubscription (
  4950. IWbemClassObject *a_LogicalConsumer
  4951. )
  4952. {
  4953. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  4954. if ( GetResumed () )
  4955. {
  4956. if ( m_Provider_IWbemEventConsumerProviderEx )
  4957. {
  4958. IUnknown *t_ServerInterface = m_Provider_IWbemEventConsumerProviderEx ;
  4959. REFIID t_InterfaceIdentifier = IID_IWbemEventConsumerProviderEx ;
  4960. DWORD t_ProxyIndex = ProxyIndex_IWbemEventConsumerProviderEx ;
  4961. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventConsumerProviderEx ;
  4962. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventConsumerProviderEx ;
  4963. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventConsumerProviderEx ;
  4964. BOOL t_Impersonating ;
  4965. IUnknown *t_OldContext ;
  4966. IServerSecurity *t_OldSecurity ;
  4967. BOOL t_IsProxy ;
  4968. IUnknown *t_Interface ;
  4969. BOOL t_Revert ;
  4970. IUnknown *t_Proxy ;
  4971. HANDLE t_IdentifyToken = NULL ;
  4972. HRESULT t_Result = Begin_Interface (
  4973. t_ServerInterface ,
  4974. t_InterfaceIdentifier ,
  4975. t_ProxyIndex ,
  4976. t_InternalServerInterface ,
  4977. t_InternalInterfaceIdentifier ,
  4978. t_InternalProxyIndex ,
  4979. m_ProcessIdentifier ,
  4980. t_IdentifyToken ,
  4981. t_Impersonating ,
  4982. t_OldContext ,
  4983. t_OldSecurity ,
  4984. t_IsProxy ,
  4985. t_Interface ,
  4986. t_Revert ,
  4987. t_Proxy
  4988. ) ;
  4989. if ( SUCCEEDED ( t_Result ) )
  4990. {
  4991. if ( t_IdentifyToken )
  4992. {
  4993. WmiInternalContext t_InternalContext ;
  4994. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4995. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4996. t_Result = ( ( Internal_IWbemEventConsumerProviderEx * ) t_Interface )->Internal_ValidateSubscription (
  4997. t_InternalContext ,
  4998. a_LogicalConsumer
  4999. ) ;
  5000. }
  5001. else
  5002. {
  5003. t_Result = ( ( IWbemEventConsumerProviderEx * ) t_Interface )->ValidateSubscription (
  5004. a_LogicalConsumer
  5005. ) ;
  5006. }
  5007. End_Interface (
  5008. t_ServerInterface ,
  5009. t_InterfaceIdentifier ,
  5010. t_ProxyIndex ,
  5011. t_InternalServerInterface ,
  5012. t_InternalInterfaceIdentifier ,
  5013. t_InternalProxyIndex ,
  5014. m_ProcessIdentifier ,
  5015. t_IdentifyToken ,
  5016. t_Impersonating ,
  5017. t_OldContext ,
  5018. t_OldSecurity ,
  5019. t_IsProxy ,
  5020. t_Interface ,
  5021. t_Revert ,
  5022. t_Proxy
  5023. ) ;
  5024. }
  5025. if ( FAILED ( t_Result ) )
  5026. {
  5027. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5028. {
  5029. AbnormalShutdown () ;
  5030. }
  5031. }
  5032. return t_Result ;
  5033. }
  5034. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5035. }
  5036. return WBEM_E_PROVIDER_SUSPENDED ;
  5037. }
  5038. /******************************************************************************
  5039. *
  5040. * Name:
  5041. *
  5042. *
  5043. * Description:
  5044. *
  5045. *
  5046. *****************************************************************************/
  5047. HRESULT CInterceptor_IWbemProvider :: IndicateToConsumer (
  5048. IWbemClassObject *a_LogicalConsumer ,
  5049. long a_ObjectCount ,
  5050. IWbemClassObject **a_Objects
  5051. )
  5052. {
  5053. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  5054. if ( GetResumed () )
  5055. {
  5056. if ( m_Provider_IWbemUnboundObjectSink )
  5057. {
  5058. IUnknown *t_ServerInterface = m_Provider_IWbemUnboundObjectSink ;
  5059. REFIID t_InterfaceIdentifier = IID_IWbemUnboundObjectSink ;
  5060. DWORD t_ProxyIndex = ProxyIndex_IWbemUnboundObjectSink ;
  5061. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemUnboundObjectSink ;
  5062. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemUnboundObjectSink ;
  5063. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemUnboundObjectSink ;
  5064. BOOL t_Impersonating ;
  5065. IUnknown *t_OldContext ;
  5066. IServerSecurity *t_OldSecurity ;
  5067. BOOL t_IsProxy ;
  5068. IUnknown *t_Interface ;
  5069. BOOL t_Revert ;
  5070. IUnknown *t_Proxy ;
  5071. HANDLE t_IdentifyToken = NULL ;
  5072. HRESULT t_Result = Begin_Interface (
  5073. t_ServerInterface ,
  5074. t_InterfaceIdentifier ,
  5075. t_ProxyIndex ,
  5076. t_InternalServerInterface ,
  5077. t_InternalInterfaceIdentifier ,
  5078. t_InternalProxyIndex ,
  5079. m_ProcessIdentifier ,
  5080. t_IdentifyToken ,
  5081. t_Impersonating ,
  5082. t_OldContext ,
  5083. t_OldSecurity ,
  5084. t_IsProxy ,
  5085. t_Interface ,
  5086. t_Revert ,
  5087. t_Proxy
  5088. ) ;
  5089. if ( SUCCEEDED ( t_Result ) )
  5090. {
  5091. if ( t_IdentifyToken )
  5092. {
  5093. WmiInternalContext t_InternalContext ;
  5094. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  5095. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  5096. t_Result = ( ( Internal_IWbemUnboundObjectSink * ) t_Interface )->Internal_IndicateToConsumer (
  5097. t_InternalContext ,
  5098. a_LogicalConsumer ,
  5099. a_ObjectCount ,
  5100. a_Objects
  5101. ) ;
  5102. }
  5103. else
  5104. {
  5105. t_Result = ( ( IWbemUnboundObjectSink * ) t_Interface )->IndicateToConsumer (
  5106. a_LogicalConsumer ,
  5107. a_ObjectCount ,
  5108. a_Objects
  5109. ) ;
  5110. }
  5111. End_Interface (
  5112. t_ServerInterface ,
  5113. t_InterfaceIdentifier ,
  5114. t_ProxyIndex ,
  5115. t_InternalServerInterface ,
  5116. t_InternalInterfaceIdentifier ,
  5117. t_InternalProxyIndex ,
  5118. m_ProcessIdentifier ,
  5119. t_IdentifyToken ,
  5120. t_Impersonating ,
  5121. t_OldContext ,
  5122. t_OldSecurity ,
  5123. t_IsProxy ,
  5124. t_Interface ,
  5125. t_Revert ,
  5126. t_Proxy
  5127. ) ;
  5128. }
  5129. if ( FAILED ( t_Result ) )
  5130. {
  5131. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5132. {
  5133. AbnormalShutdown () ;
  5134. }
  5135. }
  5136. return t_Result ;
  5137. }
  5138. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5139. }
  5140. return WBEM_E_PROVIDER_SUSPENDED ;
  5141. }
  5142. /******************************************************************************
  5143. *
  5144. * Name:
  5145. *
  5146. *
  5147. * Description:
  5148. *
  5149. *
  5150. *****************************************************************************/
  5151. HRESULT CInterceptor_IWbemProvider ::QueryInstances (
  5152. IWbemServices *a_Namespace ,
  5153. WCHAR *a_Class ,
  5154. long a_Flags ,
  5155. IWbemContext *a_Context ,
  5156. IWbemObjectSink *a_Sink
  5157. )
  5158. {
  5159. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5160. }
  5161. /******************************************************************************
  5162. *
  5163. * Name:
  5164. *
  5165. *
  5166. * Description:
  5167. *
  5168. *
  5169. *****************************************************************************/
  5170. HRESULT CInterceptor_IWbemProvider ::CreateRefresher (
  5171. IWbemServices *a_Namespace ,
  5172. long a_Flags ,
  5173. IWbemRefresher **a_Refresher
  5174. )
  5175. {
  5176. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5177. }
  5178. /******************************************************************************
  5179. *
  5180. * Name:
  5181. *
  5182. *
  5183. * Description:
  5184. *
  5185. *
  5186. *****************************************************************************/
  5187. HRESULT CInterceptor_IWbemProvider ::CreateRefreshableObject (
  5188. IWbemServices *a_Namespace ,
  5189. IWbemObjectAccess *a_Template ,
  5190. IWbemRefresher *a_Refresher ,
  5191. long a_Flags ,
  5192. IWbemContext *a_Context ,
  5193. IWbemObjectAccess **a_Refreshable ,
  5194. long *a_Id
  5195. )
  5196. {
  5197. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5198. }
  5199. /******************************************************************************
  5200. *
  5201. * Name:
  5202. *
  5203. *
  5204. * Description:
  5205. *
  5206. *
  5207. *****************************************************************************/
  5208. HRESULT CInterceptor_IWbemProvider ::StopRefreshing (
  5209. IWbemRefresher *a_Refresher ,
  5210. long a_Id ,
  5211. long a_Flags
  5212. )
  5213. {
  5214. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5215. }
  5216. /******************************************************************************
  5217. *
  5218. * Name:
  5219. *
  5220. *
  5221. * Description:
  5222. *
  5223. *
  5224. *****************************************************************************/
  5225. HRESULT CInterceptor_IWbemProvider ::CreateRefreshableEnum (
  5226. IWbemServices *a_Namespace ,
  5227. LPCWSTR a_Class ,
  5228. IWbemRefresher *a_Refresher ,
  5229. long a_Flags ,
  5230. IWbemContext *a_Context ,
  5231. IWbemHiPerfEnum *a_HiPerfEnum ,
  5232. long *a_Id
  5233. )
  5234. {
  5235. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5236. }
  5237. /******************************************************************************
  5238. *
  5239. * Name:
  5240. *
  5241. *
  5242. * Description:
  5243. *
  5244. *
  5245. *****************************************************************************/
  5246. HRESULT CInterceptor_IWbemProvider ::GetObjects (
  5247. IWbemServices *a_Namespace ,
  5248. long a_ObjectCount ,
  5249. IWbemObjectAccess **a_Objects ,
  5250. long a_Flags ,
  5251. IWbemContext *a_Context
  5252. )
  5253. {
  5254. return WBEM_E_PROVIDER_NOT_CAPABLE;
  5255. }
  5256. /******************************************************************************
  5257. *
  5258. * Name:
  5259. *
  5260. *
  5261. * Description:
  5262. *
  5263. *
  5264. *****************************************************************************/
  5265. HRESULT CInterceptor_IWbemProvider :: Get (
  5266. IWbemServices *a_Service ,
  5267. long a_Flags ,
  5268. IWbemContext *a_Context ,
  5269. LPCWSTR a_Class ,
  5270. LPCWSTR a_Path ,
  5271. IWbemObjectSink *a_Sink
  5272. )
  5273. {
  5274. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  5275. HRESULT t_Result = S_OK ;
  5276. if ( wbem_wcsicmp ( a_Class , L"Msft_Providers" ) == 0 )
  5277. {
  5278. CWaitingObjectSink *t_Sink = new CWaitingObjectSink ( m_Allocator ) ;
  5279. if ( t_Sink )
  5280. {
  5281. t_Sink->AddRef () ;
  5282. t_Result = t_Sink->SinkInitialize () ;
  5283. if ( SUCCEEDED ( t_Result ) )
  5284. {
  5285. try
  5286. {
  5287. ProviderCacheKey t_Key = ServiceCacheElement :: GetKey () ;
  5288. t_Result = m_Provider__IWmiProviderConfiguration->Get (
  5289. a_Service ,
  5290. a_Flags ,
  5291. a_Context ,
  5292. a_Class ,
  5293. a_Path ,
  5294. t_Sink
  5295. ) ;
  5296. t_Result = t_Sink->Wait ( INFINITE ) ;
  5297. if ( SUCCEEDED ( t_Result ) )
  5298. {
  5299. t_Result = t_Sink->GetResult () ;
  5300. if ( FAILED ( t_Result ) )
  5301. {
  5302. }
  5303. }
  5304. WmiQueue <IWbemClassObject *,8> &t_Queue = t_Sink->GetQueue () ;
  5305. WmiStatusCode t_StatusCode = e_StatusCode_Success ;
  5306. IWbemClassObject *t_Object = NULL ;
  5307. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  5308. {
  5309. if ( SUCCEEDED ( t_Result ) )
  5310. {
  5311. VARIANT t_VariantNamespace ;
  5312. VariantInit ( & t_VariantNamespace ) ;
  5313. t_VariantNamespace.vt = VT_BSTR ;
  5314. t_VariantNamespace.bstrVal = m_Namespace ? SysAllocString ( m_Namespace ) : SysAllocString ( L"" ) ;
  5315. t_Object->Put ( L"Namespace" , 0 , & t_VariantNamespace , 0 ) ;
  5316. VariantClear ( & t_VariantNamespace ) ;
  5317. VARIANT t_VariantUser ;
  5318. VariantInit ( & t_VariantUser ) ;
  5319. t_VariantUser.vt = VT_BSTR ;
  5320. t_VariantUser.bstrVal = t_Key.m_User ? SysAllocString ( t_Key.m_User ) : SysAllocString ( L"" ) ;
  5321. t_Object->Put ( L"User" , 0 , & t_VariantUser , 0 ) ;
  5322. VariantClear ( & t_VariantUser ) ;
  5323. VARIANT t_VariantLocale ;
  5324. VariantInit ( & t_VariantLocale ) ;
  5325. t_VariantLocale.vt = VT_BSTR ;
  5326. t_VariantLocale.bstrVal = t_Key.m_Locale ? SysAllocString ( t_Key.m_Locale ) : SysAllocString ( L"" ) ;
  5327. t_Object->Put ( L"Locale" , 0 , & t_VariantLocale , 0 ) ;
  5328. VariantClear ( & t_VariantLocale ) ;
  5329. VARIANT t_VariantProvider ;
  5330. VariantInit ( & t_VariantProvider ) ;
  5331. t_VariantProvider.vt = VT_BSTR ;
  5332. t_VariantProvider.bstrVal = t_Key.m_Provider ? SysAllocString ( t_Key.m_Provider ) : SysAllocString ( L"" ) ;
  5333. t_Object->Put ( L"Provider" , 0 , & t_VariantProvider , 0 ) ;
  5334. VariantClear ( & t_VariantProvider ) ;
  5335. VARIANT t_VariantHostingSpecification ;
  5336. VariantInit ( & t_VariantHostingSpecification ) ;
  5337. t_VariantHostingSpecification.vt = VT_I4 ;
  5338. t_VariantHostingSpecification.lVal = t_Key.m_Hosting ;
  5339. t_Object->Put ( L"HostingSpecification" , 0 , & t_VariantHostingSpecification , 0 ) ;
  5340. VariantClear ( & t_VariantHostingSpecification ) ;
  5341. VARIANT t_VariantHostGroup ;
  5342. VariantInit ( & t_VariantHostGroup ) ;
  5343. t_VariantHostGroup.vt = VT_BSTR ;
  5344. t_VariantHostGroup.bstrVal = t_Key.m_Group ? SysAllocString ( t_Key.m_Group ) : SysAllocString ( L"" ) ;
  5345. t_Object->Put ( L"HostingGroup" , 0 , & t_VariantHostGroup , 0 ) ;
  5346. VariantClear ( & t_VariantHostGroup ) ;
  5347. wchar_t t_TransactionIdentifier [ sizeof ( L"{00000000-0000-0000-0000-000000000000}" ) ] ;
  5348. if ( t_Key.m_TransactionIdentifier )
  5349. {
  5350. StringFromGUID2 ( *t_Key.m_TransactionIdentifier , t_TransactionIdentifier , sizeof ( t_TransactionIdentifier ) / sizeof ( wchar_t ) );
  5351. }
  5352. VARIANT t_VariantTransactionIdentifier ;
  5353. VariantInit ( & t_VariantTransactionIdentifier ) ;
  5354. t_VariantTransactionIdentifier.vt = VT_BSTR ;
  5355. t_VariantTransactionIdentifier.bstrVal = t_Key.m_TransactionIdentifier ? SysAllocString ( t_TransactionIdentifier ) : SysAllocString ( L"" ) ;
  5356. t_Object->Put ( L"TransactionIdentifier" , 0 , & t_VariantTransactionIdentifier , 0 ) ;
  5357. VariantClear ( & t_VariantTransactionIdentifier ) ;
  5358. a_Sink->Indicate ( 1, & t_Object ) ;
  5359. }
  5360. t_Object->Release () ;
  5361. t_StatusCode = t_Queue.DeQueue () ;
  5362. }
  5363. }
  5364. catch ( Wmi_Heap_Exception &a_Exception )
  5365. {
  5366. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5367. }
  5368. catch ( ... )
  5369. {
  5370. t_Result = WBEM_E_CRITICAL_ERROR ;
  5371. }
  5372. }
  5373. t_Sink->Release () ;
  5374. }
  5375. else
  5376. {
  5377. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5378. }
  5379. }
  5380. else
  5381. {
  5382. t_Result = WBEM_E_INVALID_CLASS ;
  5383. }
  5384. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  5385. if ( FAILED ( t_Result ) )
  5386. {
  5387. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5388. {
  5389. AbnormalShutdown () ;
  5390. }
  5391. }
  5392. return t_Result ;
  5393. }
  5394. /******************************************************************************
  5395. *
  5396. * Name:
  5397. *
  5398. *
  5399. * Description:
  5400. *
  5401. *
  5402. *****************************************************************************/
  5403. HRESULT CInterceptor_IWbemProvider :: Set (
  5404. IWbemServices *a_Service ,
  5405. long a_Flags ,
  5406. IWbemContext *a_Context ,
  5407. LPCWSTR a_Provider ,
  5408. LPCWSTR a_Class ,
  5409. LPCWSTR a_Path ,
  5410. IWbemClassObject *a_OldObject ,
  5411. IWbemClassObject *a_NewObject
  5412. )
  5413. {
  5414. HRESULT t_Result = m_Provider__IWmiProviderConfiguration->Set (
  5415. a_Service ,
  5416. a_Flags ,
  5417. a_Context ,
  5418. a_Provider ,
  5419. a_Class ,
  5420. a_Path ,
  5421. a_OldObject ,
  5422. a_NewObject
  5423. ) ;
  5424. if ( FAILED ( t_Result ) )
  5425. {
  5426. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5427. {
  5428. AbnormalShutdown () ;
  5429. }
  5430. }
  5431. return t_Result ;
  5432. }
  5433. /******************************************************************************
  5434. *
  5435. * Name:
  5436. *
  5437. *
  5438. * Description:
  5439. *
  5440. *
  5441. *****************************************************************************/
  5442. HRESULT CInterceptor_IWbemProvider :: Deleted (
  5443. IWbemServices *a_Service ,
  5444. long a_Flags ,
  5445. IWbemContext *a_Context ,
  5446. LPCWSTR a_Provider ,
  5447. LPCWSTR a_Class ,
  5448. LPCWSTR a_Path ,
  5449. IWbemClassObject *a_Object
  5450. )
  5451. {
  5452. HRESULT t_Result = m_Provider__IWmiProviderConfiguration->Deleted (
  5453. a_Service ,
  5454. a_Flags ,
  5455. a_Context ,
  5456. a_Provider ,
  5457. a_Class ,
  5458. a_Path ,
  5459. a_Object
  5460. ) ;
  5461. if ( FAILED ( t_Result ) )
  5462. {
  5463. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5464. {
  5465. AbnormalShutdown () ;
  5466. }
  5467. }
  5468. return t_Result ;
  5469. }
  5470. /******************************************************************************
  5471. *
  5472. * Name:
  5473. *
  5474. *
  5475. * Description:
  5476. *
  5477. *
  5478. *****************************************************************************/
  5479. HRESULT CInterceptor_IWbemProvider :: Enumerate (
  5480. IWbemServices *a_Service ,
  5481. long a_Flags ,
  5482. IWbemContext *a_Context ,
  5483. LPCWSTR a_Class ,
  5484. IWbemObjectSink *a_Sink
  5485. )
  5486. {
  5487. HRESULT t_Result = S_OK ;
  5488. if ( wbem_wcsicmp ( a_Class , L"Msft_Providers" ) == 0 )
  5489. {
  5490. CWaitingObjectSink *t_Sink = new CWaitingObjectSink ( m_Allocator ) ;
  5491. if ( t_Sink )
  5492. {
  5493. t_Sink->AddRef () ;
  5494. t_Result = t_Sink->SinkInitialize () ;
  5495. if ( SUCCEEDED ( t_Result ) )
  5496. {
  5497. try
  5498. {
  5499. ProviderCacheKey t_Key = ServiceCacheElement :: GetKey () ;
  5500. t_Result = m_Provider__IWmiProviderConfiguration->Enumerate (
  5501. a_Service ,
  5502. a_Flags ,
  5503. a_Context ,
  5504. a_Class ,
  5505. t_Sink
  5506. ) ;
  5507. if (SUCCEEDED(t_Result))
  5508. {
  5509. t_Result = t_Sink->Wait ( INFINITE ) ;
  5510. if ( SUCCEEDED ( t_Result ) )
  5511. {
  5512. t_Result = t_Sink->GetResult () ;
  5513. if ( FAILED ( t_Result ) )
  5514. {
  5515. }
  5516. }
  5517. }
  5518. WmiQueue <IWbemClassObject *,8> &t_Queue = t_Sink->GetQueue () ;
  5519. WmiStatusCode t_StatusCode = e_StatusCode_Success ;
  5520. IWbemClassObject *t_Object = NULL ;
  5521. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  5522. {
  5523. if ( SUCCEEDED ( t_Result ) )
  5524. {
  5525. VARIANT t_VariantNamespace ;
  5526. VariantInit ( & t_VariantNamespace ) ;
  5527. t_VariantNamespace.vt = VT_BSTR ;
  5528. t_VariantNamespace.bstrVal = m_Namespace ? SysAllocString ( m_Namespace ) : SysAllocString ( L"" ) ;
  5529. t_Object->Put ( L"Namespace" , 0 , & t_VariantNamespace , 0 ) ;
  5530. VariantClear ( & t_VariantNamespace ) ;
  5531. VARIANT t_VariantUser ;
  5532. VariantInit ( & t_VariantUser ) ;
  5533. t_VariantUser.vt = VT_BSTR ;
  5534. t_VariantUser.bstrVal = t_Key.m_User ? SysAllocString ( t_Key.m_User ) : SysAllocString ( L"" ) ;
  5535. t_Object->Put ( L"User" , 0 , & t_VariantUser , 0 ) ;
  5536. VariantClear ( & t_VariantUser ) ;
  5537. VARIANT t_VariantLocale ;
  5538. VariantInit ( & t_VariantLocale ) ;
  5539. t_VariantLocale.vt = VT_BSTR ;
  5540. t_VariantLocale.bstrVal = t_Key.m_Locale ? SysAllocString ( t_Key.m_Locale ) : SysAllocString ( L"" ) ;
  5541. t_Object->Put ( L"Locale" , 0 , & t_VariantLocale , 0 ) ;
  5542. VariantClear ( & t_VariantLocale ) ;
  5543. VARIANT t_VariantProvider ;
  5544. VariantInit ( & t_VariantProvider ) ;
  5545. t_VariantProvider.vt = VT_BSTR ;
  5546. t_VariantProvider.bstrVal = t_Key.m_Provider ? SysAllocString ( t_Key.m_Provider ) : SysAllocString ( L"" ) ;
  5547. t_Object->Put ( L"Provider" , 0 , & t_VariantProvider , 0 ) ;
  5548. VariantClear ( & t_VariantProvider ) ;
  5549. VARIANT t_VariantHostingSpecification ;
  5550. VariantInit ( & t_VariantHostingSpecification ) ;
  5551. t_VariantHostingSpecification.vt = VT_I4 ;
  5552. t_VariantHostingSpecification.lVal = t_Key.m_Hosting ;
  5553. t_Object->Put ( L"HostingSpecification" , 0 , & t_VariantHostingSpecification , 0 ) ;
  5554. VariantClear ( & t_VariantHostingSpecification ) ;
  5555. VARIANT t_VariantHostGroup ;
  5556. VariantInit ( & t_VariantHostGroup ) ;
  5557. t_VariantHostGroup.vt = VT_BSTR ;
  5558. t_VariantHostGroup.bstrVal = t_Key.m_Group ? SysAllocString ( t_Key.m_Group ) : SysAllocString ( L"" ) ;
  5559. t_Object->Put ( L"HostingGroup" , 0 , & t_VariantHostGroup , 0 ) ;
  5560. VariantClear ( & t_VariantHostGroup ) ;
  5561. wchar_t t_TransactionIdentifier [ sizeof ( L"{00000000-0000-0000-0000-000000000000}" ) ] ;
  5562. if ( t_Key.m_TransactionIdentifier )
  5563. {
  5564. StringFromGUID2 ( *t_Key.m_TransactionIdentifier , t_TransactionIdentifier , sizeof ( t_TransactionIdentifier ) / sizeof ( wchar_t ) );
  5565. }
  5566. VARIANT t_VariantTransactionIdentifier ;
  5567. VariantInit ( & t_VariantTransactionIdentifier ) ;
  5568. t_VariantTransactionIdentifier.vt = VT_BSTR ;
  5569. t_VariantTransactionIdentifier.bstrVal = t_Key.m_TransactionIdentifier ? SysAllocString ( t_TransactionIdentifier ) : SysAllocString ( L"" ) ;
  5570. t_Object->Put ( L"TransactionIdentifier" , 0 , & t_VariantTransactionIdentifier , 0 ) ;
  5571. VariantClear ( & t_VariantTransactionIdentifier ) ;
  5572. a_Sink->Indicate ( 1, & t_Object ) ;
  5573. }
  5574. t_Object->Release () ;
  5575. t_StatusCode = t_Queue.DeQueue () ;
  5576. }
  5577. }
  5578. catch ( Wmi_Heap_Exception &a_Exception )
  5579. {
  5580. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5581. }
  5582. catch ( ... )
  5583. {
  5584. t_Result = WBEM_E_CRITICAL_ERROR ;
  5585. }
  5586. }
  5587. t_Sink->Release () ;
  5588. }
  5589. else
  5590. {
  5591. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5592. }
  5593. }
  5594. else
  5595. {
  5596. t_Result = WBEM_E_INVALID_CLASS ;
  5597. }
  5598. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  5599. if ( FAILED ( t_Result ) )
  5600. {
  5601. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5602. {
  5603. AbnormalShutdown () ;
  5604. }
  5605. }
  5606. return t_Result ;
  5607. }
  5608. /******************************************************************************
  5609. *
  5610. * Name:
  5611. *
  5612. *
  5613. * Description:
  5614. *
  5615. *
  5616. *****************************************************************************/
  5617. HRESULT CInterceptor_IWbemProvider :: Shutdown (
  5618. IWbemServices *a_Service ,
  5619. long a_Flags ,
  5620. IWbemContext *a_Context ,
  5621. LPCWSTR a_Provider ,
  5622. ULONG a_MilliSeconds
  5623. )
  5624. {
  5625. HRESULT t_Result = m_Provider__IWmiProviderConfiguration->Shutdown (
  5626. a_Service ,
  5627. a_Flags ,
  5628. a_Context ,
  5629. a_Provider ,
  5630. a_MilliSeconds
  5631. ) ;
  5632. if ( FAILED ( t_Result ) )
  5633. {
  5634. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5635. {
  5636. AbnormalShutdown () ;
  5637. }
  5638. }
  5639. return t_Result ;
  5640. }
  5641. /******************************************************************************
  5642. *
  5643. * Name:
  5644. *
  5645. *
  5646. * Description:
  5647. *
  5648. *
  5649. *****************************************************************************/
  5650. HRESULT CInterceptor_IWbemProvider :: Call (
  5651. IWbemServices *a_Service ,
  5652. long a_Flags ,
  5653. IWbemContext *a_Context ,
  5654. LPCWSTR a_Class ,
  5655. LPCWSTR a_Path ,
  5656. LPCWSTR a_Method,
  5657. IWbemClassObject *a_InParams,
  5658. IWbemObjectSink *a_Sink
  5659. )
  5660. {
  5661. HRESULT t_Result = S_OK ;
  5662. if ( wbem_wcsicmp ( a_Class , L"Msft_Providers" ) == 0 )
  5663. {
  5664. if ( wbem_wcsicmp ( a_Method , L"Suspend" ) == 0 )
  5665. {
  5666. SetResumed ( 0 ) ;
  5667. }
  5668. else if ( wbem_wcsicmp ( a_Method , L"Resume" ) == 0 )
  5669. {
  5670. SetResumed ( 1 ) ;
  5671. }
  5672. else
  5673. {
  5674. CWaitingObjectSink *t_Sink = new CWaitingObjectSink ( m_Allocator ) ;
  5675. if ( t_Sink )
  5676. {
  5677. t_Sink->AddRef () ;
  5678. t_Result = t_Sink->SinkInitialize () ;
  5679. if ( SUCCEEDED ( t_Result ) )
  5680. {
  5681. try
  5682. {
  5683. ProviderCacheKey t_Key = ServiceCacheElement :: GetKey () ;
  5684. t_Result = m_Provider__IWmiProviderConfiguration->Call (
  5685. a_Service ,
  5686. a_Flags ,
  5687. a_Context ,
  5688. a_Class ,
  5689. a_Path ,
  5690. a_Method,
  5691. a_InParams,
  5692. t_Sink
  5693. ) ;
  5694. t_Result = t_Sink->Wait ( INFINITE ) ;
  5695. if ( SUCCEEDED ( t_Result ) )
  5696. {
  5697. t_Result = t_Sink->GetResult () ;
  5698. if ( FAILED ( t_Result ) )
  5699. {
  5700. }
  5701. }
  5702. WmiQueue <IWbemClassObject *,8> &t_Queue = t_Sink->GetQueue () ;
  5703. WmiStatusCode t_StatusCode = e_StatusCode_Success ;
  5704. IWbemClassObject *t_Object = NULL ;
  5705. while ( ( t_StatusCode = t_Queue.Top ( t_Object ) ) == e_StatusCode_Success )
  5706. {
  5707. a_Sink->Indicate ( 1, & t_Object ) ;
  5708. t_Object->Release () ;
  5709. t_StatusCode = t_Queue.DeQueue () ;
  5710. }
  5711. }
  5712. catch ( Wmi_Heap_Exception &a_Exception )
  5713. {
  5714. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5715. }
  5716. catch ( ... )
  5717. {
  5718. t_Result = WBEM_E_CRITICAL_ERROR ;
  5719. }
  5720. }
  5721. t_Sink->Release () ;
  5722. }
  5723. else
  5724. {
  5725. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5726. }
  5727. }
  5728. }
  5729. else
  5730. {
  5731. t_Result = WBEM_E_INVALID_CLASS ;
  5732. }
  5733. if ( FAILED ( t_Result ) )
  5734. {
  5735. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5736. {
  5737. AbnormalShutdown () ;
  5738. }
  5739. }
  5740. return t_Result ;
  5741. }
  5742. /******************************************************************************
  5743. *
  5744. * Name:
  5745. *
  5746. *
  5747. * Description:
  5748. *
  5749. *
  5750. *****************************************************************************/
  5751. HRESULT CInterceptor_IWbemProvider :: Query (
  5752. IWbemServices *a_Service ,
  5753. long a_Flags ,
  5754. IWbemContext *a_Context ,
  5755. WBEM_PROVIDER_CONFIGURATION_CLASS_ID a_ClassIdentifier ,
  5756. WBEM_PROVIDER_CONFIGURATION_PROPERTY_ID a_PropertyIdentifier ,
  5757. VARIANT *a_Value
  5758. )
  5759. {
  5760. if ( m_Initialized == 0 )
  5761. {
  5762. HRESULT t_Result = WBEM_E_INVALID_PROPERTY ;
  5763. if ( a_ClassIdentifier == WBEM_PROVIDER_CONFIGURATION_CLASS_ID_INSTANCE_PROVIDER_REGISTRATION )
  5764. {
  5765. if ( a_PropertyIdentifier == WBEM_PROVIDER_CONFIGURATION_PROPERTY_ID_EXTENDEDQUERY_SUPPORT )
  5766. {
  5767. a_Value->vt = VT_BOOL ;
  5768. a_Value->boolVal = VARIANT_FALSE ;
  5769. t_Result = S_OK ;
  5770. }
  5771. }
  5772. return t_Result ;
  5773. }
  5774. _DBG_ASSERT(SUCCEEDED(m_InitializeResult));
  5775. HRESULT t_Result = m_Provider__IWmiProviderConfiguration->Query (
  5776. a_Service ,
  5777. a_Flags ,
  5778. a_Context ,
  5779. a_ClassIdentifier ,
  5780. a_PropertyIdentifier ,
  5781. a_Value
  5782. ) ;
  5783. if ( FAILED ( t_Result ) )
  5784. {
  5785. if ( ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == HRESULT_ERROR_CALL_FAILED_DNE ) || ( t_Result == RPC_E_DISCONNECTED ))
  5786. {
  5787. AbnormalShutdown () ;
  5788. }
  5789. }
  5790. return t_Result ;
  5791. }
  5792. /******************************************************************************
  5793. *
  5794. * Name:
  5795. *
  5796. *
  5797. * Description:
  5798. *
  5799. *
  5800. *****************************************************************************/
  5801. HRESULT CInterceptor_IWbemProvider :: AbnormalShutdown ()
  5802. {
  5803. HRESULT t_Result = S_OK ;
  5804. Lock () ;
  5805. BOOL t_Cached = ServiceCacheElement :: GetCached () ;
  5806. CWbemGlobal_IWmiObjectSinkController_Container *t_Container = NULL ;
  5807. GetContainer ( t_Container ) ;
  5808. IWbemShutdown **t_ShutdownElements = new IWbemShutdown * [ t_Container->Size () ] ;
  5809. if ( t_ShutdownElements )
  5810. {
  5811. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator = t_Container->Begin ();
  5812. ULONG t_Count = 0 ;
  5813. while ( ! t_Iterator.Null () )
  5814. {
  5815. t_Result = t_Iterator.GetElement ()->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_ShutdownElements [ t_Count ] ) ;
  5816. t_Iterator.Increment () ;
  5817. t_Count ++ ;
  5818. }
  5819. UnLock () ;
  5820. for ( ULONG t_Index = 0 ; t_Index < t_Count ; t_Index ++ )
  5821. {
  5822. if ( t_ShutdownElements [ t_Index ] )
  5823. {
  5824. t_Result = t_ShutdownElements [ t_Index ]->Shutdown (
  5825. 0 ,
  5826. 0 ,
  5827. NULL
  5828. ) ;
  5829. t_ShutdownElements [ t_Index ]->Release () ;
  5830. }
  5831. }
  5832. delete [] t_ShutdownElements ;
  5833. }
  5834. else
  5835. {
  5836. UnLock () ;
  5837. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5838. }
  5839. CWbemGlobal_IWmiObjectSinkController :: Shutdown () ;
  5840. CWbemGlobal_IWmiProviderController *t_Controller = ServiceCacheElement :: GetController () ;
  5841. if ( t_Controller )
  5842. {
  5843. t_Controller->Shutdown ( ServiceCacheElement :: GetKey () ) ;
  5844. }
  5845. if ( t_Cached )
  5846. {
  5847. t_Result = ForceReload () ;
  5848. }
  5849. return t_Result ;
  5850. }
  5851. /******************************************************************************
  5852. *
  5853. * Name:
  5854. *
  5855. *
  5856. * Description:
  5857. *
  5858. *
  5859. *****************************************************************************/
  5860. HRESULT CInterceptor_IWbemProvider :: Expel (
  5861. long a_Flags ,
  5862. IWbemContext *a_Context
  5863. )
  5864. {
  5865. HRESULT t_Result = S_OK ;
  5866. CWbemGlobal_IWmiProviderController *t_Controller = ServiceCacheElement :: GetController () ;
  5867. if ( t_Controller )
  5868. {
  5869. t_Controller->Shutdown ( ServiceCacheElement :: GetKey () ) ;
  5870. }
  5871. return t_Result ;
  5872. }
  5873. /******************************************************************************
  5874. *
  5875. * Name:
  5876. *
  5877. *
  5878. * Description:
  5879. *
  5880. *
  5881. *****************************************************************************/
  5882. HRESULT CInterceptor_IWbemProvider :: Violation (
  5883. long a_Flags ,
  5884. IWbemContext *a_Context ,
  5885. IWbemClassObject *a_Object
  5886. )
  5887. {
  5888. HRESULT t_Result = S_OK ;
  5889. t_Result = AbnormalShutdown () ;
  5890. return t_Result ;
  5891. }
  5892. /******************************************************************************
  5893. *
  5894. * Name:
  5895. *
  5896. *
  5897. * Description:
  5898. *
  5899. *
  5900. *****************************************************************************/
  5901. HRESULT CInterceptor_IWbemProvider :: Shutdown (
  5902. LONG a_Flags ,
  5903. ULONG a_MaxMilliSeconds ,
  5904. IWbemContext *a_Context
  5905. )
  5906. {
  5907. HRESULT t_Result = S_OK ;
  5908. IWbemShutdown *t_Shutdown = NULL ;
  5909. if ( m_Unknown )
  5910. {
  5911. t_Result = m_Unknown->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  5912. if ( SUCCEEDED ( t_Result ) )
  5913. {
  5914. t_Result = t_Shutdown->Shutdown (
  5915. a_Flags ,
  5916. a_MaxMilliSeconds ,
  5917. a_Context
  5918. ) ;
  5919. t_Shutdown->Release () ;
  5920. }
  5921. }
  5922. Lock () ;
  5923. CWbemGlobal_IWmiObjectSinkController_Container *t_Container = NULL ;
  5924. GetContainer ( t_Container ) ;
  5925. LONG t_Size = t_Container->Size ();
  5926. IWbemShutdown **t_ShutdownElements = new IWbemShutdown * [ t_Size ] ;
  5927. if ( t_ShutdownElements )
  5928. {
  5929. //DBG_PRINTFA((pBuff,"WINMGMT:CInterceptor_IWbemProvider %p sinks %d\n",this,t_Size));
  5930. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator = t_Container->Begin ();
  5931. ULONG t_Count = 0 ;
  5932. while ( ! t_Iterator.Null () )
  5933. {
  5934. t_Result = t_Iterator.GetElement ()->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_ShutdownElements [ t_Count ] ) ;
  5935. t_Iterator.Increment () ;
  5936. t_Count ++ ;
  5937. }
  5938. UnLock () ;
  5939. for ( ULONG t_Index = 0 ; t_Index < t_Count ; t_Index ++ )
  5940. {
  5941. if ( t_ShutdownElements [ t_Index ] )
  5942. {
  5943. CoDisconnectObject( t_ShutdownElements [ t_Index ] , 0);
  5944. t_Result = t_ShutdownElements [ t_Index ]->Shutdown (
  5945. a_Flags ,
  5946. a_MaxMilliSeconds ,
  5947. a_Context
  5948. ) ;
  5949. t_ShutdownElements [ t_Index ]->Release () ;
  5950. }
  5951. }
  5952. delete [] t_ShutdownElements ;
  5953. }
  5954. else
  5955. {
  5956. UnLock () ;
  5957. t_Result = WBEM_E_OUT_OF_MEMORY ;
  5958. }
  5959. CWbemGlobal_IWmiObjectSinkController :: Shutdown () ;
  5960. return t_Result ;
  5961. }
  5962. /******************************************************************************
  5963. *
  5964. * Name:
  5965. *
  5966. *
  5967. * Description:
  5968. *
  5969. *
  5970. *****************************************************************************/
  5971. HRESULT CInterceptor_IWbemProvider :: ForceReload ()
  5972. {
  5973. HRESULT t_Result = ProviderSubSystem_Globals :: ForwardReload (
  5974. _IWMIPROVSSSINK_FLAGS_RELOAD ,
  5975. NULL ,
  5976. m_Namespace ,
  5977. ServiceCacheElement :: GetKey ().m_Provider
  5978. ) ;
  5979. return t_Result ;
  5980. }
  5981. /******************************************************************************
  5982. *
  5983. * Name:
  5984. *
  5985. *
  5986. * Description:
  5987. *
  5988. *
  5989. *****************************************************************************/
  5990. HRESULT CInterceptor_IWbemProvider :: Unload (
  5991. long a_Flags ,
  5992. IWbemContext *a_Context
  5993. )
  5994. {
  5995. ProviderSubSystem_Globals :: InsertGuidTag ( m_Registration->GetClsid () ) ;
  5996. HRESULT t_Result = Shutdown (
  5997. 0 ,
  5998. 0 ,
  5999. a_Context
  6000. ) ;
  6001. t_Result = ProviderSubSystem_Globals :: ForwardReload (
  6002. _IWMIPROVSSSINK_FLAGS_UNLOAD ,
  6003. NULL ,
  6004. m_Namespace ,
  6005. ServiceCacheElement :: GetKey ().m_Provider
  6006. ) ;
  6007. return t_Result ;
  6008. }
  6009. /******************************************************************************
  6010. *
  6011. * Name:
  6012. *
  6013. *
  6014. * Description:
  6015. *
  6016. *
  6017. *****************************************************************************/
  6018. HRESULT CInterceptor_IWbemProvider :: Load (
  6019. long a_Flags ,
  6020. IWbemContext *a_Context
  6021. )
  6022. {
  6023. HRESULT t_Result = ProviderSubSystem_Globals :: ForwardReload (
  6024. _IWMIPROVSSSINK_FLAGS_LOAD ,
  6025. NULL ,
  6026. m_Namespace ,
  6027. ServiceCacheElement :: GetKey ().m_Provider
  6028. ) ;
  6029. return t_Result ;
  6030. }