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.

1490 lines
44 KiB

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