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.

1035 lines
23 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2002 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // NodeInformation.cpp
  7. //
  8. // Description:
  9. // Node Information object implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-MAR-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. #include "Pch.h"
  16. #include "NodeInformation.h"
  17. #include "ClusterConfiguration.h"
  18. DEFINE_THISCLASS("CNodeInformation")
  19. // ************************************************************************
  20. //
  21. // Constructor / Destructor
  22. //
  23. // ************************************************************************
  24. //////////////////////////////////////////////////////////////////////////////
  25. //
  26. // HRESULT
  27. // CNodeInformation::S_HrCreateInstance(
  28. // IUnknown ** ppunkOut
  29. // )
  30. //
  31. //////////////////////////////////////////////////////////////////////////////
  32. HRESULT
  33. CNodeInformation::S_HrCreateInstance(
  34. IUnknown ** ppunkOut
  35. )
  36. {
  37. TraceFunc( "" );
  38. HRESULT hr = S_OK;
  39. CNodeInformation * pni = NULL;
  40. Assert( ppunkOut != NULL );
  41. if ( ppunkOut == NULL )
  42. {
  43. hr = THR( E_POINTER );
  44. goto Cleanup;
  45. }
  46. pni = new CNodeInformation;
  47. if ( pni == NULL )
  48. {
  49. hr = THR( E_OUTOFMEMORY );
  50. goto Cleanup;
  51. }
  52. hr = THR( pni->HrInit() );
  53. if ( FAILED( hr ) )
  54. {
  55. goto Cleanup;
  56. }
  57. hr = THR( pni->TypeSafeQI( IUnknown, ppunkOut ) );
  58. if ( FAILED( hr ) )
  59. {
  60. goto Cleanup;
  61. }
  62. Cleanup:
  63. if ( pni != NULL )
  64. {
  65. pni->Release();
  66. }
  67. HRETURN( hr );
  68. } //*** CNodeInformation::S_HrCreateInstance
  69. //////////////////////////////////////////////////////////////////////////////
  70. //
  71. // CNodeInformation::CNodeInformation
  72. //
  73. //////////////////////////////////////////////////////////////////////////////
  74. CNodeInformation::CNodeInformation( void )
  75. : m_cRef( 1 )
  76. {
  77. TraceFunc( "" );
  78. InterlockedIncrement( &g_cObjects );
  79. TraceFuncExit();
  80. } //*** CNodeInformation::CNodeInformation
  81. //////////////////////////////////////////////////////////////////////////////
  82. //
  83. // STDMETHODIMP
  84. // CNodeInformation::HrInit
  85. //
  86. //////////////////////////////////////////////////////////////////////////////
  87. STDMETHODIMP
  88. CNodeInformation::HrInit( void )
  89. {
  90. TraceFunc( "" );
  91. HRESULT hr = S_OK;
  92. // IUnknown stuff
  93. Assert( m_cRef == 1 );
  94. // IClusCfgNodeInfo
  95. Assert( m_bstrName == NULL );
  96. Assert( m_fHasNameChanged == FALSE );
  97. Assert( m_fIsMember == FALSE );
  98. Assert( m_pccci == NULL );
  99. Assert( m_dwHighestVersion == 0 );
  100. Assert( m_dwLowestVersion == 0 );
  101. Assert( m_dwMajorVersion == 0 );
  102. Assert( m_dwMinorVersion == 0 );
  103. Assert( m_wSuiteMask == 0 );
  104. Assert( m_bProductType == 0 );
  105. Assert( m_bstrCSDVersion == NULL );
  106. Assert( m_dlmDriveLetterMapping.dluDrives[ 0 ] == 0 );
  107. Assert( m_wProcessorArchitecture == 0 );
  108. Assert( m_wProcessorLevel == 0 );
  109. Assert( m_cMaxNodes == 0 );
  110. // IExtendObjectManager
  111. HRETURN( hr );
  112. } //*** CNodeInformation::HrInit
  113. //////////////////////////////////////////////////////////////////////////////
  114. //
  115. // CNodeInformation::~CNodeInformation
  116. //
  117. //////////////////////////////////////////////////////////////////////////////
  118. CNodeInformation::~CNodeInformation( void )
  119. {
  120. TraceFunc( "" );
  121. if ( m_pccci != NULL )
  122. {
  123. m_pccci->Release();
  124. }
  125. TraceSysFreeString( m_bstrName );
  126. TraceSysFreeString( m_bstrCSDVersion );
  127. InterlockedDecrement( &g_cObjects );
  128. TraceFuncExit();
  129. } //*** CNodeInformation::~CNodeInformation
  130. // ************************************************************************
  131. //
  132. // IUnknown
  133. //
  134. // ************************************************************************
  135. //////////////////////////////////////////////////////////////////////////////
  136. //++
  137. //
  138. // CNodeInformation::QueryInterface
  139. //
  140. // Description:
  141. // Query this object for the passed in interface.
  142. //
  143. // Arguments:
  144. // riidIn
  145. // Id of interface requested.
  146. //
  147. // ppvOut
  148. // Pointer to the requested interface.
  149. //
  150. // Return Value:
  151. // S_OK
  152. // If the interface is available on this object.
  153. //
  154. // E_NOINTERFACE
  155. // If the interface is not available.
  156. //
  157. // E_POINTER
  158. // ppvOut was NULL.
  159. //
  160. // Remarks:
  161. // None.
  162. //
  163. //--
  164. //////////////////////////////////////////////////////////////////////////////
  165. STDMETHODIMP
  166. CNodeInformation::QueryInterface(
  167. REFIID riidIn
  168. , LPVOID * ppvOut
  169. )
  170. {
  171. TraceQIFunc( riidIn, ppvOut );
  172. HRESULT hr = S_OK;
  173. //
  174. // Validate arguments.
  175. //
  176. Assert( ppvOut != NULL );
  177. if ( ppvOut == NULL )
  178. {
  179. hr = THR( E_POINTER );
  180. goto Cleanup;
  181. }
  182. //
  183. // Handle known interfaces.
  184. //
  185. if ( IsEqualIID( riidIn, IID_IUnknown ) )
  186. {
  187. *ppvOut = static_cast< IClusCfgNodeInfo * >( this );
  188. } // if: IUnknown
  189. else if ( IsEqualIID( riidIn, IID_IClusCfgNodeInfo ) )
  190. {
  191. *ppvOut = TraceInterface( __THISCLASS__, IClusCfgNodeInfo, this, 0 );
  192. } // else if: IClusCfgNodeInfo
  193. else if ( IsEqualIID( riidIn, IID_IGatherData ) )
  194. {
  195. *ppvOut = TraceInterface( __THISCLASS__, IGatherData, this, 0 );
  196. } // else if: IGatherData
  197. else if ( IsEqualIID( riidIn, IID_IExtendObjectManager ) )
  198. {
  199. *ppvOut = TraceInterface( __THISCLASS__, IExtendObjectManager, this, 0 );
  200. } // else if: IExtendObjectManager
  201. else
  202. {
  203. *ppvOut = NULL;
  204. hr = E_NOINTERFACE;
  205. }
  206. //
  207. // Add a reference to the interface if successful.
  208. //
  209. if ( SUCCEEDED( hr ) )
  210. {
  211. ((IUnknown *) *ppvOut)->AddRef();
  212. } // if: success
  213. Cleanup:
  214. QIRETURN_IGNORESTDMARSHALLING( hr, riidIn );
  215. } //*** CNodeInformation::QueryInterface
  216. //////////////////////////////////////////////////////////////////////////////
  217. //
  218. // STDMETHODIMP_(ULONG)
  219. // CNodeInformation::AddRef
  220. //
  221. //////////////////////////////////////////////////////////////////////////////
  222. STDMETHODIMP_(ULONG)
  223. CNodeInformation::AddRef( void )
  224. {
  225. TraceFunc( "[IUnknown]" );
  226. InterlockedIncrement( &m_cRef );
  227. CRETURN( m_cRef );
  228. } //*** CNodeInformation::AddRef
  229. //////////////////////////////////////////////////////////////////////////////
  230. //
  231. // STDMETHODIMP_(ULONG)
  232. // CNodeInformation::Release
  233. //
  234. //////////////////////////////////////////////////////////////////////////////
  235. STDMETHODIMP_(ULONG)
  236. CNodeInformation::Release( void )
  237. {
  238. TraceFunc( "[IUnknown]" );
  239. LONG cRef;
  240. cRef = InterlockedDecrement( &m_cRef );
  241. if ( cRef == 0 )
  242. {
  243. TraceDo( delete this );
  244. }
  245. CRETURN( cRef );
  246. } //*** CNodeInformation::Release
  247. // ************************************************************************
  248. //
  249. // IClusCfgNodeInfo
  250. //
  251. // ************************************************************************
  252. //////////////////////////////////////////////////////////////////////////////
  253. //
  254. // STDMETHODIMP
  255. // CNodeInformation::GetName(
  256. // BSTR * pbstrNameOut
  257. // )
  258. //
  259. //////////////////////////////////////////////////////////////////////////////
  260. STDMETHODIMP
  261. CNodeInformation::GetName(
  262. BSTR * pbstrNameOut
  263. )
  264. {
  265. TraceFunc( "[IClusCfgNodeInfo]" );
  266. HRESULT hr = S_OK;
  267. if ( pbstrNameOut == NULL )
  268. {
  269. hr = THR( E_POINTER );
  270. goto Cleanup;
  271. }
  272. if ( m_bstrName == NULL )
  273. {
  274. hr = THR( E_POINTER );
  275. goto Cleanup;
  276. }
  277. *pbstrNameOut = SysAllocString( m_bstrName );
  278. if ( *pbstrNameOut == NULL )
  279. {
  280. hr = THR( E_OUTOFMEMORY );
  281. goto Cleanup;
  282. }
  283. Cleanup:
  284. HRETURN( hr );
  285. } //*** CNodeInformation::GetName
  286. //////////////////////////////////////////////////////////////////////////////
  287. //
  288. // STDMETHODIMP
  289. // CNodeInformation::SetName(
  290. // LPCWSTR pcszNameIn
  291. // )
  292. //
  293. //////////////////////////////////////////////////////////////////////////////
  294. STDMETHODIMP
  295. CNodeInformation::SetName(
  296. LPCWSTR pcszNameIn
  297. )
  298. {
  299. TraceFunc( "[IClusCfgNodeInfo]" );
  300. HRESULT hr = S_OK;
  301. BSTR bstrNewName;
  302. if ( pcszNameIn == NULL )
  303. {
  304. hr = THR( E_INVALIDARG );
  305. goto Cleanup;
  306. }
  307. bstrNewName = TraceSysAllocString( pcszNameIn );
  308. if ( bstrNewName == NULL )
  309. {
  310. hr = THR( E_OUTOFMEMORY );
  311. goto Cleanup;
  312. }
  313. TraceSysFreeString( m_bstrName );
  314. m_bstrName = NULL;
  315. m_fHasNameChanged = TRUE;
  316. m_bstrName = bstrNewName;
  317. Cleanup:
  318. HRETURN( hr );
  319. } //*** CNodeInformation::SetName
  320. //////////////////////////////////////////////////////////////////////////////
  321. //
  322. // STDMETHODIMP
  323. // CNodeInformation::IsMemberOfCluster
  324. //
  325. //////////////////////////////////////////////////////////////////////////////
  326. STDMETHODIMP
  327. CNodeInformation::IsMemberOfCluster( void )
  328. {
  329. TraceFunc( "[IClusCfgNodeInfo]" );
  330. HRESULT hr = S_OK;
  331. if ( m_fIsMember == FALSE )
  332. {
  333. hr = S_FALSE;
  334. }
  335. HRETURN( hr );
  336. } //*** CNodeInformation::IsMemberOfCluster
  337. //////////////////////////////////////////////////////////////////////////////
  338. //
  339. // STDMETHODIMP
  340. // CNodeInformation::GetClusterConfigInfo(
  341. // IClusCfgClusterInfo * * ppClusCfgClusterInfoOut
  342. // )
  343. //
  344. //////////////////////////////////////////////////////////////////////////////
  345. STDMETHODIMP
  346. CNodeInformation::GetClusterConfigInfo(
  347. IClusCfgClusterInfo * * ppClusCfgClusterInfoOut
  348. )
  349. {
  350. TraceFunc( "[IClusCfgNodeInfo]" );
  351. HRESULT hr;
  352. if ( ppClusCfgClusterInfoOut == NULL )
  353. {
  354. hr = THR( E_POINTER );
  355. goto Cleanup;
  356. }
  357. if ( m_pccci == NULL )
  358. {
  359. hr = THR( E_POINTER );
  360. goto Cleanup;
  361. }
  362. hr = THR( m_pccci->TypeSafeQI( IClusCfgClusterInfo, ppClusCfgClusterInfoOut ) );
  363. Cleanup:
  364. HRETURN( hr );
  365. } //*** CNodeInformation::GetClusterConfigInfo
  366. //////////////////////////////////////////////////////////////////////////////
  367. //
  368. // STDMETHODIMP
  369. // CNodeInformation::GetOSVersion(
  370. // DWORD * pdwMajorVersionOut,
  371. // DWORD * pdwMinorVersionOut,
  372. // WORD * pwSuiteMaskOut,
  373. // BYTE * pbProductTypeOut
  374. // BSTR * pbstrCSDVersionOut
  375. // )
  376. //
  377. //////////////////////////////////////////////////////////////////////////////
  378. STDMETHODIMP
  379. CNodeInformation::GetOSVersion(
  380. DWORD * pdwMajorVersionOut,
  381. DWORD * pdwMinorVersionOut,
  382. WORD * pwSuiteMaskOut,
  383. BYTE * pbProductTypeOut,
  384. BSTR * pbstrCSDVersionOut
  385. )
  386. {
  387. TraceFunc( "[IClusCfgNodeInfo]" );
  388. HRESULT hr = S_OK;
  389. if ( pdwMajorVersionOut == NULL
  390. || pdwMinorVersionOut == NULL
  391. || pwSuiteMaskOut == NULL
  392. || pbProductTypeOut == NULL
  393. || pbstrCSDVersionOut == NULL
  394. )
  395. {
  396. hr = THR( E_POINTER );
  397. goto Cleanup;
  398. }
  399. *pdwMajorVersionOut = m_dwMajorVersion;
  400. *pdwMinorVersionOut = m_dwMinorVersion;
  401. *pwSuiteMaskOut = m_wSuiteMask;
  402. *pbProductTypeOut = m_bProductType;
  403. *pbstrCSDVersionOut = TraceSysAllocString( m_bstrCSDVersion );
  404. if ( *pbstrCSDVersionOut == NULL )
  405. {
  406. hr = THR( E_OUTOFMEMORY );
  407. } // if:
  408. Cleanup:
  409. HRETURN( hr );
  410. } //*** CNodeInformation::GetOSVersion
  411. //////////////////////////////////////////////////////////////////////////////
  412. //
  413. // STDMETHODIMP
  414. // CNodeInformation::GetClusterVersion(
  415. // DWORD * pdwNodeHighestVersion,
  416. // DWORD * pdwNodeLowestVersion
  417. // )
  418. //
  419. //////////////////////////////////////////////////////////////////////////////
  420. STDMETHODIMP
  421. CNodeInformation::GetClusterVersion(
  422. DWORD * pdwNodeHighestVersion,
  423. DWORD * pdwNodeLowestVersion
  424. )
  425. {
  426. TraceFunc( "[IClusCfgNodeInfo]" );
  427. HRESULT hr = S_OK;
  428. if ( pdwNodeHighestVersion == NULL
  429. || pdwNodeLowestVersion == NULL
  430. )
  431. {
  432. hr = THR( E_POINTER );
  433. goto Cleanup;
  434. }
  435. *pdwNodeHighestVersion = m_dwHighestVersion;
  436. *pdwNodeLowestVersion = m_dwLowestVersion;
  437. Cleanup:
  438. HRETURN( hr );
  439. } //*** CNodeInformation::GetClusterVersion
  440. //////////////////////////////////////////////////////////////////////////////
  441. //
  442. // STDMETHODIMP
  443. // CNodeInformation::GetDriveLetterMappings(
  444. // SDriveLetterMapping * pdlmDriveLetterUsageOut
  445. // )
  446. //
  447. //////////////////////////////////////////////////////////////////////////////
  448. STDMETHODIMP
  449. CNodeInformation::GetDriveLetterMappings(
  450. SDriveLetterMapping * pdlmDriveLetterUsageOut
  451. )
  452. {
  453. TraceFunc( "[IClusCfgNodeInfo]" );
  454. HRESULT hr = S_OK;
  455. *pdlmDriveLetterUsageOut = m_dlmDriveLetterMapping;
  456. HRETURN( hr );
  457. } //*** CNodeInformation::GetDriveLetterMappings
  458. //////////////////////////////////////////////////////////////////////////////
  459. //++
  460. //
  461. // CNodeInformation::GetMaxNodeCount
  462. //
  463. // Description:
  464. // Returns the maximun number of nodes for this node's product
  465. // suite type.
  466. //
  467. // Notes:
  468. //
  469. // Parameter:
  470. // pcMaxNodesOut
  471. // The maximum number of nodes allowed by this node's product
  472. // suite type.
  473. //
  474. // Return Value:
  475. // S_OK
  476. // Success.
  477. //
  478. // other HRESULT
  479. // The call failed.
  480. //
  481. //--
  482. //////////////////////////////////////////////////////////////////////////////
  483. STDMETHODIMP
  484. CNodeInformation::GetMaxNodeCount(
  485. DWORD * pcMaxNodesOut
  486. )
  487. {
  488. TraceFunc( "[IClusCfgNodeInfo]" );
  489. HRESULT hr = S_OK;
  490. if ( pcMaxNodesOut == NULL )
  491. {
  492. hr = THR( E_POINTER );
  493. goto Cleanup;
  494. } // if:
  495. *pcMaxNodesOut = m_cMaxNodes;
  496. Cleanup:
  497. HRETURN( hr );
  498. } //*** CNodeInformation::GetMaxNodeCount
  499. //////////////////////////////////////////////////////////////////////////////
  500. //++
  501. //
  502. // CNodeInformation::GetProcessorInfo
  503. //
  504. // Description:
  505. // Get the processor information for this node.
  506. //
  507. // Arguments:
  508. // pwProcessorArchitectureOut
  509. // The processor architecture.
  510. //
  511. // pwProcessorLevelOut
  512. // The processor type.
  513. //
  514. // Return Value:
  515. // S_OK
  516. // Success.
  517. //
  518. // other HRESULT
  519. // The call failed.
  520. //
  521. // Remarks:
  522. // See SYSTEM_INFO in MSDN and/or the Platform SDK for more
  523. // information.
  524. //
  525. //--
  526. //////////////////////////////////////////////////////////////////////////////
  527. STDMETHODIMP
  528. CNodeInformation::GetProcessorInfo(
  529. WORD * pwProcessorArchitectureOut
  530. , WORD * pwProcessorLevelOut
  531. )
  532. {
  533. TraceFunc( "[IClusCfgNodeInfo]" );
  534. HRESULT hr = S_OK;
  535. if ( ( pwProcessorArchitectureOut == NULL ) && ( pwProcessorLevelOut == NULL ) )
  536. {
  537. hr = THR( E_POINTER );
  538. goto Cleanup;
  539. } // if:
  540. if ( pwProcessorArchitectureOut != NULL )
  541. {
  542. *pwProcessorArchitectureOut = m_wProcessorArchitecture;
  543. } // if:
  544. if ( pwProcessorLevelOut != NULL )
  545. {
  546. *pwProcessorLevelOut = m_wProcessorLevel;
  547. } // if:
  548. Cleanup:
  549. HRETURN( hr );
  550. } //*** CNodeInformation::GetProcessorInfo
  551. //****************************************************************************
  552. //
  553. // IGatherData
  554. //
  555. //****************************************************************************
  556. //////////////////////////////////////////////////////////////////////////////
  557. //
  558. // STDMETHODIMP
  559. // CNodeInformation::Gather(
  560. // OBJECTCOOKIE cookieParentIn,
  561. // IUnknown * punkIn
  562. // )
  563. //
  564. //////////////////////////////////////////////////////////////////////////////
  565. STDMETHODIMP
  566. CNodeInformation::Gather(
  567. OBJECTCOOKIE cookieParentIn,
  568. IUnknown * punkIn
  569. )
  570. {
  571. TraceFunc( "[IGatherData]" );
  572. HRESULT hr;
  573. IServiceProvider * psp;
  574. BSTR bstrClusterName = NULL;
  575. IUnknown * punk = NULL;
  576. IObjectManager * pom = NULL;
  577. IClusCfgClusterInfo * pccci = NULL;
  578. IClusCfgNodeInfo * pccni = NULL;
  579. //
  580. // Check parameters.
  581. //
  582. if ( punkIn == NULL )
  583. {
  584. hr = THR( E_INVALIDARG );
  585. goto Cleanup;
  586. }
  587. //
  588. // Grab the right interface.
  589. //
  590. hr = THR( punkIn->TypeSafeQI( IClusCfgNodeInfo, &pccni ) );
  591. if ( FAILED( hr ) )
  592. {
  593. goto Cleanup;
  594. }
  595. //
  596. // Gather the object manager.
  597. //
  598. hr = THR( CoCreateInstance( CLSID_ServiceManager,
  599. NULL,
  600. CLSCTX_INPROC_SERVER,
  601. TypeSafeParams( IServiceProvider, &psp )
  602. ) );
  603. if ( FAILED( hr ) )
  604. {
  605. goto Cleanup;
  606. }
  607. hr = THR( psp->TypeSafeQS( CLSID_ObjectManager,
  608. IObjectManager,
  609. &pom
  610. ) );
  611. psp->Release(); // release promptly
  612. if ( FAILED( hr ) )
  613. {
  614. goto Cleanup;
  615. }
  616. TraceSysFreeString( m_bstrName );
  617. m_bstrName = NULL;
  618. //
  619. // Gather Name
  620. //
  621. hr = THR( pccni->GetName( &m_bstrName ) );
  622. if ( FAILED( hr ) )
  623. {
  624. goto Error;
  625. }
  626. TraceMemoryAddBSTR( m_bstrName );
  627. m_fHasNameChanged = FALSE;
  628. //
  629. // Gather Is Member?
  630. //
  631. hr = STHR( pccni->IsMemberOfCluster() );
  632. if ( FAILED( hr ) )
  633. {
  634. goto Cleanup;
  635. }
  636. if ( hr == S_OK )
  637. {
  638. m_fIsMember = TRUE;
  639. }
  640. else
  641. {
  642. m_fIsMember = FALSE;
  643. }
  644. if ( m_fIsMember )
  645. {
  646. IGatherData * pgd;
  647. //
  648. // Gather Cluster Configuration
  649. //
  650. hr = THR( pccni->GetClusterConfigInfo( &pccci ) );
  651. if ( FAILED( hr ) )
  652. {
  653. goto Cleanup;
  654. }
  655. hr = THR( CClusterConfiguration::S_HrCreateInstance( &punk ) );
  656. if ( FAILED( hr ) )
  657. {
  658. goto Cleanup;
  659. }
  660. hr = THR( punk->TypeSafeQI( IGatherData, &pgd ) );
  661. if ( FAILED( hr ) )
  662. {
  663. goto Cleanup;
  664. }
  665. hr = THR( pgd->Gather( NULL, pccci ) );
  666. pgd->Release(); // release promptly
  667. if ( FAILED( hr ) )
  668. {
  669. goto Cleanup;
  670. }
  671. hr = THR( punk->TypeSafeQI( IClusCfgClusterInfo, &m_pccci ) );
  672. if ( FAILED( hr ) )
  673. {
  674. goto Cleanup;
  675. }
  676. pccci->Release();
  677. pccci = NULL;
  678. } // if: node if a member of a cluster
  679. //
  680. // Gather OS Version
  681. //
  682. hr = THR( pccni->GetOSVersion(
  683. &m_dwMajorVersion,
  684. &m_dwMinorVersion,
  685. &m_wSuiteMask,
  686. &m_bProductType,
  687. &m_bstrCSDVersion
  688. ) );
  689. if ( FAILED( hr ) )
  690. {
  691. goto Error;
  692. }
  693. TraceMemoryAddBSTR( m_bstrCSDVersion );
  694. //
  695. // Gather Cluster Version
  696. //
  697. hr = THR( pccni->GetClusterVersion( &m_dwHighestVersion, &m_dwLowestVersion ) );
  698. if ( FAILED( hr ) )
  699. {
  700. goto Error;
  701. }
  702. //
  703. // Gather Drive Letter Mappings
  704. //
  705. hr = STHR( pccni->GetDriveLetterMappings( &m_dlmDriveLetterMapping ) );
  706. if ( FAILED( hr ) )
  707. {
  708. goto Error;
  709. }
  710. hr = STHR( pccni->GetMaxNodeCount( &m_cMaxNodes ) );
  711. if ( FAILED( hr ) )
  712. {
  713. goto Error;
  714. } // if:
  715. hr = STHR( pccni->GetProcessorInfo( &m_wProcessorArchitecture, &m_wProcessorLevel ) );
  716. if ( FAILED( hr ) )
  717. {
  718. goto Error;
  719. } // if:
  720. //
  721. // Anything else to gather??
  722. //
  723. hr = S_OK;
  724. Cleanup:
  725. if ( punk != NULL )
  726. {
  727. punk->Release();
  728. }
  729. if ( pom != NULL )
  730. {
  731. pom->Release();
  732. }
  733. if ( pccci != NULL )
  734. {
  735. pccci->Release();
  736. }
  737. if ( bstrClusterName != NULL )
  738. {
  739. TraceSysFreeString( bstrClusterName );
  740. }
  741. if ( pccni != NULL )
  742. {
  743. pccni->Release();
  744. }
  745. HRETURN( hr );
  746. Error:
  747. //
  748. // On error, invalidate all data.
  749. //
  750. TraceSysFreeString( m_bstrName );
  751. m_bstrName = NULL;
  752. m_fHasNameChanged = FALSE;
  753. m_fIsMember = FALSE;
  754. if ( m_pccci != NULL )
  755. {
  756. m_pccci->Release();
  757. m_pccci = NULL;
  758. }
  759. m_dwHighestVersion = 0;
  760. m_dwLowestVersion = 0;
  761. ZeroMemory( &m_dlmDriveLetterMapping, sizeof( m_dlmDriveLetterMapping ) );
  762. goto Cleanup;
  763. } //*** CNodeInformation::Gather
  764. // ************************************************************************
  765. //
  766. // IExtendObjectManager
  767. //
  768. // ************************************************************************
  769. //////////////////////////////////////////////////////////////////////////////
  770. //
  771. // STDMETHODIMP
  772. // CNodeInformation::FindObject(
  773. // OBJECTCOOKIE cookieIn
  774. // , REFCLSID rclsidTypeIn
  775. // , LPCWSTR pcszNameIn
  776. // , LPUNKNOWN * punkOut
  777. // )
  778. //
  779. //////////////////////////////////////////////////////////////////////////////
  780. STDMETHODIMP
  781. CNodeInformation::FindObject(
  782. OBJECTCOOKIE cookieIn
  783. , REFCLSID rclsidTypeIn
  784. , LPCWSTR pcszNameIn
  785. , LPUNKNOWN * ppunkOut
  786. )
  787. {
  788. TraceFunc( "[IExtendObjectManager]" );
  789. HRESULT hr = S_OK;
  790. //
  791. // Check parameters...
  792. //
  793. // Gotta have a cookie
  794. if ( cookieIn == NULL )
  795. {
  796. hr = THR( E_INVALIDARG );
  797. goto Cleanup;
  798. }
  799. // We need to be representing a NodeType.
  800. if ( ! IsEqualIID( rclsidTypeIn, CLSID_NodeType ) )
  801. {
  802. hr = THR( E_INVALIDARG );
  803. goto Cleanup;
  804. }
  805. // We need a name.
  806. if ( pcszNameIn == NULL )
  807. {
  808. hr = THR( E_INVALIDARG );
  809. goto Cleanup;
  810. }
  811. //
  812. // Free m_bstrName before we allocate a new value.
  813. //
  814. TraceSysFreeString( m_bstrName );
  815. m_bstrName = NULL;
  816. //
  817. // Save our name.
  818. //
  819. m_bstrName = TraceSysAllocString( pcszNameIn );
  820. if ( m_bstrName == NULL )
  821. {
  822. hr = THR( E_OUTOFMEMORY );
  823. goto Cleanup;
  824. }
  825. //
  826. // Get the pointer.
  827. //
  828. if ( ppunkOut != NULL )
  829. {
  830. hr = THR( QueryInterface( DFGUID_NodeInformation,
  831. reinterpret_cast< void ** > ( ppunkOut )
  832. ) );
  833. if ( FAILED( hr ) )
  834. {
  835. goto Cleanup;
  836. }
  837. } // if: ppunkOut
  838. //
  839. // Tell caller that the data is pending.
  840. //
  841. hr = E_PENDING;
  842. Cleanup:
  843. HRETURN( hr );
  844. } //*** CNodeInformation::FindObject