Source code of Windows XP (NT5)
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.

1731 lines
30 KiB

  1. //***************************************************************************
  2. //
  3. // VPSERV.CPP
  4. //
  5. // Module: WBEM VIEW PROVIDER
  6. //
  7. // Purpose: Contains the WBEM services interfaces
  8. //
  9. // Copyright (c) 1998-2001 Microsoft Corporation, All Rights Reserved
  10. //
  11. //***************************************************************************
  12. //need the following three lines
  13. //to get the security stuff to work
  14. #include "precomp.h"
  15. #include <provexpt.h>
  16. #include <provcoll.h>
  17. #include <provtempl.h>
  18. #include <provmt.h>
  19. #include <typeinfo.h>
  20. #include <process.h>
  21. #include <objbase.h>
  22. #include <objidl.h>
  23. #include <stdio.h>
  24. #include <wbemidl.h>
  25. #include <provcont.h>
  26. #include <provevt.h>
  27. #include <provthrd.h>
  28. #include <provlog.h>
  29. #include <cominit.h>
  30. #include <dsgetdc.h>
  31. #include <lmcons.h>
  32. #include <instpath.h>
  33. #include <genlex.h>
  34. #include <sql_1.h>
  35. #include <objpath.h>
  36. #include <vpdefs.h>
  37. #include <vpquals.h>
  38. #include <vpserv.h>
  39. #include <vptasks.h>
  40. #include <vpcfac.h>
  41. extern CRITICAL_SECTION g_CriticalSection;
  42. extern HRESULT SetSecurityLevelAndCloaking(IUnknown* pInterface, const wchar_t* prncpl);
  43. #ifdef UNICODE
  44. #if 0
  45. extern HRESULT GetCurrentSecuritySettings(DWORD *pdwAuthnSvc, DWORD *pdwAuthzSvc,
  46. DWORD *pdwAuthLevel, DWORD *pdwImpLevel,
  47. DWORD *pdwCapabilities);
  48. void VPGetUserName()
  49. {
  50. DWORD dwBuffSz = 1024;
  51. wchar_t strBuff[1024];
  52. GetUserName(strBuff, &dwBuffSz);
  53. //first get current security info then set it on the proxy...
  54. DWORD dwAuthnSvc = 0;
  55. DWORD dwAuthzSvc = 0;
  56. DWORD dwAuthLevel = 0;
  57. DWORD dwImpLevel = 0;
  58. DWORD dwCapabilities = 0;
  59. HRESULT hr = GetCurrentSecuritySettings(&dwAuthnSvc, &dwAuthzSvc, &dwAuthLevel, &dwImpLevel, &dwCapabilities);
  60. HANDLE hThreadTok = NULL;
  61. if (OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &hThreadTok) )
  62. {
  63. DWORD dwBytesReturned = 0;
  64. UCHAR tokBuff [1024];
  65. PTOKEN_USER ptokUser = (PTOKEN_USER)tokBuff;
  66. if (GetTokenInformation(hThreadTok, TokenUser, ptokUser,
  67. sizeof(tokBuff), &dwBytesReturned))
  68. {
  69. wchar_t buffN[1024];
  70. DWORD buffNlen = 1024;
  71. wchar_t buffD[1024];
  72. DWORD buffDlen = 1024;
  73. SID_NAME_USE snu;
  74. if (!LookupAccountSid(NULL, ptokUser->User.Sid, buffN, &buffNlen, buffD, &buffDlen, &snu))
  75. {
  76. DWORD dwErr = GetLastError();
  77. }
  78. }
  79. CloseHandle(hThreadTok);
  80. }
  81. }
  82. #endif
  83. #endif
  84. wchar_t *UnicodeStringDuplicate ( const wchar_t *string )
  85. {
  86. if ( string )
  87. {
  88. int textLength = wcslen ( string ) ;
  89. wchar_t *textBuffer = new wchar_t [ textLength + 1 ] ;
  90. wcscpy ( textBuffer , string ) ;
  91. return textBuffer ;
  92. }
  93. else
  94. {
  95. return NULL ;
  96. }
  97. }
  98. wchar_t *UnicodeStringAppend ( const wchar_t *prefix , const wchar_t *suffix )
  99. {
  100. int prefixTextLength = 0 ;
  101. if ( prefix )
  102. {
  103. prefixTextLength = wcstombs ( NULL , prefix , 0 ) ;
  104. }
  105. int suffixTextLength = 0 ;
  106. if ( suffix )
  107. {
  108. suffixTextLength = wcstombs ( NULL , suffix , 0 ) ;
  109. }
  110. if ( prefix || suffix )
  111. {
  112. int textLength = prefixTextLength + suffixTextLength ;
  113. wchar_t *textBuffer = new wchar_t [ textLength + 1 ] ;
  114. if ( prefix )
  115. {
  116. wcscpy ( textBuffer , prefix ) ;
  117. }
  118. if ( suffix )
  119. {
  120. wcscpy ( & textBuffer [ prefixTextLength ] , suffix ) ;
  121. }
  122. return textBuffer ;
  123. }
  124. else
  125. return NULL ;
  126. }
  127. CWbemServerWrap::CWbemServerWrap(IWbemServices *pServ, const wchar_t* prncpl, const wchar_t* path)
  128. : m_Principal(NULL), m_Path(NULL)
  129. {
  130. m_ref = 0;
  131. m_MainServ = pServ;
  132. if (prncpl != NULL)
  133. {
  134. m_Principal = UnicodeStringDuplicate(prncpl);
  135. }
  136. if (path != NULL)
  137. {
  138. m_Path = SysAllocString(path);
  139. }
  140. if (m_MainServ)
  141. {
  142. m_MainServ->AddRef();
  143. }
  144. }
  145. CWbemServerWrap::~CWbemServerWrap()
  146. {
  147. if (m_MainServ)
  148. {
  149. m_MainServ->Release();
  150. }
  151. #ifdef UNICODE
  152. if (m_Lock.Lock())
  153. {
  154. m_ProxyPool.RemoveAll();
  155. m_Lock.Unlock();
  156. }
  157. #endif
  158. if (m_Principal != NULL)
  159. {
  160. delete [] m_Principal;
  161. }
  162. if (m_Path != NULL)
  163. {
  164. SysFreeString(m_Path);
  165. }
  166. }
  167. IWbemServices* CWbemServerWrap::GetServerOrProxy()
  168. {
  169. IWbemServices * retVal = NULL;
  170. #ifdef UNICODE
  171. if (m_MainServ == NULL)
  172. {
  173. return m_MainServ;
  174. }
  175. //if (IsRemote())
  176. {
  177. if (m_Lock.Lock())
  178. {
  179. POSITION t_pos = m_ProxyPool.GetHeadPosition();
  180. while (t_pos)
  181. {
  182. CWbemProxyServerWrap &t_srvRef = m_ProxyPool.GetNext(t_pos);
  183. if (!t_srvRef.m_InUse)
  184. {
  185. t_srvRef.m_InUse = TRUE;
  186. retVal = t_srvRef.m_Proxy;
  187. break;
  188. }
  189. }
  190. //calling back into COM so must unlock
  191. //addref MainServ then release it afterward;
  192. IWbemServices *t_MainCopy = m_MainServ;
  193. t_MainCopy->AddRef();
  194. m_Lock.Unlock();
  195. if (retVal == NULL)
  196. {
  197. IClientSecurity *pcs = NULL;
  198. if ( SUCCEEDED (t_MainCopy->QueryInterface(IID_IClientSecurity, (void**)&pcs)) )
  199. {
  200. if (FAILED(pcs->CopyProxy(t_MainCopy, (IUnknown **)(&retVal))))
  201. {
  202. retVal = NULL;
  203. }
  204. else
  205. {
  206. CWbemProxyServerWrap t_srv(retVal);
  207. t_srv.m_InUse = TRUE;
  208. if (m_Lock.Lock())
  209. {
  210. //only store and use if m_MainServ is unchanged
  211. if (t_MainCopy == m_MainServ)
  212. {
  213. m_ProxyPool.AddTail(t_srv);
  214. }
  215. else
  216. {
  217. //pathological case, mainserv was bad and has changed
  218. //could recurse at this point but is it worth it?
  219. //not thought so at this time.
  220. retVal->Release();
  221. retVal = NULL;
  222. }
  223. m_Lock.Unlock();
  224. }
  225. else
  226. {
  227. //can't use this proxy if I can't store it
  228. retVal->Release();
  229. retVal = NULL;
  230. }
  231. }
  232. pcs->Release();
  233. }
  234. }
  235. t_MainCopy->Release();
  236. if (retVal && FAILED(SetSecurityLevelAndCloaking(retVal, IsRemote() ? m_Principal : COLE_DEFAULT_PRINCIPAL)))
  237. {
  238. retVal->AddRef(); //addref for the release that Returning the proxy will do
  239. ReturnServerOrProxy(retVal);
  240. retVal = NULL;
  241. }
  242. }
  243. }
  244. //else
  245. //{
  246. // retVal = m_MainServ;
  247. //}
  248. #else
  249. retVal = m_MainServ;
  250. #endif
  251. if (retVal)
  252. {
  253. retVal->AddRef();
  254. }
  255. return retVal;
  256. }
  257. void CWbemServerWrap::ReturnServerOrProxy(IWbemServices* a_pServ)
  258. {
  259. #ifdef UNICODE
  260. //if (IsRemote())
  261. {
  262. if (m_Lock.Lock())
  263. {
  264. POSITION t_pos = m_ProxyPool.GetHeadPosition();
  265. while (t_pos)
  266. {
  267. CWbemProxyServerWrap &t_proxyRef = m_ProxyPool.GetNext(t_pos);
  268. if (t_proxyRef.m_Proxy == a_pServ)
  269. {
  270. t_proxyRef.m_InUse = FALSE;
  271. break;
  272. }
  273. }
  274. m_Lock.Unlock();
  275. }
  276. }
  277. #endif
  278. a_pServ->Release();
  279. }
  280. BOOL CWbemServerWrap::ProxyBelongsTo(IWbemServices *a_proxy)
  281. {
  282. BOOL retVal = FALSE;
  283. #ifdef UNICODE
  284. if (IsRemote())
  285. {
  286. if (m_Lock.Lock())
  287. {
  288. POSITION t_pos = m_ProxyPool.GetHeadPosition();
  289. while (t_pos)
  290. {
  291. CWbemProxyServerWrap &t_proxyRef = m_ProxyPool.GetNext(t_pos);
  292. if (t_proxyRef.m_Proxy == a_proxy)
  293. {
  294. retVal = TRUE;
  295. break;
  296. }
  297. }
  298. m_Lock.Unlock();
  299. }
  300. }
  301. #endif
  302. return retVal;
  303. }
  304. void CWbemServerWrap::SetMainServer(IWbemServices *a_pServ)
  305. {
  306. #ifdef UNICODE
  307. if (m_Lock.Lock())
  308. {
  309. if (m_MainServ)
  310. {
  311. m_MainServ->Release();
  312. }
  313. m_MainServ = a_pServ;
  314. if (m_MainServ)
  315. {
  316. m_MainServ->AddRef();
  317. }
  318. m_ProxyPool.RemoveAll();
  319. m_Lock.Unlock();
  320. }
  321. #endif
  322. }
  323. ULONG CWbemServerWrap::AddRef()
  324. {
  325. return (ULONG)(InterlockedIncrement(&m_ref));
  326. }
  327. ULONG CWbemServerWrap::Release()
  328. {
  329. ULONG i = (ULONG)(InterlockedDecrement(&m_ref));
  330. if (i == 0)
  331. {
  332. delete this;
  333. }
  334. return i;
  335. }
  336. void CIWbemServMap::EmptyMap()
  337. {
  338. if (Lock())
  339. {
  340. RemoveAll();
  341. Unlock();
  342. }
  343. }
  344. /////////////////////////////////////////////////////////////////////////////
  345. // Functions constructor, destructor and IUnknown
  346. //***************************************************************************
  347. //
  348. // CViewProvServ ::CViewProvServ
  349. // CViewProvServ ::~CViewProvServ
  350. //
  351. //***************************************************************************
  352. CViewProvServ ::CViewProvServ () :
  353. sm_Locator (NULL),
  354. sm_ConnectionMade (NULL),
  355. m_UserName (NULL),
  356. m_Initialised (FALSE),
  357. m_Server (NULL),
  358. m_Namespace (NULL),
  359. m_NotificationClassObject (NULL),
  360. m_ExtendedNotificationClassObject (NULL),
  361. m_GetNotifyCalled (FALSE),
  362. m_GetExtendedNotifyCalled (FALSE ),
  363. m_localeId (NULL)
  364. {
  365. EnterCriticalSection(&g_CriticalSection);
  366. CViewProvClassFactory :: objectsInProgress++ ;
  367. LeaveCriticalSection(&g_CriticalSection);
  368. m_ReferenceCount = 0 ;
  369. /*
  370. * Implementation
  371. */
  372. sm_ConnectionMade = CreateEvent(NULL, TRUE, FALSE, NULL);
  373. }
  374. CViewProvServ ::~CViewProvServ(void)
  375. {
  376. delete [] m_localeId ;
  377. delete [] m_Namespace ;
  378. if ( m_Server )
  379. m_Server->Release () ;
  380. if ( m_NotificationClassObject )
  381. m_NotificationClassObject->Release () ;
  382. if ( m_ExtendedNotificationClassObject )
  383. m_ExtendedNotificationClassObject->Release () ;
  384. if (sm_Locator != NULL)
  385. {
  386. sm_Locator->Release();
  387. }
  388. if (NULL != sm_ConnectionMade)
  389. {
  390. CloseHandle(sm_ConnectionMade);
  391. }
  392. sm_ServerMap.EmptyMap();
  393. if (sm_ServerMap.Lock())
  394. {
  395. sm_OutStandingConnections.RemoveAll();
  396. sm_ServerMap.Unlock();
  397. }
  398. if (m_UserName != NULL)
  399. {
  400. SysFreeString(m_UserName);
  401. }
  402. EnterCriticalSection(&g_CriticalSection);
  403. CViewProvClassFactory :: objectsInProgress--;
  404. LeaveCriticalSection(&g_CriticalSection);
  405. }
  406. HRESULT CViewProvServ::GetUnsecApp(IUnsecuredApartment** ppLoc)
  407. {
  408. if (NULL == ppLoc)
  409. {
  410. return WBEM_E_INVALID_PARAMETER;
  411. }
  412. EnterCriticalSection(&g_CriticalSection);
  413. HRESULT hr = WBEM_NO_ERROR;
  414. if (NULL == sm_UnsecApp)
  415. {
  416. hr = CoCreateInstance(CLSID_UnsecuredApartment, NULL, CLSCTX_LOCAL_SERVER,
  417. IID_IUnsecuredApartment, ( void ** )&sm_UnsecApp);
  418. if (FAILED(hr))
  419. {
  420. sm_UnsecApp = NULL;
  421. }
  422. else
  423. {
  424. sm_UnsecApp->AddRef();
  425. }
  426. }
  427. else
  428. {
  429. sm_UnsecApp->AddRef();
  430. }
  431. *ppLoc = sm_UnsecApp;
  432. LeaveCriticalSection(&g_CriticalSection);
  433. return hr;
  434. }
  435. #if 0
  436. typedef HRESULT (__stdcall *VP_PROC_DllGetClassObject)(REFCLSID rclsid , REFIID riid, void **ppv);
  437. #endif
  438. HRESULT CViewProvServ::GetLocator(IWbemLocator **ppLoc)
  439. {
  440. if (NULL == ppLoc)
  441. {
  442. return WBEM_E_INVALID_PARAMETER;
  443. }
  444. else
  445. {
  446. *ppLoc = NULL;
  447. }
  448. HRESULT hr = WBEM_E_FAILED;
  449. if (m_criticalSection.Lock())
  450. {
  451. if (NULL == sm_Locator)
  452. {
  453. m_criticalSection.Unlock();
  454. #ifdef UNICODE
  455. hr = CoCreateInstance(CLSID_WbemLocator, NULL,
  456. CLSCTX_INPROC_SERVER,
  457. IID_IWbemLocator, ( void ** )ppLoc);
  458. #else
  459. hr = CoCreateInstance(CLSID_WbemUnauthenticatedLocator, NULL,
  460. CLSCTX_INPROC_SERVER,
  461. IID_IWbemLocator, ( void ** )ppLoc);
  462. #endif
  463. if (m_criticalSection.Lock())
  464. {
  465. //another thread may have connected for us...
  466. if (NULL == sm_Locator)
  467. {
  468. if (SUCCEEDED(hr))
  469. {
  470. sm_Locator = *ppLoc;
  471. sm_Locator->AddRef();
  472. }
  473. }
  474. else
  475. {
  476. if (FAILED(hr))
  477. {
  478. hr = WBEM_NO_ERROR;
  479. sm_Locator->AddRef();
  480. *ppLoc = sm_Locator;
  481. }
  482. }
  483. }
  484. else
  485. {
  486. return hr;
  487. }
  488. }
  489. else
  490. {
  491. hr = WBEM_NO_ERROR;
  492. sm_Locator->AddRef();
  493. *ppLoc = sm_Locator;
  494. }
  495. m_criticalSection.Unlock();
  496. }
  497. return hr;
  498. }
  499. //***************************************************************************
  500. //
  501. // CViewProvServ ::QueryInterface
  502. // CViewProvServ ::AddRef
  503. // CViewProvServ ::Release
  504. //
  505. // Purpose: IUnknown members for CViewProvServ object.
  506. //***************************************************************************
  507. STDMETHODIMP CViewProvServ ::QueryInterface (
  508. REFIID iid ,
  509. LPVOID FAR *iplpv
  510. )
  511. {
  512. SetStructuredExceptionHandler seh;
  513. try
  514. {
  515. if (iplpv == NULL)
  516. {
  517. return E_INVALIDARG;
  518. }
  519. *iplpv = NULL ;
  520. if ( iid == IID_IUnknown )
  521. {
  522. *iplpv = ( IWbemServices* ) this ;
  523. }
  524. else if ( iid == IID_IWbemServices )
  525. {
  526. *iplpv = ( IWbemServices* ) this ;
  527. }
  528. else if ( iid == IID_IWbemProviderInit )
  529. {
  530. *iplpv = ( IWbemProviderInit* ) this ;
  531. }
  532. if ( *iplpv )
  533. {
  534. ( ( LPUNKNOWN ) *iplpv )->AddRef () ;
  535. return S_OK ;
  536. }
  537. else
  538. {
  539. return E_NOINTERFACE ;
  540. }
  541. }
  542. catch(Structured_Exception e_SE)
  543. {
  544. return E_UNEXPECTED;
  545. }
  546. catch(Heap_Exception e_HE)
  547. {
  548. return E_OUTOFMEMORY;
  549. }
  550. catch(...)
  551. {
  552. return E_UNEXPECTED;
  553. }
  554. }
  555. STDMETHODIMP_(ULONG) CViewProvServ ::AddRef(void)
  556. {
  557. SetStructuredExceptionHandler seh;
  558. try
  559. {
  560. return InterlockedIncrement ( & m_ReferenceCount ) ;
  561. }
  562. catch(Structured_Exception e_SE)
  563. {
  564. return 0;
  565. }
  566. catch(Heap_Exception e_HE)
  567. {
  568. return 0;
  569. }
  570. catch(...)
  571. {
  572. return 0;
  573. }
  574. }
  575. STDMETHODIMP_(ULONG) CViewProvServ ::Release(void)
  576. {
  577. SetStructuredExceptionHandler seh;
  578. try
  579. {
  580. LONG t_Ref ;
  581. if ( ( t_Ref = InterlockedDecrement ( & m_ReferenceCount ) ) == 0 )
  582. {
  583. delete this ;
  584. return 0 ;
  585. }
  586. else
  587. {
  588. return t_Ref ;
  589. }
  590. }
  591. catch(Structured_Exception e_SE)
  592. {
  593. return 0;
  594. }
  595. catch(Heap_Exception e_HE)
  596. {
  597. return 0;
  598. }
  599. catch(...)
  600. {
  601. return 0;
  602. }
  603. }
  604. IWbemServices *CViewProvServ :: GetServer ()
  605. {
  606. if ( m_Server )
  607. m_Server->AddRef () ;
  608. return m_Server ;
  609. }
  610. void CViewProvServ :: SetLocaleId ( wchar_t *localeId )
  611. {
  612. m_localeId = UnicodeStringDuplicate ( localeId ) ;
  613. }
  614. wchar_t *CViewProvServ :: GetNamespace ()
  615. {
  616. return m_Namespace ;
  617. }
  618. void CViewProvServ :: SetNamespace ( wchar_t *a_Namespace )
  619. {
  620. m_Namespace = UnicodeStringDuplicate ( a_Namespace ) ;
  621. }
  622. IWbemClassObject *CViewProvServ :: GetNotificationObject (
  623. WbemProvErrorObject &a_errorObject,
  624. IWbemContext *pCtx
  625. )
  626. {
  627. if ( m_NotificationClassObject )
  628. {
  629. m_NotificationClassObject->AddRef () ;
  630. }
  631. else
  632. {
  633. BOOL t_Status = CreateNotificationObject ( a_errorObject, pCtx ) ;
  634. if ( t_Status )
  635. {
  636. /*
  637. * Keep around until we close
  638. */
  639. m_NotificationClassObject->AddRef () ;
  640. }
  641. }
  642. return m_NotificationClassObject ;
  643. }
  644. IWbemClassObject *CViewProvServ :: GetExtendedNotificationObject (
  645. WbemProvErrorObject &a_errorObject,
  646. IWbemContext *pCtx
  647. )
  648. {
  649. if ( m_ExtendedNotificationClassObject )
  650. {
  651. m_ExtendedNotificationClassObject->AddRef () ;
  652. }
  653. else
  654. {
  655. BOOL t_Status = CreateExtendedNotificationObject ( a_errorObject, pCtx ) ;
  656. if ( t_Status )
  657. {
  658. /*
  659. * Keep around until we close
  660. */
  661. m_ExtendedNotificationClassObject->AddRef () ;
  662. }
  663. }
  664. return m_ExtendedNotificationClassObject ;
  665. }
  666. BOOL CViewProvServ :: CreateExtendedNotificationObject (
  667. WbemProvErrorObject &a_errorObject,
  668. IWbemContext *pCtx
  669. )
  670. {
  671. if ( m_GetExtendedNotifyCalled )
  672. {
  673. if ( m_ExtendedNotificationClassObject )
  674. return TRUE ;
  675. else
  676. return FALSE ;
  677. }
  678. else
  679. m_GetExtendedNotifyCalled = TRUE ;
  680. BOOL t_Status = TRUE ;
  681. BSTR t_bstrTemp = SysAllocString(WBEM_CLASS_EXTENDEDSTATUS);
  682. HRESULT t_Result = m_Server->GetObject (
  683. t_bstrTemp ,
  684. 0 ,
  685. pCtx,
  686. & m_ExtendedNotificationClassObject ,
  687. NULL
  688. ) ;
  689. SysFreeString(t_bstrTemp);
  690. if ( ! SUCCEEDED ( t_Result ) )
  691. {
  692. t_Status = FALSE ;
  693. a_errorObject.SetStatus ( WBEM_PROV_E_INVALID_OBJECT ) ;
  694. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  695. a_errorObject.SetMessage ( L"Failed to get __ExtendedStatus" ) ;
  696. m_ExtendedNotificationClassObject = NULL ;
  697. }
  698. return t_Status ;
  699. }
  700. BOOL CViewProvServ :: CreateNotificationObject (
  701. WbemProvErrorObject &a_errorObject,
  702. IWbemContext *pCtx
  703. )
  704. {
  705. if ( m_GetNotifyCalled )
  706. {
  707. if ( m_NotificationClassObject )
  708. return TRUE ;
  709. else
  710. return FALSE ;
  711. }
  712. else
  713. m_GetNotifyCalled = TRUE ;
  714. BOOL t_Status = TRUE ;
  715. BSTR t_bstrTemp = SysAllocString(WBEM_CLASS_EXTENDEDSTATUS);
  716. HRESULT t_Result = m_Server->GetObject (
  717. t_bstrTemp ,
  718. 0 ,
  719. pCtx,
  720. & m_NotificationClassObject ,
  721. NULL
  722. ) ;
  723. SysFreeString(t_bstrTemp);
  724. if ( ! SUCCEEDED ( t_Result ) )
  725. {
  726. t_Status = FALSE ;
  727. a_errorObject.SetStatus ( WBEM_PROV_E_INVALID_OBJECT ) ;
  728. a_errorObject.SetWbemStatus ( WBEM_E_FAILED ) ;
  729. a_errorObject.SetMessage ( L"Failed to get __ExtendedStatus" ) ;
  730. m_NotificationClassObject = NULL;
  731. }
  732. return t_Status ;
  733. }
  734. /////////////////////////////////////////////////////////////////////////////
  735. // Functions for the IWbemServices interface that are handled here
  736. HRESULT CViewProvServ :: CancelAsyncCall (
  737. IWbemObjectSink __RPC_FAR *pSink
  738. )
  739. {
  740. return WBEM_E_NOT_AVAILABLE ;
  741. }
  742. HRESULT CViewProvServ :: QueryObjectSink (
  743. long lFlags,
  744. IWbemObjectSink __RPC_FAR* __RPC_FAR* ppHandler
  745. )
  746. {
  747. return WBEM_E_NOT_AVAILABLE ;
  748. }
  749. HRESULT CViewProvServ :: GetObject (
  750. const BSTR ObjectPath,
  751. long lFlags,
  752. IWbemContext __RPC_FAR *pCtx,
  753. IWbemClassObject __RPC_FAR* __RPC_FAR *ppObject,
  754. IWbemCallResult __RPC_FAR* __RPC_FAR *ppCallResult
  755. )
  756. {
  757. return WBEM_E_NOT_AVAILABLE ;
  758. }
  759. HRESULT CViewProvServ :: GetObjectAsync (
  760. const BSTR ObjectPath,
  761. long lFlags,
  762. IWbemContext __RPC_FAR *pCtx,
  763. IWbemObjectSink __RPC_FAR* pHandler
  764. )
  765. {
  766. HRESULT hr = S_OK;
  767. SetStructuredExceptionHandler seh;
  768. GetObjectTaskObject *t_AsyncEvent = NULL;
  769. try
  770. {
  771. if (pHandler == NULL)
  772. {
  773. hr = WBEM_E_INVALID_PARAMETER;
  774. }
  775. else
  776. {
  777. hr = WbemCoImpersonateClient();
  778. #ifdef UNICODE
  779. #if 0
  780. DWORD dwBuffSz = 1024;
  781. wchar_t strBuff[1024];
  782. GetUserName(strBuff, &dwBuffSz);
  783. VPGetUserName();
  784. #endif
  785. #endif
  786. DebugOut1(
  787. CViewProvServ::sm_debugLog->Write (
  788. _T("\r\n")
  789. ) ;
  790. CViewProvServ::sm_debugLog->WriteFileAndLine (
  791. _T(__FILE__),__LINE__,
  792. _T("CViewProvServ::GetObjectAsync ()")
  793. ) ;
  794. )
  795. if (SUCCEEDED(hr))
  796. {
  797. /*
  798. * Create Asynchronous GetObjectByPath object
  799. */
  800. t_AsyncEvent = new GetObjectTaskObject ( this , ObjectPath , lFlags , pHandler , pCtx, NULL, NULL ) ;
  801. t_AsyncEvent->GetObject();
  802. t_AsyncEvent->Release();
  803. t_AsyncEvent = NULL;
  804. WbemCoRevertToSelf();
  805. }
  806. else
  807. {
  808. hr = WBEM_E_ACCESS_DENIED;
  809. }
  810. DebugOut1(
  811. CViewProvServ::sm_debugLog->WriteW (
  812. L"Returning from CViewProvServ::GetObjectAsync ( (%s) ) with Result = (%lx)" ,
  813. ObjectPath ,
  814. hr
  815. ) ;
  816. )
  817. }
  818. }
  819. catch(Structured_Exception e_SE)
  820. {
  821. hr = WBEM_E_UNEXPECTED;
  822. }
  823. catch(Heap_Exception e_HE)
  824. {
  825. hr = WBEM_E_OUT_OF_MEMORY;
  826. }
  827. catch(...)
  828. {
  829. hr = WBEM_E_UNEXPECTED;
  830. }
  831. try
  832. {
  833. if (t_AsyncEvent != NULL)
  834. {
  835. t_AsyncEvent->CleanUpObjSinks(TRUE);
  836. t_AsyncEvent->Release();
  837. }
  838. }
  839. catch(Structured_Exception e_SE)
  840. {
  841. hr = WBEM_E_UNEXPECTED;
  842. }
  843. catch(Heap_Exception e_HE)
  844. {
  845. hr = WBEM_E_OUT_OF_MEMORY;
  846. }
  847. catch(...)
  848. {
  849. hr = WBEM_E_UNEXPECTED;
  850. }
  851. return hr ;
  852. }
  853. HRESULT CViewProvServ :: PutClass (
  854. IWbemClassObject __RPC_FAR* pClass ,
  855. long lFlags,
  856. IWbemContext __RPC_FAR *pCtx,
  857. IWbemCallResult __RPC_FAR* __RPC_FAR* ppCallResult
  858. )
  859. {
  860. return WBEM_E_NOT_AVAILABLE ;
  861. }
  862. HRESULT CViewProvServ :: PutClassAsync (
  863. IWbemClassObject __RPC_FAR* pClass,
  864. long lFlags,
  865. IWbemContext __RPC_FAR *pCtx,
  866. IWbemObjectSink __RPC_FAR* pHandler
  867. )
  868. {
  869. return WBEM_E_NOT_AVAILABLE ;
  870. }
  871. HRESULT CViewProvServ :: DeleteClass (
  872. const BSTR Class,
  873. long lFlags,
  874. IWbemContext __RPC_FAR *pCtx,
  875. IWbemCallResult __RPC_FAR* __RPC_FAR* ppCallResult
  876. )
  877. {
  878. return WBEM_E_NOT_AVAILABLE ;
  879. }
  880. HRESULT CViewProvServ :: DeleteClassAsync (
  881. const BSTR Class,
  882. long lFlags,
  883. IWbemContext __RPC_FAR *pCtx,
  884. IWbemObjectSink __RPC_FAR* pHandler
  885. )
  886. {
  887. return WBEM_E_NOT_AVAILABLE ;
  888. }
  889. HRESULT CViewProvServ :: CreateClassEnum (
  890. const BSTR Superclass,
  891. long lFlags,
  892. IWbemContext __RPC_FAR *pCtx,
  893. IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum
  894. )
  895. {
  896. return WBEM_E_NOT_AVAILABLE ;
  897. }
  898. SCODE CViewProvServ :: CreateClassEnumAsync (
  899. const BSTR Superclass,
  900. long lFlags,
  901. IWbemContext __RPC_FAR* pCtx,
  902. IWbemObjectSink __RPC_FAR* pHandler
  903. )
  904. {
  905. return WBEM_E_NOT_AVAILABLE ;
  906. }
  907. HRESULT CViewProvServ :: PutInstance (
  908. IWbemClassObject __RPC_FAR *pInstance,
  909. long lFlags,
  910. IWbemContext __RPC_FAR *pCtx,
  911. IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult
  912. )
  913. {
  914. return WBEM_E_NOT_AVAILABLE ;
  915. }
  916. HRESULT CViewProvServ :: PutInstanceAsync (
  917. IWbemClassObject __RPC_FAR* pInstance,
  918. long lFlags,
  919. IWbemContext __RPC_FAR *pCtx,
  920. IWbemObjectSink __RPC_FAR* pHandler
  921. )
  922. {
  923. HRESULT t_Result = S_OK ;
  924. SetStructuredExceptionHandler seh;
  925. PutInstanceTaskObject *t_AsyncEvent = NULL;
  926. try
  927. {
  928. if (pHandler == NULL)
  929. {
  930. t_Result = WBEM_E_INVALID_PARAMETER;
  931. }
  932. else
  933. {
  934. t_Result = WbemCoImpersonateClient();
  935. #ifdef UNICODE
  936. #if 0
  937. DWORD dwBuffSz = 1024;
  938. wchar_t strBuff[1024];
  939. GetUserName(strBuff, &dwBuffSz);
  940. VPGetUserName();
  941. #endif
  942. #endif
  943. DebugOut1(
  944. CViewProvServ::sm_debugLog->Write (
  945. _T("\r\n")
  946. ) ;
  947. CViewProvServ::sm_debugLog->WriteFileAndLine (
  948. _T(__FILE__),__LINE__,
  949. _T("CViewProvServ::PutInstanceAsync ()")
  950. ) ;
  951. )
  952. if (SUCCEEDED(t_Result))
  953. {
  954. /*
  955. * Create Asynchronous GetObjectByPath object
  956. */
  957. t_AsyncEvent = new PutInstanceTaskObject ( this , pInstance , lFlags , pHandler , pCtx ) ;
  958. t_AsyncEvent->PutInstance();
  959. t_AsyncEvent->Release();
  960. t_AsyncEvent = NULL;
  961. WbemCoRevertToSelf();
  962. }
  963. else
  964. {
  965. t_Result = WBEM_E_ACCESS_DENIED;
  966. }
  967. DebugOut1(
  968. CViewProvServ::sm_debugLog->WriteFileAndLine (
  969. _T(__FILE__),__LINE__,
  970. _T("Returning from CViewProvServ::PutInstanceAsync with Result = (%lx)"),
  971. t_Result
  972. ) ;
  973. )
  974. }
  975. }
  976. catch(Structured_Exception e_SE)
  977. {
  978. t_Result = WBEM_E_UNEXPECTED;
  979. }
  980. catch(Heap_Exception e_HE)
  981. {
  982. t_Result = WBEM_E_OUT_OF_MEMORY;
  983. }
  984. catch(...)
  985. {
  986. t_Result = WBEM_E_UNEXPECTED;
  987. }
  988. try
  989. {
  990. if (t_AsyncEvent != NULL)
  991. {
  992. t_AsyncEvent->Release();
  993. }
  994. }
  995. catch(Structured_Exception e_SE)
  996. {
  997. t_Result = WBEM_E_UNEXPECTED;
  998. }
  999. catch(Heap_Exception e_HE)
  1000. {
  1001. t_Result = WBEM_E_OUT_OF_MEMORY;
  1002. }
  1003. catch(...)
  1004. {
  1005. t_Result = WBEM_E_UNEXPECTED;
  1006. }
  1007. return t_Result ;
  1008. }
  1009. HRESULT CViewProvServ :: DeleteInstance (
  1010. const BSTR ObjectPath,
  1011. long lFlags,
  1012. IWbemContext __RPC_FAR *pCtx,
  1013. IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult
  1014. )
  1015. {
  1016. return WBEM_E_NOT_AVAILABLE ;
  1017. }
  1018. HRESULT CViewProvServ :: DeleteInstanceAsync (
  1019. const BSTR ObjectPath,
  1020. long lFlags,
  1021. IWbemContext __RPC_FAR *pCtx,
  1022. IWbemObjectSink __RPC_FAR *pHandler
  1023. )
  1024. {
  1025. return WBEM_E_NOT_AVAILABLE ;
  1026. }
  1027. HRESULT CViewProvServ :: CreateInstanceEnum (
  1028. const BSTR Class,
  1029. long lFlags,
  1030. IWbemContext __RPC_FAR *pCtx,
  1031. IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum
  1032. )
  1033. {
  1034. return WBEM_E_NOT_AVAILABLE ;
  1035. }
  1036. HRESULT CViewProvServ :: CreateInstanceEnumAsync (
  1037. const BSTR Class,
  1038. long lFlags,
  1039. IWbemContext __RPC_FAR *pCtx,
  1040. IWbemObjectSink __RPC_FAR* pHandler
  1041. )
  1042. {
  1043. HRESULT t_Result = S_OK ;
  1044. SetStructuredExceptionHandler seh;
  1045. ExecQueryTaskObject *t_AsyncEvent = NULL;
  1046. BSTR Query = NULL;
  1047. try
  1048. {
  1049. if (pHandler == NULL)
  1050. {
  1051. t_Result = WBEM_E_INVALID_PARAMETER;
  1052. }
  1053. else
  1054. {
  1055. t_Result = WbemCoImpersonateClient();
  1056. #ifdef UNICODE
  1057. #if 0
  1058. DWORD dwBuffSz = 1024;
  1059. wchar_t strBuff[1024];
  1060. GetUserName(strBuff, &dwBuffSz);
  1061. VPGetUserName();
  1062. #endif
  1063. #endif
  1064. DebugOut1(
  1065. CViewProvServ::sm_debugLog->Write (
  1066. _T("\r\n")
  1067. ) ;
  1068. CViewProvServ::sm_debugLog->WriteW (
  1069. L"CViewProvServ::CreateInstanceEnumAsync ( (%s) )" ,
  1070. Class
  1071. ) ;
  1072. )
  1073. if (SUCCEEDED(t_Result))
  1074. {
  1075. /*
  1076. * Create Synchronous Enum Instance object
  1077. */
  1078. Query = SysAllocStringLen(NULL, 33 + (wcslen(Class) * 2));
  1079. if (Query == NULL)
  1080. {
  1081. throw Heap_Exception(Heap_Exception::HEAP_ERROR::E_ALLOCATION_ERROR);
  1082. }
  1083. wcscpy(Query, ENUM_INST_QUERY_START);
  1084. wcscat(Query, Class);
  1085. wcscat(Query, ENUM_INST_QUERY_MID);
  1086. wcscat(Query, Class);
  1087. wcscat(Query, END_QUOTE);
  1088. t_AsyncEvent = new ExecQueryTaskObject ( this , WBEM_QUERY_LANGUAGE_SQL1 , Query , lFlags , pHandler , pCtx ) ;
  1089. t_AsyncEvent->ExecQuery();
  1090. t_AsyncEvent->Release();
  1091. t_AsyncEvent = NULL;
  1092. SysFreeString(Query);
  1093. WbemCoRevertToSelf();
  1094. }
  1095. else
  1096. {
  1097. t_Result = WBEM_E_ACCESS_DENIED;
  1098. }
  1099. DebugOut1(
  1100. CViewProvServ::sm_debugLog->WriteW (
  1101. L"Returning from CViewProvServ::CreateInstanceEnumAsync ( (%s),(%s) ) with Result = (%lx)" ,
  1102. Class,
  1103. Query,
  1104. t_Result
  1105. ) ;
  1106. )
  1107. }
  1108. }
  1109. catch(Structured_Exception e_SE)
  1110. {
  1111. t_Result = WBEM_E_UNEXPECTED;
  1112. }
  1113. catch(Heap_Exception e_HE)
  1114. {
  1115. t_Result = WBEM_E_OUT_OF_MEMORY;
  1116. }
  1117. catch(...)
  1118. {
  1119. t_Result = WBEM_E_UNEXPECTED;
  1120. }
  1121. try
  1122. {
  1123. if (t_AsyncEvent != NULL)
  1124. {
  1125. t_AsyncEvent->CleanUpObjSinks(TRUE);
  1126. t_AsyncEvent->Release();
  1127. SysFreeString(Query);
  1128. }
  1129. }
  1130. catch(Structured_Exception e_SE)
  1131. {
  1132. t_Result = WBEM_E_UNEXPECTED;
  1133. }
  1134. catch(Heap_Exception e_HE)
  1135. {
  1136. t_Result = WBEM_E_OUT_OF_MEMORY;
  1137. }
  1138. catch(...)
  1139. {
  1140. t_Result = WBEM_E_UNEXPECTED;
  1141. }
  1142. return t_Result ;
  1143. }
  1144. HRESULT CViewProvServ :: ExecQuery (
  1145. const BSTR QueryLanguage,
  1146. const BSTR Query,
  1147. long lFlags,
  1148. IWbemContext __RPC_FAR *pCtx,
  1149. IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum
  1150. )
  1151. {
  1152. return WBEM_E_NOT_AVAILABLE ;
  1153. }
  1154. HRESULT CViewProvServ :: ExecQueryAsync (
  1155. const BSTR QueryFormat,
  1156. const BSTR Query,
  1157. long lFlags,
  1158. IWbemContext __RPC_FAR* pCtx,
  1159. IWbemObjectSink __RPC_FAR* pHandler
  1160. )
  1161. {
  1162. HRESULT t_Result = S_OK ;
  1163. SetStructuredExceptionHandler seh;
  1164. ExecQueryTaskObject *t_AsyncEvent = NULL;
  1165. try
  1166. {
  1167. if (pHandler == NULL)
  1168. {
  1169. t_Result = WBEM_E_INVALID_PARAMETER;
  1170. }
  1171. else
  1172. {
  1173. t_Result = WbemCoImpersonateClient();
  1174. #ifdef UNICODE
  1175. #if 0
  1176. DWORD dwBuffSz = 1024;
  1177. wchar_t strBuff[1024];
  1178. GetUserName(strBuff, &dwBuffSz);
  1179. VPGetUserName();
  1180. #endif
  1181. #endif
  1182. DebugOut1(
  1183. CViewProvServ::sm_debugLog->Write (
  1184. _T("\r\n")
  1185. ) ;
  1186. CViewProvServ::sm_debugLog->WriteW (
  1187. L"CViewProvServ::ExecQueryAsync ( (%s),(%s) )" ,
  1188. QueryFormat ,
  1189. Query
  1190. ) ;
  1191. )
  1192. if (SUCCEEDED(t_Result))
  1193. {
  1194. /*
  1195. * Create Synchronous Enum Instance object
  1196. */
  1197. pHandler->SetStatus(WBEM_STATUS_REQUIREMENTS, S_OK, NULL, NULL);
  1198. t_AsyncEvent = new ExecQueryTaskObject ( this , QueryFormat , Query , lFlags , pHandler , pCtx ) ;
  1199. t_AsyncEvent->ExecQuery();
  1200. t_AsyncEvent->Release();
  1201. t_AsyncEvent = NULL;
  1202. WbemCoRevertToSelf();
  1203. }
  1204. else
  1205. {
  1206. t_Result = WBEM_E_ACCESS_DENIED;
  1207. }
  1208. DebugOut1(
  1209. CViewProvServ::sm_debugLog->WriteW (
  1210. L"Returning from CViewProvServ::ExecqQueryAsync ( (%s),(%s) ) with Result = (%lx)" ,
  1211. QueryFormat ,
  1212. Query ,
  1213. t_Result
  1214. ) ;
  1215. )
  1216. }
  1217. }
  1218. catch(Structured_Exception e_SE)
  1219. {
  1220. t_Result = WBEM_E_UNEXPECTED;
  1221. }
  1222. catch(Heap_Exception e_HE)
  1223. {
  1224. t_Result = WBEM_E_OUT_OF_MEMORY;
  1225. }
  1226. catch(...)
  1227. {
  1228. t_Result = WBEM_E_UNEXPECTED;
  1229. }
  1230. try
  1231. {
  1232. if (t_AsyncEvent != NULL)
  1233. {
  1234. t_AsyncEvent->CleanUpObjSinks(TRUE);
  1235. t_AsyncEvent->Release();
  1236. }
  1237. }
  1238. catch(Structured_Exception e_SE)
  1239. {
  1240. t_Result = WBEM_E_UNEXPECTED;
  1241. }
  1242. catch(Heap_Exception e_HE)
  1243. {
  1244. t_Result = WBEM_E_OUT_OF_MEMORY;
  1245. }
  1246. catch(...)
  1247. {
  1248. t_Result = WBEM_E_UNEXPECTED;
  1249. }
  1250. return t_Result ;
  1251. }
  1252. HRESULT CViewProvServ :: ExecNotificationQuery (
  1253. const BSTR QueryLanguage,
  1254. const BSTR Query,
  1255. long lFlags,
  1256. IWbemContext __RPC_FAR *pCtx,
  1257. IEnumWbemClassObject __RPC_FAR *__RPC_FAR *ppEnum
  1258. )
  1259. {
  1260. return WBEM_E_NOT_AVAILABLE ;
  1261. }
  1262. HRESULT CViewProvServ :: ExecNotificationQueryAsync (
  1263. const BSTR QueryLanguage,
  1264. const BSTR Query,
  1265. long lFlags,
  1266. IWbemContext __RPC_FAR *pCtx,
  1267. IWbemObjectSink __RPC_FAR *pHandler
  1268. )
  1269. {
  1270. return WBEM_E_NOT_AVAILABLE ;
  1271. }
  1272. HRESULT STDMETHODCALLTYPE CViewProvServ :: ExecMethod(
  1273. const BSTR ObjectPath,
  1274. const BSTR MethodName,
  1275. long lFlags,
  1276. IWbemContext __RPC_FAR *pCtx,
  1277. IWbemClassObject __RPC_FAR *pInParams,
  1278. IWbemClassObject __RPC_FAR *__RPC_FAR *ppOutParams,
  1279. IWbemCallResult __RPC_FAR *__RPC_FAR *ppCallResult
  1280. )
  1281. {
  1282. return WBEM_E_NOT_AVAILABLE ;
  1283. }
  1284. HRESULT STDMETHODCALLTYPE CViewProvServ :: ExecMethodAsync (
  1285. const BSTR ObjectPath,
  1286. const BSTR MethodName,
  1287. long lFlags,
  1288. IWbemContext __RPC_FAR *pCtx,
  1289. IWbemClassObject __RPC_FAR *pInParams,
  1290. IWbemObjectSink __RPC_FAR *pResponseHandler
  1291. )
  1292. {
  1293. HRESULT t_Result = S_OK ;
  1294. SetStructuredExceptionHandler seh;
  1295. ExecMethodTaskObject *t_AsyncEvent = NULL;
  1296. try
  1297. {
  1298. if (pResponseHandler == NULL)
  1299. {
  1300. t_Result = WBEM_E_INVALID_PARAMETER;
  1301. }
  1302. else
  1303. {
  1304. t_Result = WbemCoImpersonateClient();
  1305. #ifdef UNICODE
  1306. #if 0
  1307. DWORD dwBuffSz = 1024;
  1308. wchar_t strBuff[1024];
  1309. GetUserName(strBuff, &dwBuffSz);
  1310. VPGetUserName();
  1311. #endif
  1312. #endif
  1313. DebugOut1(
  1314. CViewProvServ::sm_debugLog->Write (
  1315. _T("\r\n")
  1316. ) ;
  1317. CViewProvServ::sm_debugLog->WriteFileAndLine (
  1318. _T(__FILE__),__LINE__,
  1319. _T("CViewProvServ::ExecMethodAsync ()")
  1320. ) ;
  1321. )
  1322. if (SUCCEEDED(t_Result))
  1323. {
  1324. /*
  1325. * Create Asynchronous GetObjectByPath object
  1326. */
  1327. t_AsyncEvent = new ExecMethodTaskObject ( this , ObjectPath , MethodName ,
  1328. lFlags , pInParams , pResponseHandler , pCtx ) ;
  1329. t_AsyncEvent->ExecMethod();
  1330. t_AsyncEvent->Release();
  1331. t_AsyncEvent = NULL;
  1332. WbemCoRevertToSelf();
  1333. }
  1334. else
  1335. {
  1336. t_Result = WBEM_E_ACCESS_DENIED;
  1337. }
  1338. DebugOut1(
  1339. CViewProvServ::sm_debugLog->WriteW (
  1340. L"Returning from CViewProvServ::ExecMethodAsync ( (%s) ) with Result = (%lx)" ,
  1341. ObjectPath ,
  1342. t_Result
  1343. ) ;
  1344. )
  1345. }
  1346. }
  1347. catch(Structured_Exception e_SE)
  1348. {
  1349. t_Result = WBEM_E_UNEXPECTED;
  1350. }
  1351. catch(Heap_Exception e_HE)
  1352. {
  1353. t_Result = WBEM_E_OUT_OF_MEMORY;
  1354. }
  1355. catch(...)
  1356. {
  1357. t_Result = WBEM_E_UNEXPECTED;
  1358. }
  1359. try
  1360. {
  1361. if (t_AsyncEvent != NULL)
  1362. {
  1363. t_AsyncEvent->Release();
  1364. }
  1365. }
  1366. catch(Structured_Exception e_SE)
  1367. {
  1368. t_Result = WBEM_E_UNEXPECTED;
  1369. }
  1370. catch(Heap_Exception e_HE)
  1371. {
  1372. t_Result = WBEM_E_OUT_OF_MEMORY;
  1373. }
  1374. catch(...)
  1375. {
  1376. t_Result = WBEM_E_UNEXPECTED;
  1377. }
  1378. return t_Result ;
  1379. }
  1380. HRESULT CViewProvServ :: Initialize(
  1381. LPWSTR pszUser,
  1382. LONG lFlags,
  1383. LPWSTR pszNamespace,
  1384. LPWSTR pszLocale,
  1385. IWbemServices *pCIMOM, // For anybody
  1386. IWbemContext *pCtx,
  1387. IWbemProviderInitSink *pInitSink // For init signals
  1388. )
  1389. {
  1390. SetStructuredExceptionHandler seh;
  1391. try
  1392. {
  1393. DebugOut1(
  1394. CViewProvServ::sm_debugLog->Write (
  1395. _T("\r\n")
  1396. ) ;
  1397. CViewProvServ::sm_debugLog->WriteFileAndLine (
  1398. _T(__FILE__),__LINE__,
  1399. _T("CViewProvServ::Initialize ")
  1400. ) ;
  1401. )
  1402. if ((pCIMOM == NULL) || (pInitSink == NULL) || (pszNamespace == NULL))
  1403. {
  1404. return WBEM_E_INVALID_PARAMETER;
  1405. }
  1406. #ifndef UNICODE
  1407. if (pszUser == NULL)
  1408. {
  1409. return WBEM_E_INVALID_PARAMETER;
  1410. }
  1411. m_UserName = SysAllocString(pszUser);
  1412. #endif
  1413. m_Server = pCIMOM ;
  1414. m_Server->AddRef () ;
  1415. m_NamespacePath.SetNamespacePath ( pszNamespace ) ;
  1416. pInitSink->SetStatus ( WBEM_S_INITIALIZED , 0 ) ;
  1417. DebugOut1(
  1418. CViewProvServ::sm_debugLog->WriteFileAndLine (
  1419. _T(__FILE__),__LINE__,
  1420. _T("Returning From CImpPropProv::Initialize () ")
  1421. ) ;
  1422. )
  1423. }
  1424. catch(Structured_Exception e_SE)
  1425. {
  1426. return WBEM_E_UNEXPECTED;
  1427. }
  1428. catch(Heap_Exception e_HE)
  1429. {
  1430. return WBEM_E_OUT_OF_MEMORY;
  1431. }
  1432. catch(...)
  1433. {
  1434. return WBEM_E_UNEXPECTED;
  1435. }
  1436. return WBEM_NO_ERROR ;
  1437. }
  1438. HRESULT STDMETHODCALLTYPE CViewProvServ::OpenNamespace (
  1439. const BSTR ObjectPath,
  1440. long lFlags,
  1441. IWbemContext FAR* pCtx,
  1442. IWbemServices FAR* FAR* pNewContext,
  1443. IWbemCallResult FAR* FAR* ppErrorObject
  1444. )
  1445. {
  1446. return WBEM_E_NOT_AVAILABLE ;
  1447. }