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.

1462 lines
41 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. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "InstanceProv.h"
  17. #include "ClusterResource.h"
  18. #include "Cluster.h"
  19. #include "ClusterNode.h"
  20. #include "ClusterGroup.h"
  21. #include "ClusterNodeRes.h"
  22. #include "ClusterResourceType.h"
  23. #include "ClusterEnum.h"
  24. #include "Clusternetworks.h"
  25. #include "ClusterNetInterface.h"
  26. #include "ClusterObjAssoc.h"
  27. #include "ClusterNodeGroup.h"
  28. #include "ClusterResResType.h"
  29. #include "ClusterResDepRes.h"
  30. #include "ClusterService.h"
  31. #include "InstanceProv.tmh"
  32. //////////////////////////////////////////////////////////////////////////////
  33. // Global Variables
  34. //////////////////////////////////////////////////////////////////////////////
  35. long g_lNumInst = 0;
  36. ClassMap g_ClassMap;
  37. TypeNameToClass g_TypeNameToClass;
  38. //****************************************************************************
  39. //
  40. // CInstanceProv
  41. //
  42. //****************************************************************************
  43. //////////////////////////////////////////////////////////////////////////////
  44. //++
  45. //
  46. // CInstanceProv::CInstanceProv(
  47. // BSTR bstrObjectPathIn = NULL,
  48. // BSTR bstrUserIn = NULL,
  49. // BSTR bstrPasswordIn = NULL,
  50. // IWbemContext * pCtxIn = NULL
  51. // )
  52. //
  53. // Description:
  54. // Constructor.
  55. //
  56. // Arguments:
  57. // bstrObjectPathIn --
  58. // bstrUserIn --
  59. // bstrPasswordIn --
  60. // pCtxIn --
  61. //
  62. // Return Values:
  63. // None.
  64. //
  65. //--
  66. //////////////////////////////////////////////////////////////////////////////
  67. CInstanceProv::CInstanceProv(
  68. BSTR ,// bstrObjectPathIn,
  69. BSTR ,// bstrUserIn,
  70. BSTR ,// bstrPasswordIn,
  71. IWbemContext * // pCtxIn
  72. )
  73. {
  74. // m_pNamespace = NULL;
  75. // m_cRef = 0;
  76. InterlockedIncrement( &g_cObj );
  77. return;
  78. } //*** CInstanceProv::CInstanceProv()
  79. //////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CInstanceProv::~CInstanceProv( void )
  83. //
  84. // Description:
  85. // Destructor.
  86. //
  87. // Arguments:
  88. // None.
  89. //
  90. // Return Values:
  91. // None.
  92. //
  93. //--
  94. //////////////////////////////////////////////////////////////////////////////
  95. CInstanceProv::~CInstanceProv( void )
  96. {
  97. InterlockedDecrement( &g_cObj );
  98. #ifdef _DEBUG
  99. _CrtDumpMemoryLeaks();
  100. #endif
  101. return;
  102. } //*** CInstanceProv::~CInstanceProv()
  103. //////////////////////////////////////////////////////////////////////////////
  104. //++
  105. //
  106. // SCODE
  107. // CInstanceProv::DoExecQueryAsync(
  108. // BSTR bstrQueryLanguageIn,
  109. // BSTR bstrQueryIn,
  110. // long lFlagsIn,
  111. // IWbemContext * pCtxIn,
  112. // IWbemObjectSink * pHandlerIn
  113. // )
  114. //
  115. // Description:
  116. // Enumerate instance for a given class.
  117. //
  118. // Arguments:
  119. // bstrQueryLanguageIn
  120. // A valid BSTR containing one of the query languages
  121. // supported by Windows Management. This must be WQL.
  122. //
  123. // bstrQueryIn
  124. // A valid BSTR containing the text of the query
  125. //
  126. // lFlagsIn
  127. // WMI flag
  128. //
  129. // pCtxIn
  130. // WMI context
  131. //
  132. // pHandlerIn
  133. // WMI sink pointer
  134. //
  135. // Return Values:
  136. // WBEM_E_NOT_SUPPORTED
  137. //
  138. //--
  139. //////////////////////////////////////////////////////////////////////////////
  140. SCODE
  141. CInstanceProv::DoExecQueryAsync(
  142. BSTR ,// bstrQueryLanguageIn,
  143. BSTR ,// bstrQueryIn,
  144. long ,// lFlagsIn,
  145. IWbemContext * ,// pCtxIn,
  146. IWbemObjectSink * // pHandlerIn
  147. )
  148. {
  149. // pHandler->SetStatus( WBEM_STATUS_REQUIREMENTS, S_OK, NULL, NULL );
  150. // return sc;
  151. // pHandler->SetStatus( WBEM_E_PROVIDER_NOT_CAPABLE, S_OK, NULL, NULL );
  152. return WBEM_E_NOT_SUPPORTED;
  153. // return WBEM_E_PROVIDER_NOT_CAPABLE;
  154. //WBEM_E_PROVIDER_NOT_CAPABLE;
  155. } //*** CInstanceProv::DoExecQueryAsync()
  156. //////////////////////////////////////////////////////////////////////////////
  157. //++
  158. //
  159. // SCODE
  160. // CInstanceProv::DoCreateInstanceEnumAsync(
  161. // BSTR bstrRefStrIn,
  162. // long lFlagsIn,
  163. // IWbemContext * pCtxIn,
  164. // IWbemObjectSink * pHandlerIn
  165. // )
  166. //
  167. // Description:
  168. // Enumerate instance for a given class.
  169. //
  170. // Arguments:
  171. // bstrRefStrIn -- Name the class to enumerate
  172. // lFlagsIn -- WMI flag
  173. // pCtxIn -- WMI context
  174. // pHandlerIn -- WMI sink pointer
  175. //
  176. // Return Values:
  177. // WBEM_S_NO_ERROR
  178. // WBEM_E_INVALID_PARAMETER
  179. //
  180. //--
  181. //////////////////////////////////////////////////////////////////////////////
  182. SCODE
  183. CInstanceProv::DoCreateInstanceEnumAsync(
  184. BSTR bstrRefStrIn,
  185. long lFlagsIn,
  186. IWbemContext * pCtxIn,
  187. IWbemObjectSink * pHandlerIn
  188. )
  189. {
  190. SCODE sc = WBEM_S_NO_ERROR;
  191. IWbemClassObject * pStatus = NULL;
  192. CWbemClassObject Status;
  193. auto_ptr< CProvBase > pProvBase;
  194. // Do a check of arguments and make sure we have pointer to Namespace
  195. if ( pHandlerIn == NULL || m_pNamespace == NULL )
  196. {
  197. return WBEM_E_INVALID_PARAMETER;
  198. }
  199. try
  200. {
  201. CreateClass(
  202. bstrRefStrIn,
  203. m_pNamespace,
  204. pProvBase
  205. );
  206. sc = pProvBase->EnumInstance(
  207. lFlagsIn,
  208. pCtxIn,
  209. pHandlerIn
  210. );
  211. } // try
  212. catch ( CProvException prove )
  213. {
  214. sc = SetExtendedStatus( prove, Status );
  215. if ( SUCCEEDED( sc ) )
  216. {
  217. sc = prove.hrGetError();
  218. pStatus = Status.data();
  219. }
  220. } // catch
  221. catch( ... )
  222. {
  223. sc = WBEM_E_FAILED;
  224. }
  225. sc = pHandlerIn->SetStatus(
  226. WBEM_STATUS_COMPLETE,
  227. sc,
  228. NULL,
  229. pStatus
  230. );
  231. return WBEM_S_NO_ERROR;
  232. } //*** CInstanceProv::DoCreateInstanceEnumAsync()
  233. //////////////////////////////////////////////////////////////////////////////
  234. //++
  235. //
  236. // SCODE
  237. // CInstanceProv::DoGetObjectAsync(
  238. // BSTR bstrObjectPathIn,
  239. // long lFlagsIn,
  240. // IWbemContext * pCtxIn,
  241. // IWbemObjectSink * pHandlerIn
  242. // )
  243. //
  244. // Description:
  245. // Creates an instance given a particular path value.
  246. //
  247. // Arguments:
  248. // bstrObjectPathIn -- Object path to an object
  249. // lFlagsIn -- WMI flag
  250. // pCtxIn -- WMI context
  251. // pHandlerIn -- WMI sink pointer
  252. //
  253. // Return Values:
  254. // WBEM_S_NO_ERROR
  255. // WBEM_E_INVALID_PARAMETER
  256. // WBEM_E_FAILED
  257. // Win32 error
  258. //
  259. //--
  260. //////////////////////////////////////////////////////////////////////////////
  261. SCODE
  262. CInstanceProv::DoGetObjectAsync(
  263. BSTR bstrObjectPathIn,
  264. long lFlagsIn,
  265. IWbemContext * pCtxIn,
  266. IWbemObjectSink * pHandlerIn
  267. )
  268. {
  269. SCODE sc;
  270. CObjPath ObjPath;
  271. CProvBase * pProv = NULL;
  272. auto_ptr< CProvBase > pProvBase;
  273. // Do a check of arguments and make sure we have pointer to Namespace
  274. if ( bstrObjectPathIn == NULL || pHandlerIn == NULL || m_pNamespace == NULL )
  275. {
  276. return WBEM_E_INVALID_PARAMETER;
  277. }
  278. // do the get, pass the object on to the notify
  279. try
  280. {
  281. if ( ObjPath.Init( bstrObjectPathIn ) != TRUE )
  282. {
  283. return WBEM_E_INVALID_PARAMETER;
  284. }
  285. CreateClass(
  286. ObjPath.GetClassName(),
  287. m_pNamespace,
  288. pProvBase
  289. );
  290. sc = pProvBase->GetObject(
  291. ObjPath,
  292. lFlagsIn,
  293. pCtxIn,
  294. pHandlerIn
  295. );
  296. } // try
  297. catch ( CProvException prove )
  298. {
  299. CWbemClassObject Status;
  300. sc = SetExtendedStatus( prove, Status );
  301. if ( SUCCEEDED( sc ) )
  302. {
  303. sc = pHandlerIn->SetStatus(
  304. WBEM_STATUS_COMPLETE,
  305. WBEM_E_FAILED,
  306. NULL,
  307. Status.data( )
  308. );
  309. return sc;
  310. }
  311. }
  312. catch( ... )
  313. {
  314. sc = WBEM_E_FAILED;
  315. }
  316. pHandlerIn->SetStatus(
  317. WBEM_STATUS_COMPLETE,
  318. sc,
  319. NULL,
  320. NULL
  321. );
  322. return sc;
  323. } //*** CInstanceProv::DoGetObjectAsync()
  324. //////////////////////////////////////////////////////////////////////////////
  325. //++
  326. //
  327. // SCODE
  328. // CInstanceProv::DoPutInstanceAsync(
  329. // IWbemClassObject * pInstIn,
  330. // long lFlagsIn,
  331. // IWbemContext * pCtxIn,
  332. // IWbemObjectSink * pHandlerIn
  333. // )
  334. //
  335. // Description:
  336. // Save this instance.
  337. //
  338. // Arguments:
  339. // pInstIn -- WMI object to be saved
  340. // lFlagsIn -- WMI flag
  341. // pCtxIn -- WMI context
  342. // pHandlerIn -- WMI sink pointer
  343. //
  344. // Return Values:
  345. // WBEM_S_NO_ERROR
  346. // WBEM_E_INVALID_PARAMETER
  347. // WBEM_E_FAILED
  348. // Win32 error
  349. //
  350. //--
  351. //////////////////////////////////////////////////////////////////////////////
  352. SCODE
  353. CInstanceProv::DoPutInstanceAsync(
  354. IWbemClassObject * pInstIn,
  355. long lFlagsIn,
  356. IWbemContext * pCtxIn,
  357. IWbemObjectSink * pHandlerIn
  358. )
  359. {
  360. SCODE sc = WBEM_S_NO_ERROR;
  361. IWbemClassObject * pStatus = NULL;
  362. CWbemClassObject Status;
  363. if ( pInstIn == NULL || pHandlerIn == NULL )
  364. {
  365. return WBEM_E_INVALID_PARAMETER;
  366. }
  367. try
  368. {
  369. // get class name
  370. _bstr_t bstrClass;
  371. CWbemClassObject wcoInst( pInstIn );
  372. auto_ptr< CProvBase > pProvBase;
  373. wcoInst.GetProperty( bstrClass, PVD_WBEM_CLASS );
  374. CreateClass( bstrClass, m_pNamespace, pProvBase );
  375. sc = pProvBase->PutInstance(
  376. wcoInst,
  377. lFlagsIn,
  378. pCtxIn,
  379. pHandlerIn
  380. );
  381. }
  382. catch ( CProvException prove )
  383. {
  384. sc = SetExtendedStatus( prove, Status );
  385. if ( SUCCEEDED( sc ) )
  386. {
  387. sc = prove.hrGetError();
  388. pStatus = Status.data();
  389. }
  390. }
  391. catch ( ... )
  392. {
  393. sc = WBEM_E_FAILED;
  394. }
  395. return pHandlerIn->SetStatus(
  396. WBEM_STATUS_COMPLETE,
  397. sc,
  398. NULL,
  399. pStatus
  400. );
  401. } //*** CInstanceProv::DoPutInstanceAsync()
  402. //////////////////////////////////////////////////////////////////////////////
  403. //++
  404. //
  405. // SCODE
  406. // CInstanceProv::DoDeleteInstanceAsync(
  407. // BSTR bstrObjectPathIn,
  408. // long lFlagsIn,
  409. // IWbemContext * pCtxIn,
  410. // IWbemObjectSink * pHandlerIn
  411. // )
  412. //
  413. // Description:
  414. // Delete this instance.
  415. //
  416. // Arguments:
  417. // bstrObjectPathIn -- ObjPath for the instance to be deleted
  418. // lFlagsIn -- WMI flag
  419. // pCtxIn -- WMI context
  420. // pHandlerIn -- WMI sink pointer
  421. //
  422. // Return Values:
  423. // WBEM_S_NO_ERROR
  424. // WBEM_E_INVALID_PARAMETER
  425. // WBEM_E_FAILED
  426. // Win32 error
  427. //
  428. //--
  429. //////////////////////////////////////////////////////////////////////////////
  430. SCODE
  431. CInstanceProv::DoDeleteInstanceAsync(
  432. BSTR bstrObjectPathIn,
  433. long lFlagsIn,
  434. IWbemContext * pCtxIn,
  435. IWbemObjectSink * pHandlerIn
  436. )
  437. {
  438. SCODE sc;
  439. CObjPath ObjPath;
  440. CProvBase * pProv = NULL;
  441. _bstr_t bstrClass;
  442. auto_ptr< CProvBase > pProvBase;
  443. // Do a check of arguments and make sure we have pointer to Namespace
  444. if ( bstrObjectPathIn == NULL || pHandlerIn == NULL )
  445. {
  446. return WBEM_E_INVALID_PARAMETER;
  447. }
  448. // do the get, pass the object on to the notify
  449. try
  450. {
  451. if ( ! ObjPath.Init( bstrObjectPathIn ) )
  452. {
  453. return WBEM_E_INVALID_PARAMETER;
  454. }
  455. bstrClass = ObjPath.GetClassName();
  456. CreateClass( bstrClass, m_pNamespace, pProvBase );
  457. sc = pProvBase->DeleteInstance(
  458. ObjPath,
  459. lFlagsIn,
  460. pCtxIn,
  461. pHandlerIn
  462. );
  463. } // try
  464. catch ( CProvException prove )
  465. {
  466. CWbemClassObject Status;
  467. sc = SetExtendedStatus( prove, Status );
  468. if ( SUCCEEDED( sc ) )
  469. {
  470. sc = pHandlerIn->SetStatus(
  471. WBEM_STATUS_COMPLETE,
  472. WBEM_E_FAILED,
  473. NULL,
  474. Status.data()
  475. );
  476. return sc;
  477. }
  478. }
  479. catch ( ... )
  480. {
  481. sc = WBEM_E_FAILED;
  482. }
  483. pHandlerIn->SetStatus(
  484. WBEM_STATUS_COMPLETE,
  485. sc,
  486. NULL,
  487. NULL
  488. );
  489. return sc;
  490. } //*** CInstanceProv::DoDeleteInstanceAsync()
  491. //////////////////////////////////////////////////////////////////////////////
  492. //++
  493. //
  494. // SCODE
  495. // CInstanceProv::DoExecMethodAsync(
  496. // BSTR bstrObjectPathIn,
  497. // BSTR bstrMethodNameIn,
  498. // long lFlagsIn,
  499. // IWbemContext * pCtxIn,
  500. // IWbemClassObject * pInParamsIn,
  501. // IWbemObjectSink * pHandlerIn
  502. // )
  503. //
  504. // Description:
  505. // Execute methods for the given object.
  506. //
  507. // Arguments:
  508. // bstrObjectPathIn -- Object path to a given object
  509. // bstrMethodNameIn -- Name of the method to be invoked
  510. // lFlagsIn -- WMI flag
  511. // pCtxIn -- WMI context
  512. // pInParamsIn -- Input parameters for the method
  513. // pHandlerIn -- WMI sink pointer
  514. //
  515. // Return Values:
  516. // WBEM_S_NO_ERROR
  517. //
  518. //--
  519. //////////////////////////////////////////////////////////////////////////////
  520. SCODE
  521. CInstanceProv::DoExecMethodAsync(
  522. BSTR bstrObjectPathIn,
  523. BSTR bstrMethodNameIn,
  524. long lFlagsIn,
  525. IWbemContext * pCtxIn,
  526. IWbemClassObject * pInParamsIn,
  527. IWbemObjectSink * pHandlerIn
  528. )
  529. {
  530. SCODE sc;
  531. if ( bstrObjectPathIn == NULL || pHandlerIn == NULL || m_pNamespace == NULL
  532. || bstrMethodNameIn == NULL )
  533. {
  534. return WBEM_E_INVALID_PARAMETER;
  535. }
  536. try
  537. {
  538. CObjPath ObjPath;
  539. _bstr_t bstrClass;
  540. auto_ptr< CProvBase > pProvBase;
  541. if ( ! ObjPath.Init( bstrObjectPathIn ) )
  542. {
  543. return WBEM_E_INVALID_PARAMETER;
  544. }
  545. bstrClass = ObjPath.GetClassName( );
  546. CreateClass( bstrClass, m_pNamespace, pProvBase );
  547. sc = pProvBase->ExecuteMethod(
  548. ObjPath,
  549. bstrMethodNameIn,
  550. lFlagsIn,
  551. pInParamsIn,
  552. pHandlerIn
  553. );
  554. } // try
  555. catch ( CProvException prove )
  556. {
  557. CWbemClassObject Status;
  558. sc = SetExtendedStatus( prove, Status );
  559. if ( SUCCEEDED( sc ) )
  560. {
  561. sc = pHandlerIn->SetStatus(
  562. WBEM_STATUS_COMPLETE,
  563. WBEM_E_FAILED,
  564. NULL,
  565. Status.data( )
  566. );
  567. return sc;
  568. }
  569. }
  570. catch ( ... )
  571. {
  572. sc = WBEM_E_FAILED;
  573. }
  574. pHandlerIn->SetStatus(
  575. WBEM_STATUS_COMPLETE,
  576. sc,
  577. NULL,
  578. NULL );
  579. return sc;
  580. } //*** CInstanceProv::DoExecMethodAsync()
  581. //////////////////////////////////////////////////////////////////////////////
  582. //++
  583. //
  584. // HRESULT
  585. // CInstanceProv::CreateClassEnumAsync(
  586. // const BSTR bstrSuperclassIn,
  587. // long lFlagsIn,
  588. // IWbemContext * pCtxIn,
  589. // IWbemObjectSink * pResponseHandlerIn
  590. // )
  591. //
  592. // Description:
  593. // Create a class enumerator.
  594. //
  595. // Arguments:
  596. // bstrSuperclassIn -- Class to create
  597. // lFlagsIn -- WMI flag
  598. // pCtxIn -- WMI context
  599. // pResponseHandlerIn -- WMI sink pointer
  600. //
  601. // Return Values:
  602. // WBEM_S_NO_ERROR
  603. //
  604. //--
  605. //////////////////////////////////////////////////////////////////////////////
  606. HRESULT
  607. CInstanceProv::CreateClassEnumAsync(
  608. const BSTR bstrSuperclassIn,
  609. long lFlagsIn,
  610. IWbemContext * pCtxIn,
  611. IWbemObjectSink * pResponseHandlerIn
  612. )
  613. {
  614. return WBEM_S_NO_ERROR;
  615. } //*** CInstanceProv::CreateClassEnumAsync()
  616. //////////////////////////////////////////////////////////////////////////////
  617. //++
  618. //
  619. // SCODE
  620. // CInstanceProv::SetExtendedStatus(
  621. // CProvException & rpeIn,
  622. // CWbemClassObject & rwcoInstOut
  623. // )
  624. //
  625. // Description:
  626. // Create and set extended error status.
  627. //
  628. // Arguments:
  629. // rpeIn -- Exception object.
  630. // rwcoInstOut -- Reference to WMI instance.
  631. //
  632. // Return Values:
  633. // WBEM_S_NO_ERROR
  634. //
  635. //--
  636. //////////////////////////////////////////////////////////////////////////////
  637. SCODE
  638. CInstanceProv::SetExtendedStatus(
  639. CProvException & rpeIn,
  640. CWbemClassObject & rwcoInstOut
  641. )
  642. {
  643. SCODE sc = WBEM_S_NO_ERROR;
  644. IWbemClassObject * pStatus = NULL;
  645. sc = m_pNamespace->GetObject(
  646. _bstr_t( PVD_WBEM_EXTENDEDSTATUS ),
  647. 0,
  648. NULL,
  649. &pStatus,
  650. NULL
  651. );
  652. if ( SUCCEEDED( sc ) )
  653. {
  654. sc = pStatus->SpawnInstance( 0, &rwcoInstOut );
  655. if ( SUCCEEDED( sc ) )
  656. {
  657. rwcoInstOut.SetProperty( rpeIn.PwszErrorMessage(), PVD_WBEM_DESCRIPTION );
  658. rwcoInstOut.SetProperty( rpeIn.DwGetError(), PVD_WBEM_STATUSCODE );
  659. }
  660. }
  661. return sc;
  662. } //*** CInstanceProv::SetExtendedStatus()
  663. //////////////////////////////////////////////////////////////////////////////
  664. //++
  665. //
  666. // HRESULT
  667. // CInstanceProv::S_HrCreateThis(
  668. // IUnknown * pUnknownOuterIn,
  669. // VOID ** ppvOut
  670. // )
  671. //
  672. // Description:
  673. // Create an instance of the instance provider.
  674. //
  675. // Arguments:
  676. // pUnknownOuterIn -- Outer IUnknown pointer.
  677. // ppvOut -- Receives the created instance pointer.
  678. //
  679. // Return Values:
  680. // S_OK
  681. //
  682. //--
  683. //////////////////////////////////////////////////////////////////////////////
  684. HRESULT
  685. CInstanceProv::S_HrCreateThis(
  686. IUnknown * ,// pUnknownOuterIn,
  687. VOID ** ppvOut
  688. )
  689. {
  690. *ppvOut = new CInstanceProv();
  691. return S_OK;
  692. } //*** CInstanceProv::S_HrCreateThis()
  693. //////////////////////////////////////////////////////////////////////////////
  694. //++
  695. //
  696. // STDMETHODIMP
  697. // CInstanceProv::Initialize(
  698. // LPWSTR pszUserIn,
  699. // LONG lFlagsIn,
  700. // LPWSTR pszNamespaceIn,
  701. // LPWSTR pszLocaleIn,
  702. // IWbemServices * pNamespaceIn,
  703. // IWbemContext * pCtxIn,
  704. // IWbemProviderInitSink * pInitSinkIn
  705. // )
  706. //
  707. // Description:
  708. // Initialize the instance provider.
  709. //
  710. // Arguments:
  711. // pszUserIn --
  712. // lFlagsIn -- WMI flag
  713. // pszNamespaceIn --
  714. // pszLocaleIn --
  715. // pNamespaceIn --
  716. // pCtxIn -- WMI context
  717. // pInitSinkIn -- WMI sink pointer
  718. //
  719. // Return Values:
  720. // WBEM_S_NO_ERROR
  721. //
  722. //--
  723. //////////////////////////////////////////////////////////////////////////////
  724. STDMETHODIMP
  725. CInstanceProv::Initialize(
  726. LPWSTR pszUserIn,
  727. LONG lFlagsIn,
  728. LPWSTR pszNamespaceIn,
  729. LPWSTR pszLocaleIn,
  730. IWbemServices * pNamespaceIn,
  731. IWbemContext * pCtxIn,
  732. IWbemProviderInitSink * pInitSinkIn
  733. )
  734. {
  735. HRESULT hr = WBEM_S_NO_ERROR;
  736. LONG lStatus = WBEM_S_INITIALIZED;
  737. g_ClassMap[ PVD_CLASS_CLUSTER ] =
  738. CClassCreator( (FPNEW) CCluster::S_CreateThis, PVD_CLASS_CLUSTER , 0 );
  739. g_ClassMap[ PVD_CLASS_NODE ] =
  740. CClassCreator( (FPNEW) CClusterNode::S_CreateThis, PVD_CLASS_NODE , 0 );
  741. g_ClassMap[ PVD_CLASS_RESOURCE ] =
  742. CClassCreator( (FPNEW) CClusterResource::S_CreateThis, PVD_CLASS_RESOURCE , 0 );
  743. g_ClassMap[ PVD_CLASS_RESOURCETYPE ] =
  744. CClassCreator( (FPNEW) CClusterResourceType::S_CreateThis, PVD_CLASS_RESOURCETYPE , 0 );
  745. g_ClassMap[ PVD_CLASS_GROUP ] =
  746. CClassCreator( (FPNEW) CClusterGroup::S_CreateThis, PVD_CLASS_GROUP , 0 );
  747. g_ClassMap[ PVD_CLASS_NODEACTIVERES ] =
  748. CClassCreator( (FPNEW) CClusterNodeRes::S_CreateThis, PVD_CLASS_NODEACTIVERES , 0 );
  749. g_ClassMap[ PVD_CLASS_NETWORKSINTERFACE ] =
  750. CClassCreator( (FPNEW) CClusterNetInterface::S_CreateThis, PVD_CLASS_NETWORKSINTERFACE, 0 );
  751. g_ClassMap[ PVD_CLASS_NETWORKS ] =
  752. CClassCreator( (FPNEW) CClusterNetwork::S_CreateThis, PVD_CLASS_NETWORKS , 0 );
  753. g_ClassMap[ PVD_CLASS_CLUSTERTONETWORKS ] =
  754. CClassCreator( (FPNEW) CClusterObjAssoc::S_CreateThis, PVD_CLASS_CLUSTERTONETWORKS , CLUSTER_ENUM_NETWORK );
  755. g_ClassMap[ PVD_CLASS_CLUSTERTONETINTERFACE ] =
  756. CClassCreator( (FPNEW) CClusterObjAssoc::S_CreateThis, PVD_CLASS_CLUSTERTONETINTERFACE , CLUSTER_ENUM_NETINTERFACE );
  757. g_ClassMap[ PVD_CLASS_CLUSTERTONODE ] =
  758. CClassCreator( (FPNEW) CClusterToNode::S_CreateThis, PVD_CLASS_CLUSTERTONODE , CLUSTER_ENUM_NODE );
  759. g_ClassMap[ PVD_CLASS_CLUSTERTORES ] =
  760. CClassCreator( (FPNEW) CClusterObjAssoc::S_CreateThis, PVD_CLASS_CLUSTERTORES , CLUSTER_ENUM_RESOURCE );
  761. g_ClassMap[ PVD_CLASS_CLUSTERTORESTYPE ] =
  762. CClassCreator( (FPNEW) CClusterObjAssoc::S_CreateThis, PVD_CLASS_CLUSTERTORESTYPE , CLUSTER_ENUM_RESTYPE );
  763. g_ClassMap[ PVD_CLASS_CLUSTERTOGROUP ] =
  764. CClassCreator( (FPNEW) CClusterObjAssoc::S_CreateThis, PVD_CLASS_CLUSTERTOGROUP , CLUSTER_ENUM_GROUP );
  765. g_ClassMap[ PVD_CLASS_NODEACTIVEGROUP ] =
  766. CClassCreator( (FPNEW) CClusterNodeGroup::S_CreateThis, PVD_CLASS_NODEACTIVEGROUP , CLUSTER_ENUM_GROUP );
  767. g_ClassMap[ PVD_CLASS_RESRESOURCETYPE ] =
  768. CClassCreator( (FPNEW) CClusterResResType::S_CreateThis, PVD_CLASS_RESRESOURCETYPE , CLUSTER_ENUM_RESOURCE );
  769. g_ClassMap[ PVD_CLASS_RESDEPRES ] =
  770. CClassCreator( (FPNEW) CClusterResDepRes::S_CreateThis, PVD_CLASS_RESDEPRES , CLUSTER_ENUM_RESOURCE );
  771. g_ClassMap[ PVD_CLASS_GROUPTORES ] =
  772. CClassCreator( (FPNEW) CClusterGroupRes::S_CreateThis, PVD_CLASS_GROUPTORES , CLUSTER_ENUM_RESOURCE );
  773. g_ClassMap[ PVD_CLASS_NETTONETINTERFACE ] =
  774. CClassCreator( (FPNEW) CClusterNetNetInterface::S_CreateThis, PVD_CLASS_NETTONETINTERFACE , CLUSTER_ENUM_NETINTERFACE );
  775. g_ClassMap[ PVD_CLASS_NODETONETINTERFACE ] =
  776. CClassCreator( (FPNEW) CClusterNodeNetInterface::S_CreateThis, PVD_CLASS_NODETONETINTERFACE , CLUSTER_ENUM_NETINTERFACE );
  777. g_ClassMap[ PVD_CLASS_CLUSTERTOQUORUMRES ] =
  778. CClassCreator( (FPNEW) CClusterClusterQuorum::S_CreateThis, PVD_CLASS_CLUSTERTOQUORUMRES , 0 );
  779. g_ClassMap[ PVD_CLASS_SERVICES ] =
  780. CClassCreator( (FPNEW) CClusterService::S_CreateThis, PVD_CLASS_SERVICES , 0 );
  781. g_ClassMap[ PVD_CLASS_HOSTEDSERVICES ] =
  782. CClassCreator( (FPNEW) CClusterHostedService::S_CreateThis, PVD_CLASS_HOSTEDSERVICES , 0 );
  783. return CImpersonatedProvider::Initialize(
  784. pszUserIn,
  785. lFlagsIn,
  786. pszNamespaceIn,
  787. pszLocaleIn,
  788. pNamespaceIn,
  789. pCtxIn,
  790. pInitSinkIn
  791. );
  792. } //*** CInstanceProv::Initialize()
  793. //****************************************************************************
  794. //
  795. // CClassProv
  796. //
  797. //****************************************************************************
  798. //////////////////////////////////////////////////////////////////////////////
  799. //++
  800. //
  801. // CClassProv::CClassProv( void )
  802. //
  803. // Description:
  804. // Constructor.
  805. //
  806. // Arguments:
  807. // None.
  808. //
  809. // Return Values:
  810. // None.
  811. //
  812. //--
  813. //////////////////////////////////////////////////////////////////////////////
  814. CClassProv::CClassProv( void )
  815. {
  816. InterlockedIncrement( &g_cObj );
  817. } //*** CClassProv::CClassProv()
  818. //////////////////////////////////////////////////////////////////////////////
  819. //++
  820. //
  821. // CClassProv::~CClassProv( void )
  822. //
  823. // Description:
  824. // Destructor.
  825. //
  826. // Arguments:
  827. // None.
  828. //
  829. // Return Values:
  830. // None.
  831. //
  832. //--
  833. //////////////////////////////////////////////////////////////////////////////
  834. CClassProv::~CClassProv( void )
  835. {
  836. InterlockedDecrement( &g_cObj );
  837. } //*** CClassProv::~CClassProv()
  838. //////////////////////////////////////////////////////////////////////////////
  839. //++
  840. //
  841. // STDMETHODIMP
  842. // CClassProv::Initialize(
  843. // LPWSTR pszUserIn,
  844. // LONG lFlagsIn,
  845. // LPWSTR pszNamespaceIn,
  846. // LPWSTR pszLocaleIn,
  847. // IWbemServices * pNamespaceIn,
  848. // IWbemContext * pCtxIn,
  849. // IWbemProviderInitSink * pInitSinkIn
  850. // )
  851. //
  852. // Description:
  853. // Initialize the class provider.
  854. //
  855. // Arguments:
  856. // pszUserIn --
  857. // lFlagsIn -- WMI flag
  858. // pszNamespaceIn --
  859. // pszLocaleIn --
  860. // pNamespaceIn --
  861. // pCtxIn -- WMI context
  862. // pInitSinkIn -- WMI sink pointer
  863. //
  864. // Return Values:
  865. // WBEM_S_NO_ERROR
  866. //
  867. //--
  868. //////////////////////////////////////////////////////////////////////////////
  869. STDMETHODIMP
  870. CClassProv::Initialize(
  871. LPWSTR ,// pszUserIn,
  872. LONG lFlagsIn,
  873. LPWSTR ,// pszNamespaceIn,
  874. LPWSTR ,// pszLocaleIn,
  875. IWbemServices * pNamespaceIn,
  876. IWbemContext * pCtxIn,
  877. IWbemProviderInitSink * pInitSinkIn
  878. )
  879. {
  880. HRESULT hr = WBEM_S_NO_ERROR;
  881. LONG lStatus = WBEM_S_INITIALIZED;
  882. static map< _bstr_t, bool > mapResourceType;
  883. TracePrint(( "CClassProv:Initialize entry - do resources first\n" ));
  884. try
  885. {
  886. SAFECLUSTER shCluster;
  887. SAFERESOURCE shResource;
  888. DWORD dwReturn = ERROR_SUCCESS;
  889. LPCWSTR pwszResName = NULL;
  890. LPCWSTR pwszResTypeName = NULL;
  891. DWORD cbTypeName = 1024;
  892. DWORD cbTypeNameReturned = 0;
  893. CWstrBuf wsbTypeName;
  894. CWbemClassObject wco;
  895. CWbemClassObject wcoChild;
  896. CError er;
  897. wsbTypeName.SetSize( cbTypeName );
  898. er = pNamespaceIn->GetObject(
  899. const_cast< LPWSTR >( PVD_CLASS_PROPERTY ),
  900. lFlagsIn,
  901. pCtxIn,
  902. &wco,
  903. NULL
  904. );
  905. shCluster = OpenCluster( NULL );
  906. CClusterEnum cluEnum( shCluster, CLUSTER_ENUM_RESOURCE );
  907. //
  908. // First enumerate all of the resources.
  909. //
  910. while ( pwszResName = cluEnum.GetNext() )
  911. {
  912. TracePrint(( "CClassProv:Initialize found resource = %ws\n", pwszResName ));
  913. shResource = OpenClusterResource( shCluster, pwszResName );
  914. //
  915. // get resource type name
  916. //
  917. dwReturn = ClusterResourceControl(
  918. shResource,
  919. NULL,
  920. CLUSCTL_RESOURCE_GET_RESOURCE_TYPE,
  921. NULL,
  922. 0,
  923. wsbTypeName,
  924. cbTypeName,
  925. &cbTypeNameReturned
  926. );
  927. if ( dwReturn == ERROR_MORE_DATA )
  928. {
  929. cbTypeName = cbTypeNameReturned;
  930. wsbTypeName.SetSize( cbTypeName );
  931. er = ClusterResourceControl(
  932. shResource,
  933. NULL,
  934. CLUSCTL_RESOURCE_GET_RESOURCE_TYPE,
  935. NULL,
  936. 0,
  937. wsbTypeName,
  938. cbTypeName,
  939. &cbTypeNameReturned
  940. );
  941. } // if: buffer was too small
  942. //
  943. // check if type name already handled
  944. //
  945. if ( mapResourceType[ (LPCWSTR) wsbTypeName ] )
  946. {
  947. continue;
  948. }
  949. mapResourceType[ (LPCWSTR) wsbTypeName ] = true;
  950. wco.SpawnDerivedClass( 0, &wcoChild );
  951. CreateMofClassFromResource( shResource, wsbTypeName, wcoChild );
  952. er = pNamespaceIn->PutClass(
  953. wcoChild.data(),
  954. WBEM_FLAG_OWNER_UPDATE,
  955. pCtxIn,
  956. NULL
  957. );
  958. } // while: more resources
  959. cbTypeNameReturned = 0;
  960. TracePrint(( "CClassProv:Initialize - now find resource types\n" ));
  961. //
  962. // Now enumerate all of the resource types.
  963. //
  964. CClusterEnum cluEnumResType( shCluster, CLUSTER_ENUM_RESTYPE );
  965. while ( pwszResTypeName = cluEnumResType.GetNext() )
  966. {
  967. //
  968. // check if type name already handled
  969. //
  970. if ( mapResourceType[ (LPCWSTR) pwszResTypeName ] )
  971. {
  972. TracePrint(( "CClassProv:Initialize found existing restype = %ws\n", pwszResTypeName ));
  973. continue;
  974. }
  975. mapResourceType[ (LPCWSTR) pwszResTypeName ] = true;
  976. TracePrint(( "CClassProv:Initialize Creating new restype = %ws\n", pwszResTypeName ));
  977. wco.SpawnDerivedClass( 0, &wcoChild );
  978. CreateMofClassFromResType( shCluster, pwszResTypeName, wcoChild );
  979. er = pNamespaceIn->PutClass(
  980. wcoChild.data(),
  981. WBEM_FLAG_OWNER_UPDATE,
  982. pCtxIn,
  983. NULL
  984. );
  985. //TracePrint(( "CClassProv:Initialize PutClass for %ws returned %u\n", pwszResTypeName, er ));
  986. } // while: more resource types
  987. } // try
  988. catch ( CProvException & cpe )
  989. {
  990. lStatus = cpe.hrGetError();
  991. TracePrint(( "CClassProv:Initialize Caught CProvException = %u\n", lStatus ));
  992. }
  993. catch (...)
  994. {
  995. TracePrint(( "CClassProv:Initialize Caught Unknown Exception\n" ));
  996. lStatus = WBEM_E_FAILED;
  997. }
  998. //TracePrint(( "CClassProv:Initialize exit\n" ));
  999. pInitSinkIn->SetStatus( lStatus,0 );
  1000. return WBEM_S_NO_ERROR;
  1001. } //*** CClassProv::Initialize()
  1002. //////////////////////////////////////////////////////////////////////////////
  1003. //++
  1004. //
  1005. // HRESULT
  1006. // CClassProv::S_HrCreateThis(
  1007. // IUnknown * pUnknownOuterIn,
  1008. // VOID ** ppvOut
  1009. // )
  1010. //
  1011. // Description:
  1012. // Create an instance of the instance provider.
  1013. //
  1014. // Arguments:
  1015. // pUnknownOuterIn -- Outer IUnknown pointer.
  1016. // ppvOut -- Receives the created instance pointer.
  1017. //
  1018. // Return Values:
  1019. // S_OK
  1020. //
  1021. //--
  1022. //////////////////////////////////////////////////////////////////////////////
  1023. HRESULT
  1024. CClassProv::S_HrCreateThis(
  1025. IUnknown * ,// pUnknownOuterIn,
  1026. VOID ** ppvOut
  1027. )
  1028. {
  1029. *ppvOut = new CClassProv();
  1030. return S_OK;
  1031. } //*** CClassProv::S_HrCreateThis()
  1032. //////////////////////////////////////////////////////////////////////////////
  1033. //++
  1034. //
  1035. // void
  1036. // CClassProv::CreateMofClassFromResource(
  1037. // HRESOURCE hResourceIn,
  1038. // LPCWSTR pwszTypeNameIn,
  1039. // CWbemClassObject & rClassInout
  1040. // )
  1041. //
  1042. // Description:
  1043. // Create an instance of the instance provider.
  1044. //
  1045. // Arguments:
  1046. // hResourceIn -- Cluster resource handle.
  1047. // pwszTypeNameIn -- Type name (??).
  1048. // rClassInout -- WMI class object.
  1049. //
  1050. // Return Values:
  1051. // None
  1052. //
  1053. //--
  1054. //////////////////////////////////////////////////////////////////////////////
  1055. void
  1056. CClassProv::CreateMofClassFromResource(
  1057. HRESOURCE hResourceIn,
  1058. LPCWSTR pwszTypeNameIn,
  1059. CWbemClassObject & rClassInout
  1060. )
  1061. {
  1062. WCHAR pwszClass[ MAX_PATH ];
  1063. IWbemQualifierSet * pQualifers = NULL;
  1064. LPWSTR pwsz;
  1065. TracePrint(( "CreateMofClassFromResource: entry, TypeName = %ws\n", pwszTypeNameIn ));
  1066. //
  1067. // form new class name
  1068. //
  1069. wcscpy( pwszClass, L"MSCluster_Property_" );
  1070. pwsz = wcschr( pwszClass, L'\0' );
  1071. PwszSpaceReplace( pwsz, pwszTypeNameIn, L'_');
  1072. rClassInout.SetProperty( pwszClass, PVD_WBEM_CLASS );
  1073. g_TypeNameToClass[ pwszTypeNameIn ] = pwszClass ;
  1074. //
  1075. // setup class property
  1076. //
  1077. {
  1078. static DWORD s_rgdwControl[] =
  1079. {
  1080. CLUSCTL_RESOURCE_GET_RO_PRIVATE_PROPERTIES,
  1081. CLUSCTL_RESOURCE_GET_PRIVATE_PROPERTIES
  1082. };
  1083. static DWORD s_cControl = sizeof( s_rgdwControl ) / sizeof( DWORD );
  1084. DWORD dwRt = ERROR_SUCCESS;
  1085. VARIANT var;
  1086. UINT idx;
  1087. var.vt = VT_NULL;
  1088. for ( idx = 0 ; idx < s_cControl ; idx++ )
  1089. {
  1090. CClusPropList pl;
  1091. dwRt = pl.ScGetResourceProperties(
  1092. hResourceIn,
  1093. s_rgdwControl[ idx ],
  1094. NULL,
  1095. 0 );
  1096. dwRt = pl.ScMoveToFirstProperty();
  1097. while ( dwRt == ERROR_SUCCESS )
  1098. {
  1099. LPCWSTR pwszPropName = NULL;
  1100. WCHAR pwszPropMof[MAX_PATH];
  1101. CIMTYPE cimType;
  1102. pwszPropName = pl.PszCurrentPropertyName();
  1103. PwszSpaceReplace( pwszPropMof, pwszPropName, L'_' );
  1104. switch ( pl.CpfCurrentValueFormat() )
  1105. {
  1106. case CLUSPROP_FORMAT_WORD:
  1107. {
  1108. cimType = CIM_UINT16;
  1109. break;
  1110. } // case: CLUSPROP_FORMAT_WORD
  1111. case CLUSPROP_FORMAT_DWORD:
  1112. {
  1113. cimType = CIM_UINT32;
  1114. break;
  1115. } // case: CLUSPROP_FORMAT_DWORD:
  1116. case CLUSPROP_FORMAT_LONG:
  1117. {
  1118. cimType = CIM_SINT32;
  1119. break;
  1120. } // case: CLUSPROP_FORMAT_LONG:
  1121. case CLUSPROP_FORMAT_SZ:
  1122. case CLUSPROP_FORMAT_EXPAND_SZ:
  1123. case CLUSPROP_FORMAT_EXPANDED_SZ:
  1124. {
  1125. cimType = CIM_STRING;
  1126. break;
  1127. } // case: CLUSPROP_FORMAT_SZ, etc.
  1128. case CLUSPROP_FORMAT_BINARY:
  1129. {
  1130. cimType = CIM_UINT8 | CIM_FLAG_ARRAY;
  1131. break;
  1132. } // case: CLUSPROP_FORMAT_BINARY
  1133. case CLUSPROP_FORMAT_MULTI_SZ:
  1134. {
  1135. cimType = CIM_STRING | CIM_FLAG_ARRAY;
  1136. break;
  1137. } // case: CLUSPROP_FORMAT_BINARY
  1138. case CLUSPROP_FORMAT_LARGE_INTEGER:
  1139. {
  1140. cimType = CIM_SINT32 | CIM_FLAG_ARRAY;
  1141. break;
  1142. } // case: CLUSPROP_FORMAT_ULARGE_INTEGER
  1143. case CLUSPROP_FORMAT_ULARGE_INTEGER:
  1144. {
  1145. cimType = CIM_UINT32 | CIM_FLAG_ARRAY;
  1146. break;
  1147. } // case: CLUSPROP_FORMAT_ULARGE_INTEGER
  1148. case CLUSPROP_FORMAT_SECURITY_DESCRIPTOR:
  1149. {
  1150. cimType = CIM_UINT8 | CIM_FLAG_ARRAY;
  1151. break;
  1152. }
  1153. default:
  1154. {
  1155. TracePrint(( "CreateMofClassFromResource: Unknown format value %lx\n", pl.CpfCurrentValueFormat() ));
  1156. break;
  1157. }
  1158. } // switch : property type
  1159. rClassInout.data()->Put(
  1160. pwszPropMof,
  1161. 0,
  1162. &var,
  1163. cimType
  1164. );
  1165. dwRt = pl.ScMoveToNextProperty();
  1166. } // while: proplist not empty
  1167. } // for: readwrite and readonly property
  1168. } // set properties
  1169. } //*** CClassProv::CreateMofClassFromResource()
  1170. //////////////////////////////////////////////////////////////////////////////
  1171. //++
  1172. //
  1173. // void
  1174. // CClassProv::CreateMofClassFromResType(
  1175. // HCLUSTER hCluster,
  1176. // LPCWSTR pwszTypeNameIn,
  1177. // CWbemClassObject & rClassInout
  1178. // )
  1179. //
  1180. // Description:
  1181. // Create an instance of the instance provider.
  1182. //
  1183. // Arguments:
  1184. // pwszTypeNameIn -- Type name (??).
  1185. // rClassInout -- WMI class object.
  1186. //
  1187. // Return Values:
  1188. // None
  1189. //
  1190. //--
  1191. //////////////////////////////////////////////////////////////////////////////
  1192. void
  1193. CClassProv::CreateMofClassFromResType(
  1194. HCLUSTER hCluster,
  1195. LPCWSTR pwszTypeNameIn,
  1196. CWbemClassObject & rClassInout
  1197. )
  1198. {
  1199. WCHAR pwszClass[ MAX_PATH ];
  1200. IWbemQualifierSet * pQualifers = NULL;
  1201. LPWSTR pwsz;
  1202. //
  1203. // form new class name
  1204. //
  1205. wcscpy( pwszClass, L"MSCluster_Property_" );
  1206. pwsz = wcschr( pwszClass, L'\0' );
  1207. PwszSpaceReplace( pwsz, pwszTypeNameIn, L'_');
  1208. rClassInout.SetProperty( pwszClass, PVD_WBEM_CLASS );
  1209. g_TypeNameToClass[ pwszTypeNameIn ] = pwszClass ;
  1210. TracePrint(( "CreateMofClassFromResType: entry\n" ));
  1211. //
  1212. // setup class property
  1213. //
  1214. {
  1215. static DWORD s_rgdwControl[] =
  1216. {
  1217. CLUSCTL_RESOURCE_TYPE_GET_PRIVATE_RESOURCE_PROPERTY_FMTS,
  1218. };
  1219. static DWORD s_cControl = sizeof( s_rgdwControl ) / sizeof( DWORD );
  1220. DWORD dwRt = ERROR_SUCCESS;
  1221. VARIANT var;
  1222. UINT idx;
  1223. var.vt = VT_NULL;
  1224. for ( idx = 0 ; idx < s_cControl ; idx++ )
  1225. {
  1226. CClusPropList pl;
  1227. dwRt = pl.ScGetResourceTypeProperties(
  1228. hCluster,
  1229. pwszTypeNameIn,
  1230. s_rgdwControl[ idx ],
  1231. NULL,
  1232. NULL,
  1233. 0 );
  1234. if ( dwRt != ERROR_SUCCESS ) {
  1235. TracePrint(( "CreateMofClassFromResType: error = %lx reading restype format types\n", dwRt ));
  1236. continue;
  1237. }
  1238. dwRt = pl.ScMoveToFirstProperty();
  1239. while ( dwRt == ERROR_SUCCESS )
  1240. {
  1241. LPCWSTR pwszPropName = NULL;
  1242. WCHAR pwszPropMof[MAX_PATH];
  1243. CIMTYPE cimType;
  1244. DWORD formatType;
  1245. pwszPropName = pl.PszCurrentPropertyName();
  1246. formatType = pl.CpfCurrentFormatListSyntax();
  1247. TracePrint(( "CreateMofClassFromResType: Found name = %ws, format type = %lx\n", pwszPropName, formatType ));
  1248. PwszSpaceReplace( pwszPropMof, pwszPropName, L'_' );
  1249. switch ( formatType )
  1250. {
  1251. case CLUSPROP_FORMAT_WORD:
  1252. {
  1253. cimType = CIM_UINT16;
  1254. break;
  1255. } // case: CLUSPROP_FORMAT_WORD
  1256. case CLUSPROP_FORMAT_DWORD:
  1257. {
  1258. cimType = CIM_UINT32;
  1259. break;
  1260. } // case: CLUSPROP_FORMAT_DWORD:
  1261. case CLUSPROP_FORMAT_LONG:
  1262. {
  1263. cimType = CIM_SINT32;
  1264. break;
  1265. } // case: CLUSPROP_FORMAT_LONG:
  1266. case CLUSPROP_FORMAT_SZ:
  1267. case CLUSPROP_FORMAT_EXPAND_SZ:
  1268. case CLUSPROP_FORMAT_EXPANDED_SZ:
  1269. {
  1270. cimType = CIM_STRING;
  1271. break;
  1272. } // case: CLUSPROP_FORMAT_SZ, etc.
  1273. case CLUSPROP_FORMAT_BINARY:
  1274. {
  1275. cimType = CIM_UINT8 | CIM_FLAG_ARRAY;
  1276. break;
  1277. } // case: CLUSPROP_FORMAT_BINARY
  1278. case CLUSPROP_FORMAT_MULTI_SZ:
  1279. {
  1280. cimType = CIM_STRING | CIM_FLAG_ARRAY;
  1281. break;
  1282. } // case: CLUSPROP_FORMAT_BINARY
  1283. default:
  1284. {
  1285. TracePrint(( "CreateMofClassFromResType: Unknown format type = %lx", formatType ));
  1286. break;
  1287. }
  1288. } // switch : property type
  1289. //TracePrint(( "CreateMofClassFromResType: MofProp = %ws, CIMType = %lx\n", pwszPropMof, cimType ));
  1290. rClassInout.data()->Put(
  1291. pwszPropMof,
  1292. 0,
  1293. &var,
  1294. cimType
  1295. );
  1296. dwRt = pl.ScMoveToNextProperty();
  1297. } // while: proplist not empty
  1298. } // for: readwrite and readonly property
  1299. } // set properties
  1300. } //*** CClassProv::CreateMofClassFromResType()