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.

5855 lines
136 KiB

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