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.

5450 lines
128 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. XXXX
  5. Abstract:
  6. History:
  7. --*/
  8. #include "PreComp.h"
  9. #include <wbemint.h>
  10. #include <wmiutils.h>
  11. #include "Globals.h"
  12. #include "ProvRegDeCoupled.h"
  13. #include "CGlobals.h"
  14. #include "provcache.h"
  15. #include "aggregator.h"
  16. #include "ProvWsvS.h"
  17. #include "ProvWsv.h"
  18. #include "ProvInSk.h"
  19. #include "ProvobSk.h"
  20. #include "Guids.h"
  21. /******************************************************************************
  22. *
  23. * Name:
  24. *
  25. *
  26. * Description:
  27. *
  28. *
  29. *****************************************************************************/
  30. #pragma warning( disable : 4355 )
  31. SECURITY_IMPERSONATION_LEVEL RpcToNT(DWORD impersonation)
  32. {
  33. switch(impersonation)
  34. {
  35. case RPC_C_IMP_LEVEL_IMPERSONATE:
  36. return SecurityImpersonation;
  37. case RPC_C_IMP_LEVEL_ANONYMOUS:
  38. return SecurityAnonymous;
  39. case RPC_C_IMP_LEVEL_IDENTIFY:
  40. return SecurityIdentification;
  41. case RPC_C_IMP_LEVEL_DELEGATE:
  42. return SecurityDelegation;
  43. default:
  44. #ifdef DBG
  45. DebugBreak();
  46. #endif
  47. return SECURITY_IMPERSONATION_LEVEL(0);
  48. };
  49. }
  50. CDecoupled_IWbemUnboundObjectSink :: CDecoupled_IWbemUnboundObjectSink (
  51. WmiAllocator &a_Allocator ,
  52. IUnknown *a_ServerSideProvider ,
  53. CWbemGlobal_IWmiObjectSinkController *a_Controller ,
  54. CServerObject_ProviderRegistrationV1 &a_Registration
  55. ) : VoidPointerContainerElement (
  56. a_Controller ,
  57. this
  58. ) ,
  59. m_Allocator ( a_Allocator ) ,
  60. m_Controller ( NULL ) ,
  61. m_Unknown ( NULL ) ,
  62. m_Provider_IWbemUnboundObjectSink ( NULL ) ,
  63. m_Provider_Internal_IWbemUnboundObjectSink ( NULL ) ,
  64. m_Registration ( & a_Registration ) ,
  65. m_ProxyContainer ( a_Allocator , ProxyIndex_UnBound_Size , MAX_PROXIES ) ,
  66. m_ProcessIdentifier ( 0 ) ,
  67. m_InitializeResult ( S_OK )
  68. {
  69. InterlockedIncrement ( & DecoupledProviderSubSystem_Globals :: s_CDecoupled_IWbemUnboundObjectSink_ObjectsInProgress ) ;
  70. InterlockedIncrement(&DecoupledProviderSubSystem_Globals::s_ObjectsInProgress);
  71. if ( m_Registration )
  72. {
  73. m_Registration->AddRef () ;
  74. }
  75. m_InitializeResult = a_Controller->QueryInterface ( IID__IWmiProviderAbnormalShutdown , ( void ** ) & m_Controller ) ;
  76. if ( SUCCEEDED ( m_InitializeResult ) )
  77. {
  78. if ( a_ServerSideProvider )
  79. {
  80. m_Unknown = a_ServerSideProvider ;
  81. m_Unknown->AddRef () ;
  82. m_InitializeResult = a_ServerSideProvider->QueryInterface ( IID_IWbemUnboundObjectSink , ( void ** ) & m_Provider_IWbemUnboundObjectSink ) ;
  83. if ( SUCCEEDED ( m_InitializeResult ) )
  84. {
  85. m_InitializeResult = a_ServerSideProvider->QueryInterface ( IID_Internal_IWbemUnboundObjectSink , ( void ** ) & m_Provider_Internal_IWbemUnboundObjectSink ) ;
  86. }
  87. }
  88. }
  89. }
  90. #pragma warning( default : 4355 )
  91. /******************************************************************************
  92. *
  93. * Name:
  94. *
  95. *
  96. * Description:
  97. *
  98. *
  99. *****************************************************************************/
  100. CDecoupled_IWbemUnboundObjectSink :: ~CDecoupled_IWbemUnboundObjectSink ()
  101. {
  102. if ( m_Controller )
  103. {
  104. m_Controller->Release () ;
  105. }
  106. if ( m_Unknown )
  107. {
  108. m_Unknown->Release () ;
  109. }
  110. if ( m_Provider_IWbemUnboundObjectSink )
  111. {
  112. m_Provider_IWbemUnboundObjectSink->Release () ;
  113. }
  114. if ( m_Provider_Internal_IWbemUnboundObjectSink )
  115. {
  116. m_Provider_Internal_IWbemUnboundObjectSink->Release () ;
  117. }
  118. if ( m_Registration )
  119. {
  120. m_Registration->Release () ;
  121. }
  122. InterlockedDecrement ( & DecoupledProviderSubSystem_Globals :: s_CDecoupled_IWbemUnboundObjectSink_ObjectsInProgress ) ;
  123. InterlockedDecrement(&DecoupledProviderSubSystem_Globals::s_ObjectsInProgress);
  124. }
  125. /******************************************************************************
  126. *
  127. * Name:
  128. *
  129. *
  130. * Description:
  131. *
  132. *
  133. *****************************************************************************/
  134. HRESULT CDecoupled_IWbemUnboundObjectSink :: Initialize ()
  135. {
  136. if ( SUCCEEDED ( m_InitializeResult ) )
  137. {
  138. WmiStatusCode t_StatusCode = m_ProxyContainer.Initialize () ;
  139. if ( t_StatusCode != e_StatusCode_Success )
  140. {
  141. m_InitializeResult = WBEM_E_OUT_OF_MEMORY ;
  142. }
  143. }
  144. if ( SUCCEEDED ( m_InitializeResult ) )
  145. {
  146. _IWmiProviderSite *t_Site = NULL ;
  147. m_InitializeResult = m_Unknown->QueryInterface ( IID__IWmiProviderSite , ( void ** ) & t_Site ) ;
  148. if ( SUCCEEDED ( m_InitializeResult ) )
  149. {
  150. m_InitializeResult = t_Site->GetSite ( & m_ProcessIdentifier ) ;
  151. t_Site->Release () ;
  152. }
  153. }
  154. return m_InitializeResult ;
  155. }
  156. /******************************************************************************
  157. *
  158. * Name:
  159. *
  160. *
  161. * Description:
  162. *
  163. *
  164. *****************************************************************************/
  165. STDMETHODIMP_( ULONG ) CDecoupled_IWbemUnboundObjectSink :: AddRef ()
  166. {
  167. return VoidPointerContainerElement :: AddRef () ;
  168. }
  169. /******************************************************************************
  170. *
  171. * Name:
  172. *
  173. *
  174. * Description:
  175. *
  176. *
  177. *****************************************************************************/
  178. STDMETHODIMP_(ULONG) CDecoupled_IWbemUnboundObjectSink :: Release ()
  179. {
  180. return VoidPointerContainerElement :: Release () ;
  181. }
  182. /******************************************************************************
  183. *
  184. * Name:
  185. *
  186. *
  187. * Description:
  188. *
  189. *
  190. *****************************************************************************/
  191. STDMETHODIMP CDecoupled_IWbemUnboundObjectSink :: QueryInterface (
  192. REFIID iid ,
  193. LPVOID FAR *iplpv
  194. )
  195. {
  196. *iplpv = NULL ;
  197. if ( iid == IID_IUnknown )
  198. {
  199. *iplpv = ( LPVOID ) this ;
  200. }
  201. else if ( iid == IID_IWbemUnboundObjectSink )
  202. {
  203. if ( m_Provider_IWbemUnboundObjectSink )
  204. {
  205. *iplpv = ( LPVOID ) ( IWbemUnboundObjectSink * ) this ;
  206. }
  207. }
  208. else if ( iid == IID_IWbemShutdown )
  209. {
  210. *iplpv = ( LPVOID ) ( IWbemShutdown * ) this ;
  211. }
  212. if ( *iplpv )
  213. {
  214. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  215. return ResultFromScode ( S_OK ) ;
  216. }
  217. else
  218. {
  219. return ResultFromScode ( E_NOINTERFACE ) ;
  220. }
  221. }
  222. /******************************************************************************
  223. *
  224. * Name:
  225. *
  226. *
  227. * Description:
  228. *
  229. *
  230. *****************************************************************************/
  231. HRESULT CDecoupled_IWbemUnboundObjectSink :: Begin_Interface (
  232. IUnknown *a_ServerInterface ,
  233. REFIID a_InterfaceIdentifier ,
  234. DWORD a_ProxyIndex ,
  235. IUnknown *a_InternalServerInterface ,
  236. REFIID a_InternalInterfaceIdentifier ,
  237. DWORD a_InternalProxyIndex ,
  238. DWORD a_ProcessIdentifier ,
  239. HANDLE &a_IdentifyToken ,
  240. BOOL &a_Impersonating ,
  241. IUnknown *&a_OldContext ,
  242. IServerSecurity *&a_OldSecurity ,
  243. BOOL &a_IsProxy ,
  244. IUnknown *&a_Interface ,
  245. BOOL &a_Revert ,
  246. IUnknown *&a_Proxy ,
  247. IWbemContext *a_Context
  248. )
  249. {
  250. HRESULT t_Result = S_OK ;
  251. if (!OS::secureOS_)
  252. {
  253. a_Interface = a_ServerInterface ;
  254. a_IsProxy = FALSE ;
  255. return S_OK;
  256. }
  257. a_IdentifyToken = NULL ;
  258. a_Revert = FALSE ;
  259. a_Proxy = NULL ;
  260. a_Impersonating = FALSE ;
  261. a_OldContext = NULL ;
  262. a_OldSecurity = NULL ;
  263. DWORD t_AuthenticationLevel = 0 ;
  264. t_Result = DecoupledProviderSubSystem_Globals :: BeginImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating , & t_AuthenticationLevel ) ;
  265. if ( SUCCEEDED ( t_Result ) )
  266. {
  267. if ( a_ProcessIdentifier )
  268. {
  269. t_Result = OS::CoImpersonateClient () ;
  270. if ( SUCCEEDED ( t_Result ) )
  271. {
  272. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  273. CoRevertToSelf () ;
  274. if ( (t_ImpersonationLevel == RPC_C_IMP_LEVEL_IMPERSONATE || t_ImpersonationLevel == RPC_C_IMP_LEVEL_DELEGATE) && (OS::osVer_ > OS::NT4))
  275. {
  276. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState (
  277. m_ProxyContainer ,
  278. a_ProxyIndex ,
  279. a_InterfaceIdentifier ,
  280. a_ServerInterface ,
  281. a_Proxy ,
  282. a_Revert
  283. ) ;
  284. }
  285. else
  286. {
  287. if ( m_Registration->GetComRegistration ().GetDecoupledImpersonationRestriction () )
  288. {
  289. t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
  290. }
  291. WORD t_AceSize = 0 ;
  292. ACCESS_ALLOWED_ACE *t_Ace = NULL ;
  293. t_Result = DecoupledProviderSubSystem_Globals :: GetAceWithProcessTokenUser (
  294. a_ProcessIdentifier ,
  295. t_AceSize ,
  296. t_Ace
  297. ) ;
  298. if ( SUCCEEDED ( t_Result ) )
  299. {
  300. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState_SvcHost (
  301. m_ProxyContainer ,
  302. a_InternalProxyIndex ,
  303. a_InterfaceIdentifier ,
  304. a_InternalServerInterface ,
  305. a_Proxy ,
  306. a_Revert ,
  307. a_ProcessIdentifier ,
  308. a_IdentifyToken ,
  309. t_Ace ,
  310. t_AceSize,
  311. RpcToNT(t_ImpersonationLevel)
  312. ) ;
  313. delete [] ( BYTE * ) t_Ace ;
  314. }
  315. }
  316. }
  317. }
  318. else
  319. {
  320. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState (
  321. m_ProxyContainer ,
  322. a_ProxyIndex ,
  323. a_InterfaceIdentifier ,
  324. a_ServerInterface ,
  325. a_Proxy ,
  326. a_Revert
  327. ) ;
  328. }
  329. if ( t_Result == WBEM_E_NOT_FOUND )
  330. {
  331. a_Interface = a_ServerInterface ;
  332. a_IsProxy = FALSE ;
  333. t_Result = S_OK ;
  334. }
  335. else
  336. {
  337. if ( SUCCEEDED ( t_Result ) )
  338. {
  339. a_IsProxy = TRUE ;
  340. a_Interface = ( IUnknown * ) a_Proxy ;
  341. // Set cloaking on the proxy
  342. // =========================
  343. DWORD t_ImpersonationLevel ;
  344. if ( m_Registration->GetComRegistration ().GetDecoupledImpersonationRestriction () )
  345. {
  346. t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
  347. }
  348. else
  349. {
  350. t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  351. }
  352. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  353. a_Interface ,
  354. RPC_C_AUTHN_LEVEL_CONNECT ,
  355. t_ImpersonationLevel
  356. ) ;
  357. if ( SUCCEEDED ( t_Result ) )
  358. {
  359. if ( a_Context )
  360. {
  361. VARIANT t_Variant ;
  362. VariantInit ( & t_Variant ) ;
  363. t_Variant.lVal = t_AuthenticationLevel ;
  364. t_Variant.vt = VT_I4 ;
  365. t_Result = a_Context->SetValue ( L"__WBEM_CLIENT_AUTHENTICATION_LEVEL" , 0, & t_Variant ) ;
  366. }
  367. }
  368. if ( FAILED ( t_Result ) )
  369. {
  370. if ( a_IdentifyToken )
  371. {
  372. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState_SvcHost (
  373. m_ProxyContainer ,
  374. a_InternalProxyIndex ,
  375. a_Proxy ,
  376. a_Revert ,
  377. a_ProcessIdentifier ,
  378. a_IdentifyToken
  379. ) ;
  380. }
  381. else
  382. {
  383. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState (
  384. m_ProxyContainer ,
  385. a_ProxyIndex ,
  386. a_Proxy ,
  387. a_Revert
  388. ) ;
  389. }
  390. }
  391. }
  392. }
  393. if ( FAILED ( t_Result ) )
  394. {
  395. DecoupledProviderSubSystem_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  396. }
  397. }
  398. return t_Result ;
  399. }
  400. /******************************************************************************
  401. *
  402. * Name:
  403. *
  404. *
  405. * Description:
  406. *
  407. *
  408. *****************************************************************************/
  409. HRESULT CDecoupled_IWbemUnboundObjectSink :: End_Interface (
  410. IUnknown *a_ServerInterface ,
  411. REFIID a_InterfaceIdentifier ,
  412. DWORD a_ProxyIndex ,
  413. IUnknown *a_InternalServerInterface ,
  414. REFIID a_InternalInterfaceIdentifier ,
  415. DWORD a_InternalProxyIndex ,
  416. DWORD a_ProcessIdentifier ,
  417. HANDLE a_IdentifyToken ,
  418. BOOL a_Impersonating ,
  419. IUnknown *a_OldContext ,
  420. IServerSecurity *a_OldSecurity ,
  421. BOOL a_IsProxy ,
  422. IUnknown *a_Interface ,
  423. BOOL a_Revert ,
  424. IUnknown *a_Proxy
  425. )
  426. {
  427. if (!OS::secureOS_)
  428. {
  429. return S_OK;
  430. }
  431. CoRevertToSelf () ;
  432. if ( a_Proxy )
  433. {
  434. if ( a_IdentifyToken )
  435. {
  436. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState_SvcHost (
  437. m_ProxyContainer ,
  438. a_InternalProxyIndex ,
  439. a_Proxy ,
  440. a_Revert ,
  441. a_ProcessIdentifier ,
  442. a_IdentifyToken
  443. ) ;
  444. }
  445. else
  446. {
  447. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState (
  448. m_ProxyContainer ,
  449. a_ProxyIndex ,
  450. a_Proxy ,
  451. a_Revert
  452. ) ;
  453. }
  454. }
  455. DecoupledProviderSubSystem_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  456. return S_OK ;
  457. }
  458. /******************************************************************************
  459. *
  460. * Name:
  461. *
  462. *
  463. * Description:
  464. *
  465. *
  466. *****************************************************************************/
  467. HRESULT CDecoupled_IWbemUnboundObjectSink :: IndicateToConsumer (
  468. IWbemClassObject *a_LogicalConsumer ,
  469. long a_ObjectCount ,
  470. IWbemClassObject **a_Objects
  471. )
  472. {
  473. if ( m_Provider_IWbemUnboundObjectSink )
  474. {
  475. IUnknown *t_ServerInterface = m_Provider_IWbemUnboundObjectSink ;
  476. REFIID t_InterfaceIdentifier = IID_IWbemUnboundObjectSink ;
  477. DWORD t_ProxyIndex = ProxyIndex_UnBound_IWbemUnboundObjectSink ;
  478. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemUnboundObjectSink ;
  479. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemUnboundObjectSink ;
  480. DWORD t_InternalProxyIndex = ProxyIndex_UnBound_Internal_IWbemUnboundObjectSink ;
  481. BOOL t_Impersonating ;
  482. IUnknown *t_OldContext ;
  483. IServerSecurity *t_OldSecurity ;
  484. BOOL t_IsProxy ;
  485. IUnknown *t_Interface ;
  486. BOOL t_Revert ;
  487. IUnknown *t_Proxy ;
  488. DWORD t_ProcessIdentifier = m_ProcessIdentifier ;
  489. HANDLE t_IdentifyToken = NULL ;
  490. HRESULT t_Result = Begin_Interface (
  491. t_ServerInterface ,
  492. t_InterfaceIdentifier ,
  493. t_ProxyIndex ,
  494. t_InternalServerInterface ,
  495. t_InternalInterfaceIdentifier ,
  496. t_InternalProxyIndex ,
  497. t_ProcessIdentifier ,
  498. t_IdentifyToken ,
  499. t_Impersonating ,
  500. t_OldContext ,
  501. t_OldSecurity ,
  502. t_IsProxy ,
  503. t_Interface ,
  504. t_Revert ,
  505. t_Proxy
  506. ) ;
  507. if ( SUCCEEDED ( t_Result ) )
  508. {
  509. if ( t_IdentifyToken )
  510. {
  511. WmiInternalContext t_InternalContext ;
  512. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  513. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  514. t_Result = ( ( Internal_IWbemUnboundObjectSink * ) t_Interface )->Internal_IndicateToConsumer (
  515. t_InternalContext ,
  516. a_LogicalConsumer ,
  517. a_ObjectCount ,
  518. a_Objects
  519. ) ;
  520. }
  521. else
  522. {
  523. t_Result = ( ( IWbemUnboundObjectSink * ) t_Interface )->IndicateToConsumer (
  524. a_LogicalConsumer ,
  525. a_ObjectCount ,
  526. a_Objects
  527. ) ;
  528. }
  529. End_Interface (
  530. t_ServerInterface ,
  531. t_InterfaceIdentifier ,
  532. t_ProxyIndex ,
  533. t_InternalServerInterface ,
  534. t_InternalInterfaceIdentifier ,
  535. t_InternalProxyIndex ,
  536. t_ProcessIdentifier ,
  537. t_IdentifyToken ,
  538. t_Impersonating ,
  539. t_OldContext ,
  540. t_OldSecurity ,
  541. t_IsProxy ,
  542. t_Interface ,
  543. t_Revert ,
  544. t_Proxy
  545. ) ;
  546. }
  547. if ( FAILED ( t_Result ) )
  548. {
  549. 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 ))
  550. {
  551. if ( m_Controller )
  552. {
  553. m_Controller->AbnormalShutdown () ;
  554. }
  555. }
  556. }
  557. return t_Result ;
  558. }
  559. return WBEM_E_PROVIDER_NOT_CAPABLE;
  560. }
  561. /******************************************************************************
  562. *
  563. * Name:
  564. *
  565. *
  566. * Description:
  567. *
  568. *
  569. *****************************************************************************/
  570. HRESULT CDecoupled_IWbemUnboundObjectSink :: Shutdown (
  571. LONG a_Flags ,
  572. ULONG a_MaxMilliSeconds ,
  573. IWbemContext *a_Context
  574. )
  575. {
  576. return S_OK ;
  577. }
  578. /******************************************************************************
  579. *
  580. * Name:
  581. *
  582. *
  583. * Description:
  584. *
  585. *
  586. *****************************************************************************/
  587. #pragma warning( disable : 4355 )
  588. CInterceptor_IWbemDecoupledProvider :: CInterceptor_IWbemDecoupledProvider (
  589. WmiAllocator &a_Allocator ,
  590. IUnknown *a_ServerSideProvider ,
  591. IWbemServices *a_CoreStub ,
  592. CWbemGlobal_IWbemSyncProviderController *a_Controller ,
  593. IWbemContext *a_InitializationContext ,
  594. CServerObject_ProviderRegistrationV1 &a_Registration ,
  595. GUID &a_Guid
  596. ) : CWbemGlobal_IWmiObjectSinkController ( a_Allocator ) ,
  597. SyncProviderContainerElement (
  598. a_Controller ,
  599. a_Guid
  600. ) ,
  601. m_Allocator ( a_Allocator ) ,
  602. m_Unknown ( NULL ) ,
  603. m_Provider_IWbemServices ( NULL ) ,
  604. m_Provider_IWbemPropertyProvider ( NULL ) ,
  605. m_Provider_IWbemEventProvider ( NULL ) ,
  606. m_Provider_IWbemEventProviderQuerySink ( NULL ) ,
  607. m_Provider_IWbemEventProviderSecurity ( NULL ) ,
  608. m_Provider_IWbemEventConsumerProvider ( NULL ) ,
  609. m_Provider_IWbemEventConsumerProviderEx ( NULL ) ,
  610. m_Provider_IWbemUnboundObjectSink ( NULL ) ,
  611. m_Provider_IWbemProviderInit ( NULL ) ,
  612. m_Provider_IWbemProviderIdentity ( NULL ) ,
  613. m_Provider_Internal_IWbemServices ( NULL ) ,
  614. m_Provider_Internal_IWbemPropertyProvider ( NULL ) ,
  615. m_Provider_Internal_IWbemEventProvider ( NULL ) ,
  616. m_Provider_Internal_IWbemEventProviderQuerySink ( NULL ) ,
  617. m_Provider_Internal_IWbemEventProviderSecurity ( NULL ) ,
  618. m_Provider_Internal_IWbemEventConsumerProvider ( NULL ) ,
  619. m_Provider_Internal_IWbemEventConsumerProviderEx ( NULL ) ,
  620. m_Provider_Internal_IWbemUnboundObjectSink ( NULL ) ,
  621. m_Provider_Internal_IWmiProviderConfiguration ( NULL ) ,
  622. m_Provider_Internal_IWbemProviderInit ( NULL ) ,
  623. m_Provider_Internal_IWbemProviderIdentity ( NULL ) ,
  624. m_ExtendedStatusObject ( NULL ) ,
  625. m_CoreStub ( a_CoreStub ) ,
  626. m_Registration ( & a_Registration ) ,
  627. m_Locale ( NULL ) ,
  628. m_User ( NULL ) ,
  629. m_Namespace ( NULL ) ,
  630. m_ProcessIdentifier ( 0 ) ,
  631. m_ProxyContainer ( a_Allocator , ProxyIndex_Provider_Size , MAX_PROXIES ) ,
  632. m_ProviderOperation_GetObjectAsync ( 0 ) ,
  633. m_ProviderOperation_PutClassAsync ( 0 ) ,
  634. m_ProviderOperation_DeleteClassAsync ( 0 ) ,
  635. m_ProviderOperation_CreateClassEnumAsync ( 0 ) ,
  636. m_ProviderOperation_PutInstanceAsync ( 0 ) ,
  637. m_ProviderOperation_DeleteInstanceAsync ( 0 ) ,
  638. m_ProviderOperation_CreateInstanceEnumAsync ( 0 ) ,
  639. m_ProviderOperation_ExecQueryAsync ( 0 ) ,
  640. m_ProviderOperation_ExecNotificationQueryAsync ( 0 ) ,
  641. m_ProviderOperation_ExecMethodAsync ( 0 ) ,
  642. m_ProviderOperation_QueryInstances ( 0 ) ,
  643. m_ProviderOperation_CreateRefresher ( 0 ) ,
  644. m_ProviderOperation_CreateRefreshableObject ( 0 ) ,
  645. m_ProviderOperation_StopRefreshing ( 0 ) ,
  646. m_ProviderOperation_CreateRefreshableEnum ( 0 ) ,
  647. m_ProviderOperation_GetObjects ( 0 ) ,
  648. m_ProviderOperation_GetProperty ( 0 ) ,
  649. m_ProviderOperation_PutProperty ( 0 ) ,
  650. m_ProviderOperation_ProvideEvents ( 0 ) ,
  651. m_ProviderOperation_NewQuery ( 0 ) ,
  652. m_ProviderOperation_CancelQuery ( 0 ) ,
  653. m_ProviderOperation_AccessCheck ( 0 ) ,
  654. m_ProviderOperation_SetRegistrationObject ( 0 ) ,
  655. m_ProviderOperation_FindConsumer ( 0 ) ,
  656. m_ProviderOperation_ValidateSubscription ( 0 ) ,
  657. m_Initialized ( 0 ) ,
  658. m_InitializeResult ( S_OK ) ,
  659. m_InitializedEvent ( NULL ) ,
  660. m_InitializationContext ( a_InitializationContext )
  661. {
  662. InterlockedIncrement ( & DecoupledProviderSubSystem_Globals :: s_CInterceptor_IWbemDecoupledProvider_ObjectsInProgress ) ;
  663. InterlockedIncrement(&DecoupledProviderSubSystem_Globals::s_ObjectsInProgress);
  664. if ( a_InitializationContext )
  665. {
  666. a_InitializationContext->AddRef () ;
  667. }
  668. if ( m_Registration )
  669. {
  670. m_Registration->AddRef () ;
  671. }
  672. if ( a_ServerSideProvider )
  673. {
  674. m_Unknown = a_ServerSideProvider ;
  675. m_Unknown->AddRef () ;
  676. HRESULT t_TempResult = m_Unknown->QueryInterface ( IID_IWbemServices , ( void ** ) & m_Provider_IWbemServices ) ;
  677. if ( SUCCEEDED ( t_TempResult ) )
  678. {
  679. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemServices , ( void ** ) & m_Provider_Internal_IWbemServices ) ;
  680. if ( FAILED ( t_TempResult ) )
  681. {
  682. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  683. }
  684. }
  685. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemPropertyProvider , ( void ** ) & m_Provider_IWbemPropertyProvider ) ;
  686. if ( SUCCEEDED ( t_TempResult ) )
  687. {
  688. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemPropertyProvider , ( void ** ) & m_Provider_Internal_IWbemPropertyProvider ) ;
  689. if ( FAILED ( t_TempResult ) )
  690. {
  691. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  692. }
  693. }
  694. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventProvider , ( void ** ) & m_Provider_IWbemEventProvider ) ;
  695. if ( SUCCEEDED ( t_TempResult ) )
  696. {
  697. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventProvider , ( void ** ) & m_Provider_Internal_IWbemEventProvider ) ;
  698. if ( FAILED ( t_TempResult ) )
  699. {
  700. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  701. }
  702. }
  703. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventProviderQuerySink , ( void ** ) & m_Provider_IWbemEventProviderQuerySink ) ;
  704. if ( SUCCEEDED ( t_TempResult ) )
  705. {
  706. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventProviderQuerySink , ( void ** ) & m_Provider_Internal_IWbemEventProviderQuerySink ) ;
  707. if ( FAILED ( t_TempResult ) )
  708. {
  709. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  710. }
  711. }
  712. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventProviderSecurity , ( void ** ) & m_Provider_IWbemEventProviderSecurity ) ;
  713. if ( SUCCEEDED ( t_TempResult ) )
  714. {
  715. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventProviderSecurity , ( void ** ) & m_Provider_Internal_IWbemEventProviderSecurity ) ;
  716. if ( FAILED ( t_TempResult ) )
  717. {
  718. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  719. }
  720. }
  721. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemUnboundObjectSink , ( void ** ) & m_Provider_IWbemUnboundObjectSink ) ;
  722. if ( SUCCEEDED ( t_TempResult ) )
  723. {
  724. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemUnboundObjectSink , ( void ** ) & m_Provider_Internal_IWbemUnboundObjectSink ) ;
  725. if ( FAILED ( t_TempResult ) )
  726. {
  727. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  728. }
  729. }
  730. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventConsumerProvider , ( void ** ) & m_Provider_IWbemEventConsumerProvider ) ;
  731. if ( SUCCEEDED ( t_TempResult ) )
  732. {
  733. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventConsumerProvider , ( void ** ) & m_Provider_Internal_IWbemEventConsumerProvider ) ;
  734. if ( FAILED ( t_TempResult ) )
  735. {
  736. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  737. }
  738. }
  739. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemEventConsumerProviderEx , ( void ** ) & m_Provider_IWbemEventConsumerProviderEx ) ;
  740. if ( SUCCEEDED ( t_TempResult ) )
  741. {
  742. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemEventConsumerProviderEx , ( void ** ) & m_Provider_Internal_IWbemEventConsumerProviderEx ) ;
  743. if ( FAILED ( t_TempResult ) )
  744. {
  745. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  746. }
  747. }
  748. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemProviderInit , ( void ** ) & m_Provider_IWbemProviderInit ) ;
  749. if ( SUCCEEDED ( t_TempResult ) )
  750. {
  751. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemProviderInit , ( void ** ) & m_Provider_Internal_IWbemProviderInit ) ;
  752. if ( FAILED ( t_TempResult ) )
  753. {
  754. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  755. }
  756. }
  757. t_TempResult = m_Unknown->QueryInterface ( IID_IWbemProviderIdentity , ( void ** ) & m_Provider_IWbemProviderIdentity ) ;
  758. if ( SUCCEEDED ( t_TempResult ) )
  759. {
  760. t_TempResult = m_Unknown->QueryInterface ( IID_Internal_IWbemProviderIdentity , ( void ** ) & m_Provider_Internal_IWbemProviderIdentity ) ;
  761. if ( FAILED ( t_TempResult ) )
  762. {
  763. m_InitializeResult = WBEM_E_PROVIDER_LOAD_FAILURE ;
  764. }
  765. }
  766. }
  767. if ( m_CoreStub )
  768. {
  769. m_CoreStub->AddRef () ;
  770. }
  771. }
  772. #pragma warning( default : 4355 )
  773. /******************************************************************************
  774. *
  775. * Name:
  776. *
  777. *
  778. * Description:
  779. *
  780. *
  781. *****************************************************************************/
  782. CInterceptor_IWbemDecoupledProvider :: ~CInterceptor_IWbemDecoupledProvider ()
  783. {
  784. if ( m_ExtendedStatusObject )
  785. {
  786. m_ExtendedStatusObject->Release () ;
  787. }
  788. if ( m_Unknown )
  789. {
  790. m_Unknown->Release () ;
  791. }
  792. if ( m_Provider_IWbemServices )
  793. {
  794. m_Provider_IWbemServices->Release () ;
  795. }
  796. if ( m_Provider_IWbemPropertyProvider )
  797. {
  798. m_Provider_IWbemPropertyProvider->Release () ;
  799. }
  800. if ( m_Provider_IWbemEventProvider )
  801. {
  802. m_Provider_IWbemEventProvider->Release () ;
  803. }
  804. if ( m_Provider_IWbemEventProviderQuerySink )
  805. {
  806. m_Provider_IWbemEventProviderQuerySink->Release () ;
  807. }
  808. if ( m_Provider_IWbemEventProviderSecurity )
  809. {
  810. m_Provider_IWbemEventProviderSecurity->Release () ;
  811. }
  812. if ( m_Provider_IWbemEventConsumerProviderEx )
  813. {
  814. m_Provider_IWbemEventConsumerProviderEx->Release () ;
  815. }
  816. if ( m_Provider_IWbemEventConsumerProvider )
  817. {
  818. m_Provider_IWbemEventConsumerProvider->Release () ;
  819. }
  820. if ( m_Provider_IWbemUnboundObjectSink )
  821. {
  822. m_Provider_IWbemUnboundObjectSink->Release () ;
  823. }
  824. if ( m_Provider_IWbemUnboundObjectSink )
  825. {
  826. m_Provider_IWbemUnboundObjectSink->Release () ;
  827. }
  828. if ( m_Provider_IWbemProviderInit )
  829. {
  830. m_Provider_IWbemProviderInit->Release () ;
  831. }
  832. if ( m_Provider_IWbemProviderIdentity )
  833. {
  834. m_Provider_IWbemProviderIdentity->Release () ;
  835. }
  836. if ( m_Provider_Internal_IWbemServices )
  837. {
  838. m_Provider_Internal_IWbemServices->Release () ;
  839. }
  840. if ( m_Provider_Internal_IWbemPropertyProvider )
  841. {
  842. m_Provider_Internal_IWbemPropertyProvider->Release () ;
  843. }
  844. if ( m_Provider_Internal_IWbemEventProvider )
  845. {
  846. m_Provider_Internal_IWbemEventProvider->Release () ;
  847. }
  848. if ( m_Provider_Internal_IWbemEventProviderQuerySink )
  849. {
  850. m_Provider_Internal_IWbemEventProviderQuerySink->Release () ;
  851. }
  852. if ( m_Provider_Internal_IWbemEventProviderSecurity )
  853. {
  854. m_Provider_Internal_IWbemEventProviderSecurity->Release () ;
  855. }
  856. if ( m_Provider_Internal_IWbemEventConsumerProvider )
  857. {
  858. m_Provider_Internal_IWbemEventConsumerProvider->Release () ;
  859. }
  860. if ( m_Provider_Internal_IWbemEventConsumerProviderEx )
  861. {
  862. m_Provider_Internal_IWbemEventConsumerProviderEx->Release () ;
  863. }
  864. if ( m_Provider_Internal_IWbemUnboundObjectSink )
  865. {
  866. m_Provider_Internal_IWbemUnboundObjectSink->Release () ;
  867. }
  868. if ( m_Provider_Internal_IWmiProviderConfiguration )
  869. {
  870. m_Provider_Internal_IWmiProviderConfiguration->Release () ;
  871. }
  872. if ( m_Provider_Internal_IWbemProviderInit )
  873. {
  874. m_Provider_Internal_IWbemProviderInit->Release () ;
  875. }
  876. if ( m_Provider_Internal_IWbemProviderIdentity )
  877. {
  878. m_Provider_Internal_IWbemProviderIdentity->Release () ;
  879. }
  880. if ( m_CoreStub )
  881. {
  882. m_CoreStub->Release () ;
  883. }
  884. WmiStatusCode t_StatusCode = m_ProxyContainer.UnInitialize () ;
  885. if ( m_InitializationContext )
  886. {
  887. m_InitializationContext->Release () ;
  888. }
  889. if ( m_InitializedEvent )
  890. {
  891. CloseHandle ( m_InitializedEvent ) ;
  892. }
  893. if ( m_Namespace )
  894. {
  895. SysFreeString ( m_Namespace ) ;
  896. }
  897. if ( m_Locale )
  898. {
  899. SysFreeString ( m_Locale ) ;
  900. }
  901. if ( m_User )
  902. {
  903. SysFreeString ( m_User ) ;
  904. }
  905. if ( m_Registration )
  906. {
  907. m_Registration->Release () ;
  908. }
  909. CWbemGlobal_IWmiObjectSinkController :: UnInitialize () ;
  910. InterlockedDecrement ( & DecoupledProviderSubSystem_Globals :: s_CInterceptor_IWbemDecoupledProvider_ObjectsInProgress ) ;
  911. InterlockedDecrement(&DecoupledProviderSubSystem_Globals::s_ObjectsInProgress);
  912. }
  913. /******************************************************************************
  914. *
  915. * Name:
  916. *
  917. *
  918. * Description:
  919. *
  920. *
  921. *****************************************************************************/
  922. STDMETHODIMP_( ULONG ) CInterceptor_IWbemDecoupledProvider :: AddRef ()
  923. {
  924. return SyncProviderContainerElement :: AddRef () ;
  925. }
  926. /******************************************************************************
  927. *
  928. * Name:
  929. *
  930. *
  931. * Description:
  932. *
  933. *
  934. *****************************************************************************/
  935. STDMETHODIMP_(ULONG) CInterceptor_IWbemDecoupledProvider :: Release ()
  936. {
  937. return SyncProviderContainerElement :: Release () ;
  938. }
  939. /******************************************************************************
  940. *
  941. * Name:
  942. *
  943. *
  944. * Description:
  945. *
  946. *
  947. *****************************************************************************/
  948. STDMETHODIMP CInterceptor_IWbemDecoupledProvider :: QueryInterface (
  949. REFIID iid ,
  950. LPVOID FAR *iplpv
  951. )
  952. {
  953. *iplpv = NULL ;
  954. if ( iid == IID_IUnknown )
  955. {
  956. *iplpv = ( LPVOID ) this ;
  957. }
  958. else if ( iid == IID_IWbemServices )
  959. {
  960. if ( m_Provider_IWbemServices )
  961. {
  962. *iplpv = ( LPVOID ) ( IWbemServices * ) this ;
  963. }
  964. }
  965. else if ( iid == IID_IWbemPropertyProvider )
  966. {
  967. if ( m_Provider_IWbemPropertyProvider )
  968. {
  969. *iplpv = ( LPVOID ) ( IWbemPropertyProvider * ) this ;
  970. }
  971. }
  972. else if ( iid == IID_IWbemEventProvider )
  973. {
  974. if ( m_Provider_IWbemEventProvider )
  975. {
  976. *iplpv = ( LPVOID ) ( IWbemEventProvider * ) this ;
  977. }
  978. }
  979. else if ( iid == IID_IWbemEventProviderQuerySink )
  980. {
  981. if ( m_Provider_IWbemEventProviderQuerySink )
  982. {
  983. *iplpv = ( LPVOID ) ( IWbemEventProviderQuerySink * ) this ;
  984. }
  985. }
  986. else if ( iid == IID_IWbemEventProviderSecurity )
  987. {
  988. if ( m_Provider_IWbemEventProviderSecurity )
  989. {
  990. *iplpv = ( LPVOID ) ( IWbemEventProviderSecurity * ) this ;
  991. }
  992. }
  993. else if ( iid == IID_IWbemEventConsumerProvider )
  994. {
  995. if ( m_Provider_IWbemEventConsumerProvider )
  996. {
  997. *iplpv = ( LPVOID ) ( IWbemEventConsumerProvider * ) this ;
  998. }
  999. }
  1000. else if ( iid == IID_IWbemEventConsumerProviderEx )
  1001. {
  1002. if ( m_Provider_IWbemEventConsumerProviderEx )
  1003. {
  1004. *iplpv = ( LPVOID ) ( IWbemEventConsumerProviderEx * ) this ;
  1005. }
  1006. }
  1007. else if ( iid == IID_IWbemUnboundObjectSink )
  1008. {
  1009. if ( m_Provider_IWbemUnboundObjectSink )
  1010. {
  1011. *iplpv = ( LPVOID ) ( IWbemUnboundObjectSink * ) this ;
  1012. }
  1013. }
  1014. else if ( iid == IID_IWbemProviderInit )
  1015. {
  1016. if ( m_Provider_IWbemProviderInit )
  1017. {
  1018. *iplpv = ( LPVOID ) ( IWbemProviderInit * ) this ;
  1019. }
  1020. }
  1021. else if ( iid == IID_IWbemProviderIdentity )
  1022. {
  1023. if ( m_Provider_IWbemProviderIdentity )
  1024. {
  1025. *iplpv = ( LPVOID ) ( IWbemProviderIdentity * ) this ;
  1026. }
  1027. }
  1028. else if ( iid == IID__IWmiProviderAbnormalShutdown )
  1029. {
  1030. *iplpv = ( LPVOID ) ( _IWmiProviderAbnormalShutdown * ) this ;
  1031. }
  1032. else if ( iid == IID_IWbemShutdown )
  1033. {
  1034. *iplpv = ( LPVOID ) ( IWbemShutdown * ) this ;
  1035. }
  1036. else if ( iid == IID_CWbemGlobal_IWmiObjectSinkController )
  1037. {
  1038. *iplpv = ( LPVOID ) ( CWbemGlobal_IWmiObjectSinkController * ) this ;
  1039. }
  1040. else if ( iid == IID_CacheElement )
  1041. {
  1042. *iplpv = ( LPVOID ) ( SyncProviderContainerElement * ) this ;
  1043. }
  1044. else if ( iid == IID__IWmiProviderInitialize )
  1045. {
  1046. *iplpv = ( LPVOID ) ( _IWmiProviderInitialize * ) this ;
  1047. }
  1048. if ( *iplpv )
  1049. {
  1050. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  1051. return ResultFromScode ( S_OK ) ;
  1052. }
  1053. else
  1054. {
  1055. return ResultFromScode ( E_NOINTERFACE ) ;
  1056. }
  1057. }
  1058. /******************************************************************************
  1059. *
  1060. * Name:
  1061. *
  1062. *
  1063. * Description:
  1064. *
  1065. *
  1066. *****************************************************************************/
  1067. HRESULT CInterceptor_IWbemDecoupledProvider :: Begin_Interface (
  1068. IUnknown *a_ServerInterface ,
  1069. REFIID a_InterfaceIdentifier ,
  1070. DWORD a_ProxyIndex ,
  1071. IUnknown *a_InternalServerInterface ,
  1072. REFIID a_InternalInterfaceIdentifier ,
  1073. DWORD a_InternalProxyIndex ,
  1074. DWORD a_ProcessIdentifier ,
  1075. HANDLE &a_IdentifyToken ,
  1076. BOOL &a_Impersonating ,
  1077. IUnknown *&a_OldContext ,
  1078. IServerSecurity *&a_OldSecurity ,
  1079. BOOL &a_IsProxy ,
  1080. IUnknown *&a_Interface ,
  1081. BOOL &a_Revert ,
  1082. IUnknown *&a_Proxy ,
  1083. IWbemContext *a_Context
  1084. )
  1085. {
  1086. if (!OS::secureOS_)
  1087. {
  1088. a_Interface = a_ServerInterface ;
  1089. a_IsProxy = FALSE ;
  1090. return S_OK;
  1091. }
  1092. HRESULT t_Result = S_OK ;
  1093. a_IdentifyToken = NULL ;
  1094. a_Revert = FALSE ;
  1095. a_Proxy = NULL ;
  1096. a_Impersonating = FALSE ;
  1097. a_OldContext = NULL ;
  1098. a_OldSecurity = NULL ;
  1099. DWORD t_AuthenticationLevel = 0 ;
  1100. t_Result = DecoupledProviderSubSystem_Globals :: BeginImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating , & t_AuthenticationLevel ) ;
  1101. if ( SUCCEEDED ( t_Result ) )
  1102. {
  1103. t_Result = OS::CoImpersonateClient () ;
  1104. if ( SUCCEEDED ( t_Result ) )
  1105. {
  1106. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1107. CoRevertToSelf () ;
  1108. if ( (t_ImpersonationLevel == RPC_C_IMP_LEVEL_IMPERSONATE || t_ImpersonationLevel == RPC_C_IMP_LEVEL_DELEGATE) && (OS::osVer_ > OS::NT4) )
  1109. {
  1110. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState (
  1111. m_ProxyContainer ,
  1112. a_ProxyIndex ,
  1113. a_InterfaceIdentifier ,
  1114. a_ServerInterface ,
  1115. a_Proxy ,
  1116. a_Revert
  1117. ) ;
  1118. }
  1119. else
  1120. {
  1121. WORD t_AceSize = 0 ;
  1122. ACCESS_ALLOWED_ACE *t_Ace = NULL ;
  1123. if ( m_Registration->GetComRegistration ().GetDecoupledImpersonationRestriction () )
  1124. {
  1125. t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
  1126. }
  1127. t_Result = DecoupledProviderSubSystem_Globals :: GetAceWithProcessTokenUser (
  1128. a_ProcessIdentifier ,
  1129. t_AceSize ,
  1130. t_Ace
  1131. ) ;
  1132. if ( SUCCEEDED ( t_Result ) )
  1133. {
  1134. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState_SvcHost (
  1135. m_ProxyContainer ,
  1136. a_InternalProxyIndex ,
  1137. a_InterfaceIdentifier ,
  1138. a_InternalServerInterface ,
  1139. a_Proxy ,
  1140. a_Revert ,
  1141. a_ProcessIdentifier ,
  1142. a_IdentifyToken ,
  1143. t_Ace ,
  1144. t_AceSize,
  1145. RpcToNT(t_ImpersonationLevel)
  1146. ) ;
  1147. delete [] ( BYTE * ) t_Ace ;
  1148. }
  1149. }
  1150. }
  1151. if ( t_Result == WBEM_E_NOT_FOUND )
  1152. {
  1153. a_Interface = a_ServerInterface ;
  1154. a_IsProxy = FALSE ;
  1155. t_Result = S_OK ;
  1156. }
  1157. else
  1158. {
  1159. if ( SUCCEEDED ( t_Result ) )
  1160. {
  1161. a_IsProxy = TRUE ;
  1162. a_Interface = ( IUnknown * ) a_Proxy ;
  1163. // Set cloaking on the proxy
  1164. // =========================
  1165. DWORD t_ImpersonationLevel ;
  1166. if ( m_Registration->GetComRegistration ().GetDecoupledImpersonationRestriction () )
  1167. {
  1168. t_ImpersonationLevel = RPC_C_IMP_LEVEL_IDENTIFY ;
  1169. }
  1170. else
  1171. {
  1172. t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1173. }
  1174. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1175. a_Interface ,
  1176. RPC_C_AUTHN_LEVEL_CONNECT ,
  1177. t_ImpersonationLevel
  1178. ) ;
  1179. if ( SUCCEEDED ( t_Result ) )
  1180. {
  1181. if ( a_Context )
  1182. {
  1183. VARIANT t_Variant ;
  1184. VariantInit ( & t_Variant ) ;
  1185. t_Variant.lVal = t_AuthenticationLevel ;
  1186. t_Variant.vt = VT_I4 ;
  1187. t_Result = a_Context->SetValue ( L"__WBEM_CLIENT_AUTHENTICATION_LEVEL" , 0, & t_Variant ) ;
  1188. }
  1189. }
  1190. if ( FAILED ( t_Result ) )
  1191. {
  1192. if ( a_IdentifyToken )
  1193. {
  1194. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState_SvcHost (
  1195. m_ProxyContainer ,
  1196. a_InternalProxyIndex ,
  1197. a_Proxy ,
  1198. a_Revert ,
  1199. a_ProcessIdentifier ,
  1200. a_IdentifyToken
  1201. ) ;
  1202. }
  1203. else
  1204. {
  1205. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState (
  1206. m_ProxyContainer ,
  1207. a_ProxyIndex ,
  1208. a_Proxy ,
  1209. a_Revert
  1210. ) ;
  1211. }
  1212. }
  1213. }
  1214. }
  1215. if ( FAILED ( t_Result ) )
  1216. {
  1217. DecoupledProviderSubSystem_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  1218. }
  1219. }
  1220. return t_Result ;
  1221. }
  1222. /******************************************************************************
  1223. *
  1224. * Name:
  1225. *
  1226. *
  1227. * Description:
  1228. *
  1229. *
  1230. *****************************************************************************/
  1231. HRESULT CInterceptor_IWbemDecoupledProvider :: End_Interface (
  1232. IUnknown *a_ServerInterface ,
  1233. REFIID a_InterfaceIdentifier ,
  1234. DWORD a_ProxyIndex ,
  1235. IUnknown *a_InternalServerInterface ,
  1236. REFIID a_InternalInterfaceIdentifier ,
  1237. DWORD a_InternalProxyIndex ,
  1238. DWORD a_ProcessIdentifier ,
  1239. HANDLE a_IdentifyToken ,
  1240. BOOL a_Impersonating ,
  1241. IUnknown *a_OldContext ,
  1242. IServerSecurity *a_OldSecurity ,
  1243. BOOL a_IsProxy ,
  1244. IUnknown *a_Interface ,
  1245. BOOL a_Revert ,
  1246. IUnknown *a_Proxy
  1247. )
  1248. {
  1249. if (!OS::secureOS_)
  1250. {
  1251. return S_OK;
  1252. }
  1253. CoRevertToSelf () ;
  1254. if ( a_Proxy )
  1255. {
  1256. if ( a_IdentifyToken )
  1257. {
  1258. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState_SvcHost (
  1259. m_ProxyContainer ,
  1260. a_InternalProxyIndex ,
  1261. a_Proxy ,
  1262. a_Revert ,
  1263. a_ProcessIdentifier ,
  1264. a_IdentifyToken
  1265. ) ;
  1266. }
  1267. else
  1268. {
  1269. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState (
  1270. m_ProxyContainer ,
  1271. a_ProxyIndex ,
  1272. a_Proxy ,
  1273. a_Revert
  1274. ) ;
  1275. }
  1276. }
  1277. DecoupledProviderSubSystem_Globals :: EndImpersonation ( a_OldContext , a_OldSecurity , a_Impersonating ) ;
  1278. return S_OK ;
  1279. }
  1280. /******************************************************************************
  1281. *
  1282. * Name:
  1283. *
  1284. *
  1285. * Description:
  1286. *
  1287. *
  1288. *****************************************************************************/
  1289. HRESULT CInterceptor_IWbemDecoupledProvider::OpenNamespace (
  1290. const BSTR a_ObjectPath ,
  1291. long a_Flags ,
  1292. IWbemContext *a_Context ,
  1293. IWbemServices **a_NamespaceService ,
  1294. IWbemCallResult **a_CallResult
  1295. )
  1296. {
  1297. return WBEM_E_NOT_AVAILABLE ;
  1298. }
  1299. /******************************************************************************
  1300. *
  1301. * Name:
  1302. *
  1303. *
  1304. * Description:
  1305. *
  1306. *
  1307. *****************************************************************************/
  1308. HRESULT CInterceptor_IWbemDecoupledProvider :: CancelAsyncCall (
  1309. IWbemObjectSink *a_Sink
  1310. )
  1311. {
  1312. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1313. if ( m_Provider_IWbemServices )
  1314. {
  1315. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1316. Lock () ;
  1317. WmiStatusCode t_StatusCode = Find (
  1318. a_Sink ,
  1319. t_Iterator
  1320. ) ;
  1321. if ( t_StatusCode == e_StatusCode_Success )
  1322. {
  1323. ObjectSinkContainerElement *t_Element = t_Iterator.GetElement () ;
  1324. UnLock () ;
  1325. IWbemObjectSink *t_ObjectSink = NULL ;
  1326. t_Result = t_Element->QueryInterface ( IID_IWbemObjectSink , ( void ** ) & t_ObjectSink ) ;
  1327. if ( SUCCEEDED ( t_Result ) )
  1328. {
  1329. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  1330. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  1331. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  1332. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  1333. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  1334. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  1335. BOOL t_Impersonating ;
  1336. IUnknown *t_OldContext ;
  1337. IServerSecurity *t_OldSecurity ;
  1338. BOOL t_IsProxy ;
  1339. IUnknown *t_Interface ;
  1340. BOOL t_Revert ;
  1341. IUnknown *t_Proxy ;
  1342. HANDLE t_IdentifyToken = NULL ;
  1343. t_Result = Begin_Interface (
  1344. t_ServerInterface ,
  1345. t_InterfaceIdentifier ,
  1346. t_ProxyIndex ,
  1347. t_InternalServerInterface ,
  1348. t_InternalInterfaceIdentifier ,
  1349. t_InternalProxyIndex ,
  1350. m_ProcessIdentifier ,
  1351. t_IdentifyToken ,
  1352. t_Impersonating ,
  1353. t_OldContext ,
  1354. t_OldSecurity ,
  1355. t_IsProxy ,
  1356. t_Interface ,
  1357. t_Revert ,
  1358. t_Proxy
  1359. ) ;
  1360. if ( SUCCEEDED ( t_Result ) )
  1361. {
  1362. if ( t_IdentifyToken )
  1363. {
  1364. WmiInternalContext t_InternalContext ;
  1365. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  1366. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  1367. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_CancelAsyncCall (
  1368. t_InternalContext ,
  1369. t_ObjectSink
  1370. ) ;
  1371. }
  1372. else
  1373. {
  1374. t_Result = ( ( IWbemServices * ) t_Interface )->CancelAsyncCall (
  1375. t_ObjectSink
  1376. ) ;
  1377. }
  1378. End_Interface (
  1379. t_ServerInterface ,
  1380. t_InterfaceIdentifier ,
  1381. t_ProxyIndex ,
  1382. t_InternalServerInterface ,
  1383. t_InternalInterfaceIdentifier ,
  1384. t_InternalProxyIndex ,
  1385. m_ProcessIdentifier ,
  1386. t_IdentifyToken ,
  1387. t_Impersonating ,
  1388. t_OldContext ,
  1389. t_OldSecurity ,
  1390. t_IsProxy ,
  1391. t_Interface ,
  1392. t_Revert ,
  1393. t_Proxy
  1394. ) ;
  1395. }
  1396. t_ObjectSink->Release () ;
  1397. }
  1398. IWbemShutdown *t_Shutdown = NULL ;
  1399. HRESULT t_TempResult = t_Element->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  1400. if ( SUCCEEDED ( t_TempResult ) )
  1401. {
  1402. t_TempResult = t_Shutdown->Shutdown (
  1403. 0 ,
  1404. 0 ,
  1405. NULL
  1406. ) ;
  1407. t_Shutdown->Release () ;
  1408. }
  1409. t_Element->Release () ;
  1410. }
  1411. else
  1412. {
  1413. UnLock () ;
  1414. t_Result = WBEM_E_NOT_FOUND ;
  1415. }
  1416. }
  1417. if ( FAILED ( t_Result ) )
  1418. {
  1419. 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 ))
  1420. {
  1421. AbnormalShutdown () ;
  1422. }
  1423. }
  1424. return t_Result ;
  1425. }
  1426. /******************************************************************************
  1427. *
  1428. * Name:
  1429. *
  1430. *
  1431. * Description:
  1432. *
  1433. *
  1434. *****************************************************************************/
  1435. HRESULT CInterceptor_IWbemDecoupledProvider :: QueryObjectSink (
  1436. long a_Flags ,
  1437. IWbemObjectSink **a_Sink
  1438. )
  1439. {
  1440. return WBEM_E_NOT_AVAILABLE ;
  1441. }
  1442. /******************************************************************************
  1443. *
  1444. * Name:
  1445. *
  1446. *
  1447. * Description:
  1448. *
  1449. *
  1450. *****************************************************************************/
  1451. HRESULT CInterceptor_IWbemDecoupledProvider :: GetObject (
  1452. const BSTR a_ObjectPath ,
  1453. long a_Flags ,
  1454. IWbemContext *a_Context ,
  1455. IWbemClassObject **a_Object ,
  1456. IWbemCallResult **a_CallResult
  1457. )
  1458. {
  1459. return WBEM_E_NOT_AVAILABLE ;
  1460. }
  1461. /******************************************************************************
  1462. *
  1463. * Name:
  1464. *
  1465. *
  1466. * Description:
  1467. *
  1468. *
  1469. *****************************************************************************/
  1470. HRESULT CInterceptor_IWbemDecoupledProvider :: GetObjectAsync (
  1471. const BSTR a_ObjectPath ,
  1472. long a_Flags ,
  1473. IWbemContext *a_Context ,
  1474. IWbemObjectSink *a_Sink
  1475. )
  1476. {
  1477. if ( m_Initialized == 0 )
  1478. {
  1479. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  1480. return WBEM_E_NOT_FOUND ;
  1481. }
  1482. BOOL t_DependantCall = FALSE ;
  1483. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1484. if ( m_Provider_IWbemServices )
  1485. {
  1486. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  1487. a_Sink ,
  1488. ( IWbemServices * ) this ,
  1489. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1490. ) ;
  1491. if ( t_Sink )
  1492. {
  1493. t_Sink->AddRef () ;
  1494. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  1495. if ( SUCCEEDED ( t_Result ) )
  1496. {
  1497. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1498. Lock () ;
  1499. WmiStatusCode t_StatusCode = Insert (
  1500. *t_Sink ,
  1501. t_Iterator
  1502. ) ;
  1503. if ( t_StatusCode == e_StatusCode_Success )
  1504. {
  1505. UnLock () ;
  1506. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  1507. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  1508. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  1509. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  1510. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  1511. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  1512. BOOL t_Impersonating ;
  1513. IUnknown *t_OldContext ;
  1514. IServerSecurity *t_OldSecurity ;
  1515. BOOL t_IsProxy ;
  1516. IUnknown *t_Interface ;
  1517. BOOL t_Revert ;
  1518. IUnknown *t_Proxy ;
  1519. HANDLE t_IdentifyToken = NULL ;
  1520. t_Result = Begin_Interface (
  1521. t_ServerInterface ,
  1522. t_InterfaceIdentifier ,
  1523. t_ProxyIndex ,
  1524. t_InternalServerInterface ,
  1525. t_InternalInterfaceIdentifier ,
  1526. t_InternalProxyIndex ,
  1527. m_ProcessIdentifier ,
  1528. t_IdentifyToken ,
  1529. t_Impersonating ,
  1530. t_OldContext ,
  1531. t_OldSecurity ,
  1532. t_IsProxy ,
  1533. t_Interface ,
  1534. t_Revert ,
  1535. t_Proxy
  1536. ) ;
  1537. if ( SUCCEEDED ( t_Result ) )
  1538. {
  1539. if ( t_IdentifyToken )
  1540. {
  1541. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  1542. if ( t_ObjectPath )
  1543. {
  1544. WmiInternalContext t_InternalContext ;
  1545. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  1546. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  1547. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_GetObjectAsync (
  1548. t_InternalContext ,
  1549. t_ObjectPath,
  1550. a_Flags,
  1551. a_Context ,
  1552. t_Sink
  1553. ) ;
  1554. SysFreeString ( t_ObjectPath ) ;
  1555. }
  1556. else
  1557. {
  1558. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1559. }
  1560. }
  1561. else
  1562. {
  1563. t_Result = ( ( IWbemServices * ) t_Interface )->GetObjectAsync (
  1564. a_ObjectPath,
  1565. a_Flags,
  1566. a_Context ,
  1567. t_Sink
  1568. ) ;
  1569. }
  1570. End_Interface (
  1571. t_ServerInterface ,
  1572. t_InterfaceIdentifier ,
  1573. t_ProxyIndex ,
  1574. t_InternalServerInterface ,
  1575. t_InternalInterfaceIdentifier ,
  1576. t_InternalProxyIndex ,
  1577. m_ProcessIdentifier ,
  1578. t_IdentifyToken ,
  1579. t_Impersonating ,
  1580. t_OldContext ,
  1581. t_OldSecurity ,
  1582. t_IsProxy ,
  1583. t_Interface ,
  1584. t_Revert ,
  1585. t_Proxy
  1586. ) ;
  1587. }
  1588. }
  1589. else
  1590. {
  1591. UnLock () ;
  1592. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1593. }
  1594. }
  1595. if ( FAILED ( t_Result ) )
  1596. {
  1597. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1598. }
  1599. t_Sink->Release () ;
  1600. }
  1601. else
  1602. {
  1603. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1604. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1605. }
  1606. }
  1607. else
  1608. {
  1609. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1610. }
  1611. if ( FAILED ( t_Result ) )
  1612. {
  1613. 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 ))
  1614. {
  1615. AbnormalShutdown () ;
  1616. }
  1617. }
  1618. return t_Result ;
  1619. }
  1620. /******************************************************************************
  1621. *
  1622. * Name:
  1623. *
  1624. *
  1625. * Description:
  1626. *
  1627. *
  1628. *****************************************************************************/
  1629. HRESULT CInterceptor_IWbemDecoupledProvider :: PutClass (
  1630. IWbemClassObject *a_Object ,
  1631. long a_Flags ,
  1632. IWbemContext *a_Context ,
  1633. IWbemCallResult **a_CallResult
  1634. )
  1635. {
  1636. return WBEM_E_NOT_AVAILABLE ;
  1637. }
  1638. /******************************************************************************
  1639. *
  1640. * Name:
  1641. *
  1642. *
  1643. * Description:
  1644. *
  1645. *
  1646. *****************************************************************************/
  1647. HRESULT CInterceptor_IWbemDecoupledProvider :: PutClassAsync (
  1648. IWbemClassObject *a_Object ,
  1649. long a_Flags ,
  1650. IWbemContext FAR *a_Context ,
  1651. IWbemObjectSink *a_Sink
  1652. )
  1653. {
  1654. if ( m_Initialized == 0 )
  1655. {
  1656. if ( WBEM_FLAG_ADVISORY & a_Flags )
  1657. {
  1658. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1659. return S_OK ;
  1660. }
  1661. else
  1662. {
  1663. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  1664. return WBEM_E_NOT_FOUND ;
  1665. }
  1666. }
  1667. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1668. if ( m_Provider_IWbemServices )
  1669. {
  1670. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  1671. a_Sink ,
  1672. ( IWbemServices * ) this ,
  1673. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1674. ) ;
  1675. if ( t_Sink )
  1676. {
  1677. t_Sink->AddRef () ;
  1678. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  1679. if ( SUCCEEDED ( t_Result ) )
  1680. {
  1681. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1682. Lock () ;
  1683. WmiStatusCode t_StatusCode = Insert (
  1684. *t_Sink ,
  1685. t_Iterator
  1686. ) ;
  1687. if ( t_StatusCode == e_StatusCode_Success )
  1688. {
  1689. UnLock () ;
  1690. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  1691. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  1692. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  1693. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  1694. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  1695. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  1696. BOOL t_Impersonating ;
  1697. IUnknown *t_OldContext ;
  1698. IServerSecurity *t_OldSecurity ;
  1699. BOOL t_IsProxy ;
  1700. IUnknown *t_Interface ;
  1701. BOOL t_Revert ;
  1702. IUnknown *t_Proxy ;
  1703. HANDLE t_IdentifyToken = NULL ;
  1704. t_Result = Begin_Interface (
  1705. t_ServerInterface ,
  1706. t_InterfaceIdentifier ,
  1707. t_ProxyIndex ,
  1708. t_InternalServerInterface ,
  1709. t_InternalInterfaceIdentifier ,
  1710. t_InternalProxyIndex ,
  1711. m_ProcessIdentifier ,
  1712. t_IdentifyToken ,
  1713. t_Impersonating ,
  1714. t_OldContext ,
  1715. t_OldSecurity ,
  1716. t_IsProxy ,
  1717. t_Interface ,
  1718. t_Revert ,
  1719. t_Proxy
  1720. ) ;
  1721. if ( SUCCEEDED ( t_Result ) )
  1722. {
  1723. if ( t_IdentifyToken )
  1724. {
  1725. WmiInternalContext t_InternalContext ;
  1726. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  1727. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  1728. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_PutClassAsync (
  1729. t_InternalContext ,
  1730. a_Object ,
  1731. a_Flags,
  1732. a_Context ,
  1733. t_Sink
  1734. ) ;
  1735. }
  1736. else
  1737. {
  1738. t_Result = ( ( IWbemServices * ) t_Interface )->PutClassAsync (
  1739. a_Object ,
  1740. a_Flags,
  1741. a_Context ,
  1742. t_Sink
  1743. ) ;
  1744. }
  1745. End_Interface (
  1746. t_ServerInterface ,
  1747. t_InterfaceIdentifier ,
  1748. t_ProxyIndex ,
  1749. t_InternalServerInterface ,
  1750. t_InternalInterfaceIdentifier ,
  1751. t_InternalProxyIndex ,
  1752. m_ProcessIdentifier ,
  1753. t_IdentifyToken ,
  1754. t_Impersonating ,
  1755. t_OldContext ,
  1756. t_OldSecurity ,
  1757. t_IsProxy ,
  1758. t_Interface ,
  1759. t_Revert ,
  1760. t_Proxy
  1761. ) ;
  1762. }
  1763. }
  1764. else
  1765. {
  1766. UnLock () ;
  1767. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1768. }
  1769. }
  1770. if ( FAILED ( t_Result ) )
  1771. {
  1772. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1773. }
  1774. t_Sink->Release () ;
  1775. }
  1776. else
  1777. {
  1778. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1779. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1780. }
  1781. }
  1782. else
  1783. {
  1784. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1785. }
  1786. if ( FAILED ( t_Result ) )
  1787. {
  1788. 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 ))
  1789. {
  1790. AbnormalShutdown () ;
  1791. }
  1792. }
  1793. return t_Result ;
  1794. }
  1795. /******************************************************************************
  1796. *
  1797. * Name:
  1798. *
  1799. *
  1800. * Description:
  1801. *
  1802. *
  1803. *****************************************************************************/
  1804. HRESULT CInterceptor_IWbemDecoupledProvider :: DeleteClass (
  1805. const BSTR a_Class ,
  1806. long a_Flags ,
  1807. IWbemContext *a_Context ,
  1808. IWbemCallResult **a_CallResult
  1809. )
  1810. {
  1811. return WBEM_E_NOT_AVAILABLE ;
  1812. }
  1813. /******************************************************************************
  1814. *
  1815. * Name:
  1816. *
  1817. *
  1818. * Description:
  1819. *
  1820. *
  1821. *****************************************************************************/
  1822. HRESULT CInterceptor_IWbemDecoupledProvider :: DeleteClassAsync (
  1823. const BSTR a_Class ,
  1824. long a_Flags,
  1825. IWbemContext *a_Context ,
  1826. IWbemObjectSink *a_Sink
  1827. )
  1828. {
  1829. if ( m_Initialized == 0 )
  1830. {
  1831. if ( WBEM_FLAG_ADVISORY & a_Flags )
  1832. {
  1833. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  1834. return S_OK ;
  1835. }
  1836. else
  1837. {
  1838. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  1839. return WBEM_E_NOT_FOUND ;
  1840. }
  1841. }
  1842. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1843. if ( m_Provider_IWbemServices )
  1844. {
  1845. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  1846. a_Sink ,
  1847. ( IWbemServices * ) this ,
  1848. ( CWbemGlobal_IWmiObjectSinkController * ) this
  1849. ) ;
  1850. if ( t_Sink )
  1851. {
  1852. t_Sink->AddRef () ;
  1853. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  1854. if ( SUCCEEDED ( t_Result ) )
  1855. {
  1856. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  1857. Lock () ;
  1858. WmiStatusCode t_StatusCode = Insert (
  1859. *t_Sink ,
  1860. t_Iterator
  1861. ) ;
  1862. if ( t_StatusCode == e_StatusCode_Success )
  1863. {
  1864. UnLock () ;
  1865. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  1866. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  1867. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  1868. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  1869. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  1870. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  1871. BOOL t_Impersonating ;
  1872. IUnknown *t_OldContext ;
  1873. IServerSecurity *t_OldSecurity ;
  1874. BOOL t_IsProxy ;
  1875. IUnknown *t_Interface ;
  1876. BOOL t_Revert ;
  1877. IUnknown *t_Proxy ;
  1878. HANDLE t_IdentifyToken = NULL ;
  1879. t_Result = Begin_Interface (
  1880. t_ServerInterface ,
  1881. t_InterfaceIdentifier ,
  1882. t_ProxyIndex ,
  1883. t_InternalServerInterface ,
  1884. t_InternalInterfaceIdentifier ,
  1885. t_InternalProxyIndex ,
  1886. m_ProcessIdentifier ,
  1887. t_IdentifyToken ,
  1888. t_Impersonating ,
  1889. t_OldContext ,
  1890. t_OldSecurity ,
  1891. t_IsProxy ,
  1892. t_Interface ,
  1893. t_Revert ,
  1894. t_Proxy
  1895. ) ;
  1896. if ( SUCCEEDED ( t_Result ) )
  1897. {
  1898. if ( t_IdentifyToken )
  1899. {
  1900. BSTR t_Class = SysAllocString ( a_Class ) ;
  1901. if ( t_Class )
  1902. {
  1903. WmiInternalContext t_InternalContext ;
  1904. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  1905. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  1906. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_DeleteClassAsync (
  1907. t_InternalContext ,
  1908. t_Class ,
  1909. a_Flags,
  1910. a_Context ,
  1911. t_Sink
  1912. ) ;
  1913. SysFreeString ( t_Class ) ;
  1914. }
  1915. else
  1916. {
  1917. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1918. }
  1919. }
  1920. else
  1921. {
  1922. t_Result = ( ( IWbemServices * ) t_Interface )->DeleteClassAsync (
  1923. a_Class ,
  1924. a_Flags,
  1925. a_Context ,
  1926. t_Sink
  1927. ) ;
  1928. }
  1929. End_Interface (
  1930. t_ServerInterface ,
  1931. t_InterfaceIdentifier ,
  1932. t_ProxyIndex ,
  1933. t_InternalServerInterface ,
  1934. t_InternalInterfaceIdentifier ,
  1935. t_InternalProxyIndex ,
  1936. m_ProcessIdentifier ,
  1937. t_IdentifyToken ,
  1938. t_Impersonating ,
  1939. t_OldContext ,
  1940. t_OldSecurity ,
  1941. t_IsProxy ,
  1942. t_Interface ,
  1943. t_Revert ,
  1944. t_Proxy
  1945. ) ;
  1946. }
  1947. }
  1948. else
  1949. {
  1950. UnLock () ;
  1951. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1952. }
  1953. }
  1954. if ( FAILED ( t_Result ) )
  1955. {
  1956. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1957. }
  1958. t_Sink->Release () ;
  1959. }
  1960. else
  1961. {
  1962. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1963. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1964. }
  1965. }
  1966. else
  1967. {
  1968. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  1969. }
  1970. if ( FAILED ( t_Result ) )
  1971. {
  1972. 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 ))
  1973. {
  1974. AbnormalShutdown () ;
  1975. }
  1976. }
  1977. return t_Result ;
  1978. }
  1979. /******************************************************************************
  1980. *
  1981. * Name:
  1982. *
  1983. *
  1984. * Description:
  1985. *
  1986. *
  1987. *****************************************************************************/
  1988. HRESULT CInterceptor_IWbemDecoupledProvider :: CreateClassEnum (
  1989. const BSTR a_Superclass ,
  1990. long a_Flags,
  1991. IWbemContext *a_Context ,
  1992. IEnumWbemClassObject **a_Enum
  1993. )
  1994. {
  1995. return WBEM_E_NOT_AVAILABLE ;
  1996. }
  1997. /******************************************************************************
  1998. *
  1999. * Name:
  2000. *
  2001. *
  2002. * Description:
  2003. *
  2004. *
  2005. *****************************************************************************/
  2006. SCODE CInterceptor_IWbemDecoupledProvider :: CreateClassEnumAsync (
  2007. const BSTR a_Superclass ,
  2008. long a_Flags ,
  2009. IWbemContext *a_Context ,
  2010. IWbemObjectSink *a_Sink
  2011. )
  2012. {
  2013. if ( m_Initialized == 0 )
  2014. {
  2015. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2016. return S_OK ;
  2017. }
  2018. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2019. if ( m_Provider_IWbemServices )
  2020. {
  2021. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2022. a_Sink ,
  2023. ( IWbemServices * ) this ,
  2024. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2025. ) ;
  2026. if ( t_Sink )
  2027. {
  2028. t_Sink->AddRef () ;
  2029. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2030. if ( SUCCEEDED ( t_Result ) )
  2031. {
  2032. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2033. Lock () ;
  2034. WmiStatusCode t_StatusCode = Insert (
  2035. *t_Sink ,
  2036. t_Iterator
  2037. ) ;
  2038. if ( t_StatusCode == e_StatusCode_Success )
  2039. {
  2040. UnLock () ;
  2041. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2042. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2043. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2044. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2045. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2046. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2047. BOOL t_Impersonating ;
  2048. IUnknown *t_OldContext ;
  2049. IServerSecurity *t_OldSecurity ;
  2050. BOOL t_IsProxy ;
  2051. IUnknown *t_Interface ;
  2052. BOOL t_Revert ;
  2053. IUnknown *t_Proxy ;
  2054. HANDLE t_IdentifyToken = NULL ;
  2055. t_Result = Begin_Interface (
  2056. t_ServerInterface ,
  2057. t_InterfaceIdentifier ,
  2058. t_ProxyIndex ,
  2059. t_InternalServerInterface ,
  2060. t_InternalInterfaceIdentifier ,
  2061. t_InternalProxyIndex ,
  2062. m_ProcessIdentifier ,
  2063. t_IdentifyToken ,
  2064. t_Impersonating ,
  2065. t_OldContext ,
  2066. t_OldSecurity ,
  2067. t_IsProxy ,
  2068. t_Interface ,
  2069. t_Revert ,
  2070. t_Proxy
  2071. ) ;
  2072. if ( SUCCEEDED ( t_Result ) )
  2073. {
  2074. if ( t_IdentifyToken )
  2075. {
  2076. BSTR t_Superclass = SysAllocString ( a_Superclass ) ;
  2077. if ( t_Superclass )
  2078. {
  2079. WmiInternalContext t_InternalContext ;
  2080. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2081. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2082. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_CreateClassEnumAsync (
  2083. t_InternalContext ,
  2084. t_Superclass ,
  2085. a_Flags,
  2086. a_Context ,
  2087. t_Sink
  2088. ) ;
  2089. SysFreeString ( t_Superclass ) ;
  2090. }
  2091. else
  2092. {
  2093. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2094. }
  2095. }
  2096. else
  2097. {
  2098. t_Result = ( ( IWbemServices * ) t_Interface )->CreateClassEnumAsync (
  2099. a_Superclass ,
  2100. a_Flags,
  2101. a_Context ,
  2102. t_Sink
  2103. ) ;
  2104. }
  2105. End_Interface (
  2106. t_ServerInterface ,
  2107. t_InterfaceIdentifier ,
  2108. t_ProxyIndex ,
  2109. t_InternalServerInterface ,
  2110. t_InternalInterfaceIdentifier ,
  2111. t_InternalProxyIndex ,
  2112. m_ProcessIdentifier ,
  2113. t_IdentifyToken ,
  2114. t_Impersonating ,
  2115. t_OldContext ,
  2116. t_OldSecurity ,
  2117. t_IsProxy ,
  2118. t_Interface ,
  2119. t_Revert ,
  2120. t_Proxy
  2121. ) ;
  2122. }
  2123. }
  2124. else
  2125. {
  2126. UnLock () ;
  2127. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2128. }
  2129. }
  2130. if ( FAILED ( t_Result ) )
  2131. {
  2132. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2133. }
  2134. t_Sink->Release () ;
  2135. }
  2136. else
  2137. {
  2138. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2139. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2140. }
  2141. }
  2142. else
  2143. {
  2144. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2145. }
  2146. if ( FAILED ( t_Result ) )
  2147. {
  2148. 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 ))
  2149. {
  2150. AbnormalShutdown () ;
  2151. }
  2152. }
  2153. return t_Result ;
  2154. }
  2155. /******************************************************************************
  2156. *
  2157. * Name:
  2158. *
  2159. *
  2160. * Description:
  2161. *
  2162. *
  2163. *****************************************************************************/
  2164. HRESULT CInterceptor_IWbemDecoupledProvider :: PutInstance (
  2165. IWbemClassObject *a_Instance ,
  2166. long a_Flags ,
  2167. IWbemContext *a_Context ,
  2168. IWbemCallResult **a_CallResult
  2169. )
  2170. {
  2171. return WBEM_E_NOT_AVAILABLE ;
  2172. }
  2173. /******************************************************************************
  2174. *
  2175. * Name:
  2176. *
  2177. *
  2178. * Description:
  2179. *
  2180. *
  2181. *****************************************************************************/
  2182. HRESULT CInterceptor_IWbemDecoupledProvider :: PutInstanceAsync (
  2183. IWbemClassObject *a_Instance ,
  2184. long a_Flags ,
  2185. IWbemContext *a_Context ,
  2186. IWbemObjectSink *a_Sink
  2187. )
  2188. {
  2189. if ( m_Initialized == 0 )
  2190. {
  2191. if ( WBEM_FLAG_ADVISORY & a_Flags )
  2192. {
  2193. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2194. return S_OK ;
  2195. }
  2196. else
  2197. {
  2198. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2199. return WBEM_E_NOT_FOUND ;
  2200. }
  2201. }
  2202. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2203. if ( m_Provider_IWbemServices )
  2204. {
  2205. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2206. a_Sink ,
  2207. ( IWbemServices * ) this ,
  2208. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2209. ) ;
  2210. if ( t_Sink )
  2211. {
  2212. t_Sink->AddRef () ;
  2213. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2214. if ( SUCCEEDED ( t_Result ) )
  2215. {
  2216. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2217. Lock () ;
  2218. WmiStatusCode t_StatusCode = Insert (
  2219. *t_Sink ,
  2220. t_Iterator
  2221. ) ;
  2222. if ( t_StatusCode == e_StatusCode_Success )
  2223. {
  2224. UnLock () ;
  2225. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2226. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2227. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2228. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2229. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2230. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2231. BOOL t_Impersonating ;
  2232. IUnknown *t_OldContext ;
  2233. IServerSecurity *t_OldSecurity ;
  2234. BOOL t_IsProxy ;
  2235. IUnknown *t_Interface ;
  2236. BOOL t_Revert ;
  2237. IUnknown *t_Proxy ;
  2238. HANDLE t_IdentifyToken = NULL ;
  2239. t_Result = Begin_Interface (
  2240. t_ServerInterface ,
  2241. t_InterfaceIdentifier ,
  2242. t_ProxyIndex ,
  2243. t_InternalServerInterface ,
  2244. t_InternalInterfaceIdentifier ,
  2245. t_InternalProxyIndex ,
  2246. m_ProcessIdentifier ,
  2247. t_IdentifyToken ,
  2248. t_Impersonating ,
  2249. t_OldContext ,
  2250. t_OldSecurity ,
  2251. t_IsProxy ,
  2252. t_Interface ,
  2253. t_Revert ,
  2254. t_Proxy
  2255. ) ;
  2256. if ( SUCCEEDED ( t_Result ) )
  2257. {
  2258. if ( t_IdentifyToken )
  2259. {
  2260. WmiInternalContext t_InternalContext ;
  2261. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2262. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2263. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_PutInstanceAsync (
  2264. t_InternalContext ,
  2265. a_Instance ,
  2266. a_Flags,
  2267. a_Context ,
  2268. t_Sink
  2269. ) ;
  2270. }
  2271. else
  2272. {
  2273. t_Result = ( ( IWbemServices * ) t_Interface )->PutInstanceAsync (
  2274. a_Instance ,
  2275. a_Flags,
  2276. a_Context ,
  2277. t_Sink
  2278. ) ;
  2279. }
  2280. End_Interface (
  2281. t_ServerInterface ,
  2282. t_InterfaceIdentifier ,
  2283. t_ProxyIndex ,
  2284. t_InternalServerInterface ,
  2285. t_InternalInterfaceIdentifier ,
  2286. t_InternalProxyIndex ,
  2287. m_ProcessIdentifier ,
  2288. t_IdentifyToken ,
  2289. t_Impersonating ,
  2290. t_OldContext ,
  2291. t_OldSecurity ,
  2292. t_IsProxy ,
  2293. t_Interface ,
  2294. t_Revert ,
  2295. t_Proxy
  2296. ) ;
  2297. }
  2298. }
  2299. else
  2300. {
  2301. UnLock () ;
  2302. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2303. }
  2304. }
  2305. if ( FAILED ( t_Result ) )
  2306. {
  2307. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2308. }
  2309. t_Sink->Release () ;
  2310. }
  2311. else
  2312. {
  2313. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2314. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2315. }
  2316. }
  2317. else
  2318. {
  2319. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2320. }
  2321. if ( FAILED ( t_Result ) )
  2322. {
  2323. 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 ))
  2324. {
  2325. AbnormalShutdown () ;
  2326. }
  2327. }
  2328. return t_Result ;
  2329. }
  2330. /******************************************************************************
  2331. *
  2332. * Name:
  2333. *
  2334. *
  2335. * Description:
  2336. *
  2337. *
  2338. *****************************************************************************/
  2339. HRESULT CInterceptor_IWbemDecoupledProvider :: DeleteInstance (
  2340. const BSTR a_ObjectPath ,
  2341. long a_Flags ,
  2342. IWbemContext *a_Context ,
  2343. IWbemCallResult **a_CallResult
  2344. )
  2345. {
  2346. return WBEM_E_NOT_AVAILABLE ;
  2347. }
  2348. /******************************************************************************
  2349. *
  2350. * Name:
  2351. *
  2352. *
  2353. * Description:
  2354. *
  2355. *
  2356. *****************************************************************************/
  2357. HRESULT CInterceptor_IWbemDecoupledProvider :: DeleteInstanceAsync (
  2358. const BSTR a_ObjectPath ,
  2359. long a_Flags ,
  2360. IWbemContext *a_Context ,
  2361. IWbemObjectSink *a_Sink
  2362. )
  2363. {
  2364. if ( m_Initialized == 0 )
  2365. {
  2366. if ( WBEM_FLAG_ADVISORY & a_Flags )
  2367. {
  2368. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2369. return S_OK ;
  2370. }
  2371. else
  2372. {
  2373. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2374. return WBEM_E_NOT_FOUND ;
  2375. }
  2376. }
  2377. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2378. if ( m_Provider_IWbemServices )
  2379. {
  2380. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2381. a_Sink ,
  2382. ( IWbemServices * ) this ,
  2383. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2384. ) ;
  2385. if ( t_Sink )
  2386. {
  2387. t_Sink->AddRef () ;
  2388. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2389. if ( SUCCEEDED ( t_Result ) )
  2390. {
  2391. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2392. Lock () ;
  2393. WmiStatusCode t_StatusCode = Insert (
  2394. *t_Sink ,
  2395. t_Iterator
  2396. ) ;
  2397. if ( t_StatusCode == e_StatusCode_Success )
  2398. {
  2399. UnLock () ;
  2400. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2401. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2402. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2403. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2404. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2405. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2406. BOOL t_Impersonating ;
  2407. IUnknown *t_OldContext ;
  2408. IServerSecurity *t_OldSecurity ;
  2409. BOOL t_IsProxy ;
  2410. IUnknown *t_Interface ;
  2411. BOOL t_Revert ;
  2412. IUnknown *t_Proxy ;
  2413. HANDLE t_IdentifyToken = NULL ;
  2414. t_Result = Begin_Interface (
  2415. t_ServerInterface ,
  2416. t_InterfaceIdentifier ,
  2417. t_ProxyIndex ,
  2418. t_InternalServerInterface ,
  2419. t_InternalInterfaceIdentifier ,
  2420. t_InternalProxyIndex ,
  2421. m_ProcessIdentifier ,
  2422. t_IdentifyToken ,
  2423. t_Impersonating ,
  2424. t_OldContext ,
  2425. t_OldSecurity ,
  2426. t_IsProxy ,
  2427. t_Interface ,
  2428. t_Revert ,
  2429. t_Proxy
  2430. ) ;
  2431. if ( SUCCEEDED ( t_Result ) )
  2432. {
  2433. if ( t_IdentifyToken )
  2434. {
  2435. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  2436. if ( t_ObjectPath )
  2437. {
  2438. WmiInternalContext t_InternalContext ;
  2439. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2440. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2441. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_DeleteInstanceAsync (
  2442. t_InternalContext ,
  2443. t_ObjectPath ,
  2444. a_Flags ,
  2445. a_Context ,
  2446. t_Sink
  2447. ) ;
  2448. SysFreeString ( t_ObjectPath ) ;
  2449. }
  2450. else
  2451. {
  2452. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2453. }
  2454. }
  2455. else
  2456. {
  2457. t_Result = ( ( IWbemServices * ) t_Interface )->DeleteInstanceAsync (
  2458. a_ObjectPath ,
  2459. a_Flags ,
  2460. a_Context ,
  2461. t_Sink
  2462. ) ;
  2463. }
  2464. End_Interface (
  2465. t_ServerInterface ,
  2466. t_InterfaceIdentifier ,
  2467. t_ProxyIndex ,
  2468. t_InternalServerInterface ,
  2469. t_InternalInterfaceIdentifier ,
  2470. t_InternalProxyIndex ,
  2471. m_ProcessIdentifier ,
  2472. t_IdentifyToken ,
  2473. t_Impersonating ,
  2474. t_OldContext ,
  2475. t_OldSecurity ,
  2476. t_IsProxy ,
  2477. t_Interface ,
  2478. t_Revert ,
  2479. t_Proxy
  2480. ) ;
  2481. }
  2482. }
  2483. else
  2484. {
  2485. UnLock () ;
  2486. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2487. }
  2488. }
  2489. if ( FAILED ( t_Result ) )
  2490. {
  2491. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2492. }
  2493. t_Sink->Release () ;
  2494. }
  2495. else
  2496. {
  2497. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2498. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2499. }
  2500. }
  2501. else
  2502. {
  2503. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2504. }
  2505. if ( FAILED ( t_Result ) )
  2506. {
  2507. 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 ))
  2508. {
  2509. AbnormalShutdown () ;
  2510. }
  2511. }
  2512. return t_Result ;
  2513. }
  2514. /******************************************************************************
  2515. *
  2516. * Name:
  2517. *
  2518. *
  2519. * Description:
  2520. *
  2521. *
  2522. *****************************************************************************/
  2523. HRESULT CInterceptor_IWbemDecoupledProvider :: CreateInstanceEnum (
  2524. const BSTR a_Class ,
  2525. long a_Flags ,
  2526. IWbemContext *a_Context ,
  2527. IEnumWbemClassObject **a_Enum
  2528. )
  2529. {
  2530. return WBEM_E_NOT_AVAILABLE ;
  2531. }
  2532. /******************************************************************************
  2533. *
  2534. * Name:
  2535. *
  2536. *
  2537. * Description:
  2538. *
  2539. *
  2540. *****************************************************************************/
  2541. HRESULT CInterceptor_IWbemDecoupledProvider :: CreateInstanceEnumAsync (
  2542. const BSTR a_Class ,
  2543. long a_Flags ,
  2544. IWbemContext *a_Context ,
  2545. IWbemObjectSink *a_Sink
  2546. )
  2547. {
  2548. if ( m_Initialized == 0 )
  2549. {
  2550. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2551. return S_OK ;
  2552. }
  2553. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2554. if ( m_Provider_IWbemServices )
  2555. {
  2556. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2557. a_Sink ,
  2558. ( IWbemServices * ) this ,
  2559. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2560. ) ;
  2561. if ( t_Sink )
  2562. {
  2563. t_Sink->AddRef () ;
  2564. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2565. if ( SUCCEEDED ( t_Result ) )
  2566. {
  2567. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2568. Lock () ;
  2569. WmiStatusCode t_StatusCode = Insert (
  2570. *t_Sink ,
  2571. t_Iterator
  2572. ) ;
  2573. if ( t_StatusCode == e_StatusCode_Success )
  2574. {
  2575. UnLock () ;
  2576. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2577. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2578. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2579. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2580. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2581. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2582. BOOL t_Impersonating ;
  2583. IUnknown *t_OldContext ;
  2584. IServerSecurity *t_OldSecurity ;
  2585. BOOL t_IsProxy ;
  2586. IUnknown *t_Interface ;
  2587. BOOL t_Revert ;
  2588. IUnknown *t_Proxy ;
  2589. HANDLE t_IdentifyToken = NULL ;
  2590. t_Result = Begin_Interface (
  2591. t_ServerInterface ,
  2592. t_InterfaceIdentifier ,
  2593. t_ProxyIndex ,
  2594. t_InternalServerInterface ,
  2595. t_InternalInterfaceIdentifier ,
  2596. t_InternalProxyIndex ,
  2597. m_ProcessIdentifier ,
  2598. t_IdentifyToken ,
  2599. t_Impersonating ,
  2600. t_OldContext ,
  2601. t_OldSecurity ,
  2602. t_IsProxy ,
  2603. t_Interface ,
  2604. t_Revert ,
  2605. t_Proxy
  2606. ) ;
  2607. if ( SUCCEEDED ( t_Result ) )
  2608. {
  2609. if ( t_IdentifyToken )
  2610. {
  2611. WmiInternalContext t_InternalContext ;
  2612. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2613. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2614. BSTR t_Class = SysAllocString ( a_Class ) ;
  2615. if ( t_Class )
  2616. {
  2617. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_CreateInstanceEnumAsync (
  2618. t_InternalContext ,
  2619. t_Class ,
  2620. a_Flags ,
  2621. a_Context ,
  2622. t_Sink
  2623. ) ;
  2624. SysFreeString ( t_Class ) ;
  2625. }
  2626. else
  2627. {
  2628. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2629. }
  2630. }
  2631. else
  2632. {
  2633. t_Result = ( ( IWbemServices * ) t_Interface )->CreateInstanceEnumAsync (
  2634. a_Class ,
  2635. a_Flags ,
  2636. a_Context ,
  2637. t_Sink
  2638. ) ;
  2639. }
  2640. End_Interface (
  2641. t_ServerInterface ,
  2642. t_InterfaceIdentifier ,
  2643. t_ProxyIndex ,
  2644. t_InternalServerInterface ,
  2645. t_InternalInterfaceIdentifier ,
  2646. t_InternalProxyIndex ,
  2647. m_ProcessIdentifier ,
  2648. t_IdentifyToken ,
  2649. t_Impersonating ,
  2650. t_OldContext ,
  2651. t_OldSecurity ,
  2652. t_IsProxy ,
  2653. t_Interface ,
  2654. t_Revert ,
  2655. t_Proxy
  2656. ) ;
  2657. }
  2658. }
  2659. else
  2660. {
  2661. UnLock () ;
  2662. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2663. }
  2664. }
  2665. if ( FAILED ( t_Result ) )
  2666. {
  2667. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2668. }
  2669. t_Sink->Release () ;
  2670. }
  2671. else
  2672. {
  2673. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2674. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2675. }
  2676. }
  2677. else
  2678. {
  2679. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2680. }
  2681. if ( FAILED ( t_Result ) )
  2682. {
  2683. 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 ))
  2684. {
  2685. AbnormalShutdown () ;
  2686. }
  2687. }
  2688. return t_Result ;
  2689. }
  2690. /******************************************************************************
  2691. *
  2692. * Name:
  2693. *
  2694. *
  2695. * Description:
  2696. *
  2697. *
  2698. *****************************************************************************/
  2699. HRESULT CInterceptor_IWbemDecoupledProvider :: ExecQuery (
  2700. const BSTR a_QueryLanguage ,
  2701. const BSTR a_Query ,
  2702. long a_Flags ,
  2703. IWbemContext *a_Context ,
  2704. IEnumWbemClassObject **a_Enum
  2705. )
  2706. {
  2707. return WBEM_E_NOT_AVAILABLE ;
  2708. }
  2709. /******************************************************************************
  2710. *
  2711. * Name:
  2712. *
  2713. *
  2714. * Description:
  2715. *
  2716. *
  2717. *****************************************************************************/
  2718. HRESULT CInterceptor_IWbemDecoupledProvider :: ExecQueryAsync (
  2719. const BSTR a_QueryLanguage ,
  2720. const BSTR a_Query,
  2721. long a_Flags,
  2722. IWbemContext *a_Context ,
  2723. IWbemObjectSink *a_Sink
  2724. )
  2725. {
  2726. if ( m_Initialized == 0 )
  2727. {
  2728. a_Sink->SetStatus ( 0 , S_OK , NULL , NULL ) ;
  2729. return S_OK ;
  2730. }
  2731. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  2732. if ( m_Provider_IWbemServices )
  2733. {
  2734. CInterceptor_IWbemFilteringObjectSink *t_Sink = new CInterceptor_IWbemFilteringObjectSink (
  2735. a_Sink ,
  2736. ( IWbemServices * ) this ,
  2737. ( CWbemGlobal_IWmiObjectSinkController * ) this ,
  2738. a_QueryLanguage ,
  2739. a_Query
  2740. ) ;
  2741. if ( t_Sink )
  2742. {
  2743. t_Sink->AddRef () ;
  2744. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2745. if ( SUCCEEDED ( t_Result ) )
  2746. {
  2747. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2748. Lock () ;
  2749. WmiStatusCode t_StatusCode = Insert (
  2750. *t_Sink ,
  2751. t_Iterator
  2752. ) ;
  2753. if ( t_StatusCode == e_StatusCode_Success )
  2754. {
  2755. UnLock () ;
  2756. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2757. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2758. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2759. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2760. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2761. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2762. BOOL t_Impersonating ;
  2763. IUnknown *t_OldContext ;
  2764. IServerSecurity *t_OldSecurity ;
  2765. BOOL t_IsProxy ;
  2766. IUnknown *t_Interface ;
  2767. BOOL t_Revert ;
  2768. IUnknown *t_Proxy ;
  2769. HANDLE t_IdentifyToken = NULL ;
  2770. t_Result = Begin_Interface (
  2771. t_ServerInterface ,
  2772. t_InterfaceIdentifier ,
  2773. t_ProxyIndex ,
  2774. t_InternalServerInterface ,
  2775. t_InternalInterfaceIdentifier ,
  2776. t_InternalProxyIndex ,
  2777. m_ProcessIdentifier ,
  2778. t_IdentifyToken ,
  2779. t_Impersonating ,
  2780. t_OldContext ,
  2781. t_OldSecurity ,
  2782. t_IsProxy ,
  2783. t_Interface ,
  2784. t_Revert ,
  2785. t_Proxy
  2786. ) ;
  2787. if ( SUCCEEDED ( t_Result ) )
  2788. {
  2789. if ( t_IdentifyToken )
  2790. {
  2791. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  2792. BSTR t_Query = SysAllocString ( a_Query ) ;
  2793. if ( t_QueryLanguage && t_Query )
  2794. {
  2795. WmiInternalContext t_InternalContext ;
  2796. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  2797. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  2798. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_ExecQueryAsync (
  2799. t_InternalContext ,
  2800. t_QueryLanguage ,
  2801. t_Query,
  2802. a_Flags,
  2803. a_Context ,
  2804. t_Sink
  2805. ) ;
  2806. }
  2807. else
  2808. {
  2809. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2810. }
  2811. SysFreeString ( t_QueryLanguage ) ;
  2812. SysFreeString ( t_Query ) ;
  2813. }
  2814. else
  2815. {
  2816. t_Result = ( ( IWbemServices * ) t_Interface )->ExecQueryAsync (
  2817. a_QueryLanguage ,
  2818. a_Query,
  2819. a_Flags,
  2820. a_Context ,
  2821. t_Sink
  2822. ) ;
  2823. }
  2824. End_Interface (
  2825. t_ServerInterface ,
  2826. t_InterfaceIdentifier ,
  2827. t_ProxyIndex ,
  2828. t_InternalServerInterface ,
  2829. t_InternalInterfaceIdentifier ,
  2830. t_InternalProxyIndex ,
  2831. m_ProcessIdentifier ,
  2832. t_IdentifyToken ,
  2833. t_Impersonating ,
  2834. t_OldContext ,
  2835. t_OldSecurity ,
  2836. t_IsProxy ,
  2837. t_Interface ,
  2838. t_Revert ,
  2839. t_Proxy
  2840. ) ;
  2841. }
  2842. }
  2843. else
  2844. {
  2845. UnLock () ;
  2846. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2847. }
  2848. }
  2849. if ( FAILED ( t_Result ) )
  2850. {
  2851. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2852. }
  2853. t_Sink->Release () ;
  2854. }
  2855. else
  2856. {
  2857. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2858. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2859. }
  2860. }
  2861. else
  2862. {
  2863. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  2864. }
  2865. if ( FAILED ( t_Result ) )
  2866. {
  2867. 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 ))
  2868. {
  2869. AbnormalShutdown () ;
  2870. }
  2871. }
  2872. return t_Result ;
  2873. }
  2874. /******************************************************************************
  2875. *
  2876. * Name:
  2877. *
  2878. *
  2879. * Description:
  2880. *
  2881. *
  2882. *****************************************************************************/
  2883. HRESULT CInterceptor_IWbemDecoupledProvider :: ExecNotificationQuery (
  2884. const BSTR a_QueryLanguage ,
  2885. const BSTR a_Query ,
  2886. long a_Flags ,
  2887. IWbemContext *a_Context ,
  2888. IEnumWbemClassObject **a_Enum
  2889. )
  2890. {
  2891. return WBEM_E_NOT_AVAILABLE ;
  2892. }
  2893. /******************************************************************************
  2894. *
  2895. * Name:
  2896. *
  2897. *
  2898. * Description:
  2899. *
  2900. *
  2901. *****************************************************************************/
  2902. HRESULT CInterceptor_IWbemDecoupledProvider :: ExecNotificationQueryAsync (
  2903. const BSTR a_QueryLanguage ,
  2904. const BSTR a_Query ,
  2905. long a_Flags ,
  2906. IWbemContext *a_Context ,
  2907. IWbemObjectSink *a_Sink
  2908. )
  2909. {
  2910. return WBEM_E_NOT_AVAILABLE ;
  2911. }
  2912. /******************************************************************************
  2913. *
  2914. * Name:
  2915. *
  2916. *
  2917. * Description:
  2918. *
  2919. *
  2920. *****************************************************************************/
  2921. HRESULT CInterceptor_IWbemDecoupledProvider :: ExecMethod (
  2922. const BSTR a_ObjectPath ,
  2923. const BSTR a_MethodName ,
  2924. long a_Flags ,
  2925. IWbemContext *a_Context ,
  2926. IWbemClassObject *a_InParams ,
  2927. IWbemClassObject **a_OutParams ,
  2928. IWbemCallResult **a_CallResult
  2929. )
  2930. {
  2931. return WBEM_E_NOT_AVAILABLE ;
  2932. }
  2933. /******************************************************************************
  2934. *
  2935. * Name:
  2936. *
  2937. *
  2938. * Description:
  2939. *
  2940. *
  2941. *****************************************************************************/
  2942. HRESULT CInterceptor_IWbemDecoupledProvider :: ExecMethodAsync (
  2943. const BSTR a_ObjectPath ,
  2944. const BSTR a_MethodName ,
  2945. long a_Flags ,
  2946. IWbemContext *a_Context ,
  2947. IWbemClassObject *a_InParams ,
  2948. IWbemObjectSink *a_Sink
  2949. )
  2950. {
  2951. if ( m_Initialized == 0 )
  2952. {
  2953. a_Sink->SetStatus ( 0 , WBEM_E_NOT_FOUND , NULL , NULL ) ;
  2954. return WBEM_E_NOT_FOUND ;
  2955. }
  2956. HRESULT t_Result = WBEM_E_NOT_AVAILABLE ;
  2957. if ( m_Provider_IWbemServices )
  2958. {
  2959. CInterceptor_IWbemObjectSink *t_Sink = new CInterceptor_IWbemObjectSink (
  2960. a_Sink ,
  2961. ( IWbemServices * ) this ,
  2962. ( CWbemGlobal_IWmiObjectSinkController * ) this
  2963. ) ;
  2964. if ( t_Sink )
  2965. {
  2966. t_Sink->AddRef () ;
  2967. t_Result = t_Sink->Initialize ( m_Registration->GetComRegistration ().GetSecurityDescriptor () ) ;
  2968. if ( SUCCEEDED ( t_Result ) )
  2969. {
  2970. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator ;
  2971. Lock () ;
  2972. WmiStatusCode t_StatusCode = Insert (
  2973. *t_Sink ,
  2974. t_Iterator
  2975. ) ;
  2976. if ( t_StatusCode == e_StatusCode_Success )
  2977. {
  2978. UnLock () ;
  2979. IUnknown *t_ServerInterface = m_Provider_IWbemServices ;
  2980. REFIID t_InterfaceIdentifier = IID_IWbemServices ;
  2981. DWORD t_ProxyIndex = ProxyIndex_IWbemServices ;
  2982. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemServices ;
  2983. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemServices ;
  2984. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemServices ;
  2985. BOOL t_Impersonating ;
  2986. IUnknown *t_OldContext ;
  2987. IServerSecurity *t_OldSecurity ;
  2988. BOOL t_IsProxy ;
  2989. IUnknown *t_Interface ;
  2990. BOOL t_Revert ;
  2991. IUnknown *t_Proxy ;
  2992. HANDLE t_IdentifyToken = NULL ;
  2993. t_Result = Begin_Interface (
  2994. t_ServerInterface ,
  2995. t_InterfaceIdentifier ,
  2996. t_ProxyIndex ,
  2997. t_InternalServerInterface ,
  2998. t_InternalInterfaceIdentifier ,
  2999. t_InternalProxyIndex ,
  3000. m_ProcessIdentifier ,
  3001. t_IdentifyToken ,
  3002. t_Impersonating ,
  3003. t_OldContext ,
  3004. t_OldSecurity ,
  3005. t_IsProxy ,
  3006. t_Interface ,
  3007. t_Revert ,
  3008. t_Proxy ,
  3009. a_Context
  3010. ) ;
  3011. if ( SUCCEEDED ( t_Result ) )
  3012. {
  3013. if ( t_IdentifyToken )
  3014. {
  3015. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  3016. BSTR t_MethodName = SysAllocString ( a_MethodName ) ;
  3017. if ( t_ObjectPath && t_MethodName )
  3018. {
  3019. WmiInternalContext t_InternalContext ;
  3020. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3021. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3022. t_Result = ( ( Internal_IWbemServices * ) t_Interface )->Internal_ExecMethodAsync (
  3023. t_InternalContext ,
  3024. t_ObjectPath ,
  3025. t_MethodName ,
  3026. a_Flags ,
  3027. a_Context ,
  3028. a_InParams ,
  3029. t_Sink
  3030. ) ;
  3031. }
  3032. else
  3033. {
  3034. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3035. }
  3036. SysFreeString ( t_ObjectPath ) ;
  3037. SysFreeString ( t_MethodName ) ;
  3038. }
  3039. else
  3040. {
  3041. t_Result = ( ( IWbemServices * ) t_Interface )->ExecMethodAsync (
  3042. a_ObjectPath ,
  3043. a_MethodName ,
  3044. a_Flags ,
  3045. a_Context ,
  3046. a_InParams ,
  3047. t_Sink
  3048. ) ;
  3049. }
  3050. End_Interface (
  3051. t_ServerInterface ,
  3052. t_InterfaceIdentifier ,
  3053. t_ProxyIndex ,
  3054. t_InternalServerInterface ,
  3055. t_InternalInterfaceIdentifier ,
  3056. t_InternalProxyIndex ,
  3057. m_ProcessIdentifier ,
  3058. t_IdentifyToken ,
  3059. t_Impersonating ,
  3060. t_OldContext ,
  3061. t_OldSecurity ,
  3062. t_IsProxy ,
  3063. t_Interface ,
  3064. t_Revert ,
  3065. t_Proxy
  3066. ) ;
  3067. }
  3068. }
  3069. else
  3070. {
  3071. UnLock () ;
  3072. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3073. }
  3074. }
  3075. if ( FAILED ( t_Result ) )
  3076. {
  3077. t_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3078. }
  3079. t_Sink->Release () ;
  3080. }
  3081. else
  3082. {
  3083. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3084. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3085. }
  3086. }
  3087. else
  3088. {
  3089. a_Sink->SetStatus ( 0 , t_Result , NULL , NULL ) ;
  3090. }
  3091. if ( FAILED ( t_Result ) )
  3092. {
  3093. 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 ))
  3094. {
  3095. AbnormalShutdown () ;
  3096. }
  3097. }
  3098. return t_Result ;
  3099. }
  3100. /******************************************************************************
  3101. *
  3102. * Name:
  3103. *
  3104. *
  3105. * Description:
  3106. *
  3107. *
  3108. *****************************************************************************/
  3109. HRESULT CInterceptor_IWbemDecoupledProvider :: GetProperty (
  3110. long a_Flags ,
  3111. const BSTR a_Locale ,
  3112. const BSTR a_ClassMapping ,
  3113. const BSTR a_InstanceMapping ,
  3114. const BSTR a_PropertyMapping ,
  3115. VARIANT *a_Value
  3116. )
  3117. {
  3118. if ( m_Provider_IWbemPropertyProvider )
  3119. {
  3120. IUnknown *t_ServerInterface = m_Provider_IWbemPropertyProvider ;
  3121. REFIID t_InterfaceIdentifier = IID_IWbemPropertyProvider ;
  3122. DWORD t_ProxyIndex = ProxyIndex_IWbemPropertyProvider ;
  3123. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemPropertyProvider ;
  3124. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemPropertyProvider ;
  3125. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemPropertyProvider ;
  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. HRESULT 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. BSTR t_ClassMapping = NULL ;
  3156. BSTR t_InstanceMapping = NULL ;
  3157. BSTR t_PropertyMapping = NULL ;
  3158. if ( a_ClassMapping )
  3159. {
  3160. t_ClassMapping = SysAllocString ( a_ClassMapping ) ;
  3161. if ( t_ClassMapping == NULL )
  3162. {
  3163. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3164. }
  3165. }
  3166. if ( a_InstanceMapping )
  3167. {
  3168. t_InstanceMapping = SysAllocString ( a_InstanceMapping ) ;
  3169. if ( t_InstanceMapping == NULL )
  3170. {
  3171. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3172. }
  3173. }
  3174. if ( a_PropertyMapping )
  3175. {
  3176. t_PropertyMapping = SysAllocString ( a_PropertyMapping ) ;
  3177. if ( t_PropertyMapping == NULL )
  3178. {
  3179. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3180. }
  3181. }
  3182. if ( SUCCEEDED ( t_Result ) )
  3183. {
  3184. WmiInternalContext t_InternalContext ;
  3185. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3186. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3187. ( ( Internal_IWbemPropertyProvider * ) t_Interface )->Internal_GetProperty (
  3188. t_InternalContext ,
  3189. a_Flags ,
  3190. a_Locale ,
  3191. t_ClassMapping ,
  3192. t_InstanceMapping ,
  3193. t_PropertyMapping ,
  3194. a_Value
  3195. ) ;
  3196. }
  3197. else
  3198. {
  3199. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3200. }
  3201. SysFreeString ( t_ClassMapping ) ;
  3202. SysFreeString ( t_InstanceMapping ) ;
  3203. SysFreeString ( t_PropertyMapping ) ;
  3204. }
  3205. else
  3206. {
  3207. t_Result = ( ( IWbemPropertyProvider * ) t_Interface )->GetProperty (
  3208. a_Flags ,
  3209. a_Locale ,
  3210. a_ClassMapping ,
  3211. a_InstanceMapping ,
  3212. a_PropertyMapping ,
  3213. a_Value
  3214. ) ;
  3215. }
  3216. End_Interface (
  3217. t_ServerInterface ,
  3218. t_InterfaceIdentifier ,
  3219. t_ProxyIndex ,
  3220. t_InternalServerInterface ,
  3221. t_InternalInterfaceIdentifier ,
  3222. t_InternalProxyIndex ,
  3223. m_ProcessIdentifier ,
  3224. t_IdentifyToken ,
  3225. t_Impersonating ,
  3226. t_OldContext ,
  3227. t_OldSecurity ,
  3228. t_IsProxy ,
  3229. t_Interface ,
  3230. t_Revert ,
  3231. t_Proxy
  3232. ) ;
  3233. }
  3234. if ( FAILED ( t_Result ) )
  3235. {
  3236. 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 ))
  3237. {
  3238. AbnormalShutdown () ;
  3239. }
  3240. }
  3241. return t_Result ;
  3242. }
  3243. else
  3244. {
  3245. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3246. }
  3247. }
  3248. /******************************************************************************
  3249. *
  3250. * Name:
  3251. *
  3252. *
  3253. * Description:
  3254. *
  3255. *
  3256. *****************************************************************************/
  3257. HRESULT CInterceptor_IWbemDecoupledProvider :: PutProperty (
  3258. long a_Flags ,
  3259. const BSTR a_Locale ,
  3260. const BSTR a_ClassMapping ,
  3261. const BSTR a_InstanceMapping ,
  3262. const BSTR a_PropertyMapping ,
  3263. const VARIANT *a_Value
  3264. )
  3265. {
  3266. if ( m_Provider_IWbemPropertyProvider )
  3267. {
  3268. IUnknown *t_ServerInterface = m_Provider_IWbemPropertyProvider ;
  3269. REFIID t_InterfaceIdentifier = IID_IWbemPropertyProvider ;
  3270. DWORD t_ProxyIndex = ProxyIndex_IWbemPropertyProvider ;
  3271. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemPropertyProvider ;
  3272. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemPropertyProvider ;
  3273. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemPropertyProvider ;
  3274. BOOL t_Impersonating ;
  3275. IUnknown *t_OldContext ;
  3276. IServerSecurity *t_OldSecurity ;
  3277. BOOL t_IsProxy ;
  3278. IUnknown *t_Interface ;
  3279. BOOL t_Revert ;
  3280. IUnknown *t_Proxy ;
  3281. HANDLE t_IdentifyToken = NULL ;
  3282. HRESULT t_Result = Begin_Interface (
  3283. t_ServerInterface ,
  3284. t_InterfaceIdentifier ,
  3285. t_ProxyIndex ,
  3286. t_InternalServerInterface ,
  3287. t_InternalInterfaceIdentifier ,
  3288. t_InternalProxyIndex ,
  3289. m_ProcessIdentifier ,
  3290. t_IdentifyToken ,
  3291. t_Impersonating ,
  3292. t_OldContext ,
  3293. t_OldSecurity ,
  3294. t_IsProxy ,
  3295. t_Interface ,
  3296. t_Revert ,
  3297. t_Proxy
  3298. ) ;
  3299. if ( SUCCEEDED ( t_Result ) )
  3300. {
  3301. if ( t_IdentifyToken )
  3302. {
  3303. BSTR t_ClassMapping = NULL ;
  3304. BSTR t_InstanceMapping = NULL ;
  3305. BSTR t_PropertyMapping = NULL ;
  3306. if ( a_ClassMapping )
  3307. {
  3308. t_ClassMapping = SysAllocString ( a_ClassMapping ) ;
  3309. if ( t_ClassMapping == NULL )
  3310. {
  3311. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3312. }
  3313. }
  3314. if ( a_InstanceMapping )
  3315. {
  3316. t_InstanceMapping = SysAllocString ( a_InstanceMapping ) ;
  3317. if ( t_InstanceMapping == NULL )
  3318. {
  3319. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3320. }
  3321. }
  3322. if ( a_PropertyMapping )
  3323. {
  3324. t_PropertyMapping = SysAllocString ( a_PropertyMapping ) ;
  3325. if ( t_PropertyMapping == NULL )
  3326. {
  3327. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3328. }
  3329. }
  3330. if ( SUCCEEDED ( t_Result ) )
  3331. {
  3332. WmiInternalContext t_InternalContext ;
  3333. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3334. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3335. ( ( Internal_IWbemPropertyProvider * ) t_Interface )->Internal_PutProperty (
  3336. t_InternalContext ,
  3337. a_Flags ,
  3338. a_Locale ,
  3339. t_ClassMapping ,
  3340. t_InstanceMapping ,
  3341. t_PropertyMapping ,
  3342. a_Value
  3343. ) ;
  3344. }
  3345. else
  3346. {
  3347. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3348. }
  3349. SysFreeString ( t_ClassMapping ) ;
  3350. SysFreeString ( t_InstanceMapping ) ;
  3351. SysFreeString ( t_PropertyMapping ) ;
  3352. }
  3353. else
  3354. {
  3355. t_Result = ( ( IWbemPropertyProvider * ) t_Interface )->PutProperty (
  3356. a_Flags ,
  3357. a_Locale ,
  3358. a_ClassMapping ,
  3359. a_InstanceMapping ,
  3360. a_PropertyMapping ,
  3361. a_Value
  3362. ) ;
  3363. }
  3364. End_Interface (
  3365. t_ServerInterface ,
  3366. t_InterfaceIdentifier ,
  3367. t_ProxyIndex ,
  3368. t_InternalServerInterface ,
  3369. t_InternalInterfaceIdentifier ,
  3370. t_InternalProxyIndex ,
  3371. m_ProcessIdentifier ,
  3372. t_IdentifyToken ,
  3373. t_Impersonating ,
  3374. t_OldContext ,
  3375. t_OldSecurity ,
  3376. t_IsProxy ,
  3377. t_Interface ,
  3378. t_Revert ,
  3379. t_Proxy
  3380. ) ;
  3381. }
  3382. if ( FAILED ( t_Result ) )
  3383. {
  3384. 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 ))
  3385. {
  3386. AbnormalShutdown () ;
  3387. }
  3388. }
  3389. return t_Result ;
  3390. }
  3391. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3392. }
  3393. /******************************************************************************
  3394. *
  3395. * Name:
  3396. *
  3397. *
  3398. * Description:
  3399. *
  3400. *
  3401. *****************************************************************************/
  3402. HRESULT CInterceptor_IWbemDecoupledProvider ::ProvideEvents (
  3403. IWbemObjectSink *a_Sink ,
  3404. long a_Flags
  3405. )
  3406. {
  3407. if ( m_Provider_IWbemEventProvider )
  3408. {
  3409. IUnknown *t_ServerInterface = m_Provider_IWbemEventProvider ;
  3410. REFIID t_InterfaceIdentifier = IID_IWbemEventProvider ;
  3411. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProvider ;
  3412. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProvider ;
  3413. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProvider ;
  3414. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProvider ;
  3415. BOOL t_Impersonating ;
  3416. IUnknown *t_OldContext ;
  3417. IServerSecurity *t_OldSecurity ;
  3418. BOOL t_IsProxy ;
  3419. IUnknown *t_Interface ;
  3420. BOOL t_Revert ;
  3421. IUnknown *t_Proxy ;
  3422. HANDLE t_IdentifyToken = NULL ;
  3423. HRESULT t_Result = Begin_Interface (
  3424. t_ServerInterface ,
  3425. t_InterfaceIdentifier ,
  3426. t_ProxyIndex ,
  3427. t_InternalServerInterface ,
  3428. t_InternalInterfaceIdentifier ,
  3429. t_InternalProxyIndex ,
  3430. m_ProcessIdentifier ,
  3431. t_IdentifyToken ,
  3432. t_Impersonating ,
  3433. t_OldContext ,
  3434. t_OldSecurity ,
  3435. t_IsProxy ,
  3436. t_Interface ,
  3437. t_Revert ,
  3438. t_Proxy
  3439. ) ;
  3440. if ( SUCCEEDED ( t_Result ) )
  3441. {
  3442. if ( t_IdentifyToken )
  3443. {
  3444. WmiInternalContext t_InternalContext ;
  3445. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3446. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3447. t_Result = ( ( Internal_IWbemEventProvider * ) t_Interface )->Internal_ProvideEvents (
  3448. t_InternalContext ,
  3449. a_Sink ,
  3450. a_Flags
  3451. ) ;
  3452. }
  3453. else
  3454. {
  3455. t_Result = ( ( IWbemEventProvider * ) t_Interface )->ProvideEvents (
  3456. a_Sink ,
  3457. a_Flags
  3458. ) ;
  3459. }
  3460. End_Interface (
  3461. t_ServerInterface ,
  3462. t_InterfaceIdentifier ,
  3463. t_ProxyIndex ,
  3464. t_InternalServerInterface ,
  3465. t_InternalInterfaceIdentifier ,
  3466. t_InternalProxyIndex ,
  3467. m_ProcessIdentifier ,
  3468. t_IdentifyToken ,
  3469. t_Impersonating ,
  3470. t_OldContext ,
  3471. t_OldSecurity ,
  3472. t_IsProxy ,
  3473. t_Interface ,
  3474. t_Revert ,
  3475. t_Proxy
  3476. ) ;
  3477. }
  3478. if ( FAILED ( t_Result ) )
  3479. {
  3480. 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 ))
  3481. {
  3482. AbnormalShutdown () ;
  3483. }
  3484. }
  3485. return t_Result ;
  3486. }
  3487. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3488. }
  3489. /******************************************************************************
  3490. *
  3491. * Name:
  3492. *
  3493. *
  3494. * Description:
  3495. *
  3496. *
  3497. *****************************************************************************/
  3498. HRESULT CInterceptor_IWbemDecoupledProvider ::NewQuery (
  3499. unsigned long a_Id ,
  3500. WBEM_WSTR a_QueryLanguage ,
  3501. WBEM_WSTR a_Query
  3502. )
  3503. {
  3504. if ( m_Provider_IWbemEventProviderQuerySink )
  3505. {
  3506. IUnknown *t_ServerInterface = m_Provider_IWbemEventProviderQuerySink ;
  3507. REFIID t_InterfaceIdentifier = IID_IWbemEventProviderQuerySink ;
  3508. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProviderQuerySink ;
  3509. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProviderQuerySink ;
  3510. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProviderQuerySink ;
  3511. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProviderQuerySink ;
  3512. BOOL t_Impersonating ;
  3513. IUnknown *t_OldContext ;
  3514. IServerSecurity *t_OldSecurity ;
  3515. BOOL t_IsProxy ;
  3516. IUnknown *t_Interface ;
  3517. BOOL t_Revert ;
  3518. IUnknown *t_Proxy ;
  3519. HANDLE t_IdentifyToken = NULL ;
  3520. HRESULT t_Result = Begin_Interface (
  3521. t_ServerInterface ,
  3522. t_InterfaceIdentifier ,
  3523. t_ProxyIndex ,
  3524. t_InternalServerInterface ,
  3525. t_InternalInterfaceIdentifier ,
  3526. t_InternalProxyIndex ,
  3527. m_ProcessIdentifier ,
  3528. t_IdentifyToken ,
  3529. t_Impersonating ,
  3530. t_OldContext ,
  3531. t_OldSecurity ,
  3532. t_IsProxy ,
  3533. t_Interface ,
  3534. t_Revert ,
  3535. t_Proxy
  3536. ) ;
  3537. if ( SUCCEEDED ( t_Result ) )
  3538. {
  3539. if ( t_IdentifyToken )
  3540. {
  3541. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  3542. BSTR t_Query = SysAllocString ( a_Query ) ;
  3543. if ( t_QueryLanguage && t_Query )
  3544. {
  3545. WmiInternalContext t_InternalContext ;
  3546. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3547. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3548. t_Result = ( ( Internal_IWbemEventProviderQuerySink * ) t_Interface )->Internal_NewQuery (
  3549. t_InternalContext ,
  3550. a_Id ,
  3551. t_QueryLanguage ,
  3552. t_Query
  3553. ) ;
  3554. }
  3555. else
  3556. {
  3557. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3558. }
  3559. SysFreeString ( t_QueryLanguage ) ;
  3560. SysFreeString ( t_Query ) ;
  3561. }
  3562. else
  3563. {
  3564. t_Result = ( ( IWbemEventProviderQuerySink * ) t_Interface )->NewQuery (
  3565. a_Id ,
  3566. a_QueryLanguage ,
  3567. a_Query
  3568. ) ;
  3569. }
  3570. End_Interface (
  3571. t_ServerInterface ,
  3572. t_InterfaceIdentifier ,
  3573. t_ProxyIndex ,
  3574. t_InternalServerInterface ,
  3575. t_InternalInterfaceIdentifier ,
  3576. t_InternalProxyIndex ,
  3577. m_ProcessIdentifier ,
  3578. t_IdentifyToken ,
  3579. t_Impersonating ,
  3580. t_OldContext ,
  3581. t_OldSecurity ,
  3582. t_IsProxy ,
  3583. t_Interface ,
  3584. t_Revert ,
  3585. t_Proxy
  3586. ) ;
  3587. }
  3588. if ( FAILED ( t_Result ) )
  3589. {
  3590. 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 ))
  3591. {
  3592. AbnormalShutdown () ;
  3593. }
  3594. }
  3595. return t_Result ;
  3596. }
  3597. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3598. }
  3599. /******************************************************************************
  3600. *
  3601. * Name:
  3602. *
  3603. *
  3604. * Description:
  3605. *
  3606. *
  3607. *****************************************************************************/
  3608. HRESULT CInterceptor_IWbemDecoupledProvider ::CancelQuery (
  3609. unsigned long a_Id
  3610. )
  3611. {
  3612. if ( m_Provider_IWbemEventProviderQuerySink )
  3613. {
  3614. IUnknown *t_ServerInterface = m_Provider_IWbemEventProviderQuerySink ;
  3615. REFIID t_InterfaceIdentifier = IID_IWbemEventProviderQuerySink ;
  3616. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProviderQuerySink ;
  3617. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProviderQuerySink ;
  3618. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProviderQuerySink ;
  3619. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProviderQuerySink ;
  3620. BOOL t_Impersonating ;
  3621. IUnknown *t_OldContext ;
  3622. IServerSecurity *t_OldSecurity ;
  3623. BOOL t_IsProxy ;
  3624. IUnknown *t_Interface ;
  3625. BOOL t_Revert ;
  3626. IUnknown *t_Proxy ;
  3627. HANDLE t_IdentifyToken = NULL ;
  3628. HRESULT t_Result = Begin_Interface (
  3629. t_ServerInterface ,
  3630. t_InterfaceIdentifier ,
  3631. t_ProxyIndex ,
  3632. t_InternalServerInterface ,
  3633. t_InternalInterfaceIdentifier ,
  3634. t_InternalProxyIndex ,
  3635. m_ProcessIdentifier ,
  3636. t_IdentifyToken ,
  3637. t_Impersonating ,
  3638. t_OldContext ,
  3639. t_OldSecurity ,
  3640. t_IsProxy ,
  3641. t_Interface ,
  3642. t_Revert ,
  3643. t_Proxy
  3644. ) ;
  3645. if ( SUCCEEDED ( t_Result ) )
  3646. {
  3647. if ( t_IdentifyToken )
  3648. {
  3649. WmiInternalContext t_InternalContext ;
  3650. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3651. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3652. t_Result = ( ( Internal_IWbemEventProviderQuerySink * ) t_Interface )->Internal_CancelQuery (
  3653. t_InternalContext ,
  3654. a_Id
  3655. ) ;
  3656. }
  3657. else
  3658. {
  3659. t_Result = ( ( IWbemEventProviderQuerySink * ) t_Interface )->CancelQuery (
  3660. a_Id
  3661. ) ;
  3662. }
  3663. End_Interface (
  3664. t_ServerInterface ,
  3665. t_InterfaceIdentifier ,
  3666. t_ProxyIndex ,
  3667. t_InternalServerInterface ,
  3668. t_InternalInterfaceIdentifier ,
  3669. t_InternalProxyIndex ,
  3670. m_ProcessIdentifier ,
  3671. t_IdentifyToken ,
  3672. t_Impersonating ,
  3673. t_OldContext ,
  3674. t_OldSecurity ,
  3675. t_IsProxy ,
  3676. t_Interface ,
  3677. t_Revert ,
  3678. t_Proxy
  3679. ) ;
  3680. }
  3681. if ( FAILED ( t_Result ) )
  3682. {
  3683. 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 ))
  3684. {
  3685. AbnormalShutdown () ;
  3686. }
  3687. }
  3688. return t_Result ;
  3689. }
  3690. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3691. }
  3692. /******************************************************************************
  3693. *
  3694. * Name:
  3695. *
  3696. *
  3697. * Description:
  3698. *
  3699. *
  3700. *****************************************************************************/
  3701. HRESULT CInterceptor_IWbemDecoupledProvider ::AccessCheck (
  3702. WBEM_CWSTR a_QueryLanguage ,
  3703. WBEM_CWSTR a_Query ,
  3704. long a_SidLength ,
  3705. const BYTE *a_Sid
  3706. )
  3707. {
  3708. if ( m_Provider_IWbemEventProviderSecurity )
  3709. {
  3710. IUnknown *t_ServerInterface = m_Provider_IWbemEventProviderSecurity ;
  3711. REFIID t_InterfaceIdentifier = IID_IWbemEventProviderSecurity ;
  3712. DWORD t_ProxyIndex = ProxyIndex_IWbemEventProviderSecurity ;
  3713. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventProviderSecurity ;
  3714. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventProviderSecurity ;
  3715. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventProviderSecurity;
  3716. BOOL t_Impersonating ;
  3717. IUnknown *t_OldContext ;
  3718. IServerSecurity *t_OldSecurity ;
  3719. BOOL t_IsProxy ;
  3720. IUnknown *t_Interface ;
  3721. BOOL t_Revert ;
  3722. IUnknown *t_Proxy ;
  3723. HANDLE t_IdentifyToken = NULL ;
  3724. HRESULT t_Result = Begin_Interface (
  3725. t_ServerInterface ,
  3726. t_InterfaceIdentifier ,
  3727. t_ProxyIndex ,
  3728. t_InternalServerInterface ,
  3729. t_InternalInterfaceIdentifier ,
  3730. t_InternalProxyIndex ,
  3731. m_ProcessIdentifier ,
  3732. t_IdentifyToken ,
  3733. t_Impersonating ,
  3734. t_OldContext ,
  3735. t_OldSecurity ,
  3736. t_IsProxy ,
  3737. t_Interface ,
  3738. t_Revert ,
  3739. t_Proxy
  3740. ) ;
  3741. if ( SUCCEEDED ( t_Result ) )
  3742. {
  3743. if ( t_IdentifyToken )
  3744. {
  3745. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  3746. BSTR t_Query = SysAllocString ( a_Query ) ;
  3747. if ( t_QueryLanguage && t_Query )
  3748. {
  3749. WmiInternalContext t_InternalContext ;
  3750. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3751. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3752. t_Result = ( ( Internal_IWbemEventProviderSecurity * ) t_Interface )->Internal_AccessCheck (
  3753. t_InternalContext ,
  3754. t_QueryLanguage ,
  3755. t_Query ,
  3756. a_SidLength ,
  3757. a_Sid
  3758. ) ;
  3759. }
  3760. else
  3761. {
  3762. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3763. }
  3764. SysFreeString ( t_QueryLanguage ) ;
  3765. SysFreeString ( t_Query ) ;
  3766. }
  3767. else
  3768. {
  3769. t_Result = ( ( IWbemEventProviderSecurity * ) t_Interface )->AccessCheck (
  3770. a_QueryLanguage ,
  3771. a_Query ,
  3772. a_SidLength ,
  3773. a_Sid
  3774. ) ;
  3775. }
  3776. End_Interface (
  3777. t_ServerInterface ,
  3778. t_InterfaceIdentifier ,
  3779. t_ProxyIndex ,
  3780. t_InternalServerInterface ,
  3781. t_InternalInterfaceIdentifier ,
  3782. t_InternalProxyIndex ,
  3783. m_ProcessIdentifier ,
  3784. t_IdentifyToken ,
  3785. t_Impersonating ,
  3786. t_OldContext ,
  3787. t_OldSecurity ,
  3788. t_IsProxy ,
  3789. t_Interface ,
  3790. t_Revert ,
  3791. t_Proxy
  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. }
  3801. return t_Result ;
  3802. }
  3803. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3804. }
  3805. /******************************************************************************
  3806. *
  3807. * Name:
  3808. *
  3809. *
  3810. * Description:
  3811. *
  3812. *
  3813. *****************************************************************************/
  3814. HRESULT CInterceptor_IWbemDecoupledProvider ::FindConsumer (
  3815. IWbemClassObject *a_LogicalConsumer ,
  3816. IWbemUnboundObjectSink **a_Consumer
  3817. )
  3818. {
  3819. if ( m_Provider_IWbemEventConsumerProvider )
  3820. {
  3821. IWbemUnboundObjectSink *t_Consumer = NULL ;
  3822. IUnknown *t_ServerInterface = m_Provider_IWbemEventConsumerProvider ;
  3823. REFIID t_InterfaceIdentifier = IID_IWbemEventConsumerProvider ;
  3824. DWORD t_ProxyIndex = ProxyIndex_IWbemEventConsumerProvider ;
  3825. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventConsumerProvider ;
  3826. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventConsumerProvider ;
  3827. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventConsumerProvider ;
  3828. BOOL t_Impersonating ;
  3829. IUnknown *t_OldContext ;
  3830. IServerSecurity *t_OldSecurity ;
  3831. BOOL t_IsProxy ;
  3832. IUnknown *t_Interface ;
  3833. BOOL t_Revert ;
  3834. IUnknown *t_Proxy ;
  3835. HANDLE t_IdentifyToken = NULL ;
  3836. HRESULT t_Result = Begin_Interface (
  3837. t_ServerInterface ,
  3838. t_InterfaceIdentifier ,
  3839. t_ProxyIndex ,
  3840. t_InternalServerInterface ,
  3841. t_InternalInterfaceIdentifier ,
  3842. t_InternalProxyIndex ,
  3843. m_ProcessIdentifier ,
  3844. t_IdentifyToken ,
  3845. t_Impersonating ,
  3846. t_OldContext ,
  3847. t_OldSecurity ,
  3848. t_IsProxy ,
  3849. t_Interface ,
  3850. t_Revert ,
  3851. t_Proxy
  3852. ) ;
  3853. if ( SUCCEEDED ( t_Result ) )
  3854. {
  3855. if ( t_IdentifyToken )
  3856. {
  3857. WmiInternalContext t_InternalContext ;
  3858. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3859. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3860. t_Result = ( ( Internal_IWbemEventConsumerProvider * ) t_Interface )->Internal_FindConsumer (
  3861. t_InternalContext ,
  3862. a_LogicalConsumer ,
  3863. & t_Consumer
  3864. ) ;
  3865. }
  3866. else
  3867. {
  3868. t_Result = ( ( IWbemEventConsumerProvider * ) t_Interface )->FindConsumer (
  3869. a_LogicalConsumer ,
  3870. & t_Consumer
  3871. ) ;
  3872. }
  3873. End_Interface (
  3874. t_ServerInterface ,
  3875. t_InterfaceIdentifier ,
  3876. t_ProxyIndex ,
  3877. t_InternalServerInterface ,
  3878. t_InternalInterfaceIdentifier ,
  3879. t_InternalProxyIndex ,
  3880. m_ProcessIdentifier ,
  3881. t_IdentifyToken ,
  3882. t_Impersonating ,
  3883. t_OldContext ,
  3884. t_OldSecurity ,
  3885. t_IsProxy ,
  3886. t_Interface ,
  3887. t_Revert ,
  3888. t_Proxy
  3889. ) ;
  3890. }
  3891. if ( SUCCEEDED ( t_Result ) )
  3892. {
  3893. if ( a_Consumer )
  3894. {
  3895. CDecoupled_IWbemUnboundObjectSink *t_UnboundObjectSink = new CDecoupled_IWbemUnboundObjectSink (
  3896. m_Allocator ,
  3897. t_Consumer ,
  3898. this ,
  3899. *m_Registration
  3900. ) ;
  3901. if ( t_UnboundObjectSink )
  3902. {
  3903. t_UnboundObjectSink->AddRef () ;
  3904. t_Result = t_UnboundObjectSink->Initialize () ;
  3905. if ( SUCCEEDED ( t_Result ) )
  3906. {
  3907. CWbemGlobal_VoidPointerController_Container_Iterator t_Iterator ;
  3908. Lock () ;
  3909. WmiStatusCode t_StatusCode = Insert (
  3910. *t_UnboundObjectSink ,
  3911. t_Iterator
  3912. ) ;
  3913. if ( t_StatusCode == e_StatusCode_Success )
  3914. {
  3915. UnLock () ;
  3916. *a_Consumer = t_UnboundObjectSink ;
  3917. t_UnboundObjectSink->AddRef () ;
  3918. }
  3919. else
  3920. {
  3921. UnLock () ;
  3922. t_Result = WBEM_E_OUT_OF_MEMORY ;
  3923. }
  3924. }
  3925. t_UnboundObjectSink->Release () ;
  3926. }
  3927. }
  3928. }
  3929. else
  3930. {
  3931. 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 ))
  3932. {
  3933. AbnormalShutdown () ;
  3934. }
  3935. }
  3936. if ( t_Consumer )
  3937. {
  3938. t_Consumer->Release () ;
  3939. }
  3940. return t_Result ;
  3941. }
  3942. return WBEM_E_PROVIDER_NOT_CAPABLE;
  3943. }
  3944. /******************************************************************************
  3945. *
  3946. * Name:
  3947. *
  3948. *
  3949. * Description:
  3950. *
  3951. *
  3952. *****************************************************************************/
  3953. HRESULT CInterceptor_IWbemDecoupledProvider ::ValidateSubscription (
  3954. IWbemClassObject *a_LogicalConsumer
  3955. )
  3956. {
  3957. if ( m_Provider_IWbemEventConsumerProviderEx )
  3958. {
  3959. IUnknown *t_ServerInterface = m_Provider_IWbemEventConsumerProviderEx ;
  3960. REFIID t_InterfaceIdentifier = IID_IWbemEventConsumerProviderEx ;
  3961. DWORD t_ProxyIndex = ProxyIndex_IWbemEventConsumerProviderEx ;
  3962. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemEventConsumerProviderEx ;
  3963. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemEventConsumerProviderEx ;
  3964. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemEventConsumerProviderEx ;
  3965. BOOL t_Impersonating ;
  3966. IUnknown *t_OldContext ;
  3967. IServerSecurity *t_OldSecurity ;
  3968. BOOL t_IsProxy ;
  3969. IUnknown *t_Interface ;
  3970. BOOL t_Revert ;
  3971. IUnknown *t_Proxy ;
  3972. HANDLE t_IdentifyToken = NULL ;
  3973. HRESULT t_Result = Begin_Interface (
  3974. t_ServerInterface ,
  3975. t_InterfaceIdentifier ,
  3976. t_ProxyIndex ,
  3977. t_InternalServerInterface ,
  3978. t_InternalInterfaceIdentifier ,
  3979. t_InternalProxyIndex ,
  3980. m_ProcessIdentifier ,
  3981. t_IdentifyToken ,
  3982. t_Impersonating ,
  3983. t_OldContext ,
  3984. t_OldSecurity ,
  3985. t_IsProxy ,
  3986. t_Interface ,
  3987. t_Revert ,
  3988. t_Proxy
  3989. ) ;
  3990. if ( SUCCEEDED ( t_Result ) )
  3991. {
  3992. if ( t_IdentifyToken )
  3993. {
  3994. WmiInternalContext t_InternalContext ;
  3995. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  3996. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  3997. t_Result = ( ( Internal_IWbemEventConsumerProviderEx * ) t_Interface )->Internal_ValidateSubscription (
  3998. t_InternalContext ,
  3999. a_LogicalConsumer
  4000. ) ;
  4001. }
  4002. else
  4003. {
  4004. t_Result = ( ( IWbemEventConsumerProviderEx * ) t_Interface )->ValidateSubscription (
  4005. a_LogicalConsumer
  4006. ) ;
  4007. }
  4008. End_Interface (
  4009. t_ServerInterface ,
  4010. t_InterfaceIdentifier ,
  4011. t_ProxyIndex ,
  4012. t_InternalServerInterface ,
  4013. t_InternalInterfaceIdentifier ,
  4014. t_InternalProxyIndex ,
  4015. m_ProcessIdentifier ,
  4016. t_IdentifyToken ,
  4017. t_Impersonating ,
  4018. t_OldContext ,
  4019. t_OldSecurity ,
  4020. t_IsProxy ,
  4021. t_Interface ,
  4022. t_Revert ,
  4023. t_Proxy
  4024. ) ;
  4025. }
  4026. if ( FAILED ( t_Result ) )
  4027. {
  4028. 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 ))
  4029. {
  4030. AbnormalShutdown () ;
  4031. }
  4032. }
  4033. return t_Result ;
  4034. }
  4035. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4036. }
  4037. /******************************************************************************
  4038. *
  4039. * Name:
  4040. *
  4041. *
  4042. * Description:
  4043. *
  4044. *
  4045. *****************************************************************************/
  4046. HRESULT CInterceptor_IWbemDecoupledProvider :: IndicateToConsumer (
  4047. IWbemClassObject *a_LogicalConsumer ,
  4048. long a_ObjectCount ,
  4049. IWbemClassObject **a_Objects
  4050. )
  4051. {
  4052. if ( m_Provider_IWbemUnboundObjectSink )
  4053. {
  4054. IUnknown *t_ServerInterface = m_Provider_IWbemUnboundObjectSink ;
  4055. REFIID t_InterfaceIdentifier = IID_IWbemUnboundObjectSink ;
  4056. DWORD t_ProxyIndex = ProxyIndex_IWbemUnboundObjectSink ;
  4057. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemUnboundObjectSink ;
  4058. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemUnboundObjectSink ;
  4059. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemUnboundObjectSink ;
  4060. BOOL t_Impersonating ;
  4061. IUnknown *t_OldContext ;
  4062. IServerSecurity *t_OldSecurity ;
  4063. BOOL t_IsProxy ;
  4064. IUnknown *t_Interface ;
  4065. BOOL t_Revert ;
  4066. IUnknown *t_Proxy ;
  4067. HANDLE t_IdentifyToken = NULL ;
  4068. HRESULT t_Result = Begin_Interface (
  4069. t_ServerInterface ,
  4070. t_InterfaceIdentifier ,
  4071. t_ProxyIndex ,
  4072. t_InternalServerInterface ,
  4073. t_InternalInterfaceIdentifier ,
  4074. t_InternalProxyIndex ,
  4075. m_ProcessIdentifier ,
  4076. t_IdentifyToken ,
  4077. t_Impersonating ,
  4078. t_OldContext ,
  4079. t_OldSecurity ,
  4080. t_IsProxy ,
  4081. t_Interface ,
  4082. t_Revert ,
  4083. t_Proxy
  4084. ) ;
  4085. if ( SUCCEEDED ( t_Result ) )
  4086. {
  4087. if ( t_IdentifyToken )
  4088. {
  4089. WmiInternalContext t_InternalContext ;
  4090. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4091. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4092. t_Result = ( ( Internal_IWbemUnboundObjectSink * ) t_Interface )->Internal_IndicateToConsumer (
  4093. t_InternalContext ,
  4094. a_LogicalConsumer ,
  4095. a_ObjectCount ,
  4096. a_Objects
  4097. ) ;
  4098. }
  4099. else
  4100. {
  4101. t_Result = ( ( IWbemUnboundObjectSink * ) t_Interface )->IndicateToConsumer (
  4102. a_LogicalConsumer ,
  4103. a_ObjectCount ,
  4104. a_Objects
  4105. ) ;
  4106. }
  4107. End_Interface (
  4108. t_ServerInterface ,
  4109. t_InterfaceIdentifier ,
  4110. t_ProxyIndex ,
  4111. t_InternalServerInterface ,
  4112. t_InternalInterfaceIdentifier ,
  4113. t_InternalProxyIndex ,
  4114. m_ProcessIdentifier ,
  4115. t_IdentifyToken ,
  4116. t_Impersonating ,
  4117. t_OldContext ,
  4118. t_OldSecurity ,
  4119. t_IsProxy ,
  4120. t_Interface ,
  4121. t_Revert ,
  4122. t_Proxy
  4123. ) ;
  4124. }
  4125. if ( FAILED ( t_Result ) )
  4126. {
  4127. 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 ))
  4128. {
  4129. AbnormalShutdown () ;
  4130. }
  4131. }
  4132. return t_Result ;
  4133. }
  4134. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4135. }
  4136. /******************************************************************************
  4137. *
  4138. * Name:
  4139. *
  4140. *
  4141. * Description:
  4142. *
  4143. *
  4144. *****************************************************************************/
  4145. HRESULT CInterceptor_IWbemDecoupledProvider :: SetInitialized ( HRESULT a_InitializeResult )
  4146. {
  4147. m_InitializeResult = a_InitializeResult ;
  4148. InterlockedExchange ( & m_Initialized , 1 ) ;
  4149. if ( m_InitializedEvent )
  4150. {
  4151. SetEvent ( m_InitializedEvent ) ;
  4152. }
  4153. return S_OK ;
  4154. }
  4155. /******************************************************************************
  4156. *
  4157. * Name:
  4158. *
  4159. *
  4160. * Description:
  4161. *
  4162. *
  4163. *****************************************************************************/
  4164. HRESULT CInterceptor_IWbemDecoupledProvider :: WaitProvider ( IWbemContext *a_Context , ULONG a_Timeout )
  4165. {
  4166. HRESULT t_Result = WBEM_E_UNEXPECTED ;
  4167. if ( m_Initialized == 0 )
  4168. {
  4169. BOOL t_DependantCall = FALSE ;
  4170. t_Result = DecoupledProviderSubSystem_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  4171. if ( SUCCEEDED ( t_Result ) )
  4172. {
  4173. if ( t_DependantCall == FALSE )
  4174. {
  4175. if ( WaitForSingleObject ( m_InitializedEvent , a_Timeout ) == WAIT_TIMEOUT )
  4176. {
  4177. return WBEM_E_PROVIDER_LOAD_FAILURE ;
  4178. }
  4179. }
  4180. else
  4181. {
  4182. if ( WaitForSingleObject ( m_InitializedEvent , 0 ) == WAIT_TIMEOUT )
  4183. {
  4184. return S_FALSE ;
  4185. }
  4186. }
  4187. }
  4188. }
  4189. else
  4190. {
  4191. t_Result = S_OK ;
  4192. }
  4193. return t_Result ;
  4194. }
  4195. /******************************************************************************
  4196. *
  4197. * Name:
  4198. *
  4199. *
  4200. * Description:
  4201. *
  4202. *
  4203. *****************************************************************************/
  4204. HRESULT CInterceptor_IWbemDecoupledProvider :: SetRegistrationObject (
  4205. long a_Flags ,
  4206. IWbemClassObject *a_ProviderRegistration
  4207. )
  4208. {
  4209. if ( m_Provider_IWbemProviderIdentity )
  4210. {
  4211. IUnknown *t_ServerInterface = m_Provider_IWbemProviderIdentity ;
  4212. REFIID t_InterfaceIdentifier = IID_IWbemProviderIdentity ;
  4213. DWORD t_ProxyIndex = ProxyIndex_IWbemProviderIdentity ;
  4214. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemProviderIdentity ;
  4215. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemProviderIdentity ;
  4216. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemProviderIdentity ;
  4217. BOOL t_Impersonating ;
  4218. IUnknown *t_OldContext ;
  4219. IServerSecurity *t_OldSecurity ;
  4220. BOOL t_IsProxy ;
  4221. IUnknown *t_Interface ;
  4222. BOOL t_Revert ;
  4223. IUnknown *t_Proxy ;
  4224. HANDLE t_IdentifyToken = NULL ;
  4225. HRESULT t_Result = Begin_Interface (
  4226. t_ServerInterface ,
  4227. t_InterfaceIdentifier ,
  4228. t_ProxyIndex ,
  4229. t_InternalServerInterface ,
  4230. t_InternalInterfaceIdentifier ,
  4231. t_InternalProxyIndex ,
  4232. m_ProcessIdentifier ,
  4233. t_IdentifyToken ,
  4234. t_Impersonating ,
  4235. t_OldContext ,
  4236. t_OldSecurity ,
  4237. t_IsProxy ,
  4238. t_Interface ,
  4239. t_Revert ,
  4240. t_Proxy
  4241. ) ;
  4242. if ( SUCCEEDED ( t_Result ) )
  4243. {
  4244. if ( t_IdentifyToken )
  4245. {
  4246. WmiInternalContext t_InternalContext ;
  4247. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4248. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4249. t_Result = ( ( Internal_IWbemProviderIdentity * ) t_Interface )->Internal_SetRegistrationObject (
  4250. t_InternalContext ,
  4251. a_Flags ,
  4252. a_ProviderRegistration
  4253. ) ;
  4254. }
  4255. else
  4256. {
  4257. t_Result = ( ( IWbemProviderIdentity * ) t_Interface )->SetRegistrationObject (
  4258. a_Flags ,
  4259. a_ProviderRegistration
  4260. ) ;
  4261. }
  4262. End_Interface (
  4263. t_ServerInterface ,
  4264. t_InterfaceIdentifier ,
  4265. t_ProxyIndex ,
  4266. t_InternalServerInterface ,
  4267. t_InternalInterfaceIdentifier ,
  4268. t_InternalProxyIndex ,
  4269. m_ProcessIdentifier ,
  4270. t_IdentifyToken ,
  4271. t_Impersonating ,
  4272. t_OldContext ,
  4273. t_OldSecurity ,
  4274. t_IsProxy ,
  4275. t_Interface ,
  4276. t_Revert ,
  4277. t_Proxy
  4278. ) ;
  4279. if ( FAILED ( t_Result ) )
  4280. {
  4281. 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 ))
  4282. {
  4283. AbnormalShutdown () ;
  4284. }
  4285. }
  4286. }
  4287. return t_Result ;
  4288. }
  4289. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4290. }
  4291. /******************************************************************************
  4292. *
  4293. * Name:
  4294. *
  4295. *
  4296. * Description:
  4297. *
  4298. *
  4299. *****************************************************************************/
  4300. HRESULT CInterceptor_IWbemDecoupledProvider :: Initialize (
  4301. LPWSTR a_User ,
  4302. LONG a_Flags ,
  4303. LPWSTR a_Namespace ,
  4304. LPWSTR a_Locale ,
  4305. IWbemServices *a_CoreService ,
  4306. IWbemContext *a_Context ,
  4307. IWbemProviderInitSink *a_Sink
  4308. )
  4309. {
  4310. if ( m_Provider_IWbemProviderInit )
  4311. {
  4312. IUnknown *t_ServerInterface = m_Provider_IWbemProviderInit ;
  4313. REFIID t_InterfaceIdentifier = IID_IWbemProviderInit ;
  4314. DWORD t_ProxyIndex = ProxyIndex_IWbemProviderInit ;
  4315. IUnknown *t_InternalServerInterface = m_Provider_Internal_IWbemProviderInit ;
  4316. REFIID t_InternalInterfaceIdentifier = IID_Internal_IWbemProviderInit ;
  4317. DWORD t_InternalProxyIndex = ProxyIndex_Internal_IWbemProviderInit ;
  4318. BOOL t_Impersonating ;
  4319. IUnknown *t_OldContext ;
  4320. IServerSecurity *t_OldSecurity ;
  4321. BOOL t_IsProxy ;
  4322. IUnknown *t_Interface ;
  4323. BOOL t_Revert ;
  4324. IUnknown *t_Proxy ;
  4325. HANDLE t_IdentifyToken = NULL ;
  4326. HRESULT t_Result = Begin_Interface (
  4327. t_ServerInterface ,
  4328. t_InterfaceIdentifier ,
  4329. t_ProxyIndex ,
  4330. t_InternalServerInterface ,
  4331. t_InternalInterfaceIdentifier ,
  4332. t_InternalProxyIndex ,
  4333. m_ProcessIdentifier ,
  4334. t_IdentifyToken ,
  4335. t_Impersonating ,
  4336. t_OldContext ,
  4337. t_OldSecurity ,
  4338. t_IsProxy ,
  4339. t_Interface ,
  4340. t_Revert ,
  4341. t_Proxy
  4342. ) ;
  4343. if ( SUCCEEDED ( t_Result ) )
  4344. {
  4345. if ( t_IdentifyToken )
  4346. {
  4347. WmiInternalContext t_InternalContext ;
  4348. t_InternalContext.m_IdentifyHandle = ( unsigned __int64 ) t_IdentifyToken ;
  4349. t_InternalContext.m_ProcessIdentifier = GetCurrentProcessId () ;
  4350. t_Result = ( ( Internal_IWbemProviderInit * ) t_Interface )->Internal_Initialize (
  4351. t_InternalContext ,
  4352. a_User ,
  4353. a_Flags ,
  4354. a_Namespace ,
  4355. a_Locale ,
  4356. a_CoreService ,
  4357. a_Context ,
  4358. a_Sink
  4359. ) ;
  4360. }
  4361. else
  4362. {
  4363. t_Result = ( ( IWbemProviderInit * ) t_Interface )->Initialize (
  4364. a_User ,
  4365. a_Flags ,
  4366. a_Namespace ,
  4367. a_Locale ,
  4368. a_CoreService ,
  4369. a_Context ,
  4370. a_Sink
  4371. ) ;
  4372. }
  4373. End_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 ( FAILED ( t_Result ) )
  4391. {
  4392. 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 ))
  4393. {
  4394. AbnormalShutdown () ;
  4395. }
  4396. }
  4397. }
  4398. return t_Result ;
  4399. }
  4400. return WBEM_E_PROVIDER_NOT_CAPABLE;
  4401. }
  4402. /******************************************************************************
  4403. *
  4404. * Name:
  4405. *
  4406. *
  4407. * Description:
  4408. *
  4409. *
  4410. *****************************************************************************/
  4411. HRESULT CInterceptor_IWbemDecoupledProvider :: AbnormalShutdown ()
  4412. {
  4413. HRESULT t_Result = S_OK ;
  4414. return t_Result ;
  4415. }
  4416. /******************************************************************************
  4417. *
  4418. * Name:
  4419. *
  4420. *
  4421. * Description:
  4422. *
  4423. *
  4424. *****************************************************************************/
  4425. HRESULT CInterceptor_IWbemDecoupledProvider :: Shutdown (
  4426. LONG a_Flags ,
  4427. ULONG a_MaxMilliSeconds ,
  4428. IWbemContext *a_Context
  4429. )
  4430. {
  4431. HRESULT t_Result = S_OK ;
  4432. IWbemShutdown *t_Shutdown = NULL ;
  4433. if ( m_Unknown )
  4434. {
  4435. t_Result = m_Unknown->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  4436. if ( SUCCEEDED ( t_Result ) )
  4437. {
  4438. BOOL t_Impersonating = FALSE ;
  4439. IUnknown *t_OldContext = NULL ;
  4440. IServerSecurity *t_OldSecurity = NULL ;
  4441. t_Result = DecoupledProviderSubSystem_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  4442. if ( SUCCEEDED ( t_Result ) )
  4443. {
  4444. BOOL t_Revert = FALSE ;
  4445. IUnknown *t_Proxy = NULL ;
  4446. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_IWbemShutdown , IID_IWbemShutdown , t_Shutdown , t_Proxy , t_Revert ) ;
  4447. if ( t_Result == WBEM_E_NOT_FOUND )
  4448. {
  4449. try
  4450. {
  4451. t_Result = t_Shutdown->Shutdown (
  4452. a_Flags ,
  4453. a_MaxMilliSeconds ,
  4454. a_Context
  4455. ) ;
  4456. }
  4457. catch ( ... )
  4458. {
  4459. t_Result = WBEM_E_PROVIDER_FAILURE ;
  4460. }
  4461. CoRevertToSelf () ;
  4462. }
  4463. else
  4464. {
  4465. if ( SUCCEEDED ( t_Result ) )
  4466. {
  4467. IWbemShutdown *t_Provider = ( IWbemShutdown * ) t_Proxy ;
  4468. // Set cloaking on the proxy
  4469. // =========================
  4470. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  4471. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  4472. t_Provider ,
  4473. RPC_C_AUTHN_LEVEL_CONNECT ,
  4474. t_ImpersonationLevel
  4475. ) ;
  4476. if ( SUCCEEDED ( t_Result ) )
  4477. {
  4478. t_Result = OS::CoImpersonateClient () ;
  4479. if ( SUCCEEDED ( t_Result ) )
  4480. {
  4481. try
  4482. {
  4483. t_Result = t_Provider->Shutdown (
  4484. a_Flags ,
  4485. a_MaxMilliSeconds ,
  4486. a_Context
  4487. ) ;
  4488. }
  4489. catch ( ... )
  4490. {
  4491. t_Result = WBEM_E_PROVIDER_FAILURE ;
  4492. }
  4493. CoRevertToSelf () ;
  4494. }
  4495. }
  4496. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_IWbemShutdown , t_Proxy , t_Revert ) ;
  4497. }
  4498. }
  4499. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  4500. }
  4501. t_Shutdown->Release () ;
  4502. }
  4503. }
  4504. if ( m_CoreStub )
  4505. {
  4506. t_Shutdown = NULL ;
  4507. t_Result = m_CoreStub->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  4508. if ( SUCCEEDED ( t_Result ) )
  4509. {
  4510. t_Result = t_Shutdown->Shutdown (
  4511. a_Flags ,
  4512. a_MaxMilliSeconds ,
  4513. a_Context
  4514. ) ;
  4515. t_Shutdown->Release () ;
  4516. }
  4517. }
  4518. Lock () ;
  4519. CWbemGlobal_IWmiObjectSinkController_Container *t_Container = NULL ;
  4520. GetContainer ( t_Container ) ;
  4521. IWbemShutdown **t_ShutdownElements = new IWbemShutdown * [ t_Container->Size () ] ;
  4522. if ( t_ShutdownElements )
  4523. {
  4524. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator = t_Container->Begin ();
  4525. ULONG t_Count = 0 ;
  4526. while ( ! t_Iterator.Null () )
  4527. {
  4528. t_Result = t_Iterator.GetElement ()->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_ShutdownElements [ t_Count ] ) ;
  4529. t_Iterator.Increment () ;
  4530. t_Count ++ ;
  4531. }
  4532. UnLock () ;
  4533. for ( ULONG t_Index = 0 ; t_Index < t_Count ; t_Index ++ )
  4534. {
  4535. if ( t_ShutdownElements [ t_Index ] )
  4536. {
  4537. t_Result = t_ShutdownElements [ t_Index ]->Shutdown (
  4538. a_Flags ,
  4539. a_MaxMilliSeconds ,
  4540. a_Context
  4541. ) ;
  4542. t_ShutdownElements [ t_Index ]->Release () ;
  4543. }
  4544. }
  4545. delete [] t_ShutdownElements ;
  4546. }
  4547. else
  4548. {
  4549. UnLock () ;
  4550. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4551. }
  4552. CWbemGlobal_IWmiObjectSinkController :: Shutdown () ;
  4553. return t_Result ;
  4554. }
  4555. /******************************************************************************
  4556. *
  4557. * Name:
  4558. *
  4559. *
  4560. * Description:
  4561. *
  4562. *
  4563. *****************************************************************************/
  4564. HRESULT CInterceptor_IWbemDecoupledProvider :: Initialize (
  4565. LONG a_Flags ,
  4566. IWbemContext *a_Context ,
  4567. GUID *a_TransactionIdentifier,
  4568. LPCWSTR a_User ,
  4569. LPCWSTR a_Locale ,
  4570. LPCWSTR a_Namespace ,
  4571. IWbemServices *a_Repository ,
  4572. IWbemServices *a_Service ,
  4573. IWbemProviderInitSink *a_Sink
  4574. )
  4575. {
  4576. HRESULT t_Result = S_OK ;
  4577. WmiStatusCode t_StatusCode = CWbemGlobal_IWmiObjectSinkController :: Initialize () ;
  4578. if ( t_StatusCode != e_StatusCode_Success )
  4579. {
  4580. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4581. }
  4582. if ( SUCCEEDED ( t_Result ) )
  4583. {
  4584. t_StatusCode = m_ProxyContainer.Initialize () ;
  4585. if ( t_StatusCode != e_StatusCode_Success )
  4586. {
  4587. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4588. }
  4589. }
  4590. if ( SUCCEEDED ( t_Result ) )
  4591. {
  4592. if ( a_User )
  4593. {
  4594. m_User = SysAllocString ( a_User ) ;
  4595. if ( m_User == NULL )
  4596. {
  4597. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4598. }
  4599. }
  4600. }
  4601. if ( SUCCEEDED ( t_Result ) )
  4602. {
  4603. if ( a_Locale )
  4604. {
  4605. m_Locale = SysAllocString ( a_Locale ) ;
  4606. if ( m_Locale == NULL )
  4607. {
  4608. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4609. }
  4610. }
  4611. }
  4612. if ( SUCCEEDED ( t_Result ) )
  4613. {
  4614. if ( a_Namespace )
  4615. {
  4616. m_Namespace = SysAllocString ( a_Namespace ) ;
  4617. if ( m_Namespace == NULL )
  4618. {
  4619. t_Result = WBEM_E_OUT_OF_MEMORY ;
  4620. }
  4621. }
  4622. }
  4623. if ( SUCCEEDED ( t_Result ) )
  4624. {
  4625. if ( a_TransactionIdentifier )
  4626. {
  4627. wchar_t t_TransactionIdentifier [ sizeof ( L"{00000000-0000-0000-0000-000000000000}" ) ] ;
  4628. if ( a_TransactionIdentifier )
  4629. {
  4630. StringFromGUID2 ( *a_TransactionIdentifier , t_TransactionIdentifier , sizeof ( t_TransactionIdentifier ) / sizeof ( wchar_t ) );
  4631. }
  4632. m_TransactionIdentifier = SysAllocString ( t_TransactionIdentifier ) ;
  4633. }
  4634. }
  4635. if ( a_Repository )
  4636. {
  4637. t_Result = a_Repository->GetObject (
  4638. L"__ExtendedStatus" ,
  4639. 0 ,
  4640. a_Context ,
  4641. & m_ExtendedStatusObject ,
  4642. NULL
  4643. ) ;
  4644. }
  4645. if ( SUCCEEDED ( t_Result ) )
  4646. {
  4647. m_InitializedEvent = OS::CreateEvent ( NULL , TRUE , FALSE , NULL ) ;
  4648. if ( m_InitializedEvent == NULL )
  4649. {
  4650. t_Result = t_Result = WBEM_E_OUT_OF_MEMORY ;
  4651. }
  4652. }
  4653. if ( SUCCEEDED ( t_Result ) )
  4654. {
  4655. _IWmiProviderSite *t_Site = NULL ;
  4656. t_Result = m_Unknown->QueryInterface ( IID__IWmiProviderSite , ( void ** ) & t_Site ) ;
  4657. if ( SUCCEEDED ( t_Result ) )
  4658. {
  4659. t_Result = t_Site->GetSite ( & m_ProcessIdentifier ) ;
  4660. t_Site->Release () ;
  4661. }
  4662. }
  4663. a_Sink->SetStatus ( t_Result , 0 ) ;
  4664. return t_Result ;
  4665. }