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.

3206 lines
78 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 "Globals.h"
  11. #include "CGlobals.h"
  12. #include "ProvObSk.h"
  13. #include "ProvInSk.h"
  14. #include "ProvWsvS.h"
  15. /******************************************************************************
  16. *
  17. * Name:
  18. *
  19. *
  20. * Description:
  21. *
  22. *
  23. *****************************************************************************/
  24. CInterceptor_IWbemServices_Stub :: CInterceptor_IWbemServices_Stub (
  25. WmiAllocator &a_Allocator ,
  26. IWbemServices *a_Service
  27. ) : m_ReferenceCount ( 0 ) ,
  28. m_CoreService ( a_Service ) ,
  29. m_RefreshingService ( NULL ) ,
  30. m_GateClosed ( FALSE ) ,
  31. m_InProgress ( 0 ) ,
  32. m_Allocator ( a_Allocator ) ,
  33. m_ProxyContainer ( a_Allocator , 3 , MAX_PROXIES ),
  34. m_CriticalSection(NOTHROW_LOCK)
  35. {
  36. InterlockedIncrement ( & DecoupledProviderSubSystem_Globals :: s_CInterceptor_IWbemServices_Stub_ObjectsInProgress ) ;
  37. InterlockedIncrement (&DecoupledProviderSubSystem_Globals :: s_ObjectsInProgress) ;
  38. HRESULT t_Result = m_CoreService->QueryInterface ( IID_IWbemRefreshingServices , ( void ** ) & m_RefreshingService ) ;
  39. m_CoreService->AddRef () ;
  40. WmiStatusCode t_StatusCode = m_ProxyContainer.Initialize () ;
  41. }
  42. /******************************************************************************
  43. *
  44. * Name:
  45. *
  46. *
  47. * Description:
  48. *
  49. *
  50. *****************************************************************************/
  51. CInterceptor_IWbemServices_Stub :: ~CInterceptor_IWbemServices_Stub ()
  52. {
  53. if ( m_CoreService )
  54. {
  55. m_CoreService->Release () ;
  56. }
  57. if ( m_RefreshingService )
  58. {
  59. m_RefreshingService->Release () ;
  60. }
  61. InterlockedDecrement ( & DecoupledProviderSubSystem_Globals :: s_CInterceptor_IWbemServices_Stub_ObjectsInProgress ) ;
  62. InterlockedDecrement (&DecoupledProviderSubSystem_Globals :: s_ObjectsInProgress) ;
  63. }
  64. /******************************************************************************
  65. *
  66. * Name:
  67. *
  68. *
  69. * Description:
  70. *
  71. *
  72. *****************************************************************************/
  73. STDMETHODIMP_(ULONG) CInterceptor_IWbemServices_Stub :: AddRef ( void )
  74. {
  75. ULONG t_ReferenceCount = InterlockedIncrement ( & m_ReferenceCount ) ;
  76. return t_ReferenceCount ;
  77. }
  78. /******************************************************************************
  79. *
  80. * Name:
  81. *
  82. *
  83. * Description:
  84. *
  85. *
  86. *****************************************************************************/
  87. STDMETHODIMP_(ULONG) CInterceptor_IWbemServices_Stub :: Release ( void )
  88. {
  89. ULONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  90. if ( t_ReferenceCount == 0 )
  91. {
  92. delete this ;
  93. return 0 ;
  94. }
  95. else
  96. {
  97. return t_ReferenceCount;
  98. }
  99. }
  100. /******************************************************************************
  101. *
  102. * Name:
  103. *
  104. *
  105. * Description:
  106. *
  107. *
  108. *****************************************************************************/
  109. STDMETHODIMP CInterceptor_IWbemServices_Stub :: QueryInterface (
  110. REFIID iid ,
  111. LPVOID FAR *iplpv
  112. )
  113. {
  114. *iplpv = NULL ;
  115. if ( iid == IID_IUnknown )
  116. {
  117. *iplpv = static_cast<IWbemServices *>(this) ;
  118. }
  119. else if ( iid == IID_IWbemServices )
  120. {
  121. *iplpv = static_cast<IWbemServices *>(this) ;
  122. }
  123. else if ( iid == IID_IWbemRefreshingServices )
  124. {
  125. *iplpv = static_cast<IWbemRefreshingServices *>(this) ;
  126. }
  127. else if ( iid == IID_IWbemShutdown )
  128. {
  129. *iplpv = static_cast<IWbemShutdown *>(this) ;
  130. }
  131. if ( *iplpv )
  132. {
  133. reinterpret_cast<IUnknown*>(*iplpv)->AddRef () ;
  134. return ResultFromScode ( S_OK ) ;
  135. }
  136. else
  137. {
  138. return ResultFromScode ( E_NOINTERFACE ) ;
  139. }
  140. }
  141. /******************************************************************************
  142. *
  143. * Name:
  144. *
  145. *
  146. * Description:
  147. *
  148. *
  149. *****************************************************************************/
  150. HRESULT CInterceptor_IWbemServices_Stub::OpenNamespace (
  151. const BSTR a_ObjectPath ,
  152. long a_Flags ,
  153. IWbemContext *a_Context ,
  154. IWbemServices **a_NamespaceService ,
  155. IWbemCallResult **a_CallResult
  156. )
  157. {
  158. HRESULT t_Result = S_OK ;
  159. InterlockedIncrement ( & m_InProgress ) ;
  160. if ( m_GateClosed == 1 )
  161. {
  162. t_Result = WBEM_E_SHUTTING_DOWN ;
  163. }
  164. else
  165. {
  166. BOOL t_Impersonating = FALSE ;
  167. IUnknown *t_OldContext = NULL ;
  168. IServerSecurity *t_OldSecurity = NULL ;
  169. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  170. if ( SUCCEEDED ( t_Result ) )
  171. {
  172. BOOL t_Revert = FALSE ;
  173. IUnknown *t_Proxy = NULL ;
  174. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  175. if ( t_Result == WBEM_E_NOT_FOUND )
  176. {
  177. t_Result = m_CoreService->OpenNamespace (
  178. a_ObjectPath,
  179. a_Flags,
  180. a_Context ,
  181. a_NamespaceService,
  182. a_CallResult
  183. ) ;
  184. }
  185. else
  186. {
  187. if ( SUCCEEDED ( t_Result ) )
  188. {
  189. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  190. // Set cloaking on the proxy
  191. // =========================
  192. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  193. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  194. t_Service ,
  195. RPC_C_AUTHN_LEVEL_CONNECT ,
  196. t_ImpersonationLevel
  197. ) ;
  198. if ( SUCCEEDED ( t_Result ) )
  199. {
  200. t_Result = t_Service->OpenNamespace (
  201. a_ObjectPath,
  202. a_Flags,
  203. a_Context ,
  204. a_NamespaceService,
  205. a_CallResult
  206. ) ;
  207. }
  208. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  209. }
  210. }
  211. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  212. }
  213. }
  214. InterlockedDecrement ( & m_InProgress ) ;
  215. return t_Result ;
  216. }
  217. /******************************************************************************
  218. *
  219. * Name:
  220. *
  221. *
  222. * Description:
  223. *
  224. *
  225. *****************************************************************************/
  226. HRESULT CInterceptor_IWbemServices_Stub :: CancelAsyncCall (
  227. IWbemObjectSink *a_Sink
  228. )
  229. {
  230. HRESULT t_Result = S_OK ;
  231. InterlockedIncrement ( & m_InProgress ) ;
  232. if ( m_GateClosed == 1 )
  233. {
  234. t_Result = WBEM_E_SHUTTING_DOWN ;
  235. }
  236. else
  237. {
  238. BOOL t_Impersonating = FALSE ;
  239. IUnknown *t_OldContext = NULL ;
  240. IServerSecurity *t_OldSecurity = NULL ;
  241. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  242. if ( SUCCEEDED ( t_Result ) )
  243. {
  244. BOOL t_Revert = FALSE ;
  245. IUnknown *t_Proxy = NULL ;
  246. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  247. if ( t_Result == WBEM_E_NOT_FOUND )
  248. {
  249. t_Result = m_CoreService->CancelAsyncCall (
  250. a_Sink
  251. ) ;
  252. }
  253. else
  254. {
  255. if ( SUCCEEDED ( t_Result ) )
  256. {
  257. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  258. // Set cloaking on the proxy
  259. // =========================
  260. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  261. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  262. t_Service ,
  263. RPC_C_AUTHN_LEVEL_CONNECT ,
  264. t_ImpersonationLevel
  265. ) ;
  266. if ( SUCCEEDED ( t_Result ) )
  267. {
  268. t_Result = t_Service->CancelAsyncCall (
  269. a_Sink
  270. ) ;
  271. }
  272. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  273. }
  274. }
  275. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  276. }
  277. }
  278. InterlockedDecrement ( & m_InProgress ) ;
  279. return t_Result ;
  280. }
  281. /******************************************************************************
  282. *
  283. * Name:
  284. *
  285. *
  286. * Description:
  287. *
  288. *
  289. *****************************************************************************/
  290. HRESULT CInterceptor_IWbemServices_Stub :: QueryObjectSink (
  291. long a_Flags ,
  292. IWbemObjectSink **a_Sink
  293. )
  294. {
  295. HRESULT t_Result = S_OK ;
  296. InterlockedIncrement ( & m_InProgress ) ;
  297. if ( m_GateClosed == 1 )
  298. {
  299. t_Result = WBEM_E_SHUTTING_DOWN ;
  300. }
  301. else
  302. {
  303. BOOL t_Impersonating = FALSE ;
  304. IUnknown *t_OldContext = NULL ;
  305. IServerSecurity *t_OldSecurity = NULL ;
  306. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  307. if ( SUCCEEDED ( t_Result ) )
  308. {
  309. BOOL t_Revert = FALSE ;
  310. IUnknown *t_Proxy = NULL ;
  311. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  312. if ( t_Result == WBEM_E_NOT_FOUND )
  313. {
  314. t_Result = m_CoreService->QueryObjectSink (
  315. a_Flags,
  316. a_Sink
  317. ) ;
  318. }
  319. else
  320. {
  321. if ( SUCCEEDED ( t_Result ) )
  322. {
  323. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  324. // Set cloaking on the proxy
  325. // =========================
  326. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  327. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  328. t_Service ,
  329. RPC_C_AUTHN_LEVEL_CONNECT ,
  330. t_ImpersonationLevel
  331. ) ;
  332. if ( SUCCEEDED ( t_Result ) )
  333. {
  334. t_Result = t_Service->QueryObjectSink (
  335. a_Flags,
  336. a_Sink
  337. ) ;
  338. }
  339. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  340. }
  341. }
  342. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  343. }
  344. }
  345. InterlockedDecrement ( & m_InProgress ) ;
  346. return t_Result ;
  347. }
  348. /******************************************************************************
  349. *
  350. * Name:
  351. *
  352. *
  353. * Description:
  354. *
  355. *
  356. *****************************************************************************/
  357. HRESULT CInterceptor_IWbemServices_Stub :: GetObject (
  358. const BSTR a_ObjectPath ,
  359. long a_Flags ,
  360. IWbemContext *a_Context ,
  361. IWbemClassObject **a_Object ,
  362. IWbemCallResult **a_CallResult
  363. )
  364. {
  365. HRESULT t_Result = S_OK ;
  366. InterlockedIncrement ( & m_InProgress ) ;
  367. if ( m_GateClosed == 1 )
  368. {
  369. t_Result = WBEM_E_SHUTTING_DOWN ;
  370. }
  371. else
  372. {
  373. BOOL t_Impersonating = FALSE ;
  374. IUnknown *t_OldContext = NULL ;
  375. IServerSecurity *t_OldSecurity = NULL ;
  376. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  377. if ( SUCCEEDED ( t_Result ) )
  378. {
  379. BOOL t_Revert = FALSE ;
  380. IUnknown *t_Proxy = NULL ;
  381. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  382. if ( t_Result == WBEM_E_NOT_FOUND )
  383. {
  384. t_Result = m_CoreService->GetObject (
  385. a_ObjectPath,
  386. a_Flags,
  387. a_Context ,
  388. a_Object,
  389. a_CallResult
  390. ) ;
  391. }
  392. else
  393. {
  394. if ( SUCCEEDED ( t_Result ) )
  395. {
  396. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  397. // Set cloaking on the proxy
  398. // =========================
  399. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  400. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  401. t_Service ,
  402. RPC_C_AUTHN_LEVEL_CONNECT ,
  403. t_ImpersonationLevel
  404. ) ;
  405. if ( SUCCEEDED ( t_Result ) )
  406. {
  407. if ( a_ObjectPath )
  408. {
  409. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  410. if ( t_ObjectPath )
  411. {
  412. t_Result = t_Service->GetObject (
  413. t_ObjectPath,
  414. a_Flags,
  415. a_Context ,
  416. a_Object,
  417. a_CallResult
  418. ) ;
  419. SysFreeString ( t_ObjectPath ) ;
  420. }
  421. else
  422. {
  423. t_Result = WBEM_E_OUT_OF_MEMORY ;
  424. }
  425. }
  426. else
  427. {
  428. t_Result = t_Service->GetObject (
  429. a_ObjectPath,
  430. a_Flags,
  431. a_Context ,
  432. a_Object,
  433. a_CallResult
  434. ) ;
  435. }
  436. }
  437. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  438. }
  439. }
  440. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  441. }
  442. }
  443. InterlockedDecrement ( & m_InProgress ) ;
  444. return t_Result ;
  445. }
  446. /******************************************************************************
  447. *
  448. * Name:
  449. *
  450. *
  451. * Description:
  452. *
  453. *
  454. *****************************************************************************/
  455. HRESULT CInterceptor_IWbemServices_Stub :: GetObjectAsync (
  456. const BSTR a_ObjectPath ,
  457. long a_Flags ,
  458. IWbemContext *a_Context ,
  459. IWbemObjectSink *a_Sink
  460. )
  461. {
  462. HRESULT t_Result = S_OK ;
  463. InterlockedIncrement ( & m_InProgress ) ;
  464. if ( m_GateClosed == 1 )
  465. {
  466. t_Result = WBEM_E_SHUTTING_DOWN ;
  467. }
  468. else
  469. {
  470. BOOL t_Impersonating = FALSE ;
  471. IUnknown *t_OldContext = NULL ;
  472. IServerSecurity *t_OldSecurity = NULL ;
  473. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  474. if ( SUCCEEDED ( t_Result ) )
  475. {
  476. BOOL t_Revert = FALSE ;
  477. IUnknown *t_Proxy = NULL ;
  478. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  479. if ( t_Result == WBEM_E_NOT_FOUND )
  480. {
  481. t_Result = m_CoreService->GetObjectAsync (
  482. a_ObjectPath,
  483. a_Flags,
  484. a_Context ,
  485. a_Sink
  486. ) ;
  487. }
  488. else
  489. {
  490. if ( SUCCEEDED ( t_Result ) )
  491. {
  492. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  493. // Set cloaking on the proxy
  494. // =========================
  495. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  496. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  497. t_Service ,
  498. RPC_C_AUTHN_LEVEL_CONNECT ,
  499. t_ImpersonationLevel
  500. ) ;
  501. if ( SUCCEEDED ( t_Result ) )
  502. {
  503. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  504. if ( t_ObjectPath )
  505. {
  506. t_Result = t_Service->GetObjectAsync (
  507. t_ObjectPath,
  508. a_Flags,
  509. a_Context ,
  510. a_Sink
  511. ) ;
  512. SysFreeString ( t_ObjectPath ) ;
  513. }
  514. else
  515. {
  516. t_Result = WBEM_E_OUT_OF_MEMORY ;
  517. }
  518. }
  519. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  520. }
  521. }
  522. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  523. }
  524. }
  525. InterlockedDecrement ( & m_InProgress ) ;
  526. return t_Result ;
  527. }
  528. /******************************************************************************
  529. *
  530. * Name:
  531. *
  532. *
  533. * Description:
  534. *
  535. *
  536. *****************************************************************************/
  537. HRESULT CInterceptor_IWbemServices_Stub :: PutClass (
  538. IWbemClassObject *a_Object ,
  539. long a_Flags ,
  540. IWbemContext *a_Context ,
  541. IWbemCallResult **a_CallResult
  542. )
  543. {
  544. HRESULT t_Result = S_OK ;
  545. InterlockedIncrement ( & m_InProgress ) ;
  546. if ( m_GateClosed == 1 )
  547. {
  548. t_Result = WBEM_E_SHUTTING_DOWN ;
  549. }
  550. else
  551. {
  552. BOOL t_Impersonating = FALSE ;
  553. IUnknown *t_OldContext = NULL ;
  554. IServerSecurity *t_OldSecurity = NULL ;
  555. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  556. if ( SUCCEEDED ( t_Result ) )
  557. {
  558. BOOL t_Revert = FALSE ;
  559. IUnknown *t_Proxy = NULL ;
  560. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  561. if ( t_Result == WBEM_E_NOT_FOUND )
  562. {
  563. t_Result = m_CoreService->PutClass (
  564. a_Object,
  565. a_Flags,
  566. a_Context,
  567. a_CallResult
  568. ) ;
  569. }
  570. else
  571. {
  572. if ( SUCCEEDED ( t_Result ) )
  573. {
  574. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  575. // Set cloaking on the proxy
  576. // =========================
  577. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  578. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  579. t_Service ,
  580. RPC_C_AUTHN_LEVEL_CONNECT ,
  581. t_ImpersonationLevel
  582. ) ;
  583. if ( SUCCEEDED ( t_Result ) )
  584. {
  585. t_Result = t_Service->PutClass (
  586. a_Object,
  587. a_Flags,
  588. a_Context,
  589. a_CallResult
  590. ) ;
  591. }
  592. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  593. }
  594. }
  595. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  596. }
  597. }
  598. InterlockedDecrement ( & m_InProgress ) ;
  599. return t_Result ;
  600. }
  601. /******************************************************************************
  602. *
  603. * Name:
  604. *
  605. *
  606. * Description:
  607. *
  608. *
  609. *****************************************************************************/
  610. HRESULT CInterceptor_IWbemServices_Stub :: PutClassAsync (
  611. IWbemClassObject *a_Object ,
  612. long a_Flags ,
  613. IWbemContext FAR *a_Context ,
  614. IWbemObjectSink *a_Sink
  615. )
  616. {
  617. HRESULT t_Result = S_OK ;
  618. InterlockedIncrement ( & m_InProgress ) ;
  619. if ( m_GateClosed == 1 )
  620. {
  621. t_Result = WBEM_E_SHUTTING_DOWN ;
  622. }
  623. else
  624. {
  625. BOOL t_Impersonating = FALSE ;
  626. IUnknown *t_OldContext = NULL ;
  627. IServerSecurity *t_OldSecurity = NULL ;
  628. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  629. if ( SUCCEEDED ( t_Result ) )
  630. {
  631. BOOL t_Revert = FALSE ;
  632. IUnknown *t_Proxy = NULL ;
  633. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  634. if ( t_Result == WBEM_E_NOT_FOUND )
  635. {
  636. t_Result = m_CoreService->PutClassAsync (
  637. a_Object,
  638. a_Flags,
  639. a_Context ,
  640. a_Sink
  641. ) ;
  642. }
  643. else
  644. {
  645. if ( SUCCEEDED ( t_Result ) )
  646. {
  647. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  648. // Set cloaking on the proxy
  649. // =========================
  650. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  651. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  652. t_Service ,
  653. RPC_C_AUTHN_LEVEL_CONNECT ,
  654. t_ImpersonationLevel
  655. ) ;
  656. if ( SUCCEEDED ( t_Result ) )
  657. {
  658. t_Result = t_Service->PutClassAsync (
  659. a_Object,
  660. a_Flags,
  661. a_Context ,
  662. a_Sink
  663. ) ;
  664. }
  665. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  666. }
  667. }
  668. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  669. }
  670. }
  671. InterlockedDecrement ( & m_InProgress ) ;
  672. return t_Result ;
  673. }
  674. /******************************************************************************
  675. *
  676. * Name:
  677. *
  678. *
  679. * Description:
  680. *
  681. *
  682. *****************************************************************************/
  683. HRESULT CInterceptor_IWbemServices_Stub :: DeleteClass (
  684. const BSTR a_Class ,
  685. long a_Flags ,
  686. IWbemContext *a_Context ,
  687. IWbemCallResult **a_CallResult
  688. )
  689. {
  690. HRESULT t_Result = S_OK ;
  691. InterlockedIncrement ( & m_InProgress ) ;
  692. if ( m_GateClosed == 1 )
  693. {
  694. t_Result = WBEM_E_SHUTTING_DOWN ;
  695. }
  696. else
  697. {
  698. BOOL t_Impersonating = FALSE ;
  699. IUnknown *t_OldContext = NULL ;
  700. IServerSecurity *t_OldSecurity = NULL ;
  701. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  702. if ( SUCCEEDED ( t_Result ) )
  703. {
  704. BOOL t_Revert = FALSE ;
  705. IUnknown *t_Proxy = NULL ;
  706. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  707. if ( t_Result == WBEM_E_NOT_FOUND )
  708. {
  709. t_Result = m_CoreService->DeleteClass (
  710. a_Class,
  711. a_Flags,
  712. a_Context,
  713. a_CallResult
  714. ) ;
  715. }
  716. else
  717. {
  718. if ( SUCCEEDED ( t_Result ) )
  719. {
  720. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  721. // Set cloaking on the proxy
  722. // =========================
  723. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  724. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  725. t_Service ,
  726. RPC_C_AUTHN_LEVEL_CONNECT ,
  727. t_ImpersonationLevel
  728. ) ;
  729. if ( SUCCEEDED ( t_Result ) )
  730. {
  731. BSTR t_Class = SysAllocString ( a_Class ) ;
  732. if ( t_Class )
  733. {
  734. t_Result = t_Service->DeleteClass (
  735. t_Class,
  736. a_Flags,
  737. a_Context,
  738. a_CallResult
  739. ) ;
  740. SysFreeString ( t_Class ) ;
  741. }
  742. else
  743. {
  744. t_Result = WBEM_E_OUT_OF_MEMORY ;
  745. }
  746. }
  747. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  748. }
  749. }
  750. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  751. }
  752. }
  753. InterlockedDecrement ( & m_InProgress ) ;
  754. return t_Result ;
  755. }
  756. /******************************************************************************
  757. *
  758. * Name:
  759. *
  760. *
  761. * Description:
  762. *
  763. *
  764. *****************************************************************************/
  765. HRESULT CInterceptor_IWbemServices_Stub :: DeleteClassAsync (
  766. const BSTR a_Class ,
  767. long a_Flags,
  768. IWbemContext *a_Context ,
  769. IWbemObjectSink *a_Sink
  770. )
  771. {
  772. HRESULT t_Result = S_OK ;
  773. InterlockedIncrement ( & m_InProgress ) ;
  774. if ( m_GateClosed == 1 )
  775. {
  776. t_Result = WBEM_E_SHUTTING_DOWN ;
  777. }
  778. else
  779. {
  780. BOOL t_Impersonating = FALSE ;
  781. IUnknown *t_OldContext = NULL ;
  782. IServerSecurity *t_OldSecurity = NULL ;
  783. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  784. if ( SUCCEEDED ( t_Result ) )
  785. {
  786. BOOL t_Revert = FALSE ;
  787. IUnknown *t_Proxy = NULL ;
  788. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  789. if ( t_Result == WBEM_E_NOT_FOUND )
  790. {
  791. t_Result = m_CoreService->DeleteClassAsync (
  792. a_Class ,
  793. a_Flags ,
  794. a_Context ,
  795. a_Sink
  796. ) ;
  797. }
  798. else
  799. {
  800. if ( SUCCEEDED ( t_Result ) )
  801. {
  802. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  803. // Set cloaking on the proxy
  804. // =========================
  805. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  806. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  807. t_Service ,
  808. RPC_C_AUTHN_LEVEL_CONNECT ,
  809. t_ImpersonationLevel
  810. ) ;
  811. if ( SUCCEEDED ( t_Result ) )
  812. {
  813. BSTR t_Class = SysAllocString ( a_Class ) ;
  814. if ( t_Class )
  815. {
  816. t_Result = t_Service->DeleteClassAsync (
  817. t_Class ,
  818. a_Flags ,
  819. a_Context ,
  820. a_Sink
  821. ) ;
  822. SysFreeString ( t_Class ) ;
  823. }
  824. else
  825. {
  826. t_Result = WBEM_E_OUT_OF_MEMORY ;
  827. }
  828. }
  829. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  830. }
  831. }
  832. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  833. }
  834. }
  835. InterlockedDecrement ( & m_InProgress ) ;
  836. return t_Result ;
  837. }
  838. /******************************************************************************
  839. *
  840. * Name:
  841. *
  842. *
  843. * Description:
  844. *
  845. *
  846. *****************************************************************************/
  847. HRESULT CInterceptor_IWbemServices_Stub :: CreateClassEnum (
  848. const BSTR a_Superclass ,
  849. long a_Flags,
  850. IWbemContext *a_Context ,
  851. IEnumWbemClassObject **a_Enum
  852. )
  853. {
  854. HRESULT t_Result = S_OK ;
  855. InterlockedIncrement ( & m_InProgress ) ;
  856. if ( m_GateClosed == 1 )
  857. {
  858. t_Result = WBEM_E_SHUTTING_DOWN ;
  859. }
  860. else
  861. {
  862. BOOL t_Impersonating = FALSE ;
  863. IUnknown *t_OldContext = NULL ;
  864. IServerSecurity *t_OldSecurity = NULL ;
  865. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  866. if ( SUCCEEDED ( t_Result ) )
  867. {
  868. BOOL t_Revert = FALSE ;
  869. IUnknown *t_Proxy = NULL ;
  870. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  871. if ( t_Result == WBEM_E_NOT_FOUND )
  872. {
  873. t_Result = m_CoreService->CreateClassEnum (
  874. a_Superclass,
  875. a_Flags,
  876. a_Context,
  877. a_Enum
  878. ) ;
  879. }
  880. else
  881. {
  882. if ( SUCCEEDED ( t_Result ) )
  883. {
  884. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  885. // Set cloaking on the proxy
  886. // =========================
  887. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  888. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  889. t_Service ,
  890. RPC_C_AUTHN_LEVEL_CONNECT ,
  891. t_ImpersonationLevel
  892. ) ;
  893. if ( SUCCEEDED ( t_Result ) )
  894. {
  895. BSTR t_Superclass = SysAllocString ( a_Superclass ) ;
  896. if ( t_Superclass )
  897. {
  898. t_Result = t_Service->CreateClassEnum (
  899. t_Superclass,
  900. a_Flags,
  901. a_Context,
  902. a_Enum
  903. ) ;
  904. SysFreeString ( t_Superclass ) ;
  905. }
  906. else
  907. {
  908. t_Result = WBEM_E_OUT_OF_MEMORY ;
  909. }
  910. }
  911. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  912. }
  913. }
  914. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  915. }
  916. }
  917. InterlockedDecrement ( & m_InProgress ) ;
  918. return t_Result ;
  919. }
  920. /******************************************************************************
  921. *
  922. * Name:
  923. *
  924. *
  925. * Description:
  926. *
  927. *
  928. *****************************************************************************/
  929. SCODE CInterceptor_IWbemServices_Stub :: CreateClassEnumAsync (
  930. const BSTR a_Superclass ,
  931. long a_Flags ,
  932. IWbemContext *a_Context ,
  933. IWbemObjectSink *a_Sink
  934. )
  935. {
  936. HRESULT t_Result = S_OK ;
  937. InterlockedIncrement ( & m_InProgress ) ;
  938. if ( m_GateClosed == 1 )
  939. {
  940. t_Result = WBEM_E_SHUTTING_DOWN ;
  941. }
  942. else
  943. {
  944. BOOL t_Impersonating = FALSE ;
  945. IUnknown *t_OldContext = NULL ;
  946. IServerSecurity *t_OldSecurity = NULL ;
  947. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  948. if ( SUCCEEDED ( t_Result ) )
  949. {
  950. BOOL t_Revert = FALSE ;
  951. IUnknown *t_Proxy = NULL ;
  952. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  953. if ( t_Result == WBEM_E_NOT_FOUND )
  954. {
  955. t_Result = m_CoreService->CreateClassEnumAsync (
  956. a_Superclass,
  957. a_Flags,
  958. a_Context,
  959. a_Sink
  960. ) ;
  961. }
  962. else
  963. {
  964. if ( SUCCEEDED ( t_Result ) )
  965. {
  966. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  967. // Set cloaking on the proxy
  968. // =========================
  969. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  970. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  971. t_Service ,
  972. RPC_C_AUTHN_LEVEL_CONNECT ,
  973. t_ImpersonationLevel
  974. ) ;
  975. if ( SUCCEEDED ( t_Result ) )
  976. {
  977. BSTR t_Superclass = SysAllocString ( a_Superclass ) ;
  978. if ( t_Superclass )
  979. {
  980. t_Result = t_Service->CreateClassEnumAsync (
  981. t_Superclass,
  982. a_Flags,
  983. a_Context,
  984. a_Sink
  985. ) ;
  986. SysFreeString ( t_Superclass ) ;
  987. }
  988. else
  989. {
  990. t_Result = WBEM_E_OUT_OF_MEMORY ;
  991. }
  992. }
  993. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  994. }
  995. }
  996. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  997. }
  998. }
  999. InterlockedDecrement ( & m_InProgress ) ;
  1000. return t_Result ;
  1001. }
  1002. /******************************************************************************
  1003. *
  1004. * Name:
  1005. *
  1006. *
  1007. * Description:
  1008. *
  1009. *
  1010. *****************************************************************************/
  1011. HRESULT CInterceptor_IWbemServices_Stub :: PutInstance (
  1012. IWbemClassObject *a_Instance,
  1013. long a_Flags,
  1014. IWbemContext *a_Context,
  1015. IWbemCallResult **a_CallResult
  1016. )
  1017. {
  1018. HRESULT t_Result = S_OK ;
  1019. InterlockedIncrement ( & m_InProgress ) ;
  1020. if ( m_GateClosed == 1 )
  1021. {
  1022. t_Result = WBEM_E_SHUTTING_DOWN ;
  1023. }
  1024. else
  1025. {
  1026. BOOL t_Impersonating = FALSE ;
  1027. IUnknown *t_OldContext = NULL ;
  1028. IServerSecurity *t_OldSecurity = NULL ;
  1029. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1030. if ( SUCCEEDED ( t_Result ) )
  1031. {
  1032. BOOL t_Revert = FALSE ;
  1033. IUnknown *t_Proxy = NULL ;
  1034. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1035. if ( t_Result == WBEM_E_NOT_FOUND )
  1036. {
  1037. t_Result = m_CoreService->PutInstance (
  1038. a_Instance,
  1039. a_Flags,
  1040. a_Context,
  1041. a_CallResult
  1042. ) ;
  1043. }
  1044. else
  1045. {
  1046. if ( SUCCEEDED ( t_Result ) )
  1047. {
  1048. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1049. // Set cloaking on the proxy
  1050. // =========================
  1051. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1052. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1053. t_Service ,
  1054. RPC_C_AUTHN_LEVEL_CONNECT ,
  1055. t_ImpersonationLevel
  1056. ) ;
  1057. if ( SUCCEEDED ( t_Result ) )
  1058. {
  1059. t_Result = t_Service->PutInstance (
  1060. a_Instance,
  1061. a_Flags,
  1062. a_Context,
  1063. a_CallResult
  1064. ) ;
  1065. }
  1066. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1067. }
  1068. }
  1069. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1070. }
  1071. }
  1072. InterlockedDecrement ( & m_InProgress ) ;
  1073. return t_Result ;
  1074. }
  1075. /******************************************************************************
  1076. *
  1077. * Name:
  1078. *
  1079. *
  1080. * Description:
  1081. *
  1082. *
  1083. *****************************************************************************/
  1084. HRESULT CInterceptor_IWbemServices_Stub :: PutInstanceAsync (
  1085. IWbemClassObject *a_Instance,
  1086. long a_Flags,
  1087. IWbemContext *a_Context,
  1088. IWbemObjectSink *a_Sink
  1089. )
  1090. {
  1091. HRESULT t_Result = S_OK ;
  1092. InterlockedIncrement ( & m_InProgress ) ;
  1093. if ( m_GateClosed == 1 )
  1094. {
  1095. t_Result = WBEM_E_SHUTTING_DOWN ;
  1096. }
  1097. else
  1098. {
  1099. BOOL t_Impersonating = FALSE ;
  1100. IUnknown *t_OldContext = NULL ;
  1101. IServerSecurity *t_OldSecurity = NULL ;
  1102. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1103. if ( SUCCEEDED ( t_Result ) )
  1104. {
  1105. BOOL t_Revert = FALSE ;
  1106. IUnknown *t_Proxy = NULL ;
  1107. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1108. if ( t_Result == WBEM_E_NOT_FOUND )
  1109. {
  1110. t_Result = m_CoreService->PutInstanceAsync (
  1111. a_Instance,
  1112. a_Flags,
  1113. a_Context,
  1114. a_Sink
  1115. ) ;
  1116. }
  1117. else
  1118. {
  1119. if ( SUCCEEDED ( t_Result ) )
  1120. {
  1121. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1122. // Set cloaking on the proxy
  1123. // =========================
  1124. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1125. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1126. t_Service ,
  1127. RPC_C_AUTHN_LEVEL_CONNECT ,
  1128. t_ImpersonationLevel
  1129. ) ;
  1130. if ( SUCCEEDED ( t_Result ) )
  1131. {
  1132. t_Result = t_Service->PutInstanceAsync (
  1133. a_Instance,
  1134. a_Flags,
  1135. a_Context,
  1136. a_Sink
  1137. ) ;
  1138. }
  1139. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1140. }
  1141. }
  1142. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1143. }
  1144. }
  1145. InterlockedDecrement ( & m_InProgress ) ;
  1146. return t_Result ;
  1147. }
  1148. /******************************************************************************
  1149. *
  1150. * Name:
  1151. *
  1152. *
  1153. * Description:
  1154. *
  1155. *
  1156. *****************************************************************************/
  1157. HRESULT CInterceptor_IWbemServices_Stub :: DeleteInstance (
  1158. const BSTR a_ObjectPath,
  1159. long a_Flags,
  1160. IWbemContext *a_Context,
  1161. IWbemCallResult **a_CallResult
  1162. )
  1163. {
  1164. HRESULT t_Result = S_OK ;
  1165. InterlockedIncrement ( & m_InProgress ) ;
  1166. if ( m_GateClosed == 1 )
  1167. {
  1168. t_Result = WBEM_E_SHUTTING_DOWN ;
  1169. }
  1170. else
  1171. {
  1172. BOOL t_Impersonating = FALSE ;
  1173. IUnknown *t_OldContext = NULL ;
  1174. IServerSecurity *t_OldSecurity = NULL ;
  1175. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1176. if ( SUCCEEDED ( t_Result ) )
  1177. {
  1178. BOOL t_Revert = FALSE ;
  1179. IUnknown *t_Proxy = NULL ;
  1180. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1181. if ( t_Result == WBEM_E_NOT_FOUND )
  1182. {
  1183. t_Result = m_CoreService->DeleteInstance (
  1184. a_ObjectPath,
  1185. a_Flags,
  1186. a_Context,
  1187. a_CallResult
  1188. ) ;
  1189. }
  1190. else
  1191. {
  1192. if ( SUCCEEDED ( t_Result ) )
  1193. {
  1194. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1195. // Set cloaking on the proxy
  1196. // =========================
  1197. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1198. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1199. t_Service ,
  1200. RPC_C_AUTHN_LEVEL_CONNECT ,
  1201. t_ImpersonationLevel
  1202. ) ;
  1203. if ( SUCCEEDED ( t_Result ) )
  1204. {
  1205. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  1206. if ( t_ObjectPath )
  1207. {
  1208. t_Result = t_Service->DeleteInstance (
  1209. t_ObjectPath,
  1210. a_Flags,
  1211. a_Context,
  1212. a_CallResult
  1213. ) ;
  1214. SysFreeString ( t_ObjectPath ) ;
  1215. }
  1216. else
  1217. {
  1218. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1219. }
  1220. }
  1221. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1222. }
  1223. }
  1224. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1225. }
  1226. }
  1227. InterlockedDecrement ( & m_InProgress ) ;
  1228. return t_Result ;
  1229. }
  1230. /******************************************************************************
  1231. *
  1232. * Name:
  1233. *
  1234. *
  1235. * Description:
  1236. *
  1237. *
  1238. *****************************************************************************/
  1239. HRESULT CInterceptor_IWbemServices_Stub :: DeleteInstanceAsync (
  1240. const BSTR a_ObjectPath,
  1241. long a_Flags,
  1242. IWbemContext *a_Context,
  1243. IWbemObjectSink *a_Sink
  1244. )
  1245. {
  1246. HRESULT t_Result = S_OK ;
  1247. InterlockedIncrement ( & m_InProgress ) ;
  1248. if ( m_GateClosed == 1 )
  1249. {
  1250. t_Result = WBEM_E_SHUTTING_DOWN ;
  1251. }
  1252. else
  1253. {
  1254. BOOL t_Impersonating = FALSE ;
  1255. IUnknown *t_OldContext = NULL ;
  1256. IServerSecurity *t_OldSecurity = NULL ;
  1257. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1258. if ( SUCCEEDED ( t_Result ) )
  1259. {
  1260. BOOL t_Revert = FALSE ;
  1261. IUnknown *t_Proxy = NULL ;
  1262. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1263. if ( t_Result == WBEM_E_NOT_FOUND )
  1264. {
  1265. t_Result = m_CoreService->DeleteInstanceAsync (
  1266. a_ObjectPath,
  1267. a_Flags,
  1268. a_Context,
  1269. a_Sink
  1270. ) ;
  1271. }
  1272. else
  1273. {
  1274. if ( SUCCEEDED ( t_Result ) )
  1275. {
  1276. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1277. // Set cloaking on the proxy
  1278. // =========================
  1279. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1280. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1281. t_Service ,
  1282. RPC_C_AUTHN_LEVEL_CONNECT ,
  1283. t_ImpersonationLevel
  1284. ) ;
  1285. if ( SUCCEEDED ( t_Result ) )
  1286. {
  1287. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  1288. if ( t_ObjectPath )
  1289. {
  1290. t_Result = t_Service->DeleteInstanceAsync (
  1291. t_ObjectPath,
  1292. a_Flags,
  1293. a_Context,
  1294. a_Sink
  1295. ) ;
  1296. SysFreeString ( t_ObjectPath ) ;
  1297. }
  1298. else
  1299. {
  1300. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1301. }
  1302. }
  1303. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1304. }
  1305. }
  1306. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1307. }
  1308. }
  1309. InterlockedDecrement ( & m_InProgress ) ;
  1310. return t_Result ;
  1311. }
  1312. /******************************************************************************
  1313. *
  1314. * Name:
  1315. *
  1316. *
  1317. * Description:
  1318. *
  1319. *
  1320. *****************************************************************************/
  1321. HRESULT CInterceptor_IWbemServices_Stub :: CreateInstanceEnum (
  1322. const BSTR a_Class,
  1323. long a_Flags,
  1324. IWbemContext *a_Context,
  1325. IEnumWbemClassObject **a_Enum
  1326. )
  1327. {
  1328. HRESULT t_Result = S_OK ;
  1329. InterlockedIncrement ( & m_InProgress ) ;
  1330. if ( m_GateClosed == 1 )
  1331. {
  1332. t_Result = WBEM_E_SHUTTING_DOWN ;
  1333. }
  1334. else
  1335. {
  1336. BOOL t_Impersonating = FALSE ;
  1337. IUnknown *t_OldContext = NULL ;
  1338. IServerSecurity *t_OldSecurity = NULL ;
  1339. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1340. if ( SUCCEEDED ( t_Result ) )
  1341. {
  1342. BOOL t_Revert = FALSE ;
  1343. IUnknown *t_Proxy = NULL ;
  1344. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1345. if ( t_Result == WBEM_E_NOT_FOUND )
  1346. {
  1347. t_Result = m_CoreService->CreateInstanceEnum (
  1348. a_Class,
  1349. a_Flags,
  1350. a_Context,
  1351. a_Enum
  1352. ) ;
  1353. }
  1354. else
  1355. {
  1356. if ( SUCCEEDED ( t_Result ) )
  1357. {
  1358. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1359. // Set cloaking on the proxy
  1360. // =========================
  1361. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1362. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1363. t_Service ,
  1364. RPC_C_AUTHN_LEVEL_CONNECT ,
  1365. t_ImpersonationLevel
  1366. ) ;
  1367. if ( SUCCEEDED ( t_Result ) )
  1368. {
  1369. BSTR t_Class = SysAllocString ( a_Class ) ;
  1370. if ( t_Class )
  1371. {
  1372. t_Result = t_Service->CreateInstanceEnum (
  1373. t_Class,
  1374. a_Flags,
  1375. a_Context,
  1376. a_Enum
  1377. ) ;
  1378. SysFreeString ( t_Class ) ;
  1379. }
  1380. else
  1381. {
  1382. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1383. }
  1384. }
  1385. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1386. }
  1387. }
  1388. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1389. }
  1390. }
  1391. InterlockedDecrement ( & m_InProgress ) ;
  1392. return t_Result ;
  1393. }
  1394. /******************************************************************************
  1395. *
  1396. * Name:
  1397. *
  1398. *
  1399. * Description:
  1400. *
  1401. *
  1402. *****************************************************************************/
  1403. HRESULT CInterceptor_IWbemServices_Stub :: CreateInstanceEnumAsync (
  1404. const BSTR a_Class,
  1405. long a_Flags,
  1406. IWbemContext *a_Context,
  1407. IWbemObjectSink *a_Sink
  1408. )
  1409. {
  1410. HRESULT t_Result = S_OK ;
  1411. InterlockedIncrement ( & m_InProgress ) ;
  1412. if ( m_GateClosed == 1 )
  1413. {
  1414. t_Result = WBEM_E_SHUTTING_DOWN ;
  1415. }
  1416. else
  1417. {
  1418. BOOL t_Impersonating = FALSE ;
  1419. IUnknown *t_OldContext = NULL ;
  1420. IServerSecurity *t_OldSecurity = NULL ;
  1421. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1422. if ( SUCCEEDED ( t_Result ) )
  1423. {
  1424. BOOL t_Revert = FALSE ;
  1425. IUnknown *t_Proxy = NULL ;
  1426. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1427. if ( t_Result == WBEM_E_NOT_FOUND )
  1428. {
  1429. t_Result = m_CoreService->CreateInstanceEnumAsync (
  1430. a_Class,
  1431. a_Flags,
  1432. a_Context,
  1433. a_Sink
  1434. ) ;
  1435. }
  1436. else
  1437. {
  1438. if ( SUCCEEDED ( t_Result ) )
  1439. {
  1440. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1441. // Set cloaking on the proxy
  1442. // =========================
  1443. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1444. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1445. t_Service ,
  1446. RPC_C_AUTHN_LEVEL_CONNECT ,
  1447. t_ImpersonationLevel
  1448. ) ;
  1449. if ( SUCCEEDED ( t_Result ) )
  1450. {
  1451. BSTR t_Class = SysAllocString ( a_Class ) ;
  1452. if ( t_Class )
  1453. {
  1454. t_Result = t_Service->CreateInstanceEnumAsync (
  1455. a_Class,
  1456. a_Flags,
  1457. a_Context,
  1458. a_Sink
  1459. ) ;
  1460. SysFreeString ( t_Class ) ;
  1461. }
  1462. else
  1463. {
  1464. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1465. }
  1466. }
  1467. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1468. }
  1469. }
  1470. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1471. }
  1472. }
  1473. InterlockedDecrement ( & m_InProgress ) ;
  1474. return t_Result ;
  1475. }
  1476. /******************************************************************************
  1477. *
  1478. * Name:
  1479. *
  1480. *
  1481. * Description:
  1482. *
  1483. *
  1484. *****************************************************************************/
  1485. HRESULT CInterceptor_IWbemServices_Stub :: ExecQuery (
  1486. const BSTR a_QueryLanguage,
  1487. const BSTR a_Query,
  1488. long a_Flags,
  1489. IWbemContext *a_Context,
  1490. IEnumWbemClassObject **a_Enum
  1491. )
  1492. {
  1493. HRESULT t_Result = S_OK ;
  1494. InterlockedIncrement ( & m_InProgress ) ;
  1495. if ( m_GateClosed == 1 )
  1496. {
  1497. t_Result = WBEM_E_SHUTTING_DOWN ;
  1498. }
  1499. else
  1500. {
  1501. BOOL t_Impersonating = FALSE ;
  1502. IUnknown *t_OldContext = NULL ;
  1503. IServerSecurity *t_OldSecurity = NULL ;
  1504. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1505. if ( SUCCEEDED ( t_Result ) )
  1506. {
  1507. BOOL t_Revert = FALSE ;
  1508. IUnknown *t_Proxy = NULL ;
  1509. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1510. if ( t_Result == WBEM_E_NOT_FOUND )
  1511. {
  1512. t_Result = m_CoreService->ExecQuery (
  1513. a_QueryLanguage,
  1514. a_Query,
  1515. a_Flags,
  1516. a_Context,
  1517. a_Enum
  1518. ) ;
  1519. }
  1520. else
  1521. {
  1522. if ( SUCCEEDED ( t_Result ) )
  1523. {
  1524. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1525. // Set cloaking on the proxy
  1526. // =========================
  1527. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1528. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1529. t_Service ,
  1530. RPC_C_AUTHN_LEVEL_CONNECT ,
  1531. t_ImpersonationLevel
  1532. ) ;
  1533. if ( SUCCEEDED ( t_Result ) )
  1534. {
  1535. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  1536. BSTR t_Query = SysAllocString ( a_Query ) ;
  1537. if ( t_QueryLanguage && t_Query )
  1538. {
  1539. t_Result = t_Service->ExecQuery (
  1540. t_QueryLanguage,
  1541. t_Query,
  1542. a_Flags,
  1543. a_Context,
  1544. a_Enum
  1545. ) ;
  1546. }
  1547. else
  1548. {
  1549. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1550. }
  1551. if ( t_QueryLanguage )
  1552. {
  1553. SysFreeString ( t_QueryLanguage ) ;
  1554. }
  1555. if ( t_Query )
  1556. {
  1557. SysFreeString ( t_Query ) ;
  1558. }
  1559. }
  1560. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1561. }
  1562. }
  1563. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1564. }
  1565. }
  1566. InterlockedDecrement ( & m_InProgress ) ;
  1567. return t_Result ;
  1568. }
  1569. /******************************************************************************
  1570. *
  1571. * Name:
  1572. *
  1573. *
  1574. * Description:
  1575. *
  1576. *
  1577. *****************************************************************************/
  1578. HRESULT CInterceptor_IWbemServices_Stub :: ExecQueryAsync (
  1579. const BSTR a_QueryLanguage,
  1580. const BSTR a_Query,
  1581. long a_Flags,
  1582. IWbemContext *a_Context ,
  1583. IWbemObjectSink *a_Sink
  1584. )
  1585. {
  1586. HRESULT t_Result = S_OK ;
  1587. InterlockedIncrement ( & m_InProgress ) ;
  1588. if ( m_GateClosed == 1 )
  1589. {
  1590. t_Result = WBEM_E_SHUTTING_DOWN ;
  1591. }
  1592. else
  1593. {
  1594. BOOL t_Impersonating = FALSE ;
  1595. IUnknown *t_OldContext = NULL ;
  1596. IServerSecurity *t_OldSecurity = NULL ;
  1597. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1598. if ( SUCCEEDED ( t_Result ) )
  1599. {
  1600. BOOL t_Revert = FALSE ;
  1601. IUnknown *t_Proxy = NULL ;
  1602. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1603. if ( t_Result == WBEM_E_NOT_FOUND )
  1604. {
  1605. t_Result = m_CoreService->ExecQueryAsync (
  1606. a_QueryLanguage,
  1607. a_Query,
  1608. a_Flags,
  1609. a_Context,
  1610. a_Sink
  1611. ) ;
  1612. }
  1613. else
  1614. {
  1615. if ( SUCCEEDED ( t_Result ) )
  1616. {
  1617. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1618. // Set cloaking on the proxy
  1619. // =========================
  1620. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1621. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1622. t_Service ,
  1623. RPC_C_AUTHN_LEVEL_CONNECT ,
  1624. t_ImpersonationLevel
  1625. ) ;
  1626. if ( SUCCEEDED ( t_Result ) )
  1627. {
  1628. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  1629. BSTR t_Query = SysAllocString ( a_Query ) ;
  1630. if ( t_QueryLanguage && t_Query )
  1631. {
  1632. t_Result = t_Service->ExecQueryAsync (
  1633. t_QueryLanguage,
  1634. t_Query,
  1635. a_Flags,
  1636. a_Context,
  1637. a_Sink
  1638. ) ;
  1639. }
  1640. else
  1641. {
  1642. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1643. }
  1644. if ( t_QueryLanguage )
  1645. {
  1646. SysFreeString ( t_QueryLanguage ) ;
  1647. }
  1648. if ( t_Query )
  1649. {
  1650. SysFreeString ( t_Query ) ;
  1651. }
  1652. }
  1653. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1654. }
  1655. }
  1656. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1657. }
  1658. }
  1659. InterlockedDecrement ( & m_InProgress ) ;
  1660. return t_Result ;
  1661. }
  1662. /******************************************************************************
  1663. *
  1664. * Name:
  1665. *
  1666. *
  1667. * Description:
  1668. *
  1669. *
  1670. *****************************************************************************/
  1671. HRESULT CInterceptor_IWbemServices_Stub :: ExecNotificationQuery (
  1672. const BSTR a_QueryLanguage,
  1673. const BSTR a_Query,
  1674. long a_Flags,
  1675. IWbemContext *a_Context,
  1676. IEnumWbemClassObject **a_Enum
  1677. )
  1678. {
  1679. HRESULT t_Result = S_OK ;
  1680. InterlockedIncrement ( & m_InProgress ) ;
  1681. if ( m_GateClosed == 1 )
  1682. {
  1683. t_Result = WBEM_E_SHUTTING_DOWN ;
  1684. }
  1685. else
  1686. {
  1687. BOOL t_Impersonating = FALSE ;
  1688. IUnknown *t_OldContext = NULL ;
  1689. IServerSecurity *t_OldSecurity = NULL ;
  1690. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1691. if ( SUCCEEDED ( t_Result ) )
  1692. {
  1693. BOOL t_Revert = FALSE ;
  1694. IUnknown *t_Proxy = NULL ;
  1695. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1696. if ( t_Result == WBEM_E_NOT_FOUND )
  1697. {
  1698. t_Result = m_CoreService->ExecNotificationQuery (
  1699. a_QueryLanguage,
  1700. a_Query,
  1701. a_Flags,
  1702. a_Context,
  1703. a_Enum
  1704. ) ;
  1705. }
  1706. else
  1707. {
  1708. if ( SUCCEEDED ( t_Result ) )
  1709. {
  1710. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1711. // Set cloaking on the proxy
  1712. // =========================
  1713. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1714. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1715. t_Service ,
  1716. RPC_C_AUTHN_LEVEL_CONNECT ,
  1717. t_ImpersonationLevel
  1718. ) ;
  1719. if ( SUCCEEDED ( t_Result ) )
  1720. {
  1721. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  1722. BSTR t_Query = SysAllocString ( a_Query ) ;
  1723. if ( t_QueryLanguage && t_Query )
  1724. {
  1725. t_Result = t_Service->ExecNotificationQuery (
  1726. t_QueryLanguage,
  1727. t_Query,
  1728. a_Flags,
  1729. a_Context,
  1730. a_Enum
  1731. ) ;
  1732. }
  1733. else
  1734. {
  1735. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1736. }
  1737. if ( t_QueryLanguage )
  1738. {
  1739. SysFreeString ( t_QueryLanguage ) ;
  1740. }
  1741. if ( t_Query )
  1742. {
  1743. SysFreeString ( t_Query ) ;
  1744. }
  1745. }
  1746. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1747. }
  1748. }
  1749. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1750. }
  1751. }
  1752. InterlockedDecrement ( & m_InProgress ) ;
  1753. return t_Result ;
  1754. }
  1755. /******************************************************************************
  1756. *
  1757. * Name:
  1758. *
  1759. *
  1760. * Description:
  1761. *
  1762. *
  1763. *****************************************************************************/
  1764. HRESULT CInterceptor_IWbemServices_Stub :: ExecNotificationQueryAsync (
  1765. const BSTR a_QueryLanguage,
  1766. const BSTR a_Query,
  1767. long a_Flags,
  1768. IWbemContext *a_Context,
  1769. IWbemObjectSink *a_Sink
  1770. )
  1771. {
  1772. HRESULT t_Result = S_OK ;
  1773. InterlockedIncrement ( & m_InProgress ) ;
  1774. if ( m_GateClosed == 1 )
  1775. {
  1776. t_Result = WBEM_E_SHUTTING_DOWN ;
  1777. }
  1778. else
  1779. {
  1780. BOOL t_Impersonating = FALSE ;
  1781. IUnknown *t_OldContext = NULL ;
  1782. IServerSecurity *t_OldSecurity = NULL ;
  1783. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1784. if ( SUCCEEDED ( t_Result ) )
  1785. {
  1786. BOOL t_Revert = FALSE ;
  1787. IUnknown *t_Proxy = NULL ;
  1788. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1789. if ( t_Result == WBEM_E_NOT_FOUND )
  1790. {
  1791. t_Result = m_CoreService->ExecNotificationQueryAsync (
  1792. a_QueryLanguage,
  1793. a_Query,
  1794. a_Flags,
  1795. a_Context,
  1796. a_Sink
  1797. ) ;
  1798. }
  1799. else
  1800. {
  1801. if ( SUCCEEDED ( t_Result ) )
  1802. {
  1803. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1804. // Set cloaking on the proxy
  1805. // =========================
  1806. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1807. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1808. t_Service ,
  1809. RPC_C_AUTHN_LEVEL_CONNECT ,
  1810. t_ImpersonationLevel
  1811. ) ;
  1812. if ( SUCCEEDED ( t_Result ) )
  1813. {
  1814. BSTR t_QueryLanguage = SysAllocString ( a_QueryLanguage ) ;
  1815. BSTR t_Query = SysAllocString ( a_Query ) ;
  1816. if ( t_QueryLanguage && t_Query )
  1817. {
  1818. t_Result = t_Service->ExecNotificationQueryAsync (
  1819. t_QueryLanguage,
  1820. t_Query,
  1821. a_Flags,
  1822. a_Context,
  1823. a_Sink
  1824. ) ;
  1825. }
  1826. else
  1827. {
  1828. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1829. }
  1830. if ( t_QueryLanguage )
  1831. {
  1832. SysFreeString ( t_QueryLanguage ) ;
  1833. }
  1834. if ( t_Query )
  1835. {
  1836. SysFreeString ( t_Query ) ;
  1837. }
  1838. }
  1839. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1840. }
  1841. }
  1842. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1843. }
  1844. }
  1845. InterlockedDecrement ( & m_InProgress ) ;
  1846. return t_Result ;
  1847. }
  1848. /******************************************************************************
  1849. *
  1850. * Name:
  1851. *
  1852. *
  1853. * Description:
  1854. *
  1855. *
  1856. *****************************************************************************/
  1857. HRESULT STDMETHODCALLTYPE CInterceptor_IWbemServices_Stub :: ExecMethod (
  1858. const BSTR a_ObjectPath,
  1859. const BSTR a_MethodName,
  1860. long a_Flags,
  1861. IWbemContext *a_Context,
  1862. IWbemClassObject *a_InParams,
  1863. IWbemClassObject **a_OutParams,
  1864. IWbemCallResult **a_CallResult
  1865. )
  1866. {
  1867. HRESULT t_Result = S_OK ;
  1868. InterlockedIncrement ( & m_InProgress ) ;
  1869. if ( m_GateClosed == 1 )
  1870. {
  1871. t_Result = WBEM_E_SHUTTING_DOWN ;
  1872. }
  1873. else
  1874. {
  1875. BOOL t_Impersonating = FALSE ;
  1876. IUnknown *t_OldContext = NULL ;
  1877. IServerSecurity *t_OldSecurity = NULL ;
  1878. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1879. if ( SUCCEEDED ( t_Result ) )
  1880. {
  1881. BOOL t_Revert = FALSE ;
  1882. IUnknown *t_Proxy = NULL ;
  1883. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1884. if ( t_Result == WBEM_E_NOT_FOUND )
  1885. {
  1886. t_Result = m_CoreService->ExecMethod (
  1887. a_ObjectPath,
  1888. a_MethodName,
  1889. a_Flags,
  1890. a_Context,
  1891. a_InParams,
  1892. a_OutParams,
  1893. a_CallResult
  1894. ) ;
  1895. }
  1896. else
  1897. {
  1898. if ( SUCCEEDED ( t_Result ) )
  1899. {
  1900. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1901. // Set cloaking on the proxy
  1902. // =========================
  1903. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  1904. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  1905. t_Service ,
  1906. RPC_C_AUTHN_LEVEL_CONNECT ,
  1907. t_ImpersonationLevel
  1908. ) ;
  1909. if ( SUCCEEDED ( t_Result ) )
  1910. {
  1911. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  1912. BSTR t_MethodName = SysAllocString ( a_MethodName ) ;
  1913. if ( t_ObjectPath && t_MethodName )
  1914. {
  1915. t_Result = t_Service->ExecMethod (
  1916. t_ObjectPath,
  1917. t_MethodName,
  1918. a_Flags,
  1919. a_Context,
  1920. a_InParams,
  1921. a_OutParams,
  1922. a_CallResult
  1923. ) ;
  1924. }
  1925. else
  1926. {
  1927. t_Result = WBEM_E_OUT_OF_MEMORY ;
  1928. }
  1929. if ( t_ObjectPath )
  1930. {
  1931. SysFreeString ( t_ObjectPath ) ;
  1932. }
  1933. if ( t_MethodName )
  1934. {
  1935. SysFreeString ( t_MethodName ) ;
  1936. }
  1937. }
  1938. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  1939. }
  1940. }
  1941. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1942. }
  1943. }
  1944. InterlockedDecrement ( & m_InProgress ) ;
  1945. return t_Result ;
  1946. }
  1947. /******************************************************************************
  1948. *
  1949. * Name:
  1950. *
  1951. *
  1952. * Description:
  1953. *
  1954. *
  1955. *****************************************************************************/
  1956. HRESULT STDMETHODCALLTYPE CInterceptor_IWbemServices_Stub :: ExecMethodAsync (
  1957. const BSTR a_ObjectPath,
  1958. const BSTR a_MethodName,
  1959. long a_Flags,
  1960. IWbemContext *a_Context,
  1961. IWbemClassObject *a_InParams,
  1962. IWbemObjectSink *a_Sink
  1963. )
  1964. {
  1965. HRESULT t_Result = S_OK ;
  1966. InterlockedIncrement ( & m_InProgress ) ;
  1967. if ( m_GateClosed == 1 )
  1968. {
  1969. t_Result = WBEM_E_SHUTTING_DOWN ;
  1970. }
  1971. else
  1972. {
  1973. BOOL t_Impersonating = FALSE ;
  1974. IUnknown *t_OldContext = NULL ;
  1975. IServerSecurity *t_OldSecurity = NULL ;
  1976. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1977. if ( SUCCEEDED ( t_Result ) )
  1978. {
  1979. BOOL t_Revert = FALSE ;
  1980. IUnknown *t_Proxy = NULL ;
  1981. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , IID_IWbemServices , m_CoreService , t_Proxy , t_Revert ) ;
  1982. if ( t_Result == WBEM_E_NOT_FOUND )
  1983. {
  1984. t_Result = m_CoreService->ExecMethodAsync (
  1985. a_ObjectPath,
  1986. a_MethodName,
  1987. a_Flags,
  1988. a_Context,
  1989. a_InParams,
  1990. a_Sink
  1991. ) ;
  1992. }
  1993. else
  1994. {
  1995. if ( SUCCEEDED ( t_Result ) )
  1996. {
  1997. IWbemServices *t_Service = ( IWbemServices * ) t_Proxy ;
  1998. // Set cloaking on the proxy
  1999. // =========================
  2000. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2001. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2002. t_Service ,
  2003. RPC_C_AUTHN_LEVEL_CONNECT ,
  2004. t_ImpersonationLevel
  2005. ) ;
  2006. if ( SUCCEEDED ( t_Result ) )
  2007. {
  2008. BSTR t_ObjectPath = SysAllocString ( a_ObjectPath ) ;
  2009. BSTR t_MethodName = SysAllocString ( a_MethodName ) ;
  2010. if ( t_ObjectPath && t_MethodName )
  2011. {
  2012. t_Result = t_Service->ExecMethodAsync (
  2013. a_ObjectPath,
  2014. a_MethodName,
  2015. a_Flags,
  2016. a_Context,
  2017. a_InParams,
  2018. a_Sink
  2019. ) ;
  2020. }
  2021. else
  2022. {
  2023. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2024. }
  2025. if ( t_ObjectPath )
  2026. {
  2027. SysFreeString ( t_ObjectPath ) ;
  2028. }
  2029. if ( t_MethodName )
  2030. {
  2031. SysFreeString ( t_MethodName ) ;
  2032. }
  2033. }
  2034. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemServices , t_Proxy , t_Revert ) ;
  2035. }
  2036. }
  2037. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2038. }
  2039. }
  2040. InterlockedDecrement ( & m_InProgress ) ;
  2041. return t_Result ;
  2042. }
  2043. /******************************************************************************
  2044. *
  2045. * Name:
  2046. *
  2047. *
  2048. * Description:
  2049. *
  2050. *
  2051. *****************************************************************************/
  2052. HRESULT CInterceptor_IWbemServices_Stub :: Initialize (
  2053. LPWSTR a_User,
  2054. LONG a_Flags,
  2055. LPWSTR a_Namespace,
  2056. LPWSTR a_Locale,
  2057. IWbemServices *a_Core ,
  2058. IWbemContext *a_Context ,
  2059. IWbemProviderInitSink *a_Sink
  2060. )
  2061. {
  2062. return WBEM_E_NOT_AVAILABLE ;
  2063. }
  2064. /******************************************************************************
  2065. *
  2066. * Name:
  2067. *
  2068. *
  2069. * Description:
  2070. *
  2071. *
  2072. *****************************************************************************/
  2073. HRESULT CInterceptor_IWbemServices_Stub :: Shutdown (
  2074. LONG a_Flags ,
  2075. ULONG a_MaxMilliSeconds ,
  2076. IWbemContext *a_Context
  2077. )
  2078. {
  2079. HRESULT t_Result = S_OK ;
  2080. InterlockedIncrement ( & m_GateClosed ) ;
  2081. bool t_Acquired = false ;
  2082. while ( ! t_Acquired )
  2083. {
  2084. if ( m_InProgress == 0 )
  2085. {
  2086. t_Acquired = true ;
  2087. break ;
  2088. }
  2089. ::Sleep(0);
  2090. }
  2091. return t_Result ;
  2092. }
  2093. /******************************************************************************
  2094. *
  2095. * Name:
  2096. *
  2097. *
  2098. * Description:
  2099. *
  2100. *
  2101. *****************************************************************************/
  2102. HRESULT CInterceptor_IWbemServices_Stub :: AddObjectToRefresher (
  2103. WBEM_REFRESHER_ID *a_RefresherId ,
  2104. LPCWSTR a_Path,
  2105. long a_Flags ,
  2106. IWbemContext *a_Context,
  2107. DWORD a_ClientRefresherVersion ,
  2108. WBEM_REFRESH_INFO *a_Information ,
  2109. DWORD *a_ServerRefresherVersion
  2110. )
  2111. {
  2112. HRESULT t_Result = S_OK ;
  2113. InterlockedIncrement ( & m_InProgress ) ;
  2114. if ( m_GateClosed == 1 )
  2115. {
  2116. t_Result = WBEM_E_SHUTTING_DOWN ;
  2117. }
  2118. else
  2119. {
  2120. if ( m_RefreshingService )
  2121. {
  2122. BOOL t_Impersonating = FALSE ;
  2123. IUnknown *t_OldContext = NULL ;
  2124. IServerSecurity *t_OldSecurity = NULL ;
  2125. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2126. if ( SUCCEEDED ( t_Result ) )
  2127. {
  2128. BOOL t_Revert = FALSE ;
  2129. IUnknown *t_Proxy = NULL ;
  2130. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , IID_IWbemRefreshingServices , m_RefreshingService , t_Proxy , t_Revert ) ;
  2131. if ( t_Result == WBEM_E_NOT_FOUND )
  2132. {
  2133. t_Result = m_RefreshingService->AddObjectToRefresher (
  2134. a_RefresherId ,
  2135. a_Path,
  2136. a_Flags ,
  2137. a_Context,
  2138. a_ClientRefresherVersion ,
  2139. a_Information ,
  2140. a_ServerRefresherVersion
  2141. ) ;
  2142. }
  2143. else
  2144. {
  2145. if ( SUCCEEDED ( t_Result ) )
  2146. {
  2147. IWbemRefreshingServices *t_RefreshingService = ( IWbemRefreshingServices * ) t_Proxy ;
  2148. // Set cloaking on the proxy
  2149. // =========================
  2150. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2151. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2152. t_RefreshingService ,
  2153. RPC_C_AUTHN_LEVEL_CONNECT ,
  2154. t_ImpersonationLevel
  2155. ) ;
  2156. if ( SUCCEEDED ( t_Result ) )
  2157. {
  2158. t_Result = t_RefreshingService->AddObjectToRefresher (
  2159. a_RefresherId ,
  2160. a_Path,
  2161. a_Flags ,
  2162. a_Context,
  2163. a_ClientRefresherVersion ,
  2164. a_Information ,
  2165. a_ServerRefresherVersion
  2166. ) ;
  2167. }
  2168. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , t_Proxy , t_Revert ) ;
  2169. }
  2170. }
  2171. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2172. }
  2173. }
  2174. else
  2175. {
  2176. t_Result = WBEM_E_NOT_AVAILABLE ;
  2177. }
  2178. }
  2179. InterlockedDecrement ( & m_InProgress ) ;
  2180. return t_Result ;
  2181. }
  2182. /******************************************************************************
  2183. *
  2184. * Name:
  2185. *
  2186. *
  2187. * Description:
  2188. *
  2189. *
  2190. *****************************************************************************/
  2191. HRESULT CInterceptor_IWbemServices_Stub :: AddObjectToRefresherByTemplate (
  2192. WBEM_REFRESHER_ID *a_RefresherId ,
  2193. IWbemClassObject *a_Template ,
  2194. long a_Flags ,
  2195. IWbemContext *a_Context ,
  2196. DWORD a_ClientRefresherVersion ,
  2197. WBEM_REFRESH_INFO *a_Information ,
  2198. DWORD *a_ServerRefresherVersion
  2199. )
  2200. {
  2201. HRESULT t_Result = S_OK ;
  2202. InterlockedIncrement ( & m_InProgress ) ;
  2203. if ( m_GateClosed == 1 )
  2204. {
  2205. t_Result = WBEM_E_SHUTTING_DOWN ;
  2206. }
  2207. else
  2208. {
  2209. if ( m_RefreshingService )
  2210. {
  2211. BOOL t_Impersonating = FALSE ;
  2212. IUnknown *t_OldContext = NULL ;
  2213. IServerSecurity *t_OldSecurity = NULL ;
  2214. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2215. if ( SUCCEEDED ( t_Result ) )
  2216. {
  2217. BOOL t_Revert = FALSE ;
  2218. IUnknown *t_Proxy = NULL ;
  2219. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , IID_IWbemRefreshingServices , m_RefreshingService , t_Proxy , t_Revert ) ;
  2220. if ( t_Result == WBEM_E_NOT_FOUND )
  2221. {
  2222. t_Result = m_RefreshingService->AddObjectToRefresherByTemplate (
  2223. a_RefresherId ,
  2224. a_Template ,
  2225. a_Flags ,
  2226. a_Context ,
  2227. a_ClientRefresherVersion ,
  2228. a_Information ,
  2229. a_ServerRefresherVersion
  2230. ) ;
  2231. }
  2232. else
  2233. {
  2234. if ( SUCCEEDED ( t_Result ) )
  2235. {
  2236. IWbemRefreshingServices *t_RefreshingService = ( IWbemRefreshingServices * ) t_Proxy ;
  2237. // Set cloaking on the proxy
  2238. // =========================
  2239. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2240. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2241. t_RefreshingService ,
  2242. RPC_C_AUTHN_LEVEL_CONNECT ,
  2243. t_ImpersonationLevel
  2244. ) ;
  2245. if ( SUCCEEDED ( t_Result ) )
  2246. {
  2247. t_Result = t_RefreshingService->AddObjectToRefresherByTemplate (
  2248. a_RefresherId ,
  2249. a_Template ,
  2250. a_Flags ,
  2251. a_Context ,
  2252. a_ClientRefresherVersion ,
  2253. a_Information ,
  2254. a_ServerRefresherVersion
  2255. ) ;
  2256. }
  2257. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , t_Proxy , t_Revert ) ;
  2258. }
  2259. }
  2260. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2261. }
  2262. }
  2263. else
  2264. {
  2265. t_Result = WBEM_E_NOT_AVAILABLE ;
  2266. }
  2267. }
  2268. InterlockedDecrement ( & m_InProgress ) ;
  2269. return t_Result ;
  2270. }
  2271. /******************************************************************************
  2272. *
  2273. * Name:
  2274. *
  2275. *
  2276. * Description:
  2277. *
  2278. *
  2279. *****************************************************************************/
  2280. HRESULT CInterceptor_IWbemServices_Stub :: AddEnumToRefresher (
  2281. WBEM_REFRESHER_ID *a_RefresherId ,
  2282. LPCWSTR a_Class ,
  2283. long a_Flags ,
  2284. IWbemContext *a_Context,
  2285. DWORD a_ClientRefresherVersion ,
  2286. WBEM_REFRESH_INFO *a_Information ,
  2287. DWORD *a_ServerRefresherVersion
  2288. )
  2289. {
  2290. HRESULT t_Result = S_OK ;
  2291. InterlockedIncrement ( & m_InProgress ) ;
  2292. if ( m_GateClosed == 1 )
  2293. {
  2294. t_Result = WBEM_E_SHUTTING_DOWN ;
  2295. }
  2296. else
  2297. {
  2298. if ( m_RefreshingService )
  2299. {
  2300. BOOL t_Impersonating = FALSE ;
  2301. IUnknown *t_OldContext = NULL ;
  2302. IServerSecurity *t_OldSecurity = NULL ;
  2303. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2304. if ( SUCCEEDED ( t_Result ) )
  2305. {
  2306. BOOL t_Revert = FALSE ;
  2307. IUnknown *t_Proxy = NULL ;
  2308. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , IID_IWbemRefreshingServices , m_RefreshingService , t_Proxy , t_Revert ) ;
  2309. if ( t_Result == WBEM_E_NOT_FOUND )
  2310. {
  2311. t_Result = m_RefreshingService->AddEnumToRefresher (
  2312. a_RefresherId ,
  2313. a_Class ,
  2314. a_Flags ,
  2315. a_Context,
  2316. a_ClientRefresherVersion ,
  2317. a_Information ,
  2318. a_ServerRefresherVersion
  2319. ) ;
  2320. }
  2321. else
  2322. {
  2323. if ( SUCCEEDED ( t_Result ) )
  2324. {
  2325. IWbemRefreshingServices *t_RefreshingService = ( IWbemRefreshingServices * ) t_Proxy ;
  2326. // Set cloaking on the proxy
  2327. // =========================
  2328. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2329. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2330. t_RefreshingService ,
  2331. RPC_C_AUTHN_LEVEL_CONNECT ,
  2332. t_ImpersonationLevel
  2333. ) ;
  2334. if ( SUCCEEDED ( t_Result ) )
  2335. {
  2336. t_Result = t_RefreshingService->AddEnumToRefresher (
  2337. a_RefresherId ,
  2338. a_Class ,
  2339. a_Flags ,
  2340. a_Context,
  2341. a_ClientRefresherVersion ,
  2342. a_Information ,
  2343. a_ServerRefresherVersion
  2344. ) ;
  2345. }
  2346. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , t_Proxy , t_Revert ) ;
  2347. }
  2348. }
  2349. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2350. }
  2351. }
  2352. else
  2353. {
  2354. t_Result = WBEM_E_NOT_AVAILABLE ;
  2355. }
  2356. }
  2357. InterlockedDecrement ( & m_InProgress ) ;
  2358. return t_Result ;
  2359. }
  2360. /******************************************************************************
  2361. *
  2362. * Name:
  2363. *
  2364. *
  2365. * Description:
  2366. *
  2367. *
  2368. *****************************************************************************/
  2369. HRESULT CInterceptor_IWbemServices_Stub :: RemoveObjectFromRefresher (
  2370. WBEM_REFRESHER_ID *a_RefresherId ,
  2371. long a_Id ,
  2372. long a_Flags ,
  2373. DWORD a_ClientRefresherVersion ,
  2374. DWORD *a_ServerRefresherVersion
  2375. )
  2376. {
  2377. HRESULT t_Result = S_OK ;
  2378. InterlockedIncrement ( & m_InProgress ) ;
  2379. if ( m_GateClosed == 1 )
  2380. {
  2381. t_Result = WBEM_E_SHUTTING_DOWN ;
  2382. }
  2383. else
  2384. {
  2385. if ( m_RefreshingService )
  2386. {
  2387. BOOL t_Impersonating = FALSE ;
  2388. IUnknown *t_OldContext = NULL ;
  2389. IServerSecurity *t_OldSecurity = NULL ;
  2390. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2391. if ( SUCCEEDED ( t_Result ) )
  2392. {
  2393. BOOL t_Revert = FALSE ;
  2394. IUnknown *t_Proxy = NULL ;
  2395. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , IID_IWbemRefreshingServices , m_RefreshingService , t_Proxy , t_Revert ) ;
  2396. if ( t_Result == WBEM_E_NOT_FOUND )
  2397. {
  2398. t_Result = m_RefreshingService->RemoveObjectFromRefresher (
  2399. a_RefresherId ,
  2400. a_Id ,
  2401. a_Flags ,
  2402. a_ClientRefresherVersion ,
  2403. a_ServerRefresherVersion
  2404. ) ;
  2405. }
  2406. else
  2407. {
  2408. if ( SUCCEEDED ( t_Result ) )
  2409. {
  2410. IWbemRefreshingServices *t_RefreshingService = ( IWbemRefreshingServices * ) t_Proxy ;
  2411. // Set cloaking on the proxy
  2412. // =========================
  2413. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2414. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2415. t_RefreshingService ,
  2416. RPC_C_AUTHN_LEVEL_CONNECT ,
  2417. t_ImpersonationLevel
  2418. ) ;
  2419. if ( SUCCEEDED ( t_Result ) )
  2420. {
  2421. t_Result = t_RefreshingService->RemoveObjectFromRefresher (
  2422. a_RefresherId ,
  2423. a_Id ,
  2424. a_Flags ,
  2425. a_ClientRefresherVersion ,
  2426. a_ServerRefresherVersion
  2427. ) ;
  2428. }
  2429. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , t_Proxy , t_Revert ) ;
  2430. }
  2431. }
  2432. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2433. }
  2434. }
  2435. else
  2436. {
  2437. t_Result = WBEM_E_NOT_AVAILABLE ;
  2438. }
  2439. }
  2440. InterlockedDecrement ( & m_InProgress ) ;
  2441. return t_Result ;
  2442. }
  2443. /******************************************************************************
  2444. *
  2445. * Name:
  2446. *
  2447. *
  2448. * Description:
  2449. *
  2450. *
  2451. *****************************************************************************/
  2452. HRESULT CInterceptor_IWbemServices_Stub :: GetRemoteRefresher (
  2453. WBEM_REFRESHER_ID *a_RefresherId ,
  2454. long a_Flags ,
  2455. DWORD a_ClientRefresherVersion ,
  2456. IWbemRemoteRefresher **a_RemoteRefresher ,
  2457. GUID *a_Guid ,
  2458. DWORD *a_ServerRefresherVersion
  2459. )
  2460. {
  2461. HRESULT t_Result = S_OK ;
  2462. InterlockedIncrement ( & m_InProgress ) ;
  2463. if ( m_GateClosed == 1 )
  2464. {
  2465. t_Result = WBEM_E_SHUTTING_DOWN ;
  2466. }
  2467. else
  2468. {
  2469. if ( m_RefreshingService )
  2470. {
  2471. BOOL t_Impersonating = FALSE ;
  2472. IUnknown *t_OldContext = NULL ;
  2473. IServerSecurity *t_OldSecurity = NULL ;
  2474. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2475. if ( SUCCEEDED ( t_Result ) )
  2476. {
  2477. BOOL t_Revert = FALSE ;
  2478. IUnknown *t_Proxy = NULL ;
  2479. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , IID_IWbemRefreshingServices , m_RefreshingService , t_Proxy , t_Revert ) ;
  2480. if ( t_Result == WBEM_E_NOT_FOUND )
  2481. {
  2482. t_Result = m_RefreshingService->GetRemoteRefresher (
  2483. a_RefresherId ,
  2484. a_Flags ,
  2485. a_ClientRefresherVersion ,
  2486. a_RemoteRefresher ,
  2487. a_Guid ,
  2488. a_ServerRefresherVersion
  2489. ) ;
  2490. }
  2491. else
  2492. {
  2493. if ( SUCCEEDED ( t_Result ) )
  2494. {
  2495. IWbemRefreshingServices *t_RefreshingService = ( IWbemRefreshingServices * ) t_Proxy ;
  2496. // Set cloaking on the proxy
  2497. // =========================
  2498. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2499. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2500. t_RefreshingService ,
  2501. RPC_C_AUTHN_LEVEL_CONNECT ,
  2502. t_ImpersonationLevel
  2503. ) ;
  2504. if ( SUCCEEDED ( t_Result ) )
  2505. {
  2506. t_Result = t_RefreshingService->GetRemoteRefresher (
  2507. a_RefresherId ,
  2508. a_Flags ,
  2509. a_ClientRefresherVersion ,
  2510. a_RemoteRefresher ,
  2511. a_Guid ,
  2512. a_ServerRefresherVersion
  2513. ) ;
  2514. }
  2515. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , t_Proxy , t_Revert ) ;
  2516. }
  2517. }
  2518. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2519. }
  2520. }
  2521. else
  2522. {
  2523. t_Result = WBEM_E_NOT_AVAILABLE ;
  2524. }
  2525. }
  2526. InterlockedDecrement ( & m_InProgress ) ;
  2527. return t_Result ;
  2528. }
  2529. /******************************************************************************
  2530. *
  2531. * Name:
  2532. *
  2533. *
  2534. * Description:
  2535. *
  2536. *
  2537. *****************************************************************************/
  2538. HRESULT CInterceptor_IWbemServices_Stub :: ReconnectRemoteRefresher (
  2539. WBEM_REFRESHER_ID *a_RefresherId,
  2540. long a_Flags,
  2541. long a_NumberOfObjects,
  2542. DWORD a_ClientRefresherVersion ,
  2543. WBEM_RECONNECT_INFO *a_ReconnectInformation ,
  2544. WBEM_RECONNECT_RESULTS *a_ReconnectResults ,
  2545. DWORD *a_ServerRefresherVersion
  2546. )
  2547. {
  2548. HRESULT t_Result = S_OK ;
  2549. InterlockedIncrement ( & m_InProgress ) ;
  2550. if ( m_GateClosed == 1 )
  2551. {
  2552. t_Result = WBEM_E_SHUTTING_DOWN ;
  2553. }
  2554. else
  2555. {
  2556. if ( m_RefreshingService )
  2557. {
  2558. BOOL t_Impersonating = FALSE ;
  2559. IUnknown *t_OldContext = NULL ;
  2560. IServerSecurity *t_OldSecurity = NULL ;
  2561. t_Result = DecoupledProviderSubSystem_Globals :: BeginCallbackImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2562. if ( SUCCEEDED ( t_Result ) )
  2563. {
  2564. BOOL t_Revert = FALSE ;
  2565. IUnknown *t_Proxy = NULL ;
  2566. t_Result = DecoupledProviderSubSystem_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , IID_IWbemRefreshingServices , m_RefreshingService , t_Proxy , t_Revert ) ;
  2567. if ( t_Result == WBEM_E_NOT_FOUND )
  2568. {
  2569. t_Result = m_RefreshingService->ReconnectRemoteRefresher (
  2570. a_RefresherId,
  2571. a_Flags,
  2572. a_NumberOfObjects,
  2573. a_ClientRefresherVersion ,
  2574. a_ReconnectInformation ,
  2575. a_ReconnectResults ,
  2576. a_ServerRefresherVersion
  2577. ) ;
  2578. }
  2579. else
  2580. {
  2581. if ( SUCCEEDED ( t_Result ) )
  2582. {
  2583. IWbemRefreshingServices *t_RefreshingService = ( IWbemRefreshingServices * ) t_Proxy ;
  2584. // Set cloaking on the proxy
  2585. // =========================
  2586. DWORD t_ImpersonationLevel = DecoupledProviderSubSystem_Globals :: GetCurrentImpersonationLevel () ;
  2587. t_Result = DecoupledProviderSubSystem_Globals :: SetCloaking (
  2588. t_RefreshingService ,
  2589. RPC_C_AUTHN_LEVEL_CONNECT ,
  2590. t_ImpersonationLevel
  2591. ) ;
  2592. if ( SUCCEEDED ( t_Result ) )
  2593. {
  2594. t_Result = t_RefreshingService->ReconnectRemoteRefresher (
  2595. a_RefresherId,
  2596. a_Flags,
  2597. a_NumberOfObjects,
  2598. a_ClientRefresherVersion ,
  2599. a_ReconnectInformation ,
  2600. a_ReconnectResults ,
  2601. a_ServerRefresherVersion
  2602. ) ;
  2603. }
  2604. HRESULT t_TempResult = DecoupledProviderSubSystem_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Stub_IWbemRefreshingServices , t_Proxy , t_Revert ) ;
  2605. }
  2606. }
  2607. DecoupledProviderSubSystem_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2608. }
  2609. }
  2610. else
  2611. {
  2612. t_Result = WBEM_E_NOT_AVAILABLE ;
  2613. }
  2614. }
  2615. InterlockedDecrement ( & m_InProgress ) ;
  2616. return t_Result ;
  2617. }