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.

1701 lines
39 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. ProvSubS.cpp
  5. Abstract:
  6. History:
  7. --*/
  8. #include <precomp.h>
  9. #include <wbemint.h>
  10. #include <HelperFuncs.h>
  11. #include <Logging.h>
  12. #include "Globals.h"
  13. #include "CGlobals.h"
  14. #include "ClassFac.h"
  15. #include "ProvRMgr.h"
  16. #include "Guids.h"
  17. /******************************************************************************
  18. *
  19. * Name:
  20. *
  21. *
  22. * Description:
  23. *
  24. *
  25. *****************************************************************************/
  26. CServerProvRefreshManagerClassFactory :: CServerProvRefreshManagerClassFactory () : m_ReferenceCount ( 0 )
  27. {
  28. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CServerProvRefreshManagerClassFactory_ObjectsInProgress ) ;
  29. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  30. }
  31. /******************************************************************************
  32. *
  33. * Name:
  34. *
  35. *
  36. * Description:
  37. *
  38. *
  39. *****************************************************************************/
  40. CServerProvRefreshManagerClassFactory :: ~CServerProvRefreshManagerClassFactory ()
  41. {
  42. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CServerProvRefreshManagerClassFactory_ObjectsInProgress ) ;
  43. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  44. }
  45. /******************************************************************************
  46. *
  47. * Name:
  48. *
  49. *
  50. * Description:
  51. *
  52. *
  53. *****************************************************************************/
  54. STDMETHODIMP CServerProvRefreshManagerClassFactory :: QueryInterface (
  55. REFIID iid ,
  56. LPVOID FAR *iplpv
  57. )
  58. {
  59. *iplpv = NULL ;
  60. if ( iid == IID_IUnknown )
  61. {
  62. *iplpv = ( LPVOID ) this ;
  63. }
  64. else if ( iid == IID_IClassFactory )
  65. {
  66. *iplpv = ( LPVOID ) ( IClassFactory * ) this ;
  67. }
  68. if ( *iplpv )
  69. {
  70. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  71. return ResultFromScode ( S_OK ) ;
  72. }
  73. else
  74. {
  75. return ResultFromScode ( E_NOINTERFACE ) ;
  76. }
  77. }
  78. /******************************************************************************
  79. *
  80. * Name:
  81. *
  82. *
  83. * Description:
  84. *
  85. *
  86. *****************************************************************************/
  87. STDMETHODIMP_( ULONG ) CServerProvRefreshManagerClassFactory :: AddRef ()
  88. {
  89. return InterlockedIncrement ( & m_ReferenceCount ) ;
  90. }
  91. /******************************************************************************
  92. *
  93. * Name:
  94. *
  95. *
  96. * Description:
  97. *
  98. *
  99. *****************************************************************************/
  100. STDMETHODIMP_(ULONG) CServerProvRefreshManagerClassFactory :: Release ()
  101. {
  102. LONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  103. if ( t_ReferenceCount == 0 )
  104. {
  105. delete this ;
  106. return 0 ;
  107. }
  108. else
  109. {
  110. return t_ReferenceCount ;
  111. }
  112. }
  113. /******************************************************************************
  114. *
  115. * Name:
  116. *
  117. *
  118. * Description:
  119. *
  120. *
  121. *****************************************************************************/
  122. STDMETHODIMP CServerProvRefreshManagerClassFactory :: CreateInstance (
  123. LPUNKNOWN pUnkOuter ,
  124. REFIID riid ,
  125. LPVOID FAR *ppvObject
  126. )
  127. {
  128. HRESULT t_Result = S_OK ;
  129. if ( pUnkOuter )
  130. {
  131. t_Result = CLASS_E_NOAGGREGATION ;
  132. }
  133. else
  134. {
  135. CServerObject_ProviderRefresherManager *t_Manager = new CServerObject_ProviderRefresherManager (
  136. *ProviderSubSystem_Globals :: s_Allocator
  137. ) ;
  138. if ( t_Manager == NULL )
  139. {
  140. t_Result = E_OUTOFMEMORY ;
  141. }
  142. else
  143. {
  144. t_Result = t_Manager->QueryInterface ( riid , ppvObject ) ;
  145. if ( FAILED ( t_Result ) )
  146. {
  147. delete t_Manager ;
  148. }
  149. else
  150. {
  151. }
  152. }
  153. }
  154. return t_Result ;
  155. }
  156. /******************************************************************************
  157. *
  158. * Name:
  159. *
  160. *
  161. * Description:
  162. *
  163. *
  164. *****************************************************************************/
  165. STDMETHODIMP CServerProvRefreshManagerClassFactory :: LockServer ( BOOL fLock )
  166. {
  167. /*
  168. * Place code in critical section
  169. */
  170. if ( fLock )
  171. {
  172. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_LocksInProgress ) ;
  173. }
  174. else
  175. {
  176. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_LocksInProgress ) ;
  177. }
  178. return S_OK ;
  179. }
  180. /******************************************************************************
  181. *
  182. * Name:
  183. *
  184. *
  185. * Description:
  186. *
  187. *
  188. *****************************************************************************/
  189. #pragma warning( disable : 4355 )
  190. CServerObject_InterceptorProviderRefresherManager :: CServerObject_InterceptorProviderRefresherManager (
  191. CWbemGlobal_IWbemRefresherMgrController *a_Controller ,
  192. const ULONG &a_Period ,
  193. WmiAllocator &a_Allocator ,
  194. IWbemContext *a_InitializationContext
  195. ) : RefresherManagerCacheElement (
  196. a_Controller ,
  197. this ,
  198. a_Period
  199. ) ,
  200. m_Allocator ( a_Allocator ) ,
  201. m_Manager ( NULL ) ,
  202. m_ProxyContainer ( m_Allocator , 2 , MAX_PROXIES ) ,
  203. m_Shutdown ( NULL ) ,
  204. m_Host ( NULL ) ,
  205. m_ReferenceCount ( 0 ) ,
  206. m_UnInitialized ( 0 ) ,
  207. m_Initialized ( 0 ) ,
  208. m_InitializeResult ( S_OK ) ,
  209. m_InitializedEvent ( NULL ) ,
  210. m_InitializationContext ( a_InitializationContext )
  211. {
  212. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CServerObject_InterceptorProviderRefresherManager_ObjectsInProgress ) ;
  213. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  214. if ( m_InitializationContext )
  215. {
  216. m_InitializationContext->AddRef () ;
  217. }
  218. }
  219. #pragma warning( default : 4355 )
  220. /******************************************************************************
  221. *
  222. * Name:
  223. *
  224. *
  225. * Description:
  226. *
  227. *
  228. *****************************************************************************/
  229. CServerObject_InterceptorProviderRefresherManager :: ~CServerObject_InterceptorProviderRefresherManager ()
  230. {
  231. if ( m_Manager )
  232. {
  233. m_Manager->Release () ;
  234. }
  235. if ( m_Host )
  236. {
  237. m_Host->Release () ;
  238. }
  239. if ( m_Shutdown )
  240. {
  241. m_Shutdown->Release () ;
  242. }
  243. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CServerObject_InterceptorProviderRefresherManager_ObjectsInProgress ) ;
  244. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  245. }
  246. /******************************************************************************
  247. *
  248. * Name:
  249. *
  250. *
  251. * Description:
  252. *
  253. *
  254. *****************************************************************************/
  255. HRESULT CServerObject_InterceptorProviderRefresherManager :: AbnormalShutdown ()
  256. {
  257. WmiStatusCode t_StatusCode = ProviderSubSystem_Globals :: GetRefresherManagerController ()->Shutdown ( this ) ;
  258. if ( t_StatusCode == e_StatusCode_Success )
  259. {
  260. }
  261. return S_OK ;
  262. }
  263. /******************************************************************************
  264. *
  265. * Name:
  266. *
  267. *
  268. * Description:
  269. *
  270. *
  271. *****************************************************************************/
  272. HRESULT CServerObject_InterceptorProviderRefresherManager :: SetManager ( _IWmiProviderHost *a_Host , _IWbemRefresherMgr *a_Manager )
  273. {
  274. if ( a_Manager )
  275. {
  276. m_Manager = a_Manager ;
  277. m_Manager->AddRef () ;
  278. }
  279. if ( a_Host )
  280. {
  281. m_Host = a_Host ;
  282. m_Host->AddRef () ;
  283. }
  284. return S_OK ;
  285. }
  286. /******************************************************************************
  287. *
  288. * Name:
  289. *
  290. *
  291. * Description:
  292. *
  293. *
  294. *****************************************************************************/
  295. HRESULT CServerObject_InterceptorProviderRefresherManager :: SetInitialized ( HRESULT a_InitializeResult )
  296. {
  297. m_InitializeResult = a_InitializeResult ;
  298. InterlockedExchange ( & m_Initialized , 1 ) ;
  299. if ( m_InitializedEvent )
  300. {
  301. SetEvent ( m_InitializedEvent ) ;
  302. }
  303. return S_OK ;
  304. }
  305. /******************************************************************************
  306. *
  307. * Name:
  308. *
  309. *
  310. * Description:
  311. *
  312. *
  313. *****************************************************************************/
  314. HRESULT CServerObject_InterceptorProviderRefresherManager :: IsIndependant ( IWbemContext *a_Context )
  315. {
  316. BOOL t_DependantCall = FALSE ;
  317. HRESULT t_Result = ProviderSubSystem_Common_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  318. if ( SUCCEEDED ( t_Result ) )
  319. {
  320. if ( t_DependantCall == FALSE )
  321. {
  322. }
  323. else
  324. {
  325. return S_FALSE ;
  326. }
  327. }
  328. return t_Result ;
  329. }
  330. /******************************************************************************
  331. *
  332. * Name:
  333. *
  334. *
  335. * Description:
  336. *
  337. *
  338. *****************************************************************************/
  339. HRESULT CServerObject_InterceptorProviderRefresherManager :: WaitProvider ( IWbemContext *a_Context , ULONG a_Timeout )
  340. {
  341. HRESULT t_Result = WBEM_E_UNEXPECTED ;
  342. if ( m_Initialized == 0 )
  343. {
  344. BOOL t_DependantCall = FALSE ;
  345. t_Result = ProviderSubSystem_Common_Globals :: IsDependantCall ( m_InitializationContext , a_Context , t_DependantCall ) ;
  346. if ( SUCCEEDED ( t_Result ) )
  347. {
  348. if ( t_DependantCall == FALSE )
  349. {
  350. if ( WaitForSingleObject ( m_InitializedEvent , a_Timeout ) == WAIT_TIMEOUT )
  351. {
  352. return WBEM_E_PROVIDER_LOAD_FAILURE ;
  353. }
  354. }
  355. else
  356. {
  357. if ( WaitForSingleObject ( m_InitializedEvent , 0 ) == WAIT_TIMEOUT )
  358. {
  359. return S_FALSE ;
  360. }
  361. }
  362. }
  363. }
  364. else
  365. {
  366. t_Result = S_OK ;
  367. }
  368. return t_Result ;
  369. }
  370. /******************************************************************************
  371. *
  372. * Name:
  373. *
  374. *
  375. * Description:
  376. *
  377. *
  378. *****************************************************************************/
  379. HRESULT CServerObject_InterceptorProviderRefresherManager :: Initialize ()
  380. {
  381. HRESULT t_Result = S_OK ;
  382. WmiStatusCode t_StatusCode = m_ProxyContainer.Initialize () ;
  383. if ( t_StatusCode != e_StatusCode_Success )
  384. {
  385. t_Result = WBEM_E_OUT_OF_MEMORY ;
  386. }
  387. return t_Result ;
  388. }
  389. /******************************************************************************
  390. *
  391. * Name:
  392. *
  393. *
  394. * Description:
  395. *
  396. *
  397. *****************************************************************************/
  398. STDMETHODIMP CServerObject_InterceptorProviderRefresherManager :: QueryInterface (
  399. REFIID iid ,
  400. LPVOID FAR *iplpv
  401. )
  402. {
  403. *iplpv = NULL ;
  404. if ( iid == IID_IUnknown )
  405. {
  406. *iplpv = ( LPVOID ) this ;
  407. }
  408. else if ( iid == IID_IWbemShutdown )
  409. {
  410. *iplpv = ( LPVOID ) ( IWbemShutdown * )this ;
  411. }
  412. else if ( iid == IID__IWbemRefresherMgr )
  413. {
  414. *iplpv = ( LPVOID ) ( _IWbemRefresherMgr * ) this ;
  415. }
  416. else if ( iid == IID_CServerObject_InterceptorProviderRefresherManager )
  417. {
  418. *iplpv = ( LPVOID ) this ;
  419. }
  420. if ( *iplpv )
  421. {
  422. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  423. return ResultFromScode ( S_OK ) ;
  424. }
  425. else
  426. {
  427. return ResultFromScode ( E_NOINTERFACE ) ;
  428. }
  429. }
  430. /******************************************************************************
  431. *
  432. * Name:
  433. *
  434. *
  435. * Description:
  436. *
  437. *
  438. *****************************************************************************/
  439. STDMETHODIMP_( ULONG ) CServerObject_InterceptorProviderRefresherManager :: AddRef ()
  440. {
  441. return RefresherManagerCacheElement :: AddRef () ;
  442. }
  443. /******************************************************************************
  444. *
  445. * Name:
  446. *
  447. *
  448. * Description:
  449. *
  450. *
  451. *****************************************************************************/
  452. STDMETHODIMP_(ULONG) CServerObject_InterceptorProviderRefresherManager :: Release ()
  453. {
  454. return RefresherManagerCacheElement :: Release () ;
  455. }
  456. /******************************************************************************
  457. *
  458. * Name:
  459. *
  460. *
  461. * Description:
  462. *
  463. *
  464. *****************************************************************************/
  465. HRESULT CServerObject_InterceptorProviderRefresherManager :: Startup (
  466. LONG a_Flags ,
  467. IWbemContext *a_Context ,
  468. _IWmiProvSS *a_ProvSS
  469. )
  470. {
  471. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  472. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  473. #endif
  474. HRESULT t_Result = S_OK ;
  475. try
  476. {
  477. BOOL t_Impersonating = FALSE ;
  478. IUnknown *t_OldContext = NULL ;
  479. IServerSecurity *t_OldSecurity = NULL ;
  480. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  481. if ( SUCCEEDED ( t_Result ) )
  482. {
  483. BOOL t_Revert = FALSE ;
  484. IUnknown *t_Proxy = NULL ;
  485. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , IID__IWbemRefresherMgr , m_Manager , t_Proxy , t_Revert ) ;
  486. if ( t_Result == WBEM_E_NOT_FOUND )
  487. {
  488. t_Result = m_Manager->Startup (
  489. a_Flags ,
  490. a_Context ,
  491. a_ProvSS
  492. ) ;
  493. }
  494. else
  495. {
  496. if ( SUCCEEDED ( t_Result ) )
  497. {
  498. _IWbemRefresherMgr *t_Manager = ( _IWbemRefresherMgr * ) t_Proxy ;
  499. // Set cloaking on the proxy
  500. // =========================
  501. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  502. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  503. t_Manager ,
  504. RPC_C_AUTHN_LEVEL_DEFAULT ,
  505. t_ImpersonationLevel
  506. ) ;
  507. if ( SUCCEEDED ( t_Result ) )
  508. {
  509. t_Result = CoImpersonateClient () ;
  510. if ( SUCCEEDED ( t_Result ) )
  511. {
  512. t_Result = t_Manager->Startup (
  513. a_Flags ,
  514. a_Context ,
  515. a_ProvSS
  516. ) ;
  517. if ( FAILED ( t_Result ) )
  518. {
  519. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  520. {
  521. AbnormalShutdown () ;
  522. }
  523. }
  524. CoRevertToSelf () ;
  525. }
  526. else
  527. {
  528. t_Result = WBEM_E_ACCESS_DENIED ;
  529. }
  530. }
  531. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , t_Proxy , t_Revert ) ;
  532. }
  533. }
  534. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  535. }
  536. if ( SUCCEEDED ( t_Result ) )
  537. {
  538. t_Result = m_Manager->QueryInterface ( IID_IWbemShutdown , ( void ** ) & m_Shutdown ) ;
  539. }
  540. }
  541. catch ( Wmi_Structured_Exception t_StructuredException )
  542. {
  543. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  544. }
  545. return t_Result ;
  546. }
  547. /******************************************************************************
  548. *
  549. * Name:
  550. *
  551. *
  552. * Description:
  553. *
  554. *
  555. *****************************************************************************/
  556. HRESULT CServerObject_InterceptorProviderRefresherManager :: Shutdown (
  557. LONG a_Flags ,
  558. ULONG a_MaxMilliSeconds ,
  559. IWbemContext *a_Context
  560. )
  561. {
  562. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  563. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  564. #endif
  565. HRESULT t_Result = S_OK ;
  566. try
  567. {
  568. if ( m_Shutdown )
  569. {
  570. BOOL t_Impersonating = FALSE ;
  571. IUnknown *t_OldContext = NULL ;
  572. IServerSecurity *t_OldSecurity = NULL ;
  573. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  574. if ( SUCCEEDED ( t_Result ) )
  575. {
  576. BOOL t_Revert = FALSE ;
  577. IUnknown *t_Proxy = NULL ;
  578. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemShutdown , IID_IWbemShutdown , m_Shutdown , t_Proxy , t_Revert ) ;
  579. if ( t_Result == WBEM_E_NOT_FOUND )
  580. {
  581. t_Result = m_Shutdown->Shutdown (
  582. a_Flags ,
  583. a_MaxMilliSeconds ,
  584. a_Context
  585. ) ;
  586. }
  587. else
  588. {
  589. if ( SUCCEEDED ( t_Result ) )
  590. {
  591. IWbemShutdown *t_Shutdown = ( IWbemShutdown * ) t_Proxy ;
  592. // Set cloaking on the proxy
  593. // =========================
  594. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  595. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  596. t_Shutdown ,
  597. RPC_C_AUTHN_LEVEL_DEFAULT ,
  598. t_ImpersonationLevel
  599. ) ;
  600. if ( SUCCEEDED ( t_Result ) )
  601. {
  602. t_Result = CoImpersonateClient () ;
  603. if ( SUCCEEDED ( t_Result ) )
  604. {
  605. t_Result = t_Shutdown->Shutdown (
  606. a_Flags ,
  607. a_MaxMilliSeconds ,
  608. a_Context
  609. ) ;
  610. if ( FAILED ( t_Result ) )
  611. {
  612. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  613. {
  614. AbnormalShutdown () ;
  615. }
  616. }
  617. CoRevertToSelf () ;
  618. }
  619. else
  620. {
  621. t_Result = WBEM_E_ACCESS_DENIED ;
  622. }
  623. }
  624. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemShutdown , t_Proxy , t_Revert ) ;
  625. }
  626. }
  627. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  628. }
  629. }
  630. }
  631. catch ( Wmi_Structured_Exception t_StructuredException )
  632. {
  633. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  634. }
  635. return t_Result ;
  636. }
  637. /******************************************************************************
  638. *
  639. * Name:
  640. *
  641. *
  642. * Description:
  643. *
  644. *
  645. *****************************************************************************/
  646. HRESULT CServerObject_InterceptorProviderRefresherManager :: AddObjectToRefresher (
  647. IWbemServices *a_Service,
  648. LPCWSTR a_ServerName,
  649. LPCWSTR a_Namespace,
  650. IWbemClassObject* pClassObject,
  651. WBEM_REFRESHER_ID *a_DestinationRefresherId,
  652. IWbemClassObject *a_InstanceTemplate,
  653. long a_Flags,
  654. IWbemContext *a_Context,
  655. IUnknown* a_pLockMgr,
  656. WBEM_REFRESH_INFO *a_Information
  657. )
  658. {
  659. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  660. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  661. #endif
  662. if ( m_Initialized == 0 )
  663. {
  664. return WBEM_E_NOT_FOUND ;
  665. }
  666. HRESULT t_Result = S_OK ;
  667. try
  668. {
  669. BOOL t_Impersonating = FALSE ;
  670. IUnknown *t_OldContext = NULL ;
  671. IServerSecurity *t_OldSecurity = NULL ;
  672. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  673. if ( SUCCEEDED ( t_Result ) )
  674. {
  675. BOOL t_Revert = FALSE ;
  676. IUnknown *t_Proxy = NULL ;
  677. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , IID__IWbemRefresherMgr , m_Manager , t_Proxy , t_Revert ) ;
  678. if ( t_Result == WBEM_E_NOT_FOUND )
  679. {
  680. t_Result = m_Manager->AddObjectToRefresher (
  681. a_Service,
  682. a_ServerName,
  683. a_Namespace,
  684. pClassObject,
  685. a_DestinationRefresherId,
  686. a_InstanceTemplate,
  687. a_Flags,
  688. a_Context,
  689. a_pLockMgr,
  690. a_Information
  691. ) ;
  692. }
  693. else
  694. {
  695. if ( SUCCEEDED ( t_Result ) )
  696. {
  697. _IWbemRefresherMgr *t_Manager = ( _IWbemRefresherMgr * ) t_Proxy ;
  698. // Set cloaking on the proxy
  699. // =========================
  700. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  701. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  702. t_Manager ,
  703. RPC_C_AUTHN_LEVEL_DEFAULT ,
  704. t_ImpersonationLevel
  705. ) ;
  706. if ( SUCCEEDED ( t_Result ) )
  707. {
  708. t_Result = CoImpersonateClient () ;
  709. if ( SUCCEEDED ( t_Result ) )
  710. {
  711. t_Result = t_Manager->AddObjectToRefresher (
  712. a_Service,
  713. a_ServerName,
  714. a_Namespace,
  715. pClassObject,
  716. a_DestinationRefresherId,
  717. a_InstanceTemplate,
  718. a_Flags,
  719. a_Context,
  720. a_pLockMgr,
  721. a_Information
  722. ) ;
  723. if ( FAILED ( t_Result ) )
  724. {
  725. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  726. {
  727. AbnormalShutdown () ;
  728. }
  729. }
  730. CoRevertToSelf () ;
  731. }
  732. else
  733. {
  734. t_Result = WBEM_E_ACCESS_DENIED ;
  735. }
  736. }
  737. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , t_Proxy , t_Revert ) ;
  738. }
  739. }
  740. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  741. }
  742. }
  743. catch ( Wmi_Structured_Exception t_StructuredException )
  744. {
  745. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  746. }
  747. return t_Result ;
  748. }
  749. /******************************************************************************
  750. *
  751. * Name:
  752. *
  753. *
  754. * Description:
  755. *
  756. *
  757. *****************************************************************************/
  758. HRESULT CServerObject_InterceptorProviderRefresherManager :: AddEnumToRefresher (
  759. IWbemServices *a_Service,
  760. LPCWSTR a_ServerName,
  761. LPCWSTR a_Namespace,
  762. IWbemClassObject* pClassObject,
  763. WBEM_REFRESHER_ID *a_DestinationRefresherId,
  764. IWbemClassObject *a_InstanceTemplate,
  765. LPCWSTR a_Class,
  766. long a_Flags,
  767. IWbemContext *a_Context,
  768. IUnknown* a_pLockMgr,
  769. WBEM_REFRESH_INFO *a_Information
  770. )
  771. {
  772. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  773. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  774. #endif
  775. if ( m_Initialized == 0 )
  776. {
  777. return WBEM_E_NOT_FOUND ;
  778. }
  779. HRESULT t_Result = S_OK ;
  780. try
  781. {
  782. BOOL t_Impersonating = FALSE ;
  783. IUnknown *t_OldContext = NULL ;
  784. IServerSecurity *t_OldSecurity = NULL ;
  785. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  786. if ( SUCCEEDED ( t_Result ) )
  787. {
  788. BOOL t_Revert = FALSE ;
  789. IUnknown *t_Proxy = NULL ;
  790. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , IID__IWbemRefresherMgr , m_Manager , t_Proxy , t_Revert ) ;
  791. if ( t_Result == WBEM_E_NOT_FOUND )
  792. {
  793. t_Result = m_Manager->AddEnumToRefresher (
  794. a_Service,
  795. a_ServerName,
  796. a_Namespace,
  797. pClassObject,
  798. a_DestinationRefresherId,
  799. a_InstanceTemplate,
  800. a_Class,
  801. a_Flags,
  802. a_Context,
  803. a_pLockMgr,
  804. a_Information
  805. ) ;
  806. }
  807. else
  808. {
  809. if ( SUCCEEDED ( t_Result ) )
  810. {
  811. _IWbemRefresherMgr *t_Manager = ( _IWbemRefresherMgr * ) t_Proxy ;
  812. // Set cloaking on the proxy
  813. // =========================
  814. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  815. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  816. t_Manager ,
  817. RPC_C_AUTHN_LEVEL_DEFAULT ,
  818. t_ImpersonationLevel
  819. ) ;
  820. if ( SUCCEEDED ( t_Result ) )
  821. {
  822. t_Result = CoImpersonateClient () ;
  823. if ( SUCCEEDED ( t_Result ) )
  824. {
  825. t_Result = t_Manager->AddEnumToRefresher (
  826. a_Service,
  827. a_ServerName,
  828. a_Namespace,
  829. pClassObject,
  830. a_DestinationRefresherId,
  831. a_InstanceTemplate,
  832. a_Class,
  833. a_Flags,
  834. a_Context,
  835. a_pLockMgr,
  836. a_Information
  837. ) ;
  838. if ( FAILED ( t_Result ) )
  839. {
  840. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  841. {
  842. AbnormalShutdown () ;
  843. }
  844. }
  845. CoRevertToSelf () ;
  846. }
  847. else
  848. {
  849. t_Result = WBEM_E_ACCESS_DENIED ;
  850. }
  851. }
  852. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , t_Proxy , t_Revert ) ;
  853. }
  854. }
  855. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  856. }
  857. }
  858. catch ( Wmi_Structured_Exception t_StructuredException )
  859. {
  860. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  861. }
  862. return t_Result ;
  863. }
  864. /******************************************************************************
  865. *
  866. * Name:
  867. *
  868. *
  869. * Description:
  870. *
  871. *
  872. *****************************************************************************/
  873. HRESULT CServerObject_InterceptorProviderRefresherManager :: GetRemoteRefresher (
  874. WBEM_REFRESHER_ID *a_RefresherId ,
  875. long a_Flags,
  876. BOOL a_AddRefresher,
  877. IWbemRemoteRefresher **a_RemoteRefresher ,
  878. IUnknown* a_pLockMgr,
  879. GUID *a_Guid
  880. )
  881. {
  882. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  883. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  884. #endif
  885. if ( m_Initialized == 0 )
  886. {
  887. return WBEM_E_NOT_FOUND ;
  888. }
  889. HRESULT t_Result = S_OK ;
  890. try
  891. {
  892. BOOL t_Impersonating = FALSE ;
  893. IUnknown *t_OldContext = NULL ;
  894. IServerSecurity *t_OldSecurity = NULL ;
  895. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  896. if ( SUCCEEDED ( t_Result ) )
  897. {
  898. BOOL t_Revert = FALSE ;
  899. IUnknown *t_Proxy = NULL ;
  900. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , IID__IWbemRefresherMgr , m_Manager , t_Proxy , t_Revert ) ;
  901. if ( t_Result == WBEM_E_NOT_FOUND )
  902. {
  903. t_Result = m_Manager->GetRemoteRefresher (
  904. a_RefresherId ,
  905. a_Flags,
  906. a_AddRefresher,
  907. a_RemoteRefresher ,
  908. a_pLockMgr,
  909. a_Guid
  910. ) ;
  911. }
  912. else
  913. {
  914. if ( SUCCEEDED ( t_Result ) )
  915. {
  916. _IWbemRefresherMgr *t_Manager = ( _IWbemRefresherMgr * ) t_Proxy ;
  917. // Set cloaking on the proxy
  918. // =========================
  919. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  920. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  921. t_Manager ,
  922. RPC_C_AUTHN_LEVEL_DEFAULT ,
  923. t_ImpersonationLevel
  924. ) ;
  925. if ( SUCCEEDED ( t_Result ) )
  926. {
  927. t_Result = CoImpersonateClient () ;
  928. if ( SUCCEEDED ( t_Result ) )
  929. {
  930. t_Result = t_Manager->GetRemoteRefresher (
  931. a_RefresherId ,
  932. a_Flags,
  933. a_AddRefresher,
  934. a_RemoteRefresher ,
  935. a_pLockMgr,
  936. a_Guid
  937. ) ;
  938. if ( FAILED ( t_Result ) )
  939. {
  940. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  941. {
  942. AbnormalShutdown () ;
  943. }
  944. }
  945. CoRevertToSelf () ;
  946. }
  947. else
  948. {
  949. t_Result = WBEM_E_ACCESS_DENIED ;
  950. }
  951. }
  952. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , t_Proxy , t_Revert ) ;
  953. }
  954. }
  955. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  956. }
  957. }
  958. catch ( Wmi_Structured_Exception t_StructuredException )
  959. {
  960. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  961. }
  962. return t_Result ;
  963. }
  964. /******************************************************************************
  965. *
  966. * Name:
  967. *
  968. *
  969. * Description:
  970. *
  971. *
  972. *****************************************************************************/
  973. HRESULT CServerObject_InterceptorProviderRefresherManager :: LoadProvider (
  974. IWbemServices *a_Service ,
  975. LPCWSTR a_ProviderName ,
  976. LPCWSTR a_Namespace,
  977. IWbemContext * a_Context,
  978. IWbemHiPerfProvider **a_Provider,
  979. _IWmiProviderStack** a_ProvStack
  980. )
  981. {
  982. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  983. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  984. #endif
  985. if ( m_Initialized == 0 )
  986. {
  987. return WBEM_E_NOT_FOUND ;
  988. }
  989. HRESULT t_Result = S_OK ;
  990. try
  991. {
  992. BOOL t_Impersonating = FALSE ;
  993. IUnknown *t_OldContext = NULL ;
  994. IServerSecurity *t_OldSecurity = NULL ;
  995. t_Result = ProviderSubSystem_Common_Globals :: BeginImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  996. if ( SUCCEEDED ( t_Result ) )
  997. {
  998. BOOL t_Revert = FALSE ;
  999. IUnknown *t_Proxy = NULL ;
  1000. t_Result = ProviderSubSystem_Common_Globals :: SetProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , IID__IWbemRefresherMgr , m_Manager , t_Proxy , t_Revert ) ;
  1001. if ( t_Result == WBEM_E_NOT_FOUND )
  1002. {
  1003. t_Result = m_Manager->LoadProvider (
  1004. a_Service ,
  1005. a_ProviderName ,
  1006. a_Namespace ,
  1007. a_Context ,
  1008. a_Provider,
  1009. a_ProvStack
  1010. ) ;
  1011. }
  1012. else
  1013. {
  1014. if ( SUCCEEDED ( t_Result ) )
  1015. {
  1016. _IWbemRefresherMgr *t_Manager = ( _IWbemRefresherMgr * ) t_Proxy ;
  1017. // Set cloaking on the proxy
  1018. // =========================
  1019. DWORD t_ImpersonationLevel = ProviderSubSystem_Common_Globals :: GetCurrentImpersonationLevel () ;
  1020. t_Result = ProviderSubSystem_Common_Globals :: SetCloaking (
  1021. t_Manager ,
  1022. RPC_C_AUTHN_LEVEL_DEFAULT ,
  1023. t_ImpersonationLevel
  1024. ) ;
  1025. if ( SUCCEEDED ( t_Result ) )
  1026. {
  1027. t_Result = CoImpersonateClient () ;
  1028. if ( SUCCEEDED ( t_Result ) )
  1029. {
  1030. t_Result = t_Manager->LoadProvider (
  1031. a_Service ,
  1032. a_ProviderName ,
  1033. a_Namespace ,
  1034. a_Context ,
  1035. a_Provider ,
  1036. a_ProvStack
  1037. ) ;
  1038. if ( FAILED ( t_Result ) )
  1039. {
  1040. if ( ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_SERVER_UNAVAILABLE ) || ( HRESULT_ERROR_FUNC(t_Result) == RPC_S_CALL_FAILED_DNE ) )
  1041. {
  1042. AbnormalShutdown () ;
  1043. }
  1044. }
  1045. CoRevertToSelf () ;
  1046. }
  1047. else
  1048. {
  1049. t_Result = WBEM_E_ACCESS_DENIED ;
  1050. }
  1051. }
  1052. HRESULT t_TempResult = ProviderSubSystem_Common_Globals :: RevertProxyState ( m_ProxyContainer , ProxyIndex_RefresherManager_IWbemRefresherMgr , t_Proxy , t_Revert ) ;
  1053. }
  1054. }
  1055. ProviderSubSystem_Common_Globals :: EndImpersonation ( t_OldContext , t_OldSecurity , t_Impersonating ) ;
  1056. }
  1057. }
  1058. catch ( Wmi_Structured_Exception t_StructuredException )
  1059. {
  1060. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1061. }
  1062. return t_Result ;
  1063. }
  1064. /******************************************************************************
  1065. *
  1066. * Name:
  1067. *
  1068. *
  1069. * Description:
  1070. *
  1071. *
  1072. *****************************************************************************/
  1073. CServerObject_ProviderRefresherManager :: CServerObject_ProviderRefresherManager (
  1074. WmiAllocator &a_Allocator
  1075. ) : m_Allocator ( a_Allocator ) ,
  1076. m_Manager ( NULL ) ,
  1077. m_Shutdown ( NULL ) ,
  1078. m_ReferenceCount ( 0 )
  1079. {
  1080. InterlockedIncrement ( & ProviderSubSystem_Globals :: s_CServerObject_ProviderRefresherManager_ObjectsInProgress ) ;
  1081. ProviderSubSystem_Globals :: Increment_Global_Object_Count () ;
  1082. }
  1083. /******************************************************************************
  1084. *
  1085. * Name:
  1086. *
  1087. *
  1088. * Description:
  1089. *
  1090. *
  1091. *****************************************************************************/
  1092. CServerObject_ProviderRefresherManager :: ~CServerObject_ProviderRefresherManager ()
  1093. {
  1094. if ( m_Manager )
  1095. {
  1096. m_Manager->Release () ;
  1097. }
  1098. if ( m_Shutdown )
  1099. {
  1100. m_Shutdown->Release () ;
  1101. }
  1102. InterlockedDecrement ( & ProviderSubSystem_Globals :: s_CServerObject_ProviderRefresherManager_ObjectsInProgress ) ;
  1103. ProviderSubSystem_Globals :: Decrement_Global_Object_Count () ;
  1104. }
  1105. /******************************************************************************
  1106. *
  1107. * Name:
  1108. *
  1109. *
  1110. * Description:
  1111. *
  1112. *
  1113. *****************************************************************************/
  1114. STDMETHODIMP CServerObject_ProviderRefresherManager :: QueryInterface (
  1115. REFIID iid ,
  1116. LPVOID FAR *iplpv
  1117. )
  1118. {
  1119. *iplpv = NULL ;
  1120. if ( iid == IID_IUnknown )
  1121. {
  1122. *iplpv = ( LPVOID ) this ;
  1123. }
  1124. else if ( iid == IID_IWbemShutdown )
  1125. {
  1126. *iplpv = ( LPVOID ) ( IWbemShutdown * )this ;
  1127. }
  1128. else if ( iid == IID__IWbemRefresherMgr )
  1129. {
  1130. *iplpv = ( LPVOID ) ( _IWbemRefresherMgr * ) this ;
  1131. }
  1132. if ( *iplpv )
  1133. {
  1134. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  1135. return ResultFromScode ( S_OK ) ;
  1136. }
  1137. else
  1138. {
  1139. return ResultFromScode ( E_NOINTERFACE ) ;
  1140. }
  1141. }
  1142. /******************************************************************************
  1143. *
  1144. * Name:
  1145. *
  1146. *
  1147. * Description:
  1148. *
  1149. *
  1150. *****************************************************************************/
  1151. STDMETHODIMP_( ULONG ) CServerObject_ProviderRefresherManager :: AddRef ()
  1152. {
  1153. return InterlockedIncrement ( & m_ReferenceCount ) ;
  1154. }
  1155. /******************************************************************************
  1156. *
  1157. * Name:
  1158. *
  1159. *
  1160. * Description:
  1161. *
  1162. *
  1163. *****************************************************************************/
  1164. STDMETHODIMP_(ULONG) CServerObject_ProviderRefresherManager :: Release ()
  1165. {
  1166. LONG t_ReferenceCount = InterlockedDecrement ( & m_ReferenceCount ) ;
  1167. if ( t_ReferenceCount == 0 )
  1168. {
  1169. delete this ;
  1170. return 0 ;
  1171. }
  1172. else
  1173. {
  1174. return t_ReferenceCount ;
  1175. }
  1176. }
  1177. /******************************************************************************
  1178. *
  1179. * Name:
  1180. *
  1181. *
  1182. * Description:
  1183. *
  1184. *
  1185. *****************************************************************************/
  1186. HRESULT CServerObject_ProviderRefresherManager :: Startup (
  1187. LONG a_Flags ,
  1188. IWbemContext *a_Context ,
  1189. _IWmiProvSS *a_ProvSS
  1190. )
  1191. {
  1192. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  1193. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  1194. #endif
  1195. HRESULT t_Result = S_OK ;
  1196. try
  1197. {
  1198. t_Result = ProviderSubSystem_Common_Globals :: CreateInstance (
  1199. CLSID__WbemRefresherMgr ,
  1200. NULL ,
  1201. CLSCTX_INPROC_SERVER ,
  1202. IID__IWbemRefresherMgr ,
  1203. ( void ** ) & m_Manager
  1204. ) ;
  1205. if ( SUCCEEDED ( t_Result ) )
  1206. {
  1207. t_Result = m_Manager->Startup (
  1208. a_Flags ,
  1209. a_Context ,
  1210. a_ProvSS
  1211. ) ;
  1212. if ( SUCCEEDED ( t_Result ) )
  1213. {
  1214. t_Result = m_Manager->QueryInterface ( IID_IWbemShutdown , ( void ** ) & m_Shutdown ) ;
  1215. }
  1216. }
  1217. }
  1218. catch ( Wmi_Structured_Exception t_StructuredException )
  1219. {
  1220. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1221. }
  1222. return t_Result ;
  1223. }
  1224. /******************************************************************************
  1225. *
  1226. * Name:
  1227. *
  1228. *
  1229. * Description:
  1230. *
  1231. *
  1232. *****************************************************************************/
  1233. HRESULT CServerObject_ProviderRefresherManager :: Shutdown (
  1234. LONG a_Flags ,
  1235. ULONG a_MaxMilliSeconds ,
  1236. IWbemContext *a_Context
  1237. )
  1238. {
  1239. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  1240. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  1241. #endif
  1242. HRESULT t_Result = S_OK ;
  1243. try
  1244. {
  1245. t_Result = m_Shutdown->Shutdown (
  1246. a_Flags ,
  1247. a_MaxMilliSeconds ,
  1248. a_Context
  1249. ) ;
  1250. }
  1251. catch ( Wmi_Structured_Exception t_StructuredException )
  1252. {
  1253. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1254. }
  1255. return t_Result ;
  1256. }
  1257. /******************************************************************************
  1258. *
  1259. * Name:
  1260. *
  1261. *
  1262. * Description:
  1263. *
  1264. *
  1265. *****************************************************************************/
  1266. HRESULT CServerObject_ProviderRefresherManager :: AddObjectToRefresher (
  1267. IWbemServices *a_Service,
  1268. LPCWSTR a_ServerName,
  1269. LPCWSTR a_Namespace,
  1270. IWbemClassObject* pClassObject,
  1271. WBEM_REFRESHER_ID *a_DestinationRefresherId,
  1272. IWbemClassObject *a_InstanceTemplate,
  1273. long a_Flags,
  1274. IWbemContext *a_Context,
  1275. IUnknown* a_pLockMgr,
  1276. WBEM_REFRESH_INFO *a_Information
  1277. )
  1278. {
  1279. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  1280. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  1281. #endif
  1282. HRESULT t_Result = S_OK ;
  1283. try
  1284. {
  1285. t_Result = m_Manager->AddObjectToRefresher (
  1286. a_Service,
  1287. a_ServerName,
  1288. a_Namespace,
  1289. pClassObject,
  1290. a_DestinationRefresherId,
  1291. a_InstanceTemplate,
  1292. a_Flags,
  1293. a_Context,
  1294. a_pLockMgr,
  1295. a_Information
  1296. ) ;
  1297. }
  1298. catch ( Wmi_Structured_Exception t_StructuredException )
  1299. {
  1300. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1301. }
  1302. return t_Result ;
  1303. }
  1304. /******************************************************************************
  1305. *
  1306. * Name:
  1307. *
  1308. *
  1309. * Description:
  1310. *
  1311. *
  1312. *****************************************************************************/
  1313. HRESULT CServerObject_ProviderRefresherManager :: AddEnumToRefresher (
  1314. IWbemServices *a_Service,
  1315. LPCWSTR a_ServerName,
  1316. LPCWSTR a_Namespace,
  1317. IWbemClassObject* pClassObject,
  1318. WBEM_REFRESHER_ID *a_DestinationRefresherId,
  1319. IWbemClassObject *a_InstanceTemplate,
  1320. LPCWSTR a_Class,
  1321. long a_Flags,
  1322. IWbemContext *a_Context,
  1323. IUnknown* a_pLockMgr,
  1324. WBEM_REFRESH_INFO *a_Information
  1325. )
  1326. {
  1327. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  1328. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  1329. #endif
  1330. HRESULT t_Result = S_OK ;
  1331. try
  1332. {
  1333. t_Result = m_Manager->AddEnumToRefresher (
  1334. a_Service,
  1335. a_ServerName,
  1336. a_Namespace,
  1337. pClassObject,
  1338. a_DestinationRefresherId,
  1339. a_InstanceTemplate,
  1340. a_Class,
  1341. a_Flags,
  1342. a_Context,
  1343. a_pLockMgr,
  1344. a_Information
  1345. ) ;
  1346. }
  1347. catch ( Wmi_Structured_Exception t_StructuredException )
  1348. {
  1349. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1350. }
  1351. return t_Result ;
  1352. }
  1353. /******************************************************************************
  1354. *
  1355. * Name:
  1356. *
  1357. *
  1358. * Description:
  1359. *
  1360. *
  1361. *****************************************************************************/
  1362. HRESULT CServerObject_ProviderRefresherManager :: GetRemoteRefresher (
  1363. WBEM_REFRESHER_ID *a_RefresherId ,
  1364. long a_Flags,
  1365. BOOL fAddRefresher,
  1366. IWbemRemoteRefresher **a_RemoteRefresher ,
  1367. IUnknown* a_pLockMgr,
  1368. GUID *a_Guid
  1369. )
  1370. {
  1371. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  1372. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  1373. #endif
  1374. HRESULT t_Result = S_OK ;
  1375. try
  1376. {
  1377. t_Result = m_Manager->GetRemoteRefresher (
  1378. a_RefresherId ,
  1379. a_Flags,
  1380. fAddRefresher,
  1381. a_RemoteRefresher ,
  1382. a_pLockMgr,
  1383. a_Guid
  1384. ) ;
  1385. }
  1386. catch ( Wmi_Structured_Exception t_StructuredException )
  1387. {
  1388. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1389. }
  1390. return t_Result ;
  1391. }
  1392. /******************************************************************************
  1393. *
  1394. * Name:
  1395. *
  1396. *
  1397. * Description:
  1398. *
  1399. *
  1400. *****************************************************************************/
  1401. HRESULT CServerObject_ProviderRefresherManager :: LoadProvider (
  1402. IWbemServices *a_Service ,
  1403. LPCWSTR a_ProviderName ,
  1404. LPCWSTR a_Namespace,
  1405. IWbemContext * a_Context,
  1406. IWbemHiPerfProvider **a_Provider,
  1407. _IWmiProviderStack** a_ProvStack
  1408. )
  1409. {
  1410. #ifndef STRUCTURED_HANDLER_SET_BY_WMI
  1411. Wmi_SetStructuredExceptionHandler t_StructuredException ;
  1412. #endif
  1413. HRESULT t_Result = S_OK ;
  1414. try
  1415. {
  1416. t_Result = m_Manager->LoadProvider (
  1417. a_Service ,
  1418. a_ProviderName ,
  1419. a_Namespace ,
  1420. a_Context ,
  1421. a_Provider ,
  1422. a_ProvStack
  1423. ) ;
  1424. }
  1425. catch ( Wmi_Structured_Exception t_StructuredException )
  1426. {
  1427. t_Result = WBEM_E_CRITICAL_ERROR ; /* Need to make this WBEM_E_SUBSYSTEM_FAILURE */
  1428. }
  1429. return t_Result ;
  1430. }