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.

801 lines
22 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1999-2000 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // InstanceProv.cpp
  7. //
  8. // Description:
  9. // Implementation of CInstanceProv class
  10. //
  11. // Author:
  12. // Henry Wang (HenryWa) 24-AUG-1999
  13. // MSP Prabu (mprabu) 06-Jan-2001
  14. // Jim Benton (jbenton) 15-Oct-2001
  15. //
  16. //////////////////////////////////////////////////////////////////////////////
  17. #pragma once
  18. #include "Pch.h"
  19. #include "InstanceProv.h"
  20. #include "VssClasses.h"
  21. #include "msg.h"
  22. BOOL MapVssErrorToMsgAndWMIStatus(
  23. IN HRESULT hr,
  24. OUT LONG* plMsgNum,
  25. OUT HRESULT* pHr
  26. );
  27. //////////////////////////////////////////////////////////////////////////////
  28. // Global Variables
  29. //////////////////////////////////////////////////////////////////////////////
  30. long g_lNumInst = 0;
  31. ClassMap g_ClassMap;
  32. //****************************************************************************
  33. //
  34. // CInstanceProv
  35. //
  36. //****************************************************************************
  37. //////////////////////////////////////////////////////////////////////////////
  38. //++
  39. //
  40. // HRESULT
  41. // CInstanceProv::DoCreateInstanceEnumAsync
  42. //
  43. // Description:
  44. // Enumerate instance for a given class.
  45. //
  46. // Arguments:
  47. // bstrRefStr -- Name the class to enumerate
  48. // lFlags -- WMI flag
  49. // pCtx -- WMI context
  50. // pHandler -- WMI sink pointer
  51. //
  52. // Return Values:
  53. // WBEM_S_NO_ERROR
  54. // WBEM_E_INVALID_PARAMETER
  55. //
  56. //--
  57. //////////////////////////////////////////////////////////////////////////////
  58. HRESULT
  59. CInstanceProv::DoCreateInstanceEnumAsync(
  60. IN BSTR bstrRefStr,
  61. IN long lFlags,
  62. IN IWbemContext* pCtx,
  63. IN IWbemObjectSink* pHandler
  64. )
  65. {
  66. HRESULT hr = WBEM_S_NO_ERROR;
  67. if (bstrRefStr == NULL || pHandler == NULL || m_pNamespace == NULL)
  68. {
  69. return WBEM_E_INVALID_PARAMETER;
  70. }
  71. try
  72. {
  73. auto_ptr<CProvBase> pProvBase;
  74. CreateClass(bstrRefStr, m_pNamespace, pProvBase);
  75. hr = pProvBase->EnumInstance(
  76. lFlags,
  77. pCtx,
  78. pHandler
  79. );
  80. if (FAILED(hr))
  81. {
  82. CProvException exception(hr);
  83. hr = SetExtendedStatus(exception, &pHandler);
  84. }
  85. else // Set status OK
  86. {
  87. pHandler->SetStatus(WBEM_STATUS_COMPLETE, WBEM_S_NO_ERROR, 0, 0);
  88. }
  89. }
  90. catch (CProvException& prove)
  91. {
  92. hr = SetExtendedStatus(prove, &pHandler);
  93. }
  94. catch (_com_error& err)
  95. {
  96. CProvException exception(err.Error());
  97. hr = SetExtendedStatus(exception, &pHandler);
  98. }
  99. catch ( ... )
  100. {
  101. hr = WBEM_E_FAILED;
  102. }
  103. return hr;
  104. } //*** CInstanceProv::DoCreateInstanceEnumAsync()
  105. //////////////////////////////////////////////////////////////////////////////
  106. //++
  107. //
  108. // HRESULT
  109. // CInstanceProv::DoGetObjectAsync
  110. //
  111. // Description:
  112. // Creates an instance given a particular path value.
  113. //
  114. // Arguments:
  115. // bstrObjectPath -- Object path to an object
  116. // lFlags -- WMI flag
  117. // pCtx -- WMI context
  118. // pHandler -- WMI sink pointer
  119. //
  120. // Return Values:
  121. // WBEM_S_NO_ERROR
  122. // WBEM_E_INVALID_PARAMETER
  123. // WBEM_E_FAILED
  124. // Win32 error
  125. //
  126. //--
  127. //////////////////////////////////////////////////////////////////////////////
  128. HRESULT
  129. CInstanceProv::DoGetObjectAsync(
  130. IN BSTR bstrObjectPath,
  131. IN long lFlags,
  132. IN IWbemContext* pCtx,
  133. IN IWbemObjectSink* pHandler
  134. )
  135. {
  136. HRESULT hr = S_OK;
  137. if (bstrObjectPath == NULL || pHandler == NULL || m_pNamespace == NULL)
  138. {
  139. return WBEM_E_INVALID_PARAMETER;
  140. }
  141. try
  142. {
  143. CObjPath ObjPath;
  144. _bstr_t bstrClass;
  145. auto_ptr<CProvBase> pProvBase;
  146. if (!ObjPath.Init( bstrObjectPath))
  147. {
  148. return WBEM_E_INVALID_PARAMETER;
  149. }
  150. bstrClass = ObjPath.GetClassName();
  151. CreateClass(bstrClass, m_pNamespace, pProvBase);
  152. hr = pProvBase->GetObject(
  153. ObjPath,
  154. lFlags,
  155. pCtx,
  156. pHandler
  157. );
  158. if (FAILED(hr))
  159. {
  160. CProvException exception(hr);
  161. hr = SetExtendedStatus(exception, &pHandler);
  162. }
  163. else // Set status OK
  164. {
  165. pHandler->SetStatus(WBEM_STATUS_COMPLETE, WBEM_S_NO_ERROR, 0, 0);
  166. }
  167. }
  168. catch (CProvException& prove)
  169. {
  170. hr = SetExtendedStatus(prove, &pHandler);
  171. }
  172. catch (_com_error& err)
  173. {
  174. CProvException exception(err.Error());
  175. hr = SetExtendedStatus(exception, &pHandler);
  176. }
  177. catch ( ... )
  178. {
  179. hr = WBEM_E_FAILED;
  180. }
  181. return hr;
  182. } //*** CInstanceProv::DoGetObjectAsync()
  183. //////////////////////////////////////////////////////////////////////////////
  184. //++
  185. //
  186. // HRESULT
  187. // CInstanceProv::DoPutInstanceAsync
  188. //
  189. // Description:
  190. // Save this instance.
  191. //
  192. // Arguments:
  193. // pInst -- WMI object to be saved
  194. // lFlags -- WMI flag
  195. // pCtx -- WMI context
  196. // pHandler -- WMI sink pointer
  197. //
  198. // Return Values:
  199. // WBEM_S_NO_ERROR
  200. // WBEM_E_INVALID_PARAMETER
  201. // WBEM_E_FAILED
  202. // Win32 error
  203. //
  204. //--
  205. //////////////////////////////////////////////////////////////////////////////
  206. HRESULT
  207. CInstanceProv::DoPutInstanceAsync(
  208. IN IWbemClassObject* pInst,
  209. IN long lFlags,
  210. IN IWbemContext* pCtx,
  211. IN IWbemObjectSink* pHandler
  212. )
  213. {
  214. HRESULT hr = S_OK;
  215. if (pInst == NULL || pHandler == NULL || m_pNamespace == NULL)
  216. {
  217. return WBEM_E_INVALID_PARAMETER;
  218. }
  219. try
  220. {
  221. _variant_t varClass;
  222. auto_ptr<CProvBase> pProvBase;
  223. CWbemClassObject wcoSrc(pInst);
  224. hr = pInst->Get(L"__CLASS", 0, &varClass, 0, 0);
  225. CreateClass(varClass.bstrVal, m_pNamespace, pProvBase);
  226. hr = pProvBase->PutInstance(
  227. wcoSrc,
  228. lFlags,
  229. pCtx,
  230. pHandler
  231. );
  232. if (FAILED(hr))
  233. {
  234. CProvException exception(hr);
  235. hr = SetExtendedStatus(exception, &pHandler);
  236. }
  237. else // Set status OK
  238. {
  239. pHandler->SetStatus(WBEM_STATUS_COMPLETE, WBEM_S_NO_ERROR, 0, 0);
  240. }
  241. }
  242. catch (CProvException& prove)
  243. {
  244. hr = SetExtendedStatus(prove, &pHandler);
  245. }
  246. catch (_com_error& err)
  247. {
  248. CProvException exception(err.Error());
  249. hr = SetExtendedStatus(exception, &pHandler);
  250. }
  251. catch ( ... )
  252. {
  253. hr = WBEM_E_FAILED;
  254. }
  255. return hr;
  256. } //*** CInstanceProv::DoPutInstanceAsync()
  257. //////////////////////////////////////////////////////////////////////////////
  258. //++
  259. //
  260. // HRESULT
  261. // CInstanceProv::DoDeleteInstanceAsync
  262. //
  263. // Description:
  264. // Delete this instance.
  265. //
  266. // Arguments:
  267. // bstrObjectPath -- ObjPath for the instance to be deleted
  268. // lFlags -- WMI flag
  269. // pCtx -- WMI context
  270. // pHandler -- WMI sink pointer
  271. //
  272. // Return Values:
  273. // WBEM_S_NO_ERROR
  274. // WBEM_E_INVALID_PARAMETER
  275. // WBEM_E_FAILED
  276. // Win32 error
  277. //
  278. //--
  279. //////////////////////////////////////////////////////////////////////////////
  280. HRESULT
  281. CInstanceProv::DoDeleteInstanceAsync(
  282. IN BSTR bstrObjectPath,
  283. IN long lFlags,
  284. IN IWbemContext* pCtx,
  285. IN IWbemObjectSink* pHandler
  286. )
  287. {
  288. HRESULT hr = S_OK;
  289. if (bstrObjectPath == NULL || pHandler == NULL || m_pNamespace == NULL)
  290. {
  291. return WBEM_E_INVALID_PARAMETER;
  292. }
  293. try
  294. {
  295. CObjPath ObjPath;
  296. _bstr_t bstrClass;
  297. auto_ptr<CProvBase> pProvBase;
  298. if (!ObjPath.Init(bstrObjectPath))
  299. {
  300. return WBEM_E_INVALID_PARAMETER;
  301. }
  302. bstrClass = ObjPath.GetClassName();
  303. CreateClass(bstrClass, m_pNamespace, pProvBase);
  304. hr = pProvBase->DeleteInstance(
  305. ObjPath,
  306. lFlags,
  307. pCtx,
  308. pHandler
  309. );
  310. if (FAILED(hr))
  311. {
  312. CProvException exception( hr );
  313. hr = SetExtendedStatus(exception, &pHandler);
  314. }
  315. else // Set status OK
  316. {
  317. pHandler->SetStatus(WBEM_STATUS_COMPLETE, WBEM_S_NO_ERROR, 0, 0);
  318. }
  319. }
  320. catch (CProvException& prove)
  321. {
  322. hr = SetExtendedStatus(prove, &pHandler);
  323. }
  324. catch (_com_error& err)
  325. {
  326. CProvException exception(err.Error());
  327. hr = SetExtendedStatus(exception, &pHandler);
  328. }
  329. catch ( ... )
  330. {
  331. hr = WBEM_E_FAILED;
  332. }
  333. return hr;
  334. } //*** CInstanceProv::DoDeleteInstanceAsync()
  335. //////////////////////////////////////////////////////////////////////////////
  336. //++
  337. //
  338. // HRESULT
  339. // CInstanceProv::DoExecMethodAsync
  340. //
  341. // Description:
  342. // Execute methods for the given object.
  343. //
  344. // Arguments:
  345. // bstrObjectPath -- Object path to a given object
  346. // bstrMethodName -- Name of the method to be invoked
  347. // lFlags -- WMI flag
  348. // pCtx -- WMI context
  349. // pInParams -- Input parameters for the method
  350. // pHandler -- WMI sink pointer
  351. //
  352. // Return Values:
  353. // WBEM_S_NO_ERROR
  354. //
  355. //--
  356. //////////////////////////////////////////////////////////////////////////////
  357. HRESULT
  358. CInstanceProv::DoExecMethodAsync(
  359. IN BSTR bstrObjectPath,
  360. IN BSTR bstrMethodName,
  361. IN long lFlags,
  362. IN IWbemContext* pCtx,
  363. IN IWbemClassObject* pInParams,
  364. IN IWbemObjectSink* pHandler
  365. )
  366. {
  367. HRESULT hr = S_OK;
  368. if (bstrObjectPath == NULL || pHandler == NULL || m_pNamespace == NULL
  369. || bstrMethodName == NULL)
  370. {
  371. return WBEM_E_INVALID_PARAMETER;
  372. }
  373. try
  374. {
  375. CObjPath ObjPath;
  376. _bstr_t bstrClass;
  377. auto_ptr<CProvBase> pProvBase;
  378. if (!ObjPath.Init(bstrObjectPath))
  379. {
  380. return WBEM_E_INVALID_PARAMETER;
  381. }
  382. bstrClass = ObjPath.GetClassName();
  383. CreateClass(bstrClass, m_pNamespace, pProvBase);
  384. hr = pProvBase->ExecuteMethod(
  385. bstrObjectPath,
  386. bstrMethodName,
  387. lFlags,
  388. pInParams,
  389. pHandler
  390. );
  391. if ( FAILED( hr ) )
  392. {
  393. CProvException exception(hr);
  394. hr = SetExtendedStatus(exception, &pHandler);
  395. }
  396. else // Set status OK
  397. {
  398. pHandler->SetStatus(WBEM_STATUS_COMPLETE, WBEM_S_NO_ERROR, 0, 0);
  399. }
  400. }
  401. catch (CProvException& prove)
  402. {
  403. hr = SetExtendedStatus(prove, &pHandler);
  404. }
  405. catch (_com_error& err)
  406. {
  407. CProvException exception(err.Error());
  408. hr = SetExtendedStatus(exception, &pHandler);
  409. }
  410. catch ( ... )
  411. {
  412. hr = WBEM_E_FAILED;
  413. }
  414. return hr;
  415. } //*** CInstanceProv::DoExecMethodAsync()
  416. //////////////////////////////////////////////////////////////////////////////
  417. //++
  418. //
  419. // HRESULT
  420. // CInstanceProv::SetExtendedStatus
  421. //
  422. // Description:
  423. // Create and set extended error status.
  424. //
  425. // Arguments:
  426. // rpeIn -- Exception object.
  427. // rwcoInstOut -- Reference to WMI instance.
  428. //
  429. // Return Values:
  430. // WBEM_S_NO_ERROR
  431. //
  432. // Note:
  433. // Do not allow CProvException, _com_error or HRESULT exceptions through
  434. // this function is called to handle these exceptions.
  435. //--
  436. //////////////////////////////////////////////////////////////////////////////
  437. HRESULT
  438. CInstanceProv::SetExtendedStatus(
  439. IN CProvException & rpe,
  440. IN IWbemObjectSink ** ppHandler
  441. )
  442. {
  443. HRESULT hr = WBEM_S_NO_ERROR;
  444. HRESULT hrStatus = WBEM_S_NO_ERROR;
  445. CComPtr<IWbemClassObject> spStatus;
  446. WCHAR* pwszErrorMsg = NULL;
  447. try
  448. {
  449. hr = m_pNamespace->GetObject(
  450. _bstr_t(PVD_WBEM_EXTENDEDSTATUS),
  451. 0,
  452. NULL,
  453. &spStatus,
  454. NULL
  455. );
  456. if (SUCCEEDED(hr))
  457. {
  458. CWbemClassObject wcoInst;
  459. hr = spStatus->SpawnInstance(0, &wcoInst);
  460. if (SUCCEEDED(hr))
  461. {
  462. _bstr_t bstrError;
  463. LONG lMsg = 0;
  464. if (MapVssErrorToMsgAndWMIStatus(rpe.hrGetError(), &lMsg, &hrStatus))
  465. {
  466. // Auto-delete string
  467. CVssAutoPWSZ awszMsg(GetMsg(lMsg));
  468. // The following may throw CProvException
  469. wcoInst.SetProperty(awszMsg, PVD_WBEM_DESCRIPTION);
  470. }
  471. else
  472. {
  473. if (rpe.PwszErrorMessage())
  474. {
  475. bstrError = rpe.PwszErrorMessage();
  476. if (rpe.PwszGetErrorHelpInfo())
  477. {
  478. bstrError += L" ";
  479. bstrError += rpe.PwszGetErrorHelpInfo();
  480. }
  481. }
  482. else if (rpe.PwszGetErrorHelpInfo())
  483. {
  484. bstrError = rpe.PwszGetErrorHelpInfo();
  485. }
  486. // The following may throw CProvException
  487. wcoInst.SetProperty((WCHAR*)bstrError, PVD_WBEM_DESCRIPTION);
  488. }
  489. wcoInst.SetProperty(rpe.hrGetError(), PVD_WBEM_STATUSCODE);
  490. wcoInst.SetProperty(PVD_WBEM_PROVIDERNAME, PVD_WBEM_PROP_PROVIDERNAME);
  491. hr = (*ppHandler)->SetStatus(
  492. 0,
  493. hrStatus,
  494. 0,
  495. wcoInst.data( )
  496. );
  497. hr = hrStatus;
  498. }
  499. }
  500. }
  501. catch (CProvException& prove)
  502. {
  503. hr = prove.hrGetError();
  504. }
  505. catch (_com_error& err)
  506. {
  507. hr = err.Error();
  508. }
  509. return hr;
  510. } //*** CInstanceProv::SetExtendedStatus()
  511. //////////////////////////////////////////////////////////////////////////////
  512. //++
  513. //
  514. // HRESULT
  515. // CInstanceProv::S_HrCreateThis(
  516. // IUnknown * pUnknownOuterIn,
  517. // VOID ** ppvOut
  518. // )
  519. //
  520. // Description:
  521. // Create an instance of the instance provider.
  522. //
  523. // Arguments:
  524. // pUnknownOuterIn -- Outer IUnknown pointer.
  525. // ppvOut -- Receives the created instance pointer.
  526. //
  527. // Return Values:
  528. // S_OK
  529. //
  530. //--
  531. //////////////////////////////////////////////////////////////////////////////
  532. HRESULT
  533. CInstanceProv::S_HrCreateThis(
  534. IN IUnknown* ,// pUnknownOuterIn,
  535. OUT VOID** ppv
  536. )
  537. {
  538. _ASSERTE(ppv != NULL);
  539. *ppv = new CInstanceProv();
  540. return S_OK;
  541. } //*** CInstanceProv::S_HrCreateThis()
  542. //////////////////////////////////////////////////////////////////////////////
  543. //++
  544. //
  545. // STDMETHODIMP
  546. // CInstanceProv::Initialize
  547. //
  548. // Description:
  549. // Initialize the instance provider.
  550. //
  551. // Arguments:
  552. // pszUserIn --
  553. // lFlagsIn -- WMI flag
  554. // pszNamespaceIn --
  555. // pszLocaleIn --
  556. // pNamespaceIn --
  557. // pCtxIn -- WMI context
  558. // pInitSinkIn -- WMI sink pointer
  559. //
  560. // Return Values:
  561. // WBEM_S_NO_ERROR
  562. //
  563. //--
  564. //////////////////////////////////////////////////////////////////////////////
  565. STDMETHODIMP
  566. CInstanceProv::Initialize(
  567. IN LPWSTR pszUser,
  568. IN LONG lFlags,
  569. IN LPWSTR pszNamespace,
  570. IN LPWSTR pszLocale,
  571. IN IWbemServices* pNamespace,
  572. IN IWbemContext* pCtx,
  573. IN IWbemProviderInitSink* pInitSink
  574. )
  575. {
  576. HRESULT hr = WBEM_S_NO_ERROR;
  577. try
  578. {
  579. if (!m_fInitialized)
  580. {
  581. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_PROVIDER,
  582. CClassCreator(CProvider::S_CreateThis, PVDR_CLASS_PROVIDER)));
  583. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_SHADOW,
  584. CClassCreator(CShadow::S_CreateThis, PVDR_CLASS_SHADOW)));
  585. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_SHADOWFOR,
  586. CClassCreator(CShadowFor::S_CreateThis, PVDR_CLASS_SHADOWFOR)));
  587. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_SHADOWBY,
  588. CClassCreator(CShadowBy::S_CreateThis, PVDR_CLASS_SHADOWBY)));
  589. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_SHADOWON,
  590. CClassCreator(CShadowOn::S_CreateThis, PVDR_CLASS_SHADOWON)));
  591. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_VOLUMESUPPORT,
  592. CClassCreator(CVolumeSupport::S_CreateThis, PVDR_CLASS_VOLUMESUPPORT)));
  593. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_DIFFVOLUMESUPPORT,
  594. CClassCreator(CDiffVolumeSupport::S_CreateThis, PVDR_CLASS_DIFFVOLUMESUPPORT)));
  595. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_STORAGE,
  596. CClassCreator(CStorage::S_CreateThis, PVDR_CLASS_STORAGE)));
  597. #ifdef ENABLE_WRITERS
  598. g_ClassMap.insert(ClassMap::value_type(PVDR_CLASS_WRITER,
  599. CClassCreator(CWriter::S_CreateThis, PVDR_CLASS_WRITER)));
  600. #endif
  601. hr = CImpersonatedProvider::Initialize(
  602. pszUser,
  603. lFlags,
  604. pszNamespace,
  605. pszLocale,
  606. pNamespace,
  607. pCtx,
  608. pInitSink
  609. );
  610. m_fInitialized = TRUE;
  611. }
  612. }
  613. catch(...)
  614. {
  615. hr = E_UNEXPECTED;
  616. }
  617. return hr;
  618. } //*** CInstanceProv::Initialize()
  619. //
  620. // Returns TRUE if error message was mapped
  621. //
  622. BOOL MapVssErrorToMsgAndWMIStatus(
  623. IN HRESULT hr,
  624. OUT LONG* plMsgNum,
  625. OUT HRESULT* pHr
  626. )
  627. {
  628. CVssFunctionTracer ft( VSSDBG_VSSADMIN, L"MapVssErrorToMsg" );
  629. ft.Trace( VSSDBG_VSSADMIN, L"Input HR: 0x%08x", hr );
  630. _ASSERTE(plMsgNum != NULL);
  631. _ASSERTE(pHr != NULL);
  632. LONG msg = 0;
  633. *plMsgNum = 0;
  634. *pHr = WBEM_E_PROVIDER_FAILURE;
  635. // Let Win32 errors through
  636. if (HRESULT_FACILITY(hr) == FACILITY_WIN32)
  637. {
  638. *pHr = hr;
  639. }
  640. // Let WMI errors through
  641. else if (HRESULT_FACILITY(hr) == FACILITY_ITF &&
  642. HRESULT_CODE(hr) > 0x1000 && HRESULT_CODE(hr) < 0x108b)
  643. {
  644. *pHr = hr;
  645. }
  646. else
  647. {
  648. switch ( hr )
  649. {
  650. case E_INVALIDARG:
  651. msg = MSG_ERROR_INVALID_OPTION_VALUE;
  652. *pHr = WBEM_E_INVALID_PARAMETER;
  653. break;
  654. case E_OUTOFMEMORY:
  655. msg = MSG_ERROR_OUT_OF_MEMORY;
  656. *pHr = WBEM_E_OUT_OF_MEMORY;
  657. break;
  658. case E_ACCESSDENIED:
  659. msg = MSG_ERROR_ACCESS_DENIED;
  660. *pHr = WBEM_E_ACCESS_DENIED;
  661. break;
  662. // VSS errors
  663. case VSS_E_PROVIDER_NOT_REGISTERED:
  664. msg = MSG_ERROR_VSS_PROVIDER_NOT_REGISTERED;
  665. break;
  666. case VSS_E_OBJECT_NOT_FOUND:
  667. msg = MSG_ERROR_VSS_VOLUME_NOT_FOUND;
  668. *pHr = WBEM_E_NOT_FOUND;
  669. break;
  670. case VSS_E_PROVIDER_VETO:
  671. msg = MSG_ERROR_VSS_PROVIDER_VETO;
  672. break;
  673. case VSS_E_VOLUME_NOT_SUPPORTED:
  674. msg = MSG_ERROR_VSS_VOLUME_NOT_SUPPORTED;
  675. break;
  676. case VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER:
  677. msg = MSG_ERROR_VSS_VOLUME_NOT_SUPPORTED_BY_PROVIDER;
  678. break;
  679. case VSS_E_UNEXPECTED_PROVIDER_ERROR:
  680. msg = MSG_ERROR_VSS_UNEXPECTED_PROVIDER_ERROR;
  681. break;
  682. case VSS_E_FLUSH_WRITES_TIMEOUT:
  683. msg = MSG_ERROR_VSS_FLUSH_WRITES_TIMEOUT;
  684. break;
  685. case VSS_E_HOLD_WRITES_TIMEOUT:
  686. msg = MSG_ERROR_VSS_HOLD_WRITES_TIMEOUT;
  687. break;
  688. case VSS_E_UNEXPECTED_WRITER_ERROR:
  689. msg = MSG_ERROR_VSS_UNEXPECTED_WRITER_ERROR;
  690. break;
  691. case VSS_E_SNAPSHOT_SET_IN_PROGRESS:
  692. msg = MSG_ERROR_VSS_SNAPSHOT_SET_IN_PROGRESS;
  693. break;
  694. case VSS_E_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED:
  695. msg = MSG_ERROR_VSS_MAXIMUM_NUMBER_OF_SNAPSHOTS_REACHED;
  696. break;
  697. case VSS_E_UNSUPPORTED_CONTEXT:
  698. msg = MSG_ERROR_VSS_UNSUPPORTED_CONTEXT;
  699. *pHr = WBEM_E_INVALID_METHOD_PARAMETERS;
  700. break;
  701. case VSS_E_MAXIMUM_DIFFAREA_ASSOCIATIONS_REACHED:
  702. msg = MSG_ERROR_VSS_MAXIMUM_DIFFAREA_ASSOCIATIONS_REACHED;
  703. break;
  704. case VSS_E_INSUFFICIENT_STORAGE:
  705. msg = MSG_ERROR_VSS_INSUFFICIENT_STORAGE;
  706. *pHr = WBEM_E_BUFFER_TOO_SMALL;
  707. break;
  708. case VSS_E_BAD_STATE:
  709. case VSS_E_CORRUPT_XML_DOCUMENT:
  710. case VSS_E_INVALID_XML_DOCUMENT:
  711. case VSS_E_MAXIMUM_NUMBER_OF_VOLUMES_REACHED:
  712. msg = MSG_ERROR_INTERNAL_VSSADMIN_ERROR;
  713. break;
  714. }
  715. }
  716. if ( msg == 0 )
  717. return FALSE;
  718. *plMsgNum = msg;
  719. ft.Trace( VSSDBG_VSSADMIN, L"Output Msg#: 0x%08x", msg );
  720. return TRUE;
  721. }