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.

1003 lines
24 KiB

  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 2000-2001 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // CProxyCfgNodeInfo.cpp
  7. //
  8. // Description:
  9. // CProxyCfgNodeInfo implementation.
  10. //
  11. // Maintained By:
  12. // Galen Barbee (GalenB) 02-AUG-2000
  13. //
  14. //////////////////////////////////////////////////////////////////////////////
  15. //////////////////////////////////////////////////////////////////////////////
  16. // Include Files
  17. //////////////////////////////////////////////////////////////////////////////
  18. #include "pch.h"
  19. #include "CProxyCfgNodeInfo.h"
  20. #include "CProxyCfgClusterInfo.h"
  21. //////////////////////////////////////////////////////////////////////////////
  22. // Constant Definitions
  23. //////////////////////////////////////////////////////////////////////////////
  24. DEFINE_THISCLASS("CProxyCfgNodeInfo")
  25. //////////////////////////////////////////////////////////////////////////////
  26. //++
  27. //
  28. // CProxyCfgNodeInfo::S_HrCreateInstance()
  29. //
  30. // Description:
  31. // Create a CProxyCfgNodeInfo instance.
  32. //
  33. // Arguments:
  34. // ppunkOut
  35. //
  36. // Return Values:
  37. // S_OK
  38. // Success.
  39. //
  40. // E_POINTER
  41. // A passed in argument is NULL.
  42. //
  43. // E_OUTOFMEMORY
  44. // Out of memory.
  45. //
  46. // Other HRESULT error.
  47. //
  48. //--
  49. //////////////////////////////////////////////////////////////////////////////
  50. HRESULT
  51. CProxyCfgNodeInfo::S_HrCreateInstance(
  52. IUnknown ** ppunkOut,
  53. IUnknown * punkOuterIn,
  54. HCLUSTER * phClusterIn,
  55. CLSID * pclsidMajorIn,
  56. LPCWSTR pcszNodeNameIn,
  57. LPCWSTR pcszDomainIn
  58. )
  59. {
  60. TraceFunc( "" );
  61. HRESULT hr;
  62. CProxyCfgNodeInfo * pcc = NULL;
  63. if ( ppunkOut == NULL )
  64. {
  65. hr = THR( E_POINTER );
  66. goto Cleanup;
  67. } // if:
  68. pcc = new CProxyCfgNodeInfo;
  69. if ( pcc == NULL )
  70. {
  71. hr = THR( E_OUTOFMEMORY );
  72. goto Cleanup;
  73. } // if:
  74. hr = THR( pcc->HrInit( punkOuterIn, phClusterIn, pclsidMajorIn, pcszNodeNameIn, pcszDomainIn ) );
  75. if ( FAILED( hr ) )
  76. goto Cleanup;
  77. hr = THR( pcc->TypeSafeQI( IUnknown, ppunkOut ) );
  78. Cleanup:
  79. if ( pcc != NULL )
  80. {
  81. pcc->Release();
  82. } // if:
  83. HRETURN( hr );
  84. } //*** CProxyCfgNodeInfo::S_HrCreateInstance()
  85. //////////////////////////////////////////////////////////////////////////////
  86. //++
  87. //
  88. // CProxyCfgNodeInfo::CProxyCfgNodeInfo()
  89. //
  90. // Description:
  91. // Constructor of the CProxyCfgNodeInfo class. This initializes
  92. // the m_cRef variable to 1 instead of 0 to account of possible
  93. // QueryInterface failure in DllGetClassObject.
  94. //
  95. // Arguments:
  96. // None.
  97. //
  98. // Return Value:
  99. // None.
  100. //
  101. // Remarks:
  102. // None.
  103. //
  104. //--
  105. //////////////////////////////////////////////////////////////////////////////
  106. CProxyCfgNodeInfo::CProxyCfgNodeInfo( void )
  107. : m_cRef( 1 )
  108. {
  109. TraceFunc( "" );
  110. InterlockedIncrement( &g_cObjects );
  111. Assert( m_cRef == 1 );
  112. Assert( m_punkOuter == NULL );
  113. Assert( m_phCluster == NULL );
  114. Assert( m_pclsidMajor == NULL );
  115. Assert( m_pcccb == NULL );
  116. // m_cplNode?
  117. // m_cplNodeRO?
  118. Assert( m_hNode == NULL );
  119. TraceFuncExit();
  120. } //*** CProxyCfgNodeInfo::CProxyCfgNodeInfo()
  121. //////////////////////////////////////////////////////////////////////////////
  122. //++
  123. //
  124. // CProxyCfgNodeInfo::~CProxyCfgNodeInfo()
  125. //
  126. // Description:
  127. // Destructor of the CProxyCfgNodeInfo class.
  128. //
  129. // Arguments:
  130. // None.
  131. //
  132. // Return Value:
  133. // None.
  134. //
  135. // Remarks:
  136. // None.
  137. //
  138. //--
  139. //////////////////////////////////////////////////////////////////////////////
  140. CProxyCfgNodeInfo::~CProxyCfgNodeInfo( void )
  141. {
  142. TraceFunc( "" );
  143. // m_cRef
  144. if ( m_punkOuter != NULL )
  145. {
  146. m_punkOuter->Release( );
  147. }
  148. // m_phCluster - DO NOT CLOSE!
  149. // m_pclsidMajor
  150. if ( m_pcccb != NULL )
  151. {
  152. m_pcccb->Release();
  153. }
  154. // m_cplNode - has its own dotr
  155. // m_cplNodeRO - has its own dotr
  156. if ( m_hNode != NULL )
  157. {
  158. BOOL bRet;
  159. bRet = CloseClusterNode( m_hNode );
  160. Assert( bRet );
  161. }
  162. TraceSysFreeString( m_bstrDomain );
  163. InterlockedDecrement( &g_cObjects );
  164. TraceFuncExit();
  165. } //*** CProxyCfgNodeInfo::~CProxyCfgNodeInfo()
  166. //////////////////////////////////////////////////////////////////////////////
  167. //++
  168. //
  169. // CProxyCfgNodeInfo::HrInit()
  170. //
  171. // Description:
  172. // Initializes the object.
  173. //
  174. // Arguments:
  175. // None.
  176. //
  177. // Return Value:
  178. // S_OK
  179. // Succeeded
  180. //
  181. // other HRESULTs
  182. // Failed.
  183. //
  184. // Remarks:
  185. // None.
  186. //
  187. //--
  188. //////////////////////////////////////////////////////////////////////////////
  189. HRESULT
  190. CProxyCfgNodeInfo::HrInit(
  191. IUnknown * punkOuterIn,
  192. HCLUSTER * phClusterIn,
  193. CLSID * pclsidMajorIn,
  194. LPCWSTR pcszNodeNameIn,
  195. LPCWSTR pcszDomainIn
  196. )
  197. {
  198. TraceFunc( "" );
  199. HRESULT hr;
  200. DWORD sc;
  201. BSTR bstrName = NULL;
  202. //
  203. // Gather information from the input parameters.
  204. //
  205. if ( punkOuterIn != NULL )
  206. {
  207. m_punkOuter = punkOuterIn;
  208. m_punkOuter->AddRef( );
  209. }
  210. if ( phClusterIn == NULL )
  211. goto InvalidArg;
  212. m_phCluster = phClusterIn;
  213. if ( pclsidMajorIn != NULL )
  214. {
  215. m_pclsidMajor = pclsidMajorIn;
  216. }
  217. else
  218. {
  219. m_pclsidMajor = (CLSID *) &TASKID_Major_Client_And_Server_Log;
  220. }
  221. //
  222. // See if we can callback.
  223. //
  224. hr = THR( m_punkOuter->TypeSafeQI( IClusCfgCallback, &m_pcccb ) );
  225. if ( FAILED( hr ) )
  226. goto Cleanup;
  227. //
  228. // Save away the domain.
  229. //
  230. m_bstrDomain = TraceSysAllocString( pcszDomainIn );
  231. if ( m_bstrDomain == NULL )
  232. goto OutOfMemory;
  233. //
  234. // Use only the hostname of the node and open the node.
  235. //
  236. if ( pcszNodeNameIn != NULL )
  237. {
  238. //
  239. // Caller supplied the node name.
  240. //
  241. LPWSTR psz = wcschr( pcszNodeNameIn, L'.' );
  242. if ( psz == NULL )
  243. {
  244. m_hNode = OpenClusterNode( *m_phCluster, pcszNodeNameIn );
  245. // error case handled outside if statement
  246. }
  247. else
  248. {
  249. // Truncate the name at the dot
  250. Assert( psz > pcszNodeNameIn );
  251. bstrName = TraceSysAllocStringLen( pcszNodeNameIn, (DWORD)( psz - pcszNodeNameIn ) );
  252. if ( bstrName == NULL )
  253. goto OutOfMemory;
  254. m_hNode = OpenClusterNode( *m_phCluster, bstrName );
  255. // error case handled outside if statement
  256. }
  257. if ( m_hNode == NULL )
  258. {
  259. sc = GetLastError( );
  260. if ( sc != ERROR_NOT_FOUND )
  261. {
  262. hr = HRESULT_FROM_WIN32( TW32( sc ) );
  263. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_OpenClusterNode_Failed, hr );
  264. goto Cleanup;
  265. }
  266. }
  267. }
  268. else
  269. {
  270. sc = TW32( ResUtilEnumResourcesEx( *m_phCluster,
  271. NULL,
  272. L"Network Name",
  273. &DwEnumResourcesExCallback,
  274. this
  275. ) );
  276. if ( sc != ERROR_SUCCESS )
  277. {
  278. hr = HRESULT_FROM_WIN32( sc );
  279. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ResUtilEnumResourcesEx_Failed, hr );
  280. goto Cleanup;
  281. }
  282. Assert( m_hNode != NULL );
  283. }
  284. //
  285. // Retrieve the properties.
  286. //
  287. sc = TW32( m_cplNode.ScGetNodeProperties( m_hNode, CLUSCTL_NODE_GET_COMMON_PROPERTIES ) );
  288. if ( sc != ERROR_SUCCESS )
  289. {
  290. hr = HRESULT_FROM_WIN32( sc );
  291. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetNodeProperties_Failed, hr );
  292. goto Cleanup;
  293. } // if:
  294. sc = TW32( m_cplNodeRO.ScGetNodeProperties( m_hNode, CLUSCTL_NODE_GET_RO_COMMON_PROPERTIES ) );
  295. if ( sc != ERROR_SUCCESS )
  296. {
  297. hr = HRESULT_FROM_WIN32( sc );
  298. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_HrInit_ScGetNodeProperties_Failed, hr );
  299. goto Cleanup;
  300. } // if:
  301. Cleanup:
  302. TraceSysFreeString( bstrName );
  303. HRETURN( hr );
  304. InvalidArg:
  305. hr = THR( E_INVALIDARG );
  306. goto Cleanup;
  307. OutOfMemory:
  308. hr = E_OUTOFMEMORY;
  309. goto Cleanup;
  310. } //*** CProxyCfgNodeInfo::HrInit()
  311. //*************************************************************************//
  312. /////////////////////////////////////////////////////////////////////////////
  313. // CProxyCfgNodeInfo -- IUknkown interface.
  314. /////////////////////////////////////////////////////////////////////////////
  315. //////////////////////////////////////////////////////////////////////////////
  316. //++
  317. //
  318. // CProxyCfgNodeInfo:: [INKNOWN] QueryInterface()
  319. //
  320. // Description:
  321. // Query this object for the passed in interface.
  322. //
  323. // Arguments:
  324. // IN REFIID riid,
  325. // Id of interface requested.
  326. //
  327. // OUT void ** ppv
  328. // Pointer to the requested interface.
  329. //
  330. // Return Value:
  331. // S_OK
  332. // If the interface is available on this object.
  333. //
  334. // E_NOINTERFACE
  335. // If the interface is not available.
  336. //
  337. // Remarks:
  338. // None.
  339. //
  340. //--
  341. //////////////////////////////////////////////////////////////////////////////
  342. STDMETHODIMP
  343. CProxyCfgNodeInfo::QueryInterface(
  344. REFIID riid,
  345. LPVOID *ppv
  346. )
  347. {
  348. TraceQIFunc( riid, ppv );
  349. HRESULT hr = E_NOINTERFACE;
  350. if ( IsEqualIID( riid, IID_IUnknown ) )
  351. {
  352. *ppv = static_cast< IClusCfgNodeInfo * >( this );
  353. hr = S_OK;
  354. } // if: IUnknown
  355. else if ( IsEqualIID( riid, IID_IClusCfgNodeInfo ) )
  356. {
  357. *ppv = TraceInterface( __THISCLASS__, IClusCfgNodeInfo, this, 0 );
  358. hr = S_OK;
  359. } // else if:
  360. if ( SUCCEEDED( hr ) )
  361. {
  362. ((IUnknown*) *ppv)->AddRef();
  363. } // if: success
  364. QIRETURN_IGNORESTDMARSHALLING( hr, riid );
  365. } //*** CConfigClusApi::QueryInterface()
  366. //////////////////////////////////////////////////////////////////////////////
  367. //++
  368. //
  369. // STDMETHODIMP_( ULONG )
  370. // CProxyCfgNodeInfo:: [IUNKNOWN] AddRef()
  371. //
  372. // Description:
  373. // Increment the reference count of this object by one.
  374. //
  375. // Arguments:
  376. // None.
  377. //
  378. // Return Value:
  379. // The new reference count.
  380. //
  381. // Remarks:
  382. // None.
  383. //
  384. //--
  385. //////////////////////////////////////////////////////////////////////////////
  386. STDMETHODIMP_(ULONG)
  387. CProxyCfgNodeInfo::AddRef( void )
  388. {
  389. TraceFunc( "[IUnknown]" );
  390. InterlockedIncrement( &m_cRef );
  391. RETURN( m_cRef );
  392. } //*** CProxyCfgNodeInfo::AddRef()
  393. //////////////////////////////////////////////////////////////////////////////
  394. //++
  395. //
  396. // STDMETHODIMP_( ULONG )
  397. // CProxyCfgNodeInfo:: [IUNKNOWN] Release()
  398. //
  399. // Description:
  400. // Decrement the reference count of this object by one.
  401. //
  402. // Arguments:
  403. // None.
  404. //
  405. // Return Value:
  406. // The new reference count.
  407. //
  408. // Remarks:
  409. // None.
  410. //
  411. //--
  412. //////////////////////////////////////////////////////////////////////////////
  413. STDMETHODIMP_(ULONG)
  414. CProxyCfgNodeInfo::Release( void )
  415. {
  416. TraceFunc( "[IUnknown]" );
  417. InterlockedDecrement( &m_cRef );
  418. if ( m_cRef )
  419. RETURN( m_cRef );
  420. TraceDo( delete this );
  421. RETURN( 0 );
  422. } //*** CProxyCfgNodeInfo::Release()
  423. //*************************************************************************//
  424. /////////////////////////////////////////////////////////////////////////////
  425. // CProxyCfgNodeInfo -- IClusCfgNodeInfo interface.
  426. /////////////////////////////////////////////////////////////////////////////
  427. //
  428. //
  429. //
  430. STDMETHODIMP
  431. CProxyCfgNodeInfo::GetClusterConfigInfo(
  432. IClusCfgClusterInfo ** ppClusCfgClusterInfoOut
  433. )
  434. {
  435. TraceFunc( "[IClusCfgNodeInfo]" );
  436. HRESULT hr;
  437. IUnknown * punk = NULL;
  438. //
  439. // Check parameters.
  440. //
  441. if ( ppClusCfgClusterInfoOut == NULL )
  442. goto InvalidPointer;
  443. //
  444. // Create the cluster object
  445. //
  446. hr = THR( CProxyCfgClusterInfo::S_HrCreateInstance( &punk,
  447. m_punkOuter,
  448. m_phCluster,
  449. m_pclsidMajor,
  450. m_bstrDomain
  451. ) );
  452. if ( FAILED( hr ) )
  453. {
  454. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterConfigInfo_Create_CProxyCfgClusterInfo_Failed, hr );
  455. goto Cleanup;
  456. } // if:
  457. //
  458. // QI for the return interface.
  459. //
  460. hr = THR( punk->TypeSafeQI( IClusCfgClusterInfo, ppClusCfgClusterInfoOut ) );
  461. if ( FAILED( hr ) )
  462. {
  463. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterConfigInfo_QI_Failed, hr );
  464. goto Cleanup;
  465. }
  466. Cleanup:
  467. if ( punk != NULL )
  468. {
  469. punk->Release();
  470. } // if:
  471. HRETURN( hr );
  472. InvalidPointer:
  473. hr = THR( E_POINTER );
  474. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterConfigInfo_InvalidPointer, hr );
  475. goto Cleanup;
  476. } //*** CProxyCfgNodeInfo::GetClusterConfigInfo()
  477. //
  478. //
  479. //
  480. STDMETHODIMP
  481. CProxyCfgNodeInfo::GetOSVersion(
  482. DWORD * pdwMajorVersionOut,
  483. DWORD * pdwMinorVersionOut,
  484. WORD * pwSuiteMaskOut,
  485. BYTE * pbProductTypeOut,
  486. BSTR * pbstrCSDVersionOut
  487. )
  488. {
  489. TraceFunc( "[IClusCfgNodeInfo]" );
  490. HRESULT hr;
  491. DWORD sc;
  492. //
  493. // Check parameters.
  494. //
  495. if ( pdwMajorVersionOut == NULL )
  496. goto InvalidPointer;
  497. if ( pdwMinorVersionOut == NULL )
  498. goto InvalidPointer;
  499. if ( pwSuiteMaskOut == NULL )
  500. goto InvalidPointer;
  501. if ( pbProductTypeOut == NULL )
  502. goto InvalidPointer;
  503. if ( pbstrCSDVersionOut == NULL )
  504. goto InvalidPointer;
  505. //
  506. // "Major Version"
  507. //
  508. sc = TW32( m_cplNodeRO.ScMoveToPropertyByName( L"MajorVersion" ) );
  509. if ( sc != ERROR_SUCCESS )
  510. {
  511. hr = HRESULT_FROM_WIN32( sc );
  512. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetOSVersion_ScMoveToPropertyByName_MajorVersion_Failed, hr );
  513. goto Cleanup;
  514. } // if:
  515. Assert( m_cplNodeRO.CbhCurrentValue( ).pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_DWORD );
  516. *pdwMajorVersionOut = *m_cplNodeRO.CbhCurrentValue( ).pdw;
  517. //
  518. // "Minor Version"
  519. //
  520. sc = TW32( m_cplNodeRO.ScMoveToPropertyByName( L"MinorVersion" ) );
  521. if ( sc != ERROR_SUCCESS )
  522. {
  523. hr = HRESULT_FROM_WIN32( sc );
  524. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetOSVersion_ScMoveToPropertyByName_MinorVersion_Failed, hr );
  525. goto Cleanup;
  526. } // if:
  527. Assert( m_cplNodeRO.CbhCurrentValue( ).pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_DWORD );
  528. *pdwMinorVersionOut = *m_cplNodeRO.CbhCurrentValue( ).pdw;
  529. //
  530. // "CSD Version"
  531. //
  532. sc = TW32( m_cplNodeRO.ScMoveToPropertyByName( L"CSDVersion" ) );
  533. if ( sc != ERROR_SUCCESS )
  534. {
  535. hr = HRESULT_FROM_WIN32( sc );
  536. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetOSVersion_ScMoveToPropertyByName_CSDVersion_Failed, hr );
  537. goto Cleanup;
  538. } // if:
  539. Assert( m_cplNodeRO.CbhCurrentValue( ).pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  540. *pbstrCSDVersionOut = SysAllocString( m_cplNodeRO.CbhCurrentValue( ).pStringValue->sz );
  541. if ( *pbstrCSDVersionOut == NULL )
  542. goto OutOfMemory;
  543. //
  544. // Stuff we can't gather (yet?)
  545. //
  546. *pwSuiteMaskOut = 0;
  547. *pbProductTypeOut = 0;
  548. hr = S_OK;
  549. Cleanup:
  550. HRETURN( hr );
  551. InvalidPointer:
  552. hr = THR( E_POINTER );
  553. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetOSVersion_InvalidPointer, hr );
  554. goto Cleanup;
  555. OutOfMemory:
  556. hr = E_OUTOFMEMORY;
  557. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetOSVersion_OutOfMemory, hr );
  558. goto Cleanup;
  559. } //*** CProxyCfgNodeInfo::GetOSVersion()
  560. //
  561. //
  562. //
  563. STDMETHODIMP
  564. CProxyCfgNodeInfo::GetName(
  565. BSTR * pbstrNameOut
  566. )
  567. {
  568. TraceFunc( "[IClusCfgNodeInfo]" );
  569. HRESULT hr = S_OK;
  570. DWORD sc;
  571. if ( pbstrNameOut == NULL )
  572. goto InvalidPointer;
  573. sc = TW32( m_cplNodeRO.ScMoveToPropertyByName( L"NodeName" ) );
  574. if ( sc != ERROR_SUCCESS )
  575. {
  576. hr = HRESULT_FROM_WIN32( sc );
  577. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetOSVersion_ScMoveToPropertyByName_MinorVersion_Failed, hr );
  578. goto Cleanup;
  579. } // if:
  580. Assert( m_cplNodeRO.CbhCurrentValue( ).pSyntax->dw == CLUSPROP_SYNTAX_LIST_VALUE_SZ );
  581. *pbstrNameOut = SysAllocString( m_cplNodeRO.CbhCurrentValue( ).pStringValue->sz );
  582. if ( *pbstrNameOut == NULL )
  583. goto OutOfMemory;
  584. Cleanup:
  585. HRETURN( hr );
  586. InvalidPointer:
  587. hr = THR( E_POINTER );
  588. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2kProxy_NodeInfo_GetName_InvalidPointer, hr );
  589. goto Cleanup;
  590. OutOfMemory:
  591. hr = E_OUTOFMEMORY;
  592. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_W2KProxy_NodeInfo_GetName_OutOfMemory, hr );
  593. goto Cleanup;
  594. } //*** CProxyCfgNodeInfo::GetName()
  595. //
  596. //
  597. //
  598. STDMETHODIMP
  599. CProxyCfgNodeInfo::IsMemberOfCluster( void )
  600. {
  601. TraceFunc( "[IClusCfgNodeInfo]" );
  602. HRESULT hr = S_OK;
  603. HRETURN( hr );
  604. } //*** CProxyCfgNodeInfo::IsMemberOfCluster()
  605. //
  606. //
  607. //
  608. STDMETHODIMP
  609. CProxyCfgNodeInfo::GetClusterVersion(
  610. DWORD * pdwNodeHighestVersionOut,
  611. DWORD * pdwNodeLowestVersionOut
  612. )
  613. {
  614. TraceFunc( "[IClusCfgNodeInfo]" );
  615. HRESULT hr = S_OK;
  616. BSTR bstrClusterName = NULL;
  617. CLUSTERVERSIONINFO ClusInfo;
  618. if ( pdwNodeHighestVersionOut == NULL )
  619. goto InvalidPointer;
  620. if ( pdwNodeLowestVersionOut == NULL )
  621. goto InvalidPointer;
  622. // Initialize variables.
  623. ClusInfo.dwVersionInfoSize = sizeof(CLUSTERVERSIONINFO);
  624. hr = THR( HrGetClusterInformation( *m_phCluster, &bstrClusterName, &ClusInfo ) );
  625. if ( FAILED( hr ) )
  626. {
  627. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterInformation_Failed, hr );
  628. goto Cleanup;
  629. }
  630. *pdwNodeHighestVersionOut = ClusInfo.dwClusterHighestVersion;
  631. *pdwNodeLowestVersionOut = ClusInfo.dwClusterLowestVersion;
  632. Cleanup:
  633. TraceSysFreeString( bstrClusterName );
  634. HRETURN( hr );
  635. InvalidPointer:
  636. hr = THR( E_POINTER );
  637. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetClusterVersion_InvalidPointer, hr );
  638. goto Cleanup;
  639. } //*** CProxyCfgNodeInfo::GetClusterVersion()
  640. //
  641. //
  642. //
  643. STDMETHODIMP
  644. CProxyCfgNodeInfo::GetDriveLetterMappings(
  645. SDriveLetterMapping * pdlmDriveLetterUsageOut
  646. )
  647. {
  648. TraceFunc( "[IClusCfgNodeInfo]" );
  649. HRESULT hr = S_OK;
  650. if ( pdlmDriveLetterUsageOut == NULL )
  651. goto InvalidPointer;
  652. //
  653. // NOTE: This really does not do anything (yet). Just clear the array.
  654. //
  655. ZeroMemory( pdlmDriveLetterUsageOut, sizeof(*pdlmDriveLetterUsageOut) );
  656. Cleanup:
  657. HRETURN( hr );
  658. InvalidPointer:
  659. hr = THR( E_POINTER );
  660. SSR_W2KPROXY_STATUS( TASKID_Major_Client_And_Server_Log, TASKID_Minor_GetDriveLetterMappings_InvalidPointer, hr );
  661. goto Cleanup;
  662. } //*** CProxyCfgNodeInfo::GetDriveLetterMappings()
  663. //
  664. //
  665. //
  666. STDMETHODIMP
  667. CProxyCfgNodeInfo::SetName( LPCWSTR pcszNameIn )
  668. {
  669. TraceFunc1( "[IClusCfgNodeInfo] pcszNameIn = '%ls'", pcszNameIn );
  670. HRESULT hr = S_FALSE;
  671. AssertMsg( FALSE, "Why is someone calling this?" );
  672. HRETURN( hr );
  673. } //*** CProxyCfgNodeInfo::SetName()
  674. //****************************************************************************
  675. //
  676. // IClusCfgCallback
  677. //
  678. //****************************************************************************
  679. //////////////////////////////////////////////////////////////////////////////
  680. //++
  681. //
  682. // CProxyCfgNodeInfo::SendStatusReport()
  683. //
  684. // Description:
  685. //
  686. // Arguments:
  687. //
  688. // Return Value:
  689. //
  690. // Remarks:
  691. // None.
  692. //
  693. //--
  694. //////////////////////////////////////////////////////////////////////////////
  695. STDMETHODIMP
  696. CProxyCfgNodeInfo::SendStatusReport(
  697. LPCWSTR pcszNodeNameIn
  698. , CLSID clsidTaskMajorIn
  699. , CLSID clsidTaskMinorIn
  700. , ULONG ulMinIn
  701. , ULONG ulMaxIn
  702. , ULONG ulCurrentIn
  703. , HRESULT hrStatusIn
  704. , LPCWSTR pcszDescriptionIn
  705. , FILETIME * pftTimeIn
  706. , LPCWSTR pcszReferenceIn
  707. )
  708. {
  709. TraceFunc( "[IClusCfgCallback]" );
  710. HRESULT hr = S_OK;
  711. if ( m_pcccb != NULL )
  712. {
  713. hr = THR( m_pcccb->SendStatusReport( pcszNodeNameIn,
  714. clsidTaskMajorIn,
  715. clsidTaskMinorIn,
  716. ulMinIn,
  717. ulMaxIn,
  718. ulCurrentIn,
  719. hrStatusIn,
  720. pcszDescriptionIn,
  721. pftTimeIn,
  722. pcszReferenceIn
  723. ) );
  724. } // if:
  725. HRETURN( hr );
  726. } //*** CProxyCfgNodeInfo::SendStatusReport()
  727. //****************************************************************************
  728. //
  729. // Privates
  730. //
  731. //****************************************************************************
  732. //
  733. //
  734. //
  735. DWORD
  736. CProxyCfgNodeInfo::DwEnumResourcesExCallback(
  737. HCLUSTER hClusterIn,
  738. HRESOURCE hResourceSelfIn,
  739. HRESOURCE hResourceIn,
  740. PVOID pvIn
  741. )
  742. {
  743. TraceFunc( "" );
  744. DWORD sc;
  745. DWORD dwFlags;
  746. DWORD cchName;
  747. CLUSTER_RESOURCE_STATE state;
  748. BSTR bstrName = NULL;
  749. CProxyCfgNodeInfo * pthis = reinterpret_cast< CProxyCfgNodeInfo * >( pvIn );
  750. sc = TW32( ClusterResourceControl( hResourceIn,
  751. NULL,
  752. CLUSCTL_RESOURCE_GET_FLAGS,
  753. NULL,
  754. 0,
  755. &dwFlags,
  756. sizeof(dwFlags),
  757. NULL
  758. ) );
  759. if ( sc != ERROR_SUCCESS )
  760. goto Cleanup;
  761. if ( !( dwFlags & CLUS_FLAG_CORE ) )
  762. {
  763. Assert( sc == ERROR_SUCCESS );
  764. goto Cleanup;
  765. }
  766. cchName = 64; // arbitary size
  767. bstrName = TraceSysAllocStringLen( NULL, cchName );
  768. if ( bstrName == NULL )
  769. goto OutOfMemory;
  770. cchName ++; // SysAllocStringLen allocate cchName + 1
  771. state = GetClusterResourceState( hResourceIn, bstrName, &cchName, NULL, NULL );
  772. if ( state == ClusterResourceStateUnknown )
  773. {
  774. sc = TW32( GetLastError( ) );
  775. if ( sc == ERROR_MORE_DATA )
  776. {
  777. TraceSysFreeString( bstrName );
  778. bstrName = TraceSysAllocStringLen( NULL, cchName );
  779. if ( bstrName == NULL )
  780. goto OutOfMemory;
  781. cchName ++; // SysAllocStringLen allocate cchName + 1
  782. state = GetClusterResourceState( hResourceIn, bstrName, &cchName, NULL, NULL );
  783. if ( state == ClusterResourceStateUnknown )
  784. {
  785. sc = TW32( GetLastError( ) );
  786. goto Cleanup;
  787. }
  788. }
  789. else
  790. {
  791. goto Cleanup;
  792. }
  793. }
  794. pthis->m_hNode = OpenClusterNode( hClusterIn, bstrName );
  795. if ( pthis->m_hNode == NULL )
  796. {
  797. sc = TW32( GetLastError( ) );
  798. goto Cleanup;
  799. }
  800. sc = ERROR_SUCCESS;
  801. Cleanup:
  802. TraceSysFreeString( bstrName );
  803. RETURN( sc );
  804. OutOfMemory:
  805. sc = ERROR_NOT_ENOUGH_MEMORY;
  806. goto Cleanup;
  807. }