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.

2698 lines
64 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. ProvFact.cpp
  5. Abstract:
  6. History:
  7. --*/
  8. #include "PreComp.h"
  9. #include <wbemint.h>
  10. #include <NCObjApi.h>
  11. #include "Globals.h"
  12. #include "CGlobals.h"
  13. #include "ProvRegInfo.h"
  14. #include "ProvObSk.h"
  15. #include "ProvInSk.h"
  16. #include "StaThread.h"
  17. #include "StaTask.h"
  18. /******************************************************************************
  19. *
  20. * Name:
  21. *
  22. *
  23. * Description:
  24. *
  25. *
  26. *****************************************************************************/
  27. WmiStatusCode CServerObject_StaThread :: Initialize_Callback ()
  28. {
  29. CoInitializeEx ( NULL , COINIT_APARTMENTTHREADED ) ;
  30. return e_StatusCode_Success ;
  31. }
  32. /******************************************************************************
  33. *
  34. * Name:
  35. *
  36. *
  37. * Description:
  38. *
  39. *
  40. *****************************************************************************/
  41. WmiStatusCode CServerObject_StaThread :: UnInitialize_Callback ()
  42. {
  43. if ( m_User == NULL )
  44. {
  45. SysFreeString ( m_User ) ;
  46. }
  47. if ( m_Locale == NULL )
  48. {
  49. SysFreeString ( m_Locale ) ;
  50. }
  51. if ( m_Scope )
  52. {
  53. delete [] m_Scope ;
  54. }
  55. if ( m_Namespace )
  56. {
  57. delete [] m_Namespace ;
  58. }
  59. if ( m_NamespacePath )
  60. {
  61. m_NamespacePath->Release() ;
  62. }
  63. if ( m_Context )
  64. {
  65. m_Context->Release () ;
  66. }
  67. if ( m_Repository )
  68. {
  69. m_Repository->Release () ;
  70. }
  71. CWbemGlobal_IWmiObjectSinkController :: UnInitialize () ;
  72. CoUninitialize () ;
  73. return e_StatusCode_Success ;
  74. }
  75. /******************************************************************************
  76. *
  77. * Name:
  78. *
  79. *
  80. * Description:
  81. *
  82. *
  83. *****************************************************************************/
  84. void CServerObject_StaThread :: CallBackRelease ()
  85. {
  86. if ( m_Provider_IUnknown )
  87. {
  88. m_Provider_IUnknown->Release () ;
  89. m_Provider_IUnknown = NULL ;
  90. }
  91. if ( m_Provider_IWbemServices )
  92. {
  93. m_Provider_IWbemServices->Release () ;
  94. m_Provider_IWbemServices = NULL ;
  95. }
  96. if ( m_Provider_IWbemEventConsumerProvider )
  97. {
  98. m_Provider_IWbemEventConsumerProvider->Release () ;
  99. m_Provider_IWbemEventConsumerProvider = NULL ;
  100. }
  101. if ( m_Provider_IWbemEventConsumerProviderEx )
  102. {
  103. m_Provider_IWbemEventConsumerProviderEx->Release () ;
  104. m_Provider_IWbemEventConsumerProviderEx= NULL ;
  105. }
  106. if ( m_Provider_IWbemUnboundObjectSink )
  107. {
  108. m_Provider_IWbemUnboundObjectSink->Release () ;
  109. m_Provider_IWbemUnboundObjectSink = NULL ;
  110. }
  111. if ( m_Provider_IWbemEventProvider )
  112. {
  113. m_Provider_IWbemEventProvider->Release () ;
  114. m_Provider_IWbemEventProvider = NULL ;
  115. }
  116. if ( m_Provider_IWbemEventProviderQuerySink )
  117. {
  118. m_Provider_IWbemEventProviderQuerySink->Release () ;
  119. m_Provider_IWbemEventProviderQuerySink = NULL ;
  120. }
  121. if ( m_Provider_IWbemEventProviderSecurity )
  122. {
  123. m_Provider_IWbemEventProviderSecurity->Release () ;
  124. m_Provider_IWbemEventProviderSecurity = NULL ;
  125. }
  126. WmiStatusCode t_StatusCode = m_ProxyContainer.UnInitialize () ;
  127. }
  128. #pragma warning( disable : 4355 )
  129. /******************************************************************************
  130. *
  131. * Name:
  132. *
  133. *
  134. * Description:
  135. *
  136. *
  137. *****************************************************************************/
  138. CServerObject_StaThread :: CServerObject_StaThread (
  139. WmiAllocator &a_Allocator,
  140. CServerObject_ProviderRegistrationV1& a_Registration
  141. ) : WmiThread < ULONG > ( a_Allocator ) ,
  142. CWbemGlobal_IWmiObjectSinkController ( a_Allocator ) ,
  143. m_Allocator ( a_Allocator ) ,
  144. m_Flags ( 0 ) ,
  145. m_Context ( NULL ) ,
  146. m_TransactionIdentifier ( NULL ) ,
  147. m_User ( NULL ) ,
  148. m_Namespace ( NULL ) ,
  149. m_NamespacePath ( NULL ),
  150. m_Repository ( NULL ) ,
  151. m_Provider_IUnknown ( NULL ) ,
  152. m_Provider_IWbemServices ( NULL ) ,
  153. m_Provider_IWbemEventConsumerProvider ( NULL ) ,
  154. m_Provider_IWbemEventConsumerProviderEx ( NULL ) ,
  155. m_Provider_IWbemUnboundObjectSink ( NULL ) ,
  156. m_Provider_IWbemEventProvider ( NULL ) ,
  157. m_Provider_IWbemEventProviderQuerySink ( NULL ) ,
  158. m_Provider_IWbemEventProviderSecurity ( NULL ) ,
  159. m_ProviderName ( NULL ) ,
  160. m_ProxyContainer ( a_Allocator , ProxyIndex_Sta_Size , MAX_PROXIES ),
  161. m_Registration(&a_Registration)
  162. {
  163. m_Registration->AddRef();
  164. SetStackSize ( ProviderSubSystem_Common_Globals :: GetDefaultStackSize () ) ;
  165. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CServerObject_StaThread_ObjectsInProgress ) ;
  166. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  167. }
  168. #pragma warning( default : 4355 )
  169. /******************************************************************************
  170. *
  171. * Name:
  172. *
  173. *
  174. * Description:
  175. *
  176. *
  177. *****************************************************************************/
  178. CServerObject_StaThread::~CServerObject_StaThread ()
  179. {
  180. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CServerObject_StaThread_ObjectsInProgress ) ;
  181. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  182. m_Registration->Release();
  183. }
  184. /******************************************************************************
  185. *
  186. * Name:
  187. *
  188. *
  189. * Description:
  190. *
  191. *
  192. *****************************************************************************/
  193. HRESULT CServerObject_StaThread :: SetContext ( IWbemContext *a_Context )
  194. {
  195. HRESULT t_Result = S_OK ;
  196. if ( a_Context )
  197. {
  198. m_Context = a_Context ;
  199. m_Context->AddRef () ;
  200. }
  201. return t_Result ;
  202. }
  203. /******************************************************************************
  204. *
  205. * Name:
  206. *
  207. *
  208. * Description:
  209. *
  210. *
  211. *****************************************************************************/
  212. HRESULT CServerObject_StaThread :: SetScope ( LPCWSTR a_Scope )
  213. {
  214. HRESULT t_Result = S_OK ;
  215. if ( a_Scope )
  216. {
  217. m_Scope = DupString( a_Scope ) ;
  218. if ( m_Scope == 0)
  219. {
  220. t_Result = WBEM_E_OUT_OF_MEMORY ;
  221. }
  222. }
  223. return t_Result ;
  224. }
  225. /******************************************************************************
  226. *
  227. * Name:
  228. *
  229. *
  230. * Description:
  231. *
  232. *
  233. *****************************************************************************/
  234. HRESULT CServerObject_StaThread :: SetNamespace ( LPCWSTR a_Namespace )
  235. {
  236. HRESULT t_Result = S_OK ;
  237. if ( a_Namespace )
  238. {
  239. m_Namespace = DupString ( a_Namespace );
  240. if ( m_Namespace == 0)
  241. {
  242. t_Result = WBEM_E_OUT_OF_MEMORY ;
  243. }
  244. }
  245. return t_Result ;
  246. }
  247. /******************************************************************************
  248. *
  249. * Name:
  250. *
  251. *
  252. * Description:
  253. *
  254. *
  255. *****************************************************************************/
  256. HRESULT CServerObject_StaThread :: SetNamespacePath ( IWbemPath *a_NamespacePath )
  257. {
  258. HRESULT t_Result = S_OK ;
  259. if ( a_NamespacePath )
  260. {
  261. m_NamespacePath = a_NamespacePath ;
  262. m_NamespacePath->AddRef () ;
  263. }
  264. return t_Result ;
  265. }
  266. /******************************************************************************
  267. *
  268. * Name:
  269. *
  270. *
  271. * Description:
  272. *
  273. *
  274. *****************************************************************************/
  275. HRESULT CServerObject_StaThread :: SetRepository ( IWbemServices *a_Repository )
  276. {
  277. HRESULT t_Result = S_OK ;
  278. if ( a_Repository )
  279. {
  280. m_Repository = a_Repository ;
  281. m_Repository->AddRef () ;
  282. }
  283. return t_Result ;
  284. }
  285. /******************************************************************************
  286. *
  287. * Name:
  288. *
  289. *
  290. * Description:
  291. *
  292. *
  293. *****************************************************************************/
  294. HRESULT CServerObject_StaThread :: SetProviderService ( IUnknown *a_ProviderService )
  295. {
  296. HRESULT t_Result = S_OK ;
  297. if ( a_ProviderService )
  298. {
  299. m_Provider_IUnknown = a_ProviderService ;
  300. m_Provider_IUnknown->AddRef () ;
  301. HRESULT t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemServices , ( void ** ) & m_Provider_IWbemServices ) ;
  302. if ( t_TempResult != E_NOINTERFACE )
  303. {
  304. t_Result = t_TempResult ;
  305. }
  306. if ( SUCCEEDED ( t_Result ) )
  307. {
  308. t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemEventConsumerProvider , ( void ** ) & m_Provider_IWbemEventConsumerProvider ) ;
  309. if ( t_TempResult != E_NOINTERFACE )
  310. {
  311. t_Result = t_TempResult ;
  312. }
  313. }
  314. if ( SUCCEEDED ( t_Result ) )
  315. {
  316. t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemEventConsumerProviderEx , ( void ** ) & m_Provider_IWbemEventConsumerProviderEx ) ;
  317. if ( t_TempResult != E_NOINTERFACE )
  318. {
  319. t_Result = t_TempResult ;
  320. }
  321. }
  322. if ( SUCCEEDED ( t_Result ) )
  323. {
  324. t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemUnboundObjectSink , ( void ** ) & m_Provider_IWbemUnboundObjectSink ) ;
  325. if ( t_TempResult != E_NOINTERFACE )
  326. {
  327. t_Result = t_TempResult ;
  328. }
  329. }
  330. if ( SUCCEEDED ( t_Result ) )
  331. {
  332. t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemEventProvider , ( void ** ) & m_Provider_IWbemEventProvider ) ;
  333. if ( t_TempResult != E_NOINTERFACE )
  334. {
  335. t_Result = t_TempResult ;
  336. }
  337. }
  338. if ( SUCCEEDED ( t_Result ) )
  339. {
  340. t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemEventProviderQuerySink , ( void ** ) & m_Provider_IWbemEventProviderQuerySink ) ;
  341. if ( t_TempResult != E_NOINTERFACE )
  342. {
  343. t_Result = t_TempResult ;
  344. }
  345. }
  346. if ( SUCCEEDED ( t_Result ) )
  347. {
  348. t_TempResult = a_ProviderService->QueryInterface ( IID_IWbemEventProviderSecurity , ( void ** ) & m_Provider_IWbemEventProviderSecurity ) ;
  349. if ( t_TempResult != E_NOINTERFACE )
  350. {
  351. t_Result = t_TempResult ;
  352. }
  353. }
  354. }
  355. return t_Result ;
  356. }
  357. /******************************************************************************
  358. *
  359. * Name:
  360. *
  361. *
  362. * Description:
  363. *
  364. *
  365. *****************************************************************************/
  366. HRESULT CServerObject_StaThread :: SetProviderName ( wchar_t *a_ProviderName )
  367. {
  368. HRESULT t_Result = S_OK ;
  369. if ( m_ProviderName )
  370. {
  371. delete [] m_ProviderName ;
  372. }
  373. m_ProviderName = DupString ( a_ProviderName );
  374. if ( m_ProviderName == 0)
  375. {
  376. t_Result = WBEM_E_OUT_OF_MEMORY ;
  377. }
  378. return t_Result ;
  379. }
  380. /******************************************************************************
  381. *
  382. * Name:
  383. *
  384. *
  385. * Description:
  386. *
  387. *
  388. *****************************************************************************/
  389. HRESULT CServerObject_StaThread :: InitializeProvider (
  390. GUID *a_TransactionIdentifier ,
  391. LPCWSTR a_User ,
  392. LPCWSTR a_Locale ,
  393. LPCWSTR a_Namespace ,
  394. IWbemPath *a_NamespacePath ,
  395. IWbemServices *a_Repository ,
  396. LONG a_Flags ,
  397. IWbemContext *a_Context ,
  398. LPCWSTR a_Scope ,
  399. CServerObject_ProviderRegistrationV1 &a_Registration
  400. )
  401. {
  402. HRESULT t_Result = S_OK ;
  403. wchar_t t_TransactionIdentifier [ sizeof ( L"{00000000-0000-0000-0000-000000000000}" ) ] ;
  404. if ( a_TransactionIdentifier )
  405. {
  406. StringFromGUID2 ( *a_TransactionIdentifier , t_TransactionIdentifier , sizeof ( t_TransactionIdentifier ) / sizeof ( wchar_t ) );
  407. }
  408. if ( a_Registration.GetEventProviderRegistration ().Supported () )
  409. {
  410. IWbemProviderIdentity *t_ProviderIdentity = NULL ;
  411. HRESULT t_TempResult = m_Provider_IUnknown->QueryInterface ( IID_IWbemProviderIdentity , ( void ** ) & t_ProviderIdentity ) ;
  412. if ( SUCCEEDED ( t_TempResult ) )
  413. {
  414. BOOL t_Impersonating = FALSE ;
  415. IUnknown *t_OldContext = NULL ;
  416. IServerSecurity *t_OldSecurity = NULL ;
  417. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  418. if ( SUCCEEDED ( t_Result ) )
  419. {
  420. BOOL t_Revert = FALSE ;
  421. IUnknown *t_Proxy = NULL ;
  422. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( IID_IWbemProviderIdentity , t_ProviderIdentity , t_Proxy , t_Revert ) ;
  423. if ( t_Result == WBEM_E_NOT_FOUND )
  424. {
  425. try
  426. {
  427. t_Result = t_ProviderIdentity->SetRegistrationObject (
  428. 0 ,
  429. a_Registration.GetIdentity ()
  430. ) ;
  431. }
  432. catch ( ... )
  433. {
  434. t_Result = WBEM_E_PROVIDER_FAILURE ;
  435. }
  436. }
  437. else
  438. {
  439. if ( SUCCEEDED ( t_Result ) )
  440. {
  441. IWbemProviderIdentity *t_ProviderIdentityProxy = ( IWbemProviderIdentity * ) t_Proxy ;
  442. // Set cloaking on the proxy
  443. // =========================
  444. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  445. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  446. t_ProviderIdentityProxy ,
  447. RPC_C_AUTHN_LEVEL_DEFAULT ,
  448. t_ImpersonationLevel
  449. ) ;
  450. if ( SUCCEEDED ( t_Result ) )
  451. {
  452. t_Result = CoImpersonateClient () ;
  453. if ( SUCCEEDED ( t_Result ) )
  454. {
  455. try
  456. {
  457. t_Result = t_ProviderIdentityProxy->SetRegistrationObject (
  458. 0 ,
  459. a_Registration.GetIdentity ()
  460. ) ;
  461. }
  462. catch ( ... )
  463. {
  464. t_Result = WBEM_E_PROVIDER_FAILURE ;
  465. }
  466. CoRevertToSelf () ;
  467. }
  468. else
  469. {
  470. t_Result = WBEM_E_ACCESS_DENIED ;
  471. }
  472. }
  473. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( t_Proxy , t_Revert ) ;
  474. }
  475. }
  476. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  477. }
  478. t_ProviderIdentity->Release () ;
  479. }
  480. else
  481. {
  482. if ( t_TempResult != E_NOINTERFACE )
  483. {
  484. t_Result = t_TempResult ;
  485. }
  486. }
  487. }
  488. if ( SUCCEEDED ( t_Result ) )
  489. {
  490. IWbemProviderInit *t_ProviderInit = NULL ;
  491. HRESULT t_TempResult = m_Provider_IUnknown->QueryInterface ( IID_IWbemProviderInit , ( void ** ) & t_ProviderInit ) ;
  492. if ( SUCCEEDED ( t_TempResult ) )
  493. {
  494. if ( a_Registration.GetComRegistration ().PerUserInitialization () && a_Registration.GetComRegistration ().InitializeAsAdminFirst () )
  495. {
  496. CServerObject_ProviderInitSink *t_ProviderInitSink = new CServerObject_ProviderInitSink ;
  497. if ( t_ProviderInitSink )
  498. {
  499. t_ProviderInitSink->AddRef () ;
  500. t_Result = t_ProviderInitSink->SinkInitialize ( a_Registration.GetComRegistration ().GetSecurityDescriptor () ) ;
  501. if ( SUCCEEDED ( t_Result ) )
  502. {
  503. CInterceptor_IWbemProviderInitSink *t_Sink = new CInterceptor_IWbemProviderInitSink ( t_ProviderInitSink ) ;
  504. if ( t_Sink )
  505. {
  506. t_Sink->AddRef () ;
  507. BOOL t_Impersonating = FALSE ;
  508. IUnknown *t_OldContext = NULL ;
  509. IServerSecurity *t_OldSecurity = NULL ;
  510. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  511. if ( SUCCEEDED ( t_Result ) )
  512. {
  513. BOOL t_Revert = FALSE ;
  514. IUnknown *t_Proxy = NULL ;
  515. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( IID_IWbemProviderInit , t_ProviderInit , t_Proxy , t_Revert ) ;
  516. if ( t_Result == WBEM_E_NOT_FOUND )
  517. {
  518. try
  519. {
  520. t_Result = t_ProviderInit->Initialize (
  521. NULL ,
  522. 0 ,
  523. ( const BSTR ) a_Namespace ,
  524. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  525. a_Repository ,
  526. a_Context ,
  527. t_Sink
  528. ) ;
  529. }
  530. catch ( ... )
  531. {
  532. t_Result = WBEM_E_PROVIDER_FAILURE ;
  533. }
  534. CoRevertToSelf () ;
  535. }
  536. else
  537. {
  538. if ( SUCCEEDED ( t_Result ) )
  539. {
  540. IWbemProviderInit *t_ProviderInitProxy = ( IWbemProviderInit * ) t_Proxy ;
  541. // Set cloaking on the proxy
  542. // =========================
  543. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  544. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  545. t_ProviderInitProxy ,
  546. RPC_C_AUTHN_LEVEL_DEFAULT ,
  547. t_ImpersonationLevel
  548. ) ;
  549. if ( SUCCEEDED ( t_Result ) )
  550. {
  551. t_Result = CoImpersonateClient () ;
  552. if ( SUCCEEDED ( t_Result ) )
  553. {
  554. try
  555. {
  556. t_Result = t_ProviderInitProxy->Initialize (
  557. NULL ,
  558. 0 ,
  559. ( const BSTR ) a_Namespace ,
  560. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  561. a_Repository ,
  562. a_Context ,
  563. t_Sink
  564. ) ;
  565. }
  566. catch ( ... )
  567. {
  568. t_Result = WBEM_E_PROVIDER_FAILURE ;
  569. }
  570. CoRevertToSelf () ;
  571. }
  572. else
  573. {
  574. t_Result = WBEM_E_ACCESS_DENIED ;
  575. }
  576. }
  577. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( t_Proxy , t_Revert ) ;
  578. }
  579. }
  580. if ( SUCCEEDED ( t_Result ) )
  581. {
  582. t_ProviderInitSink->Wait ( a_Registration.GetInitializationTimeoutMilliSeconds () ) ;
  583. t_Result = t_ProviderInitSink->GetResult () ;
  584. }
  585. if ( SUCCEEDED ( t_Result ) )
  586. {
  587. WmiSetAndCommitObject (
  588. ProviderSubSystem_Globals :: s_EventClassHandles [ Msft_WmiProvider_InitializationOperationEvent ] ,
  589. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  590. a_Namespace,
  591. a_Registration.GetComRegistration ().GetClsidServer ().GetProviderName () ,
  592. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  593. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  594. a_TransactionIdentifier ? t_TransactionIdentifier : NULL
  595. ) ;
  596. }
  597. else
  598. {
  599. WmiSetAndCommitObject (
  600. ProviderSubSystem_Globals :: s_EventClassHandles [ Msft_WmiProvider_InitializationOperationFailureEvent ] ,
  601. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  602. a_Namespace,
  603. a_Registration.GetComRegistration ().GetClsidServer ().GetProviderName () ,
  604. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  605. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  606. a_TransactionIdentifier ? t_TransactionIdentifier : NULL ,
  607. t_Result
  608. ) ;
  609. t_Result = WBEM_E_PROVIDER_LOAD_FAILURE ;
  610. }
  611. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  612. }
  613. t_Sink->Release () ;
  614. }
  615. else
  616. {
  617. t_Result = WBEM_E_OUT_OF_MEMORY ;
  618. }
  619. }
  620. t_ProviderInitSink->Release () ;
  621. }
  622. else
  623. {
  624. t_Result = WBEM_E_OUT_OF_MEMORY ;
  625. }
  626. }
  627. }
  628. else
  629. {
  630. if ( t_TempResult != E_NOINTERFACE )
  631. {
  632. t_Result = t_TempResult ;
  633. }
  634. }
  635. if ( SUCCEEDED ( t_Result ) )
  636. {
  637. CServerObject_ProviderInitSink *t_ProviderInitSink = new CServerObject_ProviderInitSink ;
  638. if ( t_ProviderInitSink )
  639. {
  640. t_ProviderInitSink->AddRef () ;
  641. t_Result = t_ProviderInitSink->SinkInitialize ( a_Registration.GetComRegistration ().GetSecurityDescriptor () ) ;
  642. if ( SUCCEEDED ( t_Result ) )
  643. {
  644. CInterceptor_IWbemProviderInitSink *t_Sink = new CInterceptor_IWbemProviderInitSink ( t_ProviderInitSink ) ;
  645. if ( t_Sink )
  646. {
  647. t_Sink->AddRef () ;
  648. BOOL t_Impersonating = FALSE ;
  649. IUnknown *t_OldContext = NULL ;
  650. IServerSecurity *t_OldSecurity = NULL ;
  651. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  652. if ( SUCCEEDED ( t_Result ) )
  653. {
  654. BOOL t_Revert = FALSE ;
  655. IUnknown *t_Proxy = NULL ;
  656. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( IID_IWbemProviderInit , t_ProviderInit , t_Proxy , t_Revert ) ;
  657. if ( t_Result == WBEM_E_NOT_FOUND )
  658. {
  659. try
  660. {
  661. t_Result = t_ProviderInit->Initialize (
  662. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  663. 0 ,
  664. ( const BSTR ) a_Namespace ,
  665. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  666. a_Repository ,
  667. a_Context ,
  668. t_Sink
  669. ) ;
  670. }
  671. catch ( ... )
  672. {
  673. t_Result = WBEM_E_PROVIDER_FAILURE ;
  674. }
  675. CoRevertToSelf () ;
  676. }
  677. else
  678. {
  679. if ( SUCCEEDED ( t_Result ) )
  680. {
  681. IWbemProviderInit *t_ProviderInitProxy = ( IWbemProviderInit * ) t_Proxy ;
  682. // Set cloaking on the proxy
  683. // =========================
  684. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  685. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  686. t_ProviderInitProxy ,
  687. RPC_C_AUTHN_LEVEL_DEFAULT ,
  688. t_ImpersonationLevel
  689. ) ;
  690. if ( SUCCEEDED ( t_Result ) )
  691. {
  692. t_Result = CoImpersonateClient () ;
  693. if ( SUCCEEDED ( t_Result ) )
  694. {
  695. try
  696. {
  697. t_Result = t_ProviderInitProxy->Initialize (
  698. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  699. 0 ,
  700. ( const BSTR ) a_Namespace ,
  701. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  702. a_Repository ,
  703. a_Context ,
  704. t_Sink
  705. ) ;
  706. }
  707. catch ( ... )
  708. {
  709. t_Result = WBEM_E_PROVIDER_FAILURE ;
  710. }
  711. CoRevertToSelf () ;
  712. }
  713. else
  714. {
  715. t_Result = WBEM_E_ACCESS_DENIED ;
  716. }
  717. }
  718. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( t_Proxy , t_Revert ) ;
  719. }
  720. }
  721. if ( SUCCEEDED ( t_Result ) )
  722. {
  723. t_ProviderInitSink->Wait ( a_Registration.GetInitializationTimeoutMilliSeconds () ) ;
  724. t_Result = t_ProviderInitSink->GetResult () ;
  725. }
  726. if ( SUCCEEDED ( t_Result ) )
  727. {
  728. WmiSetAndCommitObject (
  729. ProviderSubSystem_Globals :: s_EventClassHandles [ Msft_WmiProvider_InitializationOperationEvent ] ,
  730. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  731. a_Namespace,
  732. a_Registration.GetComRegistration ().GetClsidServer ().GetProviderName () ,
  733. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  734. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  735. a_TransactionIdentifier ? t_TransactionIdentifier : NULL
  736. ) ;
  737. }
  738. else
  739. {
  740. WmiSetAndCommitObject (
  741. ProviderSubSystem_Globals :: s_EventClassHandles [ Msft_WmiProvider_InitializationOperationFailureEvent ] ,
  742. WMI_SENDCOMMIT_SET_NOT_REQUIRED,
  743. a_Namespace,
  744. a_Registration.GetComRegistration ().GetClsidServer ().GetProviderName () ,
  745. a_Registration.GetComRegistration ().PerUserInitialization () ? ( const BSTR ) a_User : NULL ,
  746. a_Registration.GetComRegistration ().PerLocaleInitialization () ? ( const BSTR ) a_Locale : NULL ,
  747. a_TransactionIdentifier ? t_TransactionIdentifier : NULL ,
  748. t_Result
  749. ) ;
  750. t_Result = WBEM_E_PROVIDER_LOAD_FAILURE ;
  751. }
  752. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  753. }
  754. t_Sink->Release () ;
  755. }
  756. else
  757. {
  758. t_Result = WBEM_E_OUT_OF_MEMORY ;
  759. }
  760. }
  761. t_ProviderInitSink->Release () ;
  762. }
  763. else
  764. {
  765. t_Result = WBEM_E_OUT_OF_MEMORY ;
  766. }
  767. }
  768. t_ProviderInit->Release () ;
  769. }
  770. return t_Result ;
  771. }
  772. /******************************************************************************
  773. *
  774. * Name:
  775. *
  776. *
  777. * Description:
  778. *
  779. *
  780. *****************************************************************************/
  781. HRESULT CServerObject_StaThread :: GetApartmentInstanceProvider (
  782. GUID *a_TransactionIdentifier ,
  783. LPCWSTR a_User ,
  784. LPCWSTR a_Locale ,
  785. LPCWSTR a_Namespace ,
  786. IWbemPath *a_NamespacePath ,
  787. IWbemServices *a_Repository ,
  788. LONG a_Flags ,
  789. IWbemContext *a_Context ,
  790. LPCWSTR a_Scope ,
  791. CServerObject_ProviderRegistrationV1 &a_Registration
  792. )
  793. {
  794. HRESULT t_Result = S_OK ;
  795. m_TransactionIdentifier = a_TransactionIdentifier ;
  796. if ( a_User )
  797. {
  798. m_User = SysAllocString ( ( LPWSTR ) a_User ) ;
  799. if ( m_User == NULL )
  800. {
  801. t_Result = WBEM_E_OUT_OF_MEMORY ;
  802. return t_Result ;
  803. }
  804. }
  805. if ( SUCCEEDED ( t_Result ) )
  806. {
  807. if ( a_Locale )
  808. {
  809. m_Locale = SysAllocString ( ( LPWSTR ) a_Locale ) ;
  810. if ( m_Locale == NULL )
  811. {
  812. t_Result = WBEM_E_OUT_OF_MEMORY ;
  813. }
  814. }
  815. }
  816. if ( SUCCEEDED ( t_Result ) )
  817. {
  818. t_Result = SetScope ( a_Scope ) ;
  819. }
  820. if ( SUCCEEDED ( t_Result ) )
  821. {
  822. t_Result = SetNamespace ( a_Namespace ) ;
  823. }
  824. if ( SUCCEEDED ( t_Result ) )
  825. {
  826. t_Result = SetNamespacePath ( a_NamespacePath ) ;
  827. }
  828. if ( SUCCEEDED ( t_Result ) )
  829. {
  830. m_Flags = a_Flags ;
  831. StaTask_Create *t_Task = new StaTask_Create (
  832. m_Allocator ,
  833. *this ,
  834. a_Scope ,
  835. a_Namespace
  836. ) ;
  837. if ( t_Task )
  838. {
  839. t_Task->AddRef () ;
  840. if ( t_Task->Initialize () == e_StatusCode_Success )
  841. {
  842. t_Result = t_Task->MarshalContext (
  843. a_Context ,
  844. a_Repository
  845. ) ;
  846. if ( SUCCEEDED ( t_Result ) )
  847. {
  848. WmiStatusCode t_StatusCode = EnQueue (
  849. 0 ,
  850. *t_Task
  851. ) ;
  852. if ( t_StatusCode == e_StatusCode_Success )
  853. {
  854. t_StatusCode = t_Task->WaitInterruptable ( INFINITE ) ;
  855. if ( t_StatusCode == e_StatusCode_Success )
  856. {
  857. t_Result = t_Task->GetResultCode () ;
  858. if ( SUCCEEDED ( t_Result ) )
  859. {
  860. t_Result = t_Task->UnMarshalOutgoing () ;
  861. if ( SUCCEEDED ( t_Result ) )
  862. {
  863. t_Result = InitializeProvider (
  864. a_TransactionIdentifier ,
  865. a_User ,
  866. a_Locale ,
  867. a_Namespace ,
  868. a_NamespacePath ,
  869. a_Repository ,
  870. a_Flags ,
  871. a_Context ,
  872. a_Scope ,
  873. a_Registration
  874. ) ;
  875. }
  876. }
  877. }
  878. else
  879. {
  880. t_Result = WBEM_E_OUT_OF_MEMORY ;
  881. }
  882. }
  883. else
  884. {
  885. t_Result = WBEM_E_OUT_OF_MEMORY ;
  886. }
  887. }
  888. }
  889. else
  890. {
  891. t_Result = WBEM_E_OUT_OF_MEMORY ;
  892. }
  893. t_Task->Release () ;
  894. }
  895. else
  896. {
  897. t_Result = WBEM_E_OUT_OF_MEMORY ;
  898. }
  899. }
  900. return t_Result ;
  901. }
  902. /******************************************************************************
  903. *
  904. * Name:
  905. *
  906. *
  907. * Description:
  908. *
  909. *
  910. *****************************************************************************/
  911. STDMETHODIMP_(ULONG) CServerObject_StaThread :: AddRef ( void )
  912. {
  913. return WmiThread <ULONG> :: AddRef () ;
  914. }
  915. /******************************************************************************
  916. *
  917. * Name:
  918. *
  919. *
  920. * Description:
  921. *
  922. *
  923. *****************************************************************************/
  924. STDMETHODIMP_(ULONG) CServerObject_StaThread :: Release ( void )
  925. {
  926. return WmiThread <ULONG> :: Release () ;
  927. }
  928. /******************************************************************************
  929. *
  930. * Name:
  931. *
  932. *
  933. * Description:
  934. *
  935. *
  936. *****************************************************************************/
  937. STDMETHODIMP CServerObject_StaThread :: QueryInterface (
  938. REFIID iid ,
  939. LPVOID FAR *iplpv
  940. )
  941. {
  942. *iplpv = NULL ;
  943. if ( iid == IID_IUnknown )
  944. {
  945. *iplpv = ( LPVOID ) this ;
  946. }
  947. else if ( iid == IID_IWbemProviderInit )
  948. {
  949. *iplpv = ( LPVOID ) ( IWbemProviderInit * ) this ;
  950. }
  951. else if ( iid == IID_IWbemServices )
  952. {
  953. if ( m_Provider_IWbemServices )
  954. {
  955. *iplpv = ( LPVOID ) ( IWbemServices * ) this ;
  956. }
  957. }
  958. else if ( iid == IID_IWbemEventProvider )
  959. {
  960. if ( m_Provider_IWbemEventProvider )
  961. {
  962. *iplpv = ( LPVOID ) ( IWbemEventProvider * ) this ;
  963. }
  964. }
  965. else if ( iid == IID_IWbemEventProviderQuerySink )
  966. {
  967. if ( m_Provider_IWbemEventProviderQuerySink )
  968. {
  969. *iplpv = ( LPVOID ) ( IWbemEventProviderQuerySink * ) this ;
  970. }
  971. }
  972. else if ( iid == IID_IWbemEventProviderSecurity )
  973. {
  974. if ( m_Provider_IWbemEventProviderSecurity )
  975. {
  976. *iplpv = ( LPVOID ) ( IWbemEventProviderSecurity * ) this ;
  977. }
  978. }
  979. else if ( iid == IID_IWbemEventConsumerProvider )
  980. {
  981. if ( m_Provider_IWbemEventConsumerProvider )
  982. {
  983. *iplpv = ( LPVOID ) ( IWbemEventConsumerProvider * ) this ;
  984. }
  985. }
  986. else if ( iid == IID_IWbemEventConsumerProviderEx )
  987. {
  988. if ( m_Provider_IWbemEventConsumerProviderEx )
  989. {
  990. *iplpv = ( LPVOID ) ( IWbemEventConsumerProviderEx * ) this ;
  991. }
  992. }
  993. else if ( iid == IID_IWbemUnboundObjectSink )
  994. {
  995. if ( m_Provider_IWbemUnboundObjectSink )
  996. {
  997. *iplpv = ( LPVOID ) ( IWbemUnboundObjectSink * ) this ;
  998. }
  999. }
  1000. else if ( iid == IID_IWbemShutdown )
  1001. {
  1002. *iplpv = ( LPVOID ) ( IWbemShutdown * ) this ;
  1003. }
  1004. if ( *iplpv )
  1005. {
  1006. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  1007. return ResultFromScode ( S_OK ) ;
  1008. }
  1009. else
  1010. {
  1011. return ResultFromScode ( E_NOINTERFACE ) ;
  1012. }
  1013. }
  1014. /******************************************************************************
  1015. *
  1016. * Name:
  1017. *
  1018. *
  1019. * Description:
  1020. *
  1021. *
  1022. *****************************************************************************/
  1023. HRESULT CServerObject_StaThread::OpenNamespace (
  1024. const BSTR a_ObjectPath,
  1025. long a_Flags,
  1026. IWbemContext *a_Context,
  1027. IWbemServices **a_NamespaceService,
  1028. IWbemCallResult **a_CallResult
  1029. )
  1030. {
  1031. return WBEM_E_NOT_AVAILABLE ;
  1032. }
  1033. /******************************************************************************
  1034. *
  1035. * Name:
  1036. *
  1037. *
  1038. * Description:
  1039. *
  1040. *
  1041. *****************************************************************************/
  1042. HRESULT CServerObject_StaThread :: CancelAsyncCall (
  1043. IWbemObjectSink *a_Sink
  1044. )
  1045. {
  1046. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1047. if ( m_Provider_IWbemServices )
  1048. {
  1049. BOOL t_Revert = FALSE ;
  1050. IUnknown *t_Proxy = NULL ;
  1051. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1052. if ( t_Result == WBEM_E_NOT_FOUND )
  1053. {
  1054. t_Result = WBEM_E_UNEXPECTED ;
  1055. }
  1056. else
  1057. {
  1058. if ( SUCCEEDED ( t_Result ) )
  1059. {
  1060. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1061. // Set cloaking on the proxy
  1062. // =========================
  1063. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1064. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1065. t_Provider ,
  1066. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1067. t_ImpersonationLevel
  1068. ) ;
  1069. if ( SUCCEEDED ( t_Result ) )
  1070. {
  1071. t_Result = t_Provider->CancelAsyncCall (
  1072. a_Sink
  1073. ) ;
  1074. }
  1075. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1076. }
  1077. }
  1078. }
  1079. return t_Result ;
  1080. }
  1081. /******************************************************************************
  1082. *
  1083. * Name:
  1084. *
  1085. *
  1086. * Description:
  1087. *
  1088. *
  1089. *****************************************************************************/
  1090. HRESULT CServerObject_StaThread :: QueryObjectSink (
  1091. long a_Flags,
  1092. IWbemObjectSink **a_Sink
  1093. )
  1094. {
  1095. return WBEM_E_NOT_AVAILABLE ;
  1096. }
  1097. /******************************************************************************
  1098. *
  1099. * Name:
  1100. *
  1101. *
  1102. * Description:
  1103. *
  1104. *
  1105. *****************************************************************************/
  1106. HRESULT CServerObject_StaThread :: GetObject (
  1107. const BSTR a_ObjectPath,
  1108. long a_Flags,
  1109. IWbemContext *a_Context,
  1110. IWbemClassObject **a_Object,
  1111. IWbemCallResult **a_CallResult
  1112. )
  1113. {
  1114. return WBEM_E_NOT_AVAILABLE ;
  1115. }
  1116. /******************************************************************************
  1117. *
  1118. * Name:
  1119. *
  1120. *
  1121. * Description:
  1122. *
  1123. *
  1124. *****************************************************************************/
  1125. HRESULT CServerObject_StaThread :: GetObjectAsync (
  1126. const BSTR a_ObjectPath,
  1127. long a_Flags,
  1128. IWbemContext *a_Context,
  1129. IWbemObjectSink *a_Sink
  1130. )
  1131. {
  1132. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1133. if ( m_Provider_IWbemServices )
  1134. {
  1135. BOOL t_Revert = FALSE ;
  1136. IUnknown *t_Proxy = NULL ;
  1137. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1138. if ( t_Result == WBEM_E_NOT_FOUND )
  1139. {
  1140. t_Result = WBEM_E_UNEXPECTED ;
  1141. }
  1142. else
  1143. {
  1144. if ( SUCCEEDED ( t_Result ) )
  1145. {
  1146. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1147. // Set cloaking on the proxy
  1148. // =========================
  1149. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1150. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1151. t_Provider ,
  1152. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1153. t_ImpersonationLevel
  1154. ) ;
  1155. if ( SUCCEEDED ( t_Result ) )
  1156. {
  1157. t_Result = t_Provider->GetObjectAsync (
  1158. a_ObjectPath,
  1159. a_Flags,
  1160. a_Context,
  1161. a_Sink
  1162. ) ;
  1163. }
  1164. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1165. }
  1166. }
  1167. }
  1168. return t_Result ;
  1169. }
  1170. /******************************************************************************
  1171. *
  1172. * Name:
  1173. *
  1174. *
  1175. * Description:
  1176. *
  1177. *
  1178. *****************************************************************************/
  1179. HRESULT CServerObject_StaThread :: PutClass (
  1180. IWbemClassObject *a_Object,
  1181. long a_Flags,
  1182. IWbemContext *a_Context,
  1183. IWbemCallResult ** a_CallResult
  1184. )
  1185. {
  1186. return WBEM_E_NOT_AVAILABLE ;
  1187. }
  1188. /******************************************************************************
  1189. *
  1190. * Name:
  1191. *
  1192. *
  1193. * Description:
  1194. *
  1195. *
  1196. *****************************************************************************/
  1197. HRESULT CServerObject_StaThread :: PutClassAsync (
  1198. IWbemClassObject *a_Object,
  1199. long a_Flags,
  1200. IWbemContext *a_Context,
  1201. IWbemObjectSink *a_Sink
  1202. )
  1203. {
  1204. return WBEM_E_NOT_AVAILABLE ;
  1205. }
  1206. /******************************************************************************
  1207. *
  1208. * Name:
  1209. *
  1210. *
  1211. * Description:
  1212. *
  1213. *
  1214. *****************************************************************************/
  1215. HRESULT CServerObject_StaThread :: DeleteClass (
  1216. const BSTR a_Class,
  1217. long a_Flags,
  1218. IWbemContext *a_Context,
  1219. IWbemCallResult **a_CallResult
  1220. )
  1221. {
  1222. return WBEM_E_NOT_AVAILABLE ;
  1223. }
  1224. /******************************************************************************
  1225. *
  1226. * Name:
  1227. *
  1228. *
  1229. * Description:
  1230. *
  1231. *
  1232. *****************************************************************************/
  1233. HRESULT CServerObject_StaThread :: DeleteClassAsync (
  1234. const BSTR a_Class,
  1235. long a_Flags,
  1236. IWbemContext *a_Context,
  1237. IWbemObjectSink *a_Sink
  1238. )
  1239. {
  1240. return WBEM_E_NOT_AVAILABLE ;
  1241. }
  1242. /******************************************************************************
  1243. *
  1244. * Name:
  1245. *
  1246. *
  1247. * Description:
  1248. *
  1249. *
  1250. *****************************************************************************/
  1251. HRESULT CServerObject_StaThread :: CreateClassEnum (
  1252. const BSTR a_Superclass,
  1253. long a_Flags,
  1254. IWbemContext *a_Context,
  1255. IEnumWbemClassObject **a_Enum
  1256. )
  1257. {
  1258. return WBEM_E_NOT_AVAILABLE ;
  1259. }
  1260. /******************************************************************************
  1261. *
  1262. * Name:
  1263. *
  1264. *
  1265. * Description:
  1266. *
  1267. *
  1268. *****************************************************************************/
  1269. SCODE CServerObject_StaThread :: CreateClassEnumAsync (
  1270. const BSTR a_Superclass,
  1271. long a_Flags,
  1272. IWbemContext *a_Context,
  1273. IWbemObjectSink *a_Sink
  1274. )
  1275. {
  1276. return WBEM_E_NOT_AVAILABLE ;
  1277. }
  1278. /******************************************************************************
  1279. *
  1280. * Name:
  1281. *
  1282. *
  1283. * Description:
  1284. *
  1285. *
  1286. *****************************************************************************/
  1287. HRESULT CServerObject_StaThread :: PutInstance (
  1288. IWbemClassObject *a_Instance,
  1289. long a_Flags,
  1290. IWbemContext *a_Context,
  1291. IWbemCallResult **a_CallResult
  1292. )
  1293. {
  1294. return WBEM_E_NOT_AVAILABLE ;
  1295. }
  1296. /******************************************************************************
  1297. *
  1298. * Name:
  1299. *
  1300. *
  1301. * Description:
  1302. *
  1303. *
  1304. *****************************************************************************/
  1305. HRESULT CServerObject_StaThread :: PutInstanceAsync (
  1306. IWbemClassObject *a_Instance,
  1307. long a_Flags,
  1308. IWbemContext *a_Context,
  1309. IWbemObjectSink *a_Sink
  1310. )
  1311. {
  1312. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1313. if ( m_Provider_IWbemServices )
  1314. {
  1315. BOOL t_Revert = FALSE ;
  1316. IUnknown *t_Proxy = NULL ;
  1317. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1318. if ( t_Result == WBEM_E_NOT_FOUND )
  1319. {
  1320. t_Result = WBEM_E_UNEXPECTED ;
  1321. }
  1322. else
  1323. {
  1324. if ( SUCCEEDED ( t_Result ) )
  1325. {
  1326. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1327. // Set cloaking on the proxy
  1328. // =========================
  1329. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1330. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1331. t_Provider ,
  1332. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1333. t_ImpersonationLevel
  1334. ) ;
  1335. if ( SUCCEEDED ( t_Result ) )
  1336. {
  1337. t_Result = t_Provider->PutInstanceAsync (
  1338. a_Instance,
  1339. a_Flags,
  1340. a_Context,
  1341. a_Sink
  1342. ) ;
  1343. }
  1344. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1345. }
  1346. }
  1347. }
  1348. return t_Result ;
  1349. }
  1350. /******************************************************************************
  1351. *
  1352. * Name:
  1353. *
  1354. *
  1355. * Description:
  1356. *
  1357. *
  1358. *****************************************************************************/
  1359. HRESULT CServerObject_StaThread :: DeleteInstance (
  1360. const BSTR a_ObjectPath,
  1361. long a_Flags,
  1362. IWbemContext *a_Context,
  1363. IWbemCallResult **a_CallResult
  1364. )
  1365. {
  1366. return WBEM_E_NOT_AVAILABLE ;
  1367. }
  1368. /******************************************************************************
  1369. *
  1370. * Name:
  1371. *
  1372. *
  1373. * Description:
  1374. *
  1375. *
  1376. *****************************************************************************/
  1377. HRESULT CServerObject_StaThread :: DeleteInstanceAsync (
  1378. const BSTR a_ObjectPath,
  1379. long a_Flags,
  1380. IWbemContext *a_Context,
  1381. IWbemObjectSink *a_Sink
  1382. )
  1383. {
  1384. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1385. if ( m_Provider_IWbemServices )
  1386. {
  1387. BOOL t_Revert = FALSE ;
  1388. IUnknown *t_Proxy = NULL ;
  1389. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1390. if ( t_Result == WBEM_E_NOT_FOUND )
  1391. {
  1392. t_Result = WBEM_E_UNEXPECTED ;
  1393. }
  1394. else
  1395. {
  1396. if ( SUCCEEDED ( t_Result ) )
  1397. {
  1398. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1399. // Set cloaking on the proxy
  1400. // =========================
  1401. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1402. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1403. t_Provider ,
  1404. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1405. t_ImpersonationLevel
  1406. ) ;
  1407. if ( SUCCEEDED ( t_Result ) )
  1408. {
  1409. t_Result = t_Provider->DeleteInstanceAsync (
  1410. a_ObjectPath,
  1411. a_Flags,
  1412. a_Context,
  1413. a_Sink
  1414. ) ;
  1415. }
  1416. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1417. }
  1418. }
  1419. }
  1420. return t_Result ;
  1421. }
  1422. /******************************************************************************
  1423. *
  1424. * Name:
  1425. *
  1426. *
  1427. * Description:
  1428. *
  1429. *
  1430. *****************************************************************************/
  1431. HRESULT CServerObject_StaThread :: CreateInstanceEnum (
  1432. const BSTR a_Class,
  1433. long a_Flags,
  1434. IWbemContext *a_Context,
  1435. IEnumWbemClassObject **a_Enum
  1436. )
  1437. {
  1438. return WBEM_E_NOT_AVAILABLE ;
  1439. }
  1440. /******************************************************************************
  1441. *
  1442. * Name:
  1443. *
  1444. *
  1445. * Description:
  1446. *
  1447. *
  1448. *****************************************************************************/
  1449. HRESULT CServerObject_StaThread :: CreateInstanceEnumAsync (
  1450. const BSTR a_Class,
  1451. long a_Flags,
  1452. IWbemContext *a_Context,
  1453. IWbemObjectSink *a_Sink
  1454. )
  1455. {
  1456. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1457. if ( m_Provider_IWbemServices )
  1458. {
  1459. BOOL t_Revert = FALSE ;
  1460. IUnknown *t_Proxy = NULL ;
  1461. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1462. if ( t_Result == WBEM_E_NOT_FOUND )
  1463. {
  1464. t_Result = WBEM_E_UNEXPECTED ;
  1465. }
  1466. else
  1467. {
  1468. if ( SUCCEEDED ( t_Result ) )
  1469. {
  1470. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1471. // Set cloaking on the proxy
  1472. // =========================
  1473. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1474. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1475. t_Provider ,
  1476. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1477. t_ImpersonationLevel
  1478. ) ;
  1479. if ( SUCCEEDED ( t_Result ) )
  1480. {
  1481. t_Result = t_Provider->CreateInstanceEnumAsync (
  1482. a_Class ,
  1483. a_Flags ,
  1484. a_Context ,
  1485. a_Sink
  1486. ) ;
  1487. }
  1488. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1489. }
  1490. }
  1491. }
  1492. return t_Result ;
  1493. }
  1494. /******************************************************************************
  1495. *
  1496. * Name:
  1497. *
  1498. *
  1499. * Description:
  1500. *
  1501. *
  1502. *****************************************************************************/
  1503. HRESULT CServerObject_StaThread :: ExecQuery (
  1504. const BSTR a_QueryLanguage,
  1505. const BSTR a_Query,
  1506. long a_Flags,
  1507. IWbemContext *a_Context,
  1508. IEnumWbemClassObject **a_Enum
  1509. )
  1510. {
  1511. return WBEM_E_NOT_AVAILABLE ;
  1512. }
  1513. /******************************************************************************
  1514. *
  1515. * Name:
  1516. *
  1517. *
  1518. * Description:
  1519. *
  1520. *
  1521. *****************************************************************************/
  1522. HRESULT CServerObject_StaThread :: ExecQueryAsync (
  1523. const BSTR a_QueryLanguage,
  1524. const BSTR a_Query,
  1525. long a_Flags,
  1526. IWbemContext *a_Context,
  1527. IWbemObjectSink *a_Sink
  1528. )
  1529. {
  1530. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1531. if ( m_Provider_IWbemServices )
  1532. {
  1533. BOOL t_Revert = FALSE ;
  1534. IUnknown *t_Proxy = NULL ;
  1535. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1536. if ( t_Result == WBEM_E_NOT_FOUND )
  1537. {
  1538. t_Result = WBEM_E_UNEXPECTED ;
  1539. }
  1540. else
  1541. {
  1542. if ( SUCCEEDED ( t_Result ) )
  1543. {
  1544. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1545. // Set cloaking on the proxy
  1546. // =========================
  1547. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1548. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1549. t_Provider ,
  1550. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1551. t_ImpersonationLevel
  1552. ) ;
  1553. if ( SUCCEEDED ( t_Result ) )
  1554. {
  1555. t_Result = t_Provider->ExecQueryAsync (
  1556. a_QueryLanguage,
  1557. a_Query,
  1558. a_Flags,
  1559. a_Context,
  1560. a_Sink
  1561. ) ;
  1562. }
  1563. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1564. }
  1565. }
  1566. }
  1567. return t_Result ;
  1568. }
  1569. /******************************************************************************
  1570. *
  1571. * Name:
  1572. *
  1573. *
  1574. * Description:
  1575. *
  1576. *
  1577. *****************************************************************************/
  1578. HRESULT CServerObject_StaThread :: ExecNotificationQuery (
  1579. const BSTR a_QueryLanguage,
  1580. const BSTR a_Query,
  1581. long a_Flags,
  1582. IWbemContext *a_Context,
  1583. IEnumWbemClassObject **a_Enum
  1584. )
  1585. {
  1586. return WBEM_E_NOT_AVAILABLE ;
  1587. }
  1588. /******************************************************************************
  1589. *
  1590. * Name:
  1591. *
  1592. *
  1593. * Description:
  1594. *
  1595. *
  1596. *****************************************************************************/
  1597. HRESULT CServerObject_StaThread :: ExecNotificationQueryAsync (
  1598. const BSTR a_QueryLanguage,
  1599. const BSTR a_Query,
  1600. long a_Flags,
  1601. IWbemContext *a_Context,
  1602. IWbemObjectSink *a_Sink
  1603. )
  1604. {
  1605. return WBEM_E_NOT_AVAILABLE ;
  1606. }
  1607. /******************************************************************************
  1608. *
  1609. * Name:
  1610. *
  1611. *
  1612. * Description:
  1613. *
  1614. *
  1615. *****************************************************************************/
  1616. HRESULT STDMETHODCALLTYPE CServerObject_StaThread :: ExecMethod(
  1617. const BSTR a_ObjectPath,
  1618. const BSTR a_MethodName,
  1619. long a_Flags,
  1620. IWbemContext *a_Context,
  1621. IWbemClassObject *a_InParams,
  1622. IWbemClassObject **a_OutParams,
  1623. IWbemCallResult **a_CallResult
  1624. )
  1625. {
  1626. return WBEM_E_NOT_AVAILABLE ;
  1627. }
  1628. /******************************************************************************
  1629. *
  1630. * Name:
  1631. *
  1632. *
  1633. * Description:
  1634. *
  1635. *
  1636. *****************************************************************************/
  1637. HRESULT STDMETHODCALLTYPE CServerObject_StaThread :: ExecMethodAsync (
  1638. const BSTR a_ObjectPath,
  1639. const BSTR a_MethodName,
  1640. long a_Flags,
  1641. IWbemContext *a_Context,
  1642. IWbemClassObject *a_InParams,
  1643. IWbemObjectSink *a_Sink
  1644. )
  1645. {
  1646. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1647. if ( m_Provider_IWbemServices )
  1648. {
  1649. BOOL t_Revert = FALSE ;
  1650. IUnknown *t_Proxy = NULL ;
  1651. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , IID_IWbemServices , m_Provider_IWbemServices , t_Proxy , t_Revert ) ;
  1652. if ( t_Result == WBEM_E_NOT_FOUND )
  1653. {
  1654. t_Result = WBEM_E_UNEXPECTED ;
  1655. }
  1656. else
  1657. {
  1658. if ( SUCCEEDED ( t_Result ) )
  1659. {
  1660. IWbemServices *t_Provider = ( IWbemServices * ) t_Proxy ;
  1661. // Set cloaking on the proxy
  1662. // =========================
  1663. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1664. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1665. t_Provider ,
  1666. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1667. t_ImpersonationLevel
  1668. ) ;
  1669. if ( SUCCEEDED ( t_Result ) )
  1670. {
  1671. t_Result = t_Provider->ExecMethodAsync (
  1672. a_ObjectPath,
  1673. a_MethodName,
  1674. a_Flags,
  1675. a_Context,
  1676. a_InParams,
  1677. a_Sink
  1678. ) ;
  1679. }
  1680. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemServices , t_Proxy , t_Revert ) ;
  1681. }
  1682. }
  1683. }
  1684. return t_Result ;
  1685. }
  1686. /******************************************************************************
  1687. *
  1688. * Name:
  1689. *
  1690. *
  1691. * Description:
  1692. *
  1693. *
  1694. *****************************************************************************/
  1695. HRESULT CServerObject_StaThread :: ProvideEvents (
  1696. IWbemObjectSink *a_Sink ,
  1697. long a_Flags
  1698. )
  1699. {
  1700. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1701. if ( m_Provider_IWbemEventProvider )
  1702. {
  1703. BOOL t_Revert = FALSE ;
  1704. IUnknown *t_Proxy = NULL ;
  1705. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProvider , IID_IWbemEventProvider , m_Provider_IWbemEventProvider , t_Proxy , t_Revert ) ;
  1706. if ( t_Result == WBEM_E_NOT_FOUND )
  1707. {
  1708. t_Result = WBEM_E_UNEXPECTED ;
  1709. }
  1710. else
  1711. {
  1712. if ( SUCCEEDED ( t_Result ) )
  1713. {
  1714. IWbemEventProvider *t_Provider = ( IWbemEventProvider * ) t_Proxy ;
  1715. // Set cloaking on the proxy
  1716. // =========================
  1717. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1718. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1719. t_Provider ,
  1720. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1721. t_ImpersonationLevel
  1722. ) ;
  1723. if ( SUCCEEDED ( t_Result ) )
  1724. {
  1725. t_Result = t_Provider->ProvideEvents (
  1726. a_Sink ,
  1727. a_Flags
  1728. ) ;
  1729. }
  1730. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProvider , t_Proxy , t_Revert ) ;
  1731. }
  1732. }
  1733. }
  1734. return t_Result ;
  1735. }
  1736. /******************************************************************************
  1737. *
  1738. * Name:
  1739. *
  1740. *
  1741. * Description:
  1742. *
  1743. *
  1744. *****************************************************************************/
  1745. HRESULT CServerObject_StaThread :: NewQuery (
  1746. unsigned long a_Id ,
  1747. WBEM_WSTR a_QueryLanguage ,
  1748. WBEM_WSTR a_Query
  1749. )
  1750. {
  1751. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1752. if ( m_Provider_IWbemEventProviderQuerySink )
  1753. {
  1754. BOOL t_Revert = FALSE ;
  1755. IUnknown *t_Proxy = NULL ;
  1756. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProviderQuerySink , IID_IWbemEventProviderQuerySink , m_Provider_IWbemEventProviderQuerySink , t_Proxy , t_Revert ) ;
  1757. if ( t_Result == WBEM_E_NOT_FOUND )
  1758. {
  1759. t_Result = WBEM_E_UNEXPECTED ;
  1760. }
  1761. else
  1762. {
  1763. if ( SUCCEEDED ( t_Result ) )
  1764. {
  1765. IWbemEventProviderQuerySink *t_Provider = ( IWbemEventProviderQuerySink * ) t_Proxy ;
  1766. // Set cloaking on the proxy
  1767. // =========================
  1768. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1769. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1770. t_Provider ,
  1771. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1772. t_ImpersonationLevel
  1773. ) ;
  1774. if ( SUCCEEDED ( t_Result ) )
  1775. {
  1776. t_Result = t_Provider->NewQuery (
  1777. a_Id ,
  1778. a_QueryLanguage ,
  1779. a_Query
  1780. ) ;
  1781. }
  1782. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProviderQuerySink , t_Proxy , t_Revert ) ;
  1783. }
  1784. }
  1785. }
  1786. return t_Result ;
  1787. }
  1788. /******************************************************************************
  1789. *
  1790. * Name:
  1791. *
  1792. *
  1793. * Description:
  1794. *
  1795. *
  1796. *****************************************************************************/
  1797. HRESULT CServerObject_StaThread :: CancelQuery (
  1798. unsigned long a_Id
  1799. )
  1800. {
  1801. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1802. if ( m_Provider_IWbemEventProviderQuerySink )
  1803. {
  1804. BOOL t_Revert = FALSE ;
  1805. IUnknown *t_Proxy = NULL ;
  1806. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProviderQuerySink , IID_IWbemEventProviderQuerySink , m_Provider_IWbemEventProviderQuerySink , t_Proxy , t_Revert ) ;
  1807. if ( t_Result == WBEM_E_NOT_FOUND )
  1808. {
  1809. t_Result = WBEM_E_UNEXPECTED ;
  1810. }
  1811. else
  1812. {
  1813. if ( SUCCEEDED ( t_Result ) )
  1814. {
  1815. IWbemEventProviderQuerySink *t_Provider = ( IWbemEventProviderQuerySink * ) t_Proxy ;
  1816. // Set cloaking on the proxy
  1817. // =========================
  1818. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1819. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1820. t_Provider ,
  1821. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1822. t_ImpersonationLevel
  1823. ) ;
  1824. if ( SUCCEEDED ( t_Result ) )
  1825. {
  1826. t_Result = t_Provider->CancelQuery (
  1827. a_Id
  1828. ) ;
  1829. }
  1830. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProviderQuerySink , t_Proxy , t_Revert ) ;
  1831. }
  1832. }
  1833. }
  1834. return t_Result ;
  1835. }
  1836. /******************************************************************************
  1837. *
  1838. * Name:
  1839. *
  1840. *
  1841. * Description:
  1842. *
  1843. *
  1844. *****************************************************************************/
  1845. HRESULT CServerObject_StaThread :: AccessCheck (
  1846. WBEM_CWSTR a_QueryLanguage ,
  1847. WBEM_CWSTR a_Query ,
  1848. long a_SidLength ,
  1849. const BYTE *a_Sid
  1850. )
  1851. {
  1852. HRESULT t_Result = WBEM_E_PROVIDER_NOT_CAPABLE ;
  1853. if ( m_Provider_IWbemEventProviderSecurity )
  1854. {
  1855. BOOL t_Revert = FALSE ;
  1856. IUnknown *t_Proxy = NULL ;
  1857. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProviderSecurity , IID_IWbemEventProviderSecurity , m_Provider_IWbemEventProviderSecurity , t_Proxy , t_Revert ) ;
  1858. if ( t_Result == WBEM_E_NOT_FOUND )
  1859. {
  1860. t_Result = WBEM_E_UNEXPECTED ;
  1861. }
  1862. else
  1863. {
  1864. if ( SUCCEEDED ( t_Result ) )
  1865. {
  1866. IWbemEventProviderSecurity *t_Provider = ( IWbemEventProviderSecurity * ) t_Proxy ;
  1867. // Set cloaking on the proxy
  1868. // =========================
  1869. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1870. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1871. t_Provider ,
  1872. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1873. t_ImpersonationLevel
  1874. ) ;
  1875. if ( SUCCEEDED ( t_Result ) )
  1876. {
  1877. t_Result = t_Provider->AccessCheck (
  1878. a_QueryLanguage ,
  1879. a_Query ,
  1880. a_SidLength ,
  1881. a_Sid
  1882. ) ;
  1883. }
  1884. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventProviderSecurity , t_Proxy , t_Revert ) ;
  1885. }
  1886. }
  1887. }
  1888. return t_Result ;
  1889. }
  1890. /******************************************************************************
  1891. *
  1892. * Name:
  1893. *
  1894. *
  1895. * Description:
  1896. *
  1897. *
  1898. *****************************************************************************/
  1899. HRESULT CServerObject_StaThread ::FindConsumer (
  1900. IWbemClassObject *a_LogicalConsumer ,
  1901. IWbemUnboundObjectSink **a_Consumer
  1902. )
  1903. {
  1904. if ( m_Provider_IWbemEventConsumerProvider )
  1905. {
  1906. IWbemUnboundObjectSink *t_Consumer = NULL ;
  1907. BOOL t_Impersonating = FALSE ;
  1908. IUnknown *t_OldContext = NULL ;
  1909. IServerSecurity *t_OldSecurity = NULL ;
  1910. HRESULT t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1911. if ( SUCCEEDED ( t_Result ) )
  1912. {
  1913. BOOL t_Revert = FALSE ;
  1914. IUnknown *t_Proxy = NULL ;
  1915. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventConsumerProvider , IID_IWbemEventConsumerProvider , m_Provider_IWbemEventConsumerProvider , t_Proxy , t_Revert ) ;
  1916. if ( t_Result == WBEM_E_NOT_FOUND )
  1917. {
  1918. try
  1919. {
  1920. t_Result = m_Provider_IWbemEventConsumerProvider->FindConsumer (
  1921. a_LogicalConsumer ,
  1922. & t_Consumer
  1923. ) ;
  1924. }
  1925. catch ( ... )
  1926. {
  1927. t_Result = WBEM_E_PROVIDER_FAILURE ;
  1928. }
  1929. CoRevertToSelf () ;
  1930. }
  1931. else
  1932. {
  1933. if ( SUCCEEDED ( t_Result ) )
  1934. {
  1935. IWbemEventConsumerProvider *t_Provider = ( IWbemEventConsumerProvider * ) t_Proxy ;
  1936. // Set cloaking on the proxy
  1937. // =========================
  1938. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1939. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1940. t_Provider ,
  1941. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1942. t_ImpersonationLevel
  1943. ) ;
  1944. if ( SUCCEEDED ( t_Result ) )
  1945. {
  1946. t_Result = CoImpersonateClient () ;
  1947. if ( SUCCEEDED ( t_Result ) )
  1948. {
  1949. try
  1950. {
  1951. t_Result = t_Provider->FindConsumer (
  1952. a_LogicalConsumer ,
  1953. & t_Consumer
  1954. ) ;
  1955. }
  1956. catch ( ... )
  1957. {
  1958. t_Result = WBEM_E_PROVIDER_FAILURE ;
  1959. }
  1960. CoRevertToSelf () ;
  1961. }
  1962. else
  1963. {
  1964. t_Result = WBEM_E_ACCESS_DENIED ;
  1965. }
  1966. }
  1967. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventConsumerProvider , t_Proxy , t_Revert ) ;
  1968. }
  1969. }
  1970. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1971. }
  1972. if ( SUCCEEDED ( t_Result ) )
  1973. {
  1974. if ( a_Consumer )
  1975. {
  1976. CInterceptor_IWbemSyncUnboundObjectSink *t_UnboundObjectSink = new CInterceptor_IWbemSyncUnboundObjectSink (
  1977. m_Allocator ,
  1978. t_Consumer ,
  1979. this ,
  1980. *m_Registration
  1981. ) ;
  1982. if ( t_UnboundObjectSink )
  1983. {
  1984. t_UnboundObjectSink->AddRef () ;
  1985. t_Result = t_UnboundObjectSink->Initialize () ;
  1986. if ( SUCCEEDED ( t_Result ) )
  1987. {
  1988. CWbemGlobal_VoidPointerController_Container_Iterator t_Iterator ;
  1989. Lock () ;
  1990. WmiStatusCode t_StatusCode = Insert (
  1991. *t_UnboundObjectSink ,
  1992. t_Iterator
  1993. ) ;
  1994. if ( t_StatusCode == e_StatusCode_Success )
  1995. {
  1996. UnLock () ;
  1997. *a_Consumer = t_UnboundObjectSink ;
  1998. t_UnboundObjectSink->AddRef () ;
  1999. }
  2000. else
  2001. {
  2002. UnLock () ;
  2003. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2004. }
  2005. }
  2006. t_UnboundObjectSink->Release () ;
  2007. }
  2008. }
  2009. }
  2010. if ( t_Consumer )
  2011. {
  2012. t_Consumer->Release () ;
  2013. }
  2014. return t_Result ;
  2015. }
  2016. return WBEM_E_PROVIDER_NOT_CAPABLE;
  2017. }
  2018. /******************************************************************************
  2019. *
  2020. * Name:
  2021. *
  2022. *
  2023. * Description:
  2024. *
  2025. *
  2026. *****************************************************************************/
  2027. HRESULT CServerObject_StaThread ::ValidateSubscription (
  2028. IWbemClassObject *a_LogicalConsumer
  2029. )
  2030. {
  2031. if ( m_Provider_IWbemEventConsumerProviderEx )
  2032. {
  2033. BOOL t_Impersonating = FALSE ;
  2034. IUnknown *t_OldContext = NULL ;
  2035. IServerSecurity *t_OldSecurity = NULL ;
  2036. HRESULT t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2037. if ( SUCCEEDED ( t_Result ) )
  2038. {
  2039. BOOL t_Revert = FALSE ;
  2040. IUnknown *t_Proxy = NULL ;
  2041. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventConsumerProviderEx , IID_IWbemEventConsumerProviderEx , m_Provider_IWbemEventConsumerProviderEx , t_Proxy , t_Revert ) ;
  2042. if ( t_Result == WBEM_E_NOT_FOUND )
  2043. {
  2044. try
  2045. {
  2046. t_Result = m_Provider_IWbemEventConsumerProviderEx->ValidateSubscription (
  2047. a_LogicalConsumer
  2048. ) ;
  2049. }
  2050. catch ( ... )
  2051. {
  2052. t_Result = WBEM_E_PROVIDER_FAILURE ;
  2053. }
  2054. CoRevertToSelf () ;
  2055. }
  2056. else
  2057. {
  2058. if ( SUCCEEDED ( t_Result ) )
  2059. {
  2060. IWbemEventConsumerProviderEx *t_Provider = ( IWbemEventConsumerProviderEx * ) t_Proxy ;
  2061. // Set cloaking on the proxy
  2062. // =========================
  2063. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  2064. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  2065. t_Provider ,
  2066. RPC_C_AUTHN_LEVEL_DEFAULT ,
  2067. t_ImpersonationLevel
  2068. ) ;
  2069. if ( SUCCEEDED ( t_Result ) )
  2070. {
  2071. t_Result = CoImpersonateClient () ;
  2072. if ( SUCCEEDED ( t_Result ) )
  2073. {
  2074. try
  2075. {
  2076. t_Result = t_Provider->ValidateSubscription (
  2077. a_LogicalConsumer
  2078. ) ;
  2079. }
  2080. catch ( ... )
  2081. {
  2082. t_Result = WBEM_E_PROVIDER_FAILURE ;
  2083. }
  2084. CoRevertToSelf () ;
  2085. }
  2086. else
  2087. {
  2088. t_Result = WBEM_E_ACCESS_DENIED ;
  2089. }
  2090. }
  2091. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemEventConsumerProviderEx , t_Proxy , t_Revert ) ;
  2092. }
  2093. }
  2094. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2095. }
  2096. return t_Result ;
  2097. }
  2098. return WBEM_E_PROVIDER_NOT_CAPABLE;
  2099. }
  2100. /******************************************************************************
  2101. *
  2102. * Name:
  2103. *
  2104. *
  2105. * Description:
  2106. *
  2107. *
  2108. *****************************************************************************/
  2109. HRESULT CServerObject_StaThread :: IndicateToConsumer (
  2110. IWbemClassObject *a_LogicalConsumer ,
  2111. long a_ObjectCount ,
  2112. IWbemClassObject **a_Objects
  2113. )
  2114. {
  2115. if ( m_Provider_IWbemUnboundObjectSink )
  2116. {
  2117. BOOL t_Impersonating = FALSE ;
  2118. IUnknown *t_OldContext = NULL ;
  2119. IServerSecurity *t_OldSecurity = NULL ;
  2120. HRESULT t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2121. if ( SUCCEEDED ( t_Result ) )
  2122. {
  2123. BOOL t_Revert = FALSE ;
  2124. IUnknown *t_Proxy = NULL ;
  2125. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemUnboundObjectSink , IID_IWbemUnboundObjectSink , m_Provider_IWbemUnboundObjectSink , t_Proxy , t_Revert ) ;
  2126. if ( t_Result == WBEM_E_NOT_FOUND )
  2127. {
  2128. t_Result = m_Provider_IWbemUnboundObjectSink->IndicateToConsumer (
  2129. a_LogicalConsumer ,
  2130. a_ObjectCount ,
  2131. a_Objects
  2132. ) ;
  2133. }
  2134. else
  2135. {
  2136. if ( SUCCEEDED ( t_Result ) )
  2137. {
  2138. IWbemUnboundObjectSink *t_Provider = ( IWbemUnboundObjectSink * ) t_Proxy ;
  2139. // Set cloaking on the proxy
  2140. // =========================
  2141. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  2142. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  2143. t_Provider ,
  2144. RPC_C_AUTHN_LEVEL_DEFAULT ,
  2145. t_ImpersonationLevel
  2146. ) ;
  2147. if ( SUCCEEDED ( t_Result ) )
  2148. {
  2149. t_Result = t_Provider->IndicateToConsumer (
  2150. a_LogicalConsumer ,
  2151. a_ObjectCount ,
  2152. a_Objects
  2153. ) ;
  2154. }
  2155. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_Sta_IWbemUnboundObjectSink , t_Proxy , t_Revert ) ;
  2156. }
  2157. }
  2158. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  2159. }
  2160. return t_Result ;
  2161. }
  2162. return WBEM_E_PROVIDER_NOT_CAPABLE;
  2163. }
  2164. /******************************************************************************
  2165. *
  2166. * Name:
  2167. *
  2168. *
  2169. * Description:
  2170. *
  2171. *
  2172. *****************************************************************************/
  2173. HRESULT CServerObject_StaThread :: Initialize (
  2174. LPWSTR a_User,
  2175. LONG a_Flags,
  2176. LPWSTR a_Namespace,
  2177. LPWSTR a_Locale,
  2178. IWbemServices *a_Core,
  2179. IWbemContext *a_Context,
  2180. IWbemProviderInitSink *a_Sink
  2181. )
  2182. {
  2183. HRESULT t_Result = S_OK ;
  2184. WmiStatusCode t_StatusCode = CWbemGlobal_IWmiObjectSinkController :: Initialize () ;
  2185. if ( t_StatusCode != e_StatusCode_Success )
  2186. {
  2187. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2188. }
  2189. if ( SUCCEEDED ( t_Result ) )
  2190. {
  2191. t_StatusCode = m_ProxyContainer.Initialize () ;
  2192. if ( t_StatusCode != e_StatusCode_Success )
  2193. {
  2194. t_Result = WBEM_E_OUT_OF_MEMORY ;
  2195. }
  2196. }
  2197. a_Sink->SetStatus ( t_Result , 0 ) ;
  2198. return t_Result ;
  2199. }
  2200. /******************************************************************************
  2201. *
  2202. * Name:
  2203. *
  2204. *
  2205. * Description:
  2206. *
  2207. *
  2208. *****************************************************************************/
  2209. HRESULT CServerObject_StaThread :: Shutdown (
  2210. LONG a_Flags ,
  2211. ULONG a_MaxMilliSeconds ,
  2212. IWbemContext *a_Context
  2213. )
  2214. {
  2215. HRESULT t_Result = S_OK ;
  2216. Lock () ;
  2217. CWbemGlobal_IWmiObjectSinkController_Container *t_Container = NULL ;
  2218. GetContainer ( t_Container ) ;
  2219. CWbemGlobal_IWmiObjectSinkController_Container_Iterator t_Iterator = t_Container->Begin ();
  2220. while ( ! t_Iterator.Null () )
  2221. {
  2222. IWbemShutdown *t_Shutdown = NULL ;
  2223. t_Result = t_Iterator.GetElement ()->QueryInterface ( IID_IWbemShutdown , ( void ** ) & t_Shutdown ) ;
  2224. t_Iterator.Increment () ;
  2225. if ( SUCCEEDED ( t_Result ) )
  2226. {
  2227. t_Result = t_Shutdown->Shutdown (
  2228. a_Flags ,
  2229. a_MaxMilliSeconds ,
  2230. a_Context
  2231. ) ;
  2232. t_Shutdown->Release () ;
  2233. }
  2234. }
  2235. CWbemGlobal_IWmiObjectSinkController :: Shutdown () ;
  2236. UnLock () ;
  2237. return t_Result ;
  2238. }