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.

2776 lines
67 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1997-1999 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // PropList.cpp
  7. //
  8. // Description:
  9. // Implementation of the CClusPropList class.
  10. //
  11. // Author:
  12. // David Potter (davidp) February 24, 1997
  13. //
  14. // Revision History:
  15. // Galen Barbee (galenb) December 18, 1998
  16. // Added parsing methods.
  17. //
  18. // Notes:
  19. //
  20. /////////////////////////////////////////////////////////////////////////////
  21. #include "Pch.h"
  22. #include "proplist.tmh"
  23. #ifdef _DEBUG
  24. #ifdef __AFX_H__
  25. #define new DEBUG_NEW
  26. #undef THIS_FILE
  27. static char THIS_FILE[] = __FILE__;
  28. #endif // __AFX_H__
  29. #endif
  30. #ifndef __AFX_H__
  31. class CMemoryException
  32. {
  33. public:
  34. void Delete( void ) { }
  35. }; //*** class CMemoryException
  36. #endif // __AFX_H__
  37. /////////////////////////////////////////////////////////////////////////////
  38. // Constant Definitions
  39. /////////////////////////////////////////////////////////////////////////////
  40. const int BUFFER_GROWTH_FACTOR = 256;
  41. /////////////////////////////////////////////////////////////////////////////
  42. //++
  43. //
  44. // CchMultiSz
  45. //
  46. // Description:
  47. // Length of all of the substrings of a multisz string minus the final NULL.
  48. //
  49. // (i.e., includes the nulls of the substrings, excludes the final null)
  50. // multiszlen( "abcd\0efgh\0\0" => 5 + 5 = 10
  51. //
  52. // Arguments:
  53. // psz [IN] The string to get the length of.
  54. //
  55. // Return Value:
  56. // Count of characters in the multisz or 0 if empty.
  57. //
  58. //--
  59. /////////////////////////////////////////////////////////////////////////////
  60. static size_t CchMultiSz(
  61. IN LPCWSTR psz
  62. )
  63. {
  64. ASSERT( psz != NULL );
  65. size_t _cchTotal = 0;
  66. size_t _cchChars;
  67. while ( *psz != _T( '\0' ) )
  68. {
  69. _cchChars = lstrlenW( psz ) + 1;
  70. _cchTotal += _cchChars;
  71. psz += _cchChars;
  72. } // while: pointer not stopped on EOS
  73. return _cchTotal;
  74. } //*** CchMultiSz
  75. /////////////////////////////////////////////////////////////////////////////
  76. //++
  77. //
  78. // NCompareMultiSz
  79. //
  80. // Description:
  81. // Compare two MULTI_SZ buffers.
  82. //
  83. // Arguments:
  84. // pszSource [IN] The source string.
  85. // pszTarget [IN] The target string.
  86. //
  87. // Return Value:
  88. // If the string pointed to by pszSource is less than the string pointed
  89. // to by pszTarget, the return value is negative. If the string pointed
  90. // to by pszSource is greater than the string pointed to by pszTarget,
  91. // the return value is positive. If the strings are equal, the return value
  92. // is zero.
  93. //
  94. //--
  95. /////////////////////////////////////////////////////////////////////////////
  96. static int NCompareMultiSz(
  97. IN LPCWSTR pszSource,
  98. IN LPCWSTR pszTarget
  99. )
  100. {
  101. ASSERT( pszSource != NULL );
  102. ASSERT( pszTarget != NULL );
  103. while ( ( *pszSource != L'\0' ) && ( *pszTarget != L'\0') )
  104. {
  105. //
  106. // Move to end of strings.
  107. //
  108. while ( ( *pszSource != L'\0' ) && ( *pszTarget != L'\0') && ( *pszSource == *pszTarget ) )
  109. {
  110. ++pszSource;
  111. ++pszTarget;
  112. } // while: pointer not stopped on EOS
  113. //
  114. // If strings are the same, skip past terminating NUL.
  115. // Otherwise exit the loop.
  116. if ( ( *pszSource == L'\0' ) && ( *pszTarget == L'\0') )
  117. {
  118. ++pszSource;
  119. ++pszTarget;
  120. } // if: both stopped on EOS
  121. else
  122. {
  123. break;
  124. } // else: stopped because something is not equal -- wr are done.
  125. } // while: pointer not stopped on EOS
  126. return *pszSource - *pszTarget;
  127. } //*** NCompareMultiSz()
  128. //*************************************************************************//
  129. /////////////////////////////////////////////////////////////////////////////
  130. // CClusPropValueList class
  131. /////////////////////////////////////////////////////////////////////////////
  132. #ifdef __AFX_H__
  133. IMPLEMENT_DYNAMIC( CClusPropValueList, CObject );
  134. #endif // __AFX_H__
  135. /////////////////////////////////////////////////////////////////////////////
  136. //++
  137. //
  138. // CClusPropValueList::ScMoveToFirstValue
  139. //
  140. // Description:
  141. // Move the cursor to the first value in the value list.
  142. //
  143. // Arguments:
  144. // None.
  145. //
  146. // Return Value:
  147. // ERROR_SUCCESS Position moved to the first value successfully.
  148. //
  149. //--
  150. /////////////////////////////////////////////////////////////////////////////
  151. DWORD CClusPropValueList::ScMoveToFirstValue( void )
  152. {
  153. ASSERT( m_cbhValueList.pb != NULL );
  154. DWORD _sc;
  155. m_cbhCurrentValue = m_cbhValueList;
  156. m_cbDataLeft = m_cbDataSize;
  157. m_bAtEnd = FALSE;
  158. if ( m_cbhCurrentValue.pSyntax->dw == CLUSPROP_SYNTAX_ENDMARK )
  159. {
  160. _sc = ERROR_NO_MORE_ITEMS;
  161. } // if: no items in the value list
  162. else
  163. {
  164. _sc = ERROR_SUCCESS;
  165. } // else: items exist in the value list
  166. return _sc;
  167. } //*** CClusPropValueList::ScMoveToFirstValue()
  168. /////////////////////////////////////////////////////////////////////////////
  169. //++
  170. //
  171. // CClusPropValueList::ScMoveToNextValue
  172. //
  173. // Description:
  174. // Move the cursor to the next value in the list.
  175. //
  176. // Arguments:
  177. // None.
  178. //
  179. // Return Value:
  180. // ERROR_SUCCESS Position moved to the next value successfully.
  181. // ERROR_NO_MORE_ITEMS Already at the end of the list.
  182. // ERROR_INVALID_DATA Not enough data in the buffer.
  183. //
  184. //--
  185. /////////////////////////////////////////////////////////////////////////////
  186. DWORD CClusPropValueList::ScMoveToNextValue( void )
  187. {
  188. ASSERT( m_cbhCurrentValue.pb != NULL );
  189. DWORD _sc = ERROR_NO_MORE_ITEMS;
  190. DWORD _cbDataSize;
  191. CLUSPROP_BUFFER_HELPER _cbhCurrentValue;
  192. _cbhCurrentValue = m_cbhCurrentValue;
  193. do
  194. {
  195. //
  196. // Don't try to move if we're already at the end.
  197. //
  198. if ( m_bAtEnd )
  199. {
  200. break;
  201. } // if: already at the end of the list
  202. //
  203. // Make sure the buffer is big enough for the value header.
  204. //
  205. if ( m_cbDataLeft < sizeof( *_cbhCurrentValue.pValue ) )
  206. {
  207. _sc = ERROR_INVALID_DATA;
  208. break;
  209. } // if: not enough data left
  210. //
  211. // Calculate how much to advance buffer pointer.
  212. //
  213. _cbDataSize = sizeof( *_cbhCurrentValue.pValue )
  214. + ALIGN_CLUSPROP( _cbhCurrentValue.pValue->cbLength );
  215. //
  216. // Make sure the buffer is big enough for the value header,
  217. // the data itself, and the endmark.
  218. //
  219. if ( m_cbDataLeft < _cbDataSize + sizeof( CLUSPROP_SYNTAX ) )
  220. {
  221. _sc = ERROR_INVALID_DATA;
  222. break;
  223. } // if: not enough data left
  224. //
  225. // Move past the current value to the next value's syntax.
  226. //
  227. _cbhCurrentValue.pb += _cbDataSize;
  228. //
  229. // This test will ensure that the value is always valid since we won't
  230. // advance if the next thing is the endmark.
  231. //
  232. if ( _cbhCurrentValue.pSyntax->dw != CLUSPROP_SYNTAX_ENDMARK )
  233. {
  234. m_cbhCurrentValue = _cbhCurrentValue;
  235. m_cbDataLeft -= _cbDataSize;
  236. _sc = ERROR_SUCCESS;
  237. } // if: next value's syntax is not the endmark
  238. else
  239. {
  240. m_bAtEnd = TRUE;
  241. } // else: next value's syntax is the endmark
  242. } while ( 0 );
  243. return _sc;
  244. } //*** CClusPropValueList::ScMoveToNextValue()
  245. /////////////////////////////////////////////////////////////////////////////
  246. //++
  247. //
  248. // CClusPropValueList::ScCheckIfAtLastValue
  249. //
  250. // Description:
  251. // Indicate whether we are on the last value in the list or not.
  252. //
  253. // Arguments:
  254. // None.
  255. //
  256. // Return Value:
  257. // ERROR_SUCCESS Not currently at the last value in the list.
  258. // ERROR_NO_MORE_ITEMS Currently at the last value in the list.
  259. // ERROR_INVALID_DATA Not enough data in the buffer.
  260. //
  261. //--
  262. /////////////////////////////////////////////////////////////////////////////
  263. DWORD CClusPropValueList::ScCheckIfAtLastValue( void )
  264. {
  265. ASSERT( m_cbhCurrentValue.pb != NULL );
  266. DWORD _sc = ERROR_SUCCESS;
  267. CLUSPROP_BUFFER_HELPER _cbhCurrentValue;
  268. DWORD _cbDataSize;
  269. _cbhCurrentValue = m_cbhCurrentValue;
  270. do
  271. {
  272. //
  273. // Don't try to recalculate if we already know
  274. // we're at the end of the list.
  275. //
  276. if ( m_bAtEnd )
  277. {
  278. break;
  279. } // if: already at the end of the list
  280. //
  281. // Make sure the buffer is big enough for the value header.
  282. //
  283. if ( m_cbDataLeft < sizeof( *_cbhCurrentValue.pValue ) )
  284. {
  285. _sc = ERROR_INVALID_DATA;
  286. break;
  287. } // if: not enough data left
  288. //
  289. // Calculate how much to advance buffer pointer.
  290. //
  291. _cbDataSize = sizeof( *_cbhCurrentValue.pValue )
  292. + ALIGN_CLUSPROP( _cbhCurrentValue.pValue->cbLength );
  293. //
  294. // Make sure the buffer is big enough for the value header,
  295. // the data itself, and the endmark.
  296. //
  297. if ( m_cbDataLeft < _cbDataSize + sizeof( CLUSPROP_SYNTAX ) )
  298. {
  299. _sc = ERROR_INVALID_DATA;
  300. break;
  301. } // if: not enough data left
  302. //
  303. // Move past the current value to the next value's syntax.
  304. //
  305. _cbhCurrentValue.pb += _cbDataSize;
  306. //
  307. // We are on the last value if the next thing after this value
  308. // is an endmark.
  309. //
  310. if ( _cbhCurrentValue.pSyntax->dw == CLUSPROP_SYNTAX_ENDMARK )
  311. {
  312. _sc = ERROR_NO_MORE_ITEMS;
  313. } // if: next value's syntax is the endmark
  314. } while ( 0 );
  315. return _sc;
  316. } //*** CClusPropValueList::ScCheckIfAtLastValue()
  317. /////////////////////////////////////////////////////////////////////////////
  318. //++
  319. //
  320. // CClusPropValueList::ScAllocValueList
  321. //
  322. // Description:
  323. // Allocate a value list buffer that's big enough to hold the next
  324. // value.
  325. //
  326. // Arguments:
  327. // cbMinimum [IN] Minimum size of the value list.
  328. //
  329. // Return Value:
  330. // None.
  331. //
  332. // Exceptions Thrown:
  333. // Any exceptions thrown by new. By default, no exceptions are thrown.
  334. //
  335. //--
  336. /////////////////////////////////////////////////////////////////////////////
  337. DWORD CClusPropValueList::ScAllocValueList( IN DWORD cbMinimum )
  338. {
  339. ASSERT( cbMinimum > 0 );
  340. DWORD _sc = ERROR_SUCCESS;
  341. DWORD _cbTotal = 0;
  342. //
  343. // Add the size of the item count and final endmark.
  344. //
  345. cbMinimum += sizeof( CLUSPROP_VALUE );
  346. _cbTotal = m_cbDataSize + cbMinimum;
  347. if ( m_cbBufferSize < _cbTotal )
  348. {
  349. PBYTE _pbNewValuelist = NULL;
  350. cbMinimum = max( BUFFER_GROWTH_FACTOR, cbMinimum );
  351. _cbTotal = m_cbDataSize + cbMinimum;
  352. //
  353. // Allocate and zero a new buffer.
  354. //
  355. _pbNewValuelist = new BYTE[ _cbTotal ];
  356. if ( _pbNewValuelist != NULL )
  357. {
  358. ZeroMemory( _pbNewValuelist, _cbTotal );
  359. //
  360. // If there was a previous buffer, copy it and the delete it.
  361. //
  362. if ( m_cbhValueList.pb != NULL )
  363. {
  364. if ( m_cbDataSize != 0 )
  365. {
  366. CopyMemory( _pbNewValuelist, m_cbhValueList.pb, m_cbDataSize );
  367. } // if: data already exists in buffer
  368. delete [] m_cbhValueList.pb;
  369. m_cbhCurrentValue.pb = _pbNewValuelist + (m_cbhCurrentValue.pb - m_cbhValueList.pb);
  370. } // if: there was a previous buffer
  371. else
  372. {
  373. m_cbhCurrentValue.pb = _pbNewValuelist + sizeof( DWORD ); // move past prop count
  374. } // else: no previous buffer
  375. //
  376. // Save the new buffer.
  377. //
  378. m_cbhValueList.pb = _pbNewValuelist;
  379. m_cbBufferSize = _cbTotal;
  380. } // if: allocation succeeded
  381. else
  382. {
  383. _sc = ERROR_NOT_ENOUGH_MEMORY;
  384. } // else: allocation failed
  385. } // if: buffer isn't big enough
  386. return _sc;
  387. } //*** CClusPropValueList::ScAllocValueList()
  388. /////////////////////////////////////////////////////////////////////////////
  389. //++
  390. //
  391. // CClusPropValueList::ScGetResourceValueList
  392. //
  393. // Description:
  394. // Get value list of a resource.
  395. //
  396. // Arguments:
  397. // hResource [IN] Handle for the resource to get properties from.
  398. // dwControlCode [IN] Control code for the request.
  399. // hHostNode [IN] Handle for the node to direct this request to.
  400. // Defaults to NULL.
  401. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  402. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  403. //
  404. // Return Value:
  405. // None.
  406. //
  407. // Exceptions Thrown:
  408. // Any exceptions CClusPropValueList::ScAllocValueList().
  409. //
  410. //--
  411. /////////////////////////////////////////////////////////////////////////////
  412. DWORD CClusPropValueList::ScGetResourceValueList(
  413. IN HRESOURCE hResource,
  414. IN DWORD dwControlCode,
  415. IN HNODE hHostNode,
  416. IN LPVOID lpInBuffer,
  417. IN DWORD cbInBufferSize
  418. )
  419. {
  420. ASSERT( hResource != NULL );
  421. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  422. == (CLUS_OBJECT_RESOURCE << CLUSCTL_OBJECT_SHIFT) );
  423. DWORD _sc = ERROR_SUCCESS;
  424. DWORD _cb = 512;
  425. TracePrint(( "GetResourceValueList entry\n" ));
  426. //
  427. // Overwrite anything that may be in the buffer.
  428. // Allows this class instance to be reused.
  429. //
  430. m_cbDataSize = 0;
  431. //
  432. // Get values.
  433. //
  434. _sc = ScAllocValueList( _cb );
  435. if ( _sc == ERROR_SUCCESS )
  436. {
  437. _sc = ClusterResourceControl(
  438. hResource,
  439. hHostNode,
  440. dwControlCode,
  441. lpInBuffer,
  442. cbInBufferSize,
  443. m_cbhValueList.pb,
  444. m_cbBufferSize,
  445. &_cb
  446. );
  447. if ( _sc == ERROR_MORE_DATA )
  448. {
  449. _sc = ScAllocValueList( _cb );
  450. if ( _sc == ERROR_SUCCESS )
  451. {
  452. _sc = ClusterResourceControl(
  453. hResource,
  454. hHostNode,
  455. dwControlCode,
  456. lpInBuffer,
  457. cbInBufferSize,
  458. m_cbhValueList.pb,
  459. m_cbBufferSize,
  460. &_cb
  461. );
  462. } // if: ScAllocValueList succeeded
  463. } // if: buffer too small
  464. } // if: ScAllocValueList succeeded
  465. if ( _sc != ERROR_SUCCESS )
  466. {
  467. DeleteValueList();
  468. } // if: error getting properties.
  469. else
  470. {
  471. m_cbDataSize = _cb;
  472. m_cbDataLeft = _cb;
  473. } // else: no errors
  474. return _sc;
  475. } //*** CClusPropValueList::ScGetResourceValueList()
  476. /////////////////////////////////////////////////////////////////////////////
  477. //++
  478. //
  479. // CClusPropValueList::ScGetResourceTypeValueList
  480. //
  481. // Description:
  482. // Get value list of a resource type.
  483. //
  484. // Arguments:
  485. // hCluster [IN] Handle for the cluster in which the resource
  486. // type resides.
  487. // pwszResTypeName [IN] Name of the resource type.
  488. // dwControlCode [IN] Control code for the request.
  489. // hHostNode [IN] Handle for the node to direct this request to.
  490. // Defaults to NULL.
  491. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  492. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  493. //
  494. // Return Value:
  495. // None.
  496. //
  497. // Exceptions Thrown:
  498. // Any exceptions CClusPropValueList::ScAllocValueList().
  499. //
  500. //--
  501. /////////////////////////////////////////////////////////////////////////////
  502. DWORD CClusPropValueList::ScGetResourceTypeValueList(
  503. IN HCLUSTER hCluster,
  504. IN LPCWSTR pwszResTypeName,
  505. IN DWORD dwControlCode,
  506. IN HNODE hHostNode,
  507. IN LPVOID lpInBuffer,
  508. IN DWORD cbInBufferSize
  509. )
  510. {
  511. ASSERT( hCluster != NULL );
  512. ASSERT( pwszResTypeName != NULL );
  513. ASSERT( *pwszResTypeName != L'\0' );
  514. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  515. == (CLUS_OBJECT_RESOURCE_TYPE << CLUSCTL_OBJECT_SHIFT) );
  516. DWORD _sc = ERROR_SUCCESS;
  517. DWORD _cb = 512;
  518. TracePrint(( "GetResourceTypeValueList entry\n" ));
  519. //
  520. // Overwrite anything that may be in the buffer.
  521. // Allows this class instance to be reused.
  522. //
  523. m_cbDataSize = 0;
  524. //
  525. // Get values.
  526. //
  527. _sc = ScAllocValueList( _cb );
  528. if ( _sc == ERROR_SUCCESS )
  529. {
  530. _sc = ClusterResourceTypeControl(
  531. hCluster,
  532. pwszResTypeName,
  533. hHostNode,
  534. dwControlCode,
  535. lpInBuffer,
  536. cbInBufferSize,
  537. m_cbhValueList.pb,
  538. m_cbBufferSize,
  539. &_cb
  540. );
  541. if ( _sc == ERROR_MORE_DATA )
  542. {
  543. _sc = ScAllocValueList( _cb );
  544. if ( _sc == ERROR_SUCCESS )
  545. {
  546. _sc = ClusterResourceTypeControl(
  547. hCluster,
  548. pwszResTypeName,
  549. hHostNode,
  550. dwControlCode,
  551. lpInBuffer,
  552. cbInBufferSize,
  553. m_cbhValueList.pb,
  554. m_cbBufferSize,
  555. &_cb
  556. );
  557. } // if: ScAllocValueList succeeded
  558. } // if: buffer too small
  559. } // if: ScAllocValueList succeeded
  560. if ( _sc != ERROR_SUCCESS )
  561. {
  562. DeleteValueList();
  563. } // if: error getting properties.
  564. else
  565. {
  566. m_cbDataSize = _cb;
  567. m_cbDataLeft = _cb;
  568. } // else: no errors
  569. return _sc;
  570. } //*** CClusPropValueList::ScGetResourceTypeValueList()
  571. //*************************************************************************//
  572. /////////////////////////////////////////////////////////////////////////////
  573. // CClusPropList class
  574. /////////////////////////////////////////////////////////////////////////////
  575. #ifdef __AFX_H__
  576. IMPLEMENT_DYNAMIC( CClusPropList, CObject );
  577. #endif // __AFX_H__
  578. /////////////////////////////////////////////////////////////////////////////
  579. //++
  580. //
  581. // CClusPropList::ScCopy
  582. //
  583. // Description:
  584. // Copy a property list. This function is equivalent to an assignment
  585. // operator. Since this operation can fail, no assignment operator is
  586. // provided.
  587. //
  588. // Arguments:
  589. // pcplPropList [IN] The proplist to copy into this instance.
  590. // cbListSize [IN] The total size of the prop list.
  591. //
  592. // Return Value:
  593. // Win32 status code.
  594. //
  595. //--
  596. /////////////////////////////////////////////////////////////////////////////
  597. DWORD CClusPropList::ScCopy(
  598. IN const PCLUSPROP_LIST pcplPropList,
  599. IN DWORD cbListSize
  600. )
  601. {
  602. ASSERT( pcplPropList != NULL );
  603. DWORD _sc = ERROR_SUCCESS;
  604. //
  605. // Clean up any vestiges of a previous prop list.
  606. //
  607. if ( m_cbhPropList.pb != NULL )
  608. {
  609. DeletePropList();
  610. } // if: the current list is not empty
  611. //
  612. // Allocate the new property list buffer. If successful,
  613. // copy the source list.
  614. //
  615. m_cbhPropList.pb = new BYTE[ cbListSize ];
  616. if ( m_cbhPropList.pb != NULL )
  617. {
  618. CopyMemory( m_cbhPropList.pList, pcplPropList, cbListSize );
  619. m_cbBufferSize = cbListSize;
  620. m_cbDataSize = cbListSize;
  621. m_cbDataLeft = cbListSize;
  622. _sc = ScMoveToFirstProperty();
  623. } // if: new succeeded
  624. else
  625. {
  626. _sc = ERROR_NOT_ENOUGH_MEMORY;
  627. } // else:
  628. return _sc;
  629. } //*** CClusPropList::ScCopy()
  630. ////////////////////////////////////////////////////////////////////////////
  631. //++
  632. //
  633. // CClusPropList::ScMoveToFirstProperty
  634. //
  635. // Description:
  636. // Move the cursor to the first property in the list.
  637. //
  638. // Arguments:
  639. // None.
  640. //
  641. // Return Value:
  642. // ERROR_SUCCESS Position moved to the first property successfully.
  643. // ERROR_NO_MORE_ITEMS There are no properties in the list.
  644. // ERROR_INVALID_DATA Not enough data in the buffer.
  645. //
  646. //--
  647. /////////////////////////////////////////////////////////////////////////////
  648. DWORD CClusPropList::ScMoveToFirstProperty( void )
  649. {
  650. ASSERT( m_cbhPropList.pb != NULL );
  651. ASSERT( m_cbDataSize >= sizeof( m_cbhPropList.pList->nPropertyCount ) );
  652. DWORD _sc;
  653. DWORD _cbDataLeft;
  654. DWORD _cbDataSize;
  655. CLUSPROP_BUFFER_HELPER _cbhCurrentValue;
  656. TracePrint(( "MoveToFirstProperty: entry\n" ));
  657. do
  658. {
  659. //
  660. // Make sure the buffer is big enough for the list header.
  661. //
  662. if ( m_cbDataSize < sizeof( m_cbhPropList.pList->nPropertyCount ) )
  663. {
  664. _sc = ERROR_INVALID_DATA;
  665. break;
  666. } // if: not enough data
  667. //
  668. // Set the property counter to the number of properties in the list.
  669. //
  670. m_nPropsRemaining = m_cbhPropList.pList->nPropertyCount;
  671. //
  672. // Point the name pointer to the first name in the list.
  673. //
  674. m_cbhCurrentPropName.pName = &m_cbhPropList.pList->PropertyName;
  675. m_cbDataLeft = m_cbDataSize - sizeof( m_cbhPropList.pList->nPropertyCount );
  676. //
  677. // Check to see if there are any properties in the list.
  678. //
  679. if ( m_nPropsRemaining == 0 )
  680. {
  681. TracePrint(( "MoveToFirstProperty: no properties found!\n" ));
  682. _sc = ERROR_NO_MORE_ITEMS;
  683. break;
  684. } // if: no properties in the list
  685. //
  686. // Make sure the buffer is big enough for the first property name.
  687. //
  688. if ( m_cbDataLeft < sizeof( *m_cbhCurrentPropName.pName ) )
  689. {
  690. _sc = ERROR_INVALID_DATA;
  691. break;
  692. } // if: not enough data left
  693. //
  694. // Calculate how much to advance the buffer pointer.
  695. //
  696. _cbDataSize = sizeof( *m_cbhCurrentPropName.pName )
  697. + ALIGN_CLUSPROP( m_cbhCurrentPropName.pName->cbLength );
  698. //
  699. // Make sure the buffer is big enough for the name header
  700. // and the data itself.
  701. //
  702. if ( m_cbDataLeft < _cbDataSize )
  703. {
  704. _sc = ERROR_INVALID_DATA;
  705. break;
  706. } // if: not enough data left
  707. //
  708. // Point the value buffer to the first value in the list.
  709. //
  710. //TracePrint(( "MoveToFirstProperty: First Property Name = %ws, props remain = %u\n", _cbhCurrentValue.pStringValue->sz, m_nPropsRemaining ));
  711. _cbhCurrentValue.pb = m_cbhCurrentPropName.pb + _cbDataSize;
  712. _cbDataLeft = m_cbDataLeft - _cbDataSize;
  713. m_pvlValues.Init( _cbhCurrentValue, _cbDataLeft );
  714. //
  715. // Indicate we are successful.
  716. //
  717. _sc = ERROR_SUCCESS;
  718. } while ( 0 );
  719. //_cbhCurrentValue = m_pvlValues;
  720. //TracePrint(( "MoveToFirstProperty: First Property Name = %ws, props remain = %u\n", _cbhCurrentValue.pStringValue->sz, m_nPropsRemaining ));
  721. TracePrint(( "MoveToFirstProperty: exit\n" ));
  722. return _sc;
  723. } //*** CClusPropList::ScMoveToFirstProperty
  724. /////////////////////////////////////////////////////////////////////////////
  725. //++
  726. //
  727. // CClusPropList::ScMoveToNextProperty
  728. //
  729. // Description:
  730. // Move the cursor to the next property in the list.
  731. //
  732. // Arguments:
  733. // None.
  734. //
  735. // Return Value:
  736. // ERROR_SUCCESS Position moved to the next property successfully.
  737. // ERROR_NO_MORE_ITEMS Already at the end of the list.
  738. // ERROR_INVALID_DATA Not enough data in the buffer.
  739. //
  740. //--
  741. /////////////////////////////////////////////////////////////////////////////
  742. DWORD CClusPropList::ScMoveToNextProperty( void )
  743. {
  744. ASSERT( m_cbhPropList.pb != NULL );
  745. ASSERT( m_pvlValues.CbhValueList().pb != NULL );
  746. DWORD _sc;
  747. DWORD _cbNameSize;
  748. DWORD _cbDataLeft;
  749. DWORD _cbDataSize;
  750. CLUSPROP_BUFFER_HELPER _cbhCurrentValue;
  751. CLUSPROP_BUFFER_HELPER _cbhPropName;
  752. _cbhCurrentValue = m_pvlValues;
  753. _cbDataLeft = m_pvlValues.CbDataLeft();
  754. //TracePrint(( "CClusPropList:ScMoveToNextProperty entry\n" ));
  755. //
  756. // If we aren't already at the last property, attempt to move to the next one.
  757. //
  758. _sc = ScCheckIfAtLastProperty();
  759. if ( _sc == ERROR_SUCCESS )
  760. {
  761. do
  762. {
  763. //
  764. // Make sure the buffer is big enough for the value header.
  765. //
  766. if ( _cbDataLeft < sizeof( *_cbhCurrentValue.pValue ) )
  767. {
  768. _sc = ERROR_INVALID_DATA;
  769. break;
  770. } // if: not enough data left
  771. //
  772. // Careful! Add offset only to cbhCurrentValue.pb. Otherwise
  773. // pointer arithmetic will give undesirable results.
  774. //
  775. while ( _cbhCurrentValue.pSyntax->dw != CLUSPROP_SYNTAX_ENDMARK )
  776. {
  777. //
  778. // Make sure the buffer is big enough for the value
  779. // and an endmark.
  780. //
  781. _cbDataSize = sizeof( *_cbhCurrentValue.pValue )
  782. + ALIGN_CLUSPROP( _cbhCurrentValue.pValue->cbLength );
  783. if ( _cbDataLeft < _cbDataSize + sizeof( *_cbhCurrentValue.pSyntax ) )
  784. {
  785. _sc = ERROR_INVALID_DATA;
  786. break;
  787. } // if: not enough data left
  788. //
  789. // Advance past the value.
  790. //
  791. _cbhCurrentValue.pb += _cbDataSize;
  792. _cbDataLeft -= _cbDataSize;
  793. } // while: not at endmark
  794. if ( _sc != ERROR_SUCCESS )
  795. {
  796. break;
  797. } // if: error occurred in loop
  798. //
  799. // Advanced past the endmark.
  800. // Size check already performed in above loop.
  801. //
  802. _cbDataSize = sizeof( *_cbhCurrentValue.pSyntax );
  803. _cbhCurrentValue.pb += _cbDataSize;
  804. _cbDataLeft -= _cbDataSize;
  805. //
  806. // Point the name pointer to the next name in the list.
  807. //
  808. _cbhPropName = _cbhCurrentValue;
  809. //TracePrint(( "MoveToNextProperty: name = %ws\n", _cbhPropName.pStringValue->sz ));
  810. ASSERT( _cbDataLeft == m_cbDataSize - (_cbhPropName.pb - m_cbhPropList.pb) );
  811. //
  812. // Calculate the size of the name with header.
  813. // Make sure the buffer is big enough for the name and an endmark.
  814. //
  815. if ( _cbDataLeft < sizeof( *_cbhPropName.pName ) )
  816. {
  817. _sc = ERROR_INVALID_DATA;
  818. break;
  819. } // if: not enough data
  820. _cbNameSize = sizeof( *_cbhPropName.pName )
  821. + ALIGN_CLUSPROP( _cbhPropName.pName->cbLength );
  822. if ( _cbDataLeft < _cbNameSize + sizeof( CLUSPROP_SYNTAX ) )
  823. {
  824. _sc = ERROR_INVALID_DATA;
  825. break;
  826. } // if: not enough data
  827. //
  828. // Point the value buffer to the first value in the list.
  829. //
  830. _cbhCurrentValue.pb = _cbhPropName.pb + _cbNameSize;
  831. m_cbhCurrentPropName = _cbhPropName;
  832. m_cbDataLeft = _cbDataLeft - _cbNameSize;
  833. m_pvlValues.Init( _cbhCurrentValue, m_cbDataLeft );
  834. //
  835. // We've successfully advanced to the next property,
  836. // so there is now one fewer property remaining.
  837. //
  838. --m_nPropsRemaining;
  839. ASSERT( m_nPropsRemaining >= 1 );
  840. _sc = ERROR_SUCCESS;
  841. } while ( 0 );
  842. } // if: not at last property
  843. return _sc;
  844. } //*** CClusPropList::ScMoveToNextProperty()
  845. /////////////////////////////////////////////////////////////////////////////
  846. //++
  847. //
  848. // CClusPropList::ScMoveToPropertyByName
  849. //
  850. // Description:
  851. // Find the passed in property name in the proplist. Note that the
  852. // cursor is reset to the beginning at the beginning of the routine and
  853. // the current state of the cursor is lost.
  854. //
  855. // Arguments:
  856. // pwszPropName [IN] Name of the property
  857. //
  858. // Return Value:
  859. // TRUE if the property was found, FALSE if not.
  860. //
  861. //--
  862. /////////////////////////////////////////////////////////////////////////////
  863. DWORD CClusPropList::ScMoveToPropertyByName( IN LPCWSTR pwszPropName )
  864. {
  865. ASSERT( m_cbhPropList.pb != NULL );
  866. DWORD _sc;
  867. _sc = ScMoveToFirstProperty();
  868. if ( _sc == ERROR_SUCCESS )
  869. {
  870. do
  871. {
  872. //
  873. // See if this is the specified property. If so, we're done.
  874. //
  875. if ( lstrcmpiW( m_cbhCurrentPropName.pName->sz, pwszPropName ) == 0 )
  876. {
  877. break;
  878. } // if: property found
  879. //
  880. // Advance to the next property.
  881. //
  882. _sc = ScMoveToNextProperty();
  883. } while ( _sc == ERROR_SUCCESS ); // do-while: not end of list
  884. } // if: successfully moved to the first property
  885. return _sc;
  886. } //*** ClusPropList::ScMoveToPropertyByName( LPCWSTR )
  887. /////////////////////////////////////////////////////////////////////////////
  888. //++
  889. //
  890. // CClusPropList::ScAllocPropList
  891. //
  892. // Description:
  893. // Allocate a property list buffer that's big enough to hold the next
  894. // property.
  895. //
  896. // Arguments:
  897. // cbMinimum [IN] Minimum size of the property list.
  898. //
  899. // Return Value:
  900. // None.
  901. //
  902. // Exceptions Thrown:
  903. // Any exceptions thrown by new. By default, no exceptions are thrown.
  904. //
  905. //--
  906. /////////////////////////////////////////////////////////////////////////////
  907. DWORD CClusPropList::ScAllocPropList( IN DWORD cbMinimum )
  908. {
  909. ASSERT( cbMinimum > 0 );
  910. DWORD _sc = ERROR_SUCCESS;
  911. DWORD _cbTotal = 0;
  912. //
  913. // Add the size of the item count and final endmark.
  914. //
  915. cbMinimum += sizeof( CLUSPROP_VALUE );
  916. _cbTotal = m_cbDataSize + cbMinimum;
  917. if ( m_cbBufferSize < _cbTotal )
  918. {
  919. PBYTE _pbNewProplist = NULL;
  920. cbMinimum = max( BUFFER_GROWTH_FACTOR, cbMinimum );
  921. _cbTotal = m_cbDataSize + cbMinimum;
  922. //
  923. // Allocate and zero a new buffer.
  924. //
  925. _pbNewProplist = new BYTE[ _cbTotal ];
  926. if ( _pbNewProplist != NULL )
  927. {
  928. ZeroMemory( _pbNewProplist, _cbTotal );
  929. //
  930. // If there was a previous buffer, copy it and the delete it.
  931. //
  932. if ( m_cbhPropList.pb != NULL )
  933. {
  934. if ( m_cbDataSize != 0 )
  935. {
  936. CopyMemory( _pbNewProplist, m_cbhPropList.pb, m_cbDataSize );
  937. } // if: data already exists in buffer
  938. delete [] m_cbhPropList.pb;
  939. m_cbhCurrentProp.pb = _pbNewProplist + (m_cbhCurrentProp.pb - m_cbhPropList.pb);
  940. } // if: there was a previous buffer
  941. else
  942. {
  943. m_cbhCurrentProp.pb = _pbNewProplist + sizeof( DWORD ); // move past prop count
  944. } // else: no previous buffer
  945. //
  946. // Save the new buffer.
  947. //
  948. m_cbhPropList.pb = _pbNewProplist;
  949. m_cbBufferSize = _cbTotal;
  950. } // if: allocation succeeded
  951. else
  952. {
  953. _sc = ERROR_NOT_ENOUGH_MEMORY;
  954. } // else: allocation failed
  955. } // if: buffer isn't big enough
  956. return _sc;
  957. } //*** CClusPropList::ScAllocPropList()
  958. /////////////////////////////////////////////////////////////////////////////
  959. //++
  960. //
  961. // CClusPropList::ScAddProp
  962. //
  963. // Description:
  964. // Add a string property to a property list if it has changed.
  965. //
  966. // Arguments:
  967. // pwszName [IN] Name of the property.
  968. // pwszValue [IN] Value of the property to set in the list.
  969. // pwszPrevValue [IN] Previous value of the property.
  970. //
  971. // Return Value:
  972. // ERROR_SUCCESS or other Win32 error code.
  973. //
  974. //--
  975. /////////////////////////////////////////////////////////////////////////////
  976. DWORD CClusPropList::ScAddProp(
  977. IN LPCWSTR pwszName,
  978. IN LPCWSTR pwszValue,
  979. IN LPCWSTR pwszPrevValue
  980. )
  981. {
  982. ASSERT( pwszName != NULL );
  983. DWORD _sc = ERROR_SUCCESS;
  984. BOOL _bValuesDifferent = TRUE;
  985. PCLUSPROP_PROPERTY_NAME _pName;
  986. PCLUSPROP_SZ _pValue;
  987. if (( pwszPrevValue != NULL ) && ( lstrcmpW( pwszValue, pwszPrevValue ) == 0 ))
  988. {
  989. _bValuesDifferent = FALSE;
  990. } // if: we have a prev value and the values are the same
  991. //
  992. // If we should always add, or if the new value and the previous value
  993. // are not equal, add the property to the property list.
  994. //
  995. if ( m_bAlwaysAddProp || _bValuesDifferent )
  996. {
  997. DWORD _cbNameSize;
  998. DWORD _cbDataSize;
  999. DWORD _cbValueSize;
  1000. //
  1001. // Calculate sizes and make sure we have a property list.
  1002. //
  1003. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1004. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1005. _cbDataSize = (lstrlenW( pwszValue ) + 1) * sizeof( WCHAR );
  1006. _cbValueSize = sizeof( CLUSPROP_SZ )
  1007. + ALIGN_CLUSPROP( _cbDataSize )
  1008. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1009. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1010. if ( _sc == ERROR_SUCCESS )
  1011. {
  1012. //
  1013. // Set the property name.
  1014. //
  1015. _pName = m_cbhCurrentProp.pName;
  1016. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1017. m_cbhCurrentProp.pb += _cbNameSize;
  1018. //
  1019. // Set the property value.
  1020. //
  1021. _pValue = m_cbhCurrentProp.pStringValue;
  1022. CopyProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, pwszValue, _cbDataSize );
  1023. m_cbhCurrentProp.pb += _cbValueSize;
  1024. //
  1025. // Increment the property count and buffer size.
  1026. //
  1027. m_cbhPropList.pList->nPropertyCount++;
  1028. m_cbDataSize += _cbNameSize + _cbValueSize;
  1029. } // if: ScAllocPropList successfully grew the proplist
  1030. } // if: the value has changed
  1031. return _sc;
  1032. } //*** CClusPropList::ScAddProp( LPCWSTR )
  1033. /////////////////////////////////////////////////////////////////////////////
  1034. //++
  1035. //
  1036. // CClusPropList::ScAddMultiSzProp
  1037. //
  1038. // Description:
  1039. // Add a string property to a property list if it has changed.
  1040. //
  1041. // Arguments:
  1042. // pwszName [IN] Name of the property.
  1043. // pwszValue [IN] Value of the property to set in the list.
  1044. // pwszPrevValue [IN] Previous value of the property.
  1045. //
  1046. // Return Value:
  1047. // ERROR_SUCCESS or other Win32 error code.
  1048. //
  1049. //--
  1050. /////////////////////////////////////////////////////////////////////////////
  1051. DWORD CClusPropList::ScAddMultiSzProp(
  1052. IN LPCWSTR pwszName,
  1053. IN LPCWSTR pwszValue,
  1054. IN LPCWSTR pwszPrevValue
  1055. )
  1056. {
  1057. ASSERT( pwszName != NULL );
  1058. DWORD _sc = ERROR_SUCCESS;
  1059. BOOL _bValuesDifferent = TRUE;
  1060. PCLUSPROP_PROPERTY_NAME _pName;
  1061. PCLUSPROP_MULTI_SZ _pValue;
  1062. if ( ( pwszPrevValue != NULL ) && ( NCompareMultiSz( pwszValue, pwszPrevValue ) == 0 ) )
  1063. {
  1064. _bValuesDifferent = FALSE;
  1065. } // if: we have a prev value and the values are the same
  1066. //
  1067. // If we should always add, or if the new value and the previous value
  1068. // are not equal, add the property to the property list.
  1069. //
  1070. if ( m_bAlwaysAddProp || _bValuesDifferent )
  1071. {
  1072. DWORD _cbNameSize;
  1073. DWORD _cbDataSize;
  1074. DWORD _cbValueSize;
  1075. //
  1076. // Calculate sizes and make sure we have a property list.
  1077. //
  1078. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1079. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1080. _cbDataSize = (CchMultiSz( pwszValue ) + 1) * sizeof( WCHAR );
  1081. _cbValueSize = sizeof( CLUSPROP_SZ )
  1082. + ALIGN_CLUSPROP( _cbDataSize )
  1083. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1084. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1085. if ( _sc == ERROR_SUCCESS )
  1086. {
  1087. //
  1088. // Set the property name.
  1089. //
  1090. _pName = m_cbhCurrentProp.pName;
  1091. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1092. m_cbhCurrentProp.pb += _cbNameSize;
  1093. //
  1094. // Set the property value.
  1095. //
  1096. _pValue = m_cbhCurrentProp.pMultiSzValue;
  1097. CopyMultiSzProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, pwszValue, _cbDataSize );
  1098. m_cbhCurrentProp.pb += _cbValueSize;
  1099. //
  1100. // Increment the property count and buffer size.
  1101. //
  1102. m_cbhPropList.pList->nPropertyCount++;
  1103. m_cbDataSize += _cbNameSize + _cbValueSize;
  1104. } // if: ScAllocPropList successfully grew the proplist
  1105. } // if: the value has changed
  1106. return _sc;
  1107. } //*** CClusPropList::ScAddMultiSzProp( LPCWSTR )
  1108. /////////////////////////////////////////////////////////////////////////////
  1109. //++
  1110. //
  1111. // CClusPropList::ScAddExpandSzProp
  1112. //
  1113. // Description:
  1114. // Add an EXPAND_SZ string property to a property list if it has changed.
  1115. //
  1116. // Arguments:
  1117. // pwszName [IN] Name of the property.
  1118. // pwszValue [IN] Value of the property to set in the list.
  1119. // pwszPrevValue [IN] Previous value of the property.
  1120. //
  1121. // Return Value:
  1122. // None.
  1123. //
  1124. //--
  1125. /////////////////////////////////////////////////////////////////////////////
  1126. DWORD CClusPropList::ScAddExpandSzProp(
  1127. IN LPCWSTR pwszName,
  1128. IN LPCWSTR pwszValue,
  1129. IN LPCWSTR pwszPrevValue
  1130. )
  1131. {
  1132. ASSERT( pwszName != NULL );
  1133. DWORD _sc = ERROR_SUCCESS;
  1134. BOOL _bValuesDifferent = TRUE;
  1135. PCLUSPROP_PROPERTY_NAME _pName;
  1136. PCLUSPROP_SZ _pValue;
  1137. if ( ( pwszPrevValue != NULL ) && ( lstrcmpW( pwszValue, pwszPrevValue ) == 0 ) )
  1138. {
  1139. _bValuesDifferent = FALSE;
  1140. } // if: we have a prev value and the values are the same
  1141. //
  1142. // If we should always add, or if the new value and the previous value
  1143. // are not equal, add the property to the property list.
  1144. //
  1145. if ( m_bAlwaysAddProp || _bValuesDifferent )
  1146. {
  1147. DWORD _cbNameSize;
  1148. DWORD _cbDataSize;
  1149. DWORD _cbValueSize;
  1150. //
  1151. // Calculate sizes and make sure we have a property list.
  1152. //
  1153. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1154. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1155. _cbDataSize = (lstrlenW( pwszValue ) + 1) * sizeof( WCHAR );
  1156. _cbValueSize = sizeof( CLUSPROP_SZ )
  1157. + ALIGN_CLUSPROP( _cbDataSize )
  1158. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1159. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1160. if ( _sc == ERROR_SUCCESS )
  1161. {
  1162. //
  1163. // Set the property name.
  1164. //
  1165. _pName = m_cbhCurrentProp.pName;
  1166. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1167. m_cbhCurrentProp.pb += _cbNameSize;
  1168. //
  1169. // Set the property value.
  1170. //
  1171. _pValue = m_cbhCurrentProp.pStringValue;
  1172. CopyExpandSzProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, pwszValue, _cbDataSize );
  1173. m_cbhCurrentProp.pb += _cbValueSize;
  1174. //
  1175. // Increment the property count and buffer size.
  1176. //
  1177. m_cbhPropList.pList->nPropertyCount++;
  1178. m_cbDataSize += _cbNameSize + _cbValueSize;
  1179. } // if: ScAllocPropList successfully grew the proplist
  1180. } // if: the value has changed
  1181. return _sc;
  1182. } //*** CClusPropList::ScAddExpandSzProp( LPCWSTR )
  1183. /////////////////////////////////////////////////////////////////////////////
  1184. //++
  1185. //
  1186. // CClusPropList::ScAddProp
  1187. //
  1188. // Description:
  1189. // Add a DWORD property to a property list if it has changed.
  1190. //
  1191. // Arguments:
  1192. // pwszName [IN] Name of the property.
  1193. // nValue [IN] Value of the property to set in the list.
  1194. // nPrevValue [IN] Previous value of the property.
  1195. //
  1196. // Return Value:
  1197. // None.
  1198. //
  1199. //--
  1200. /////////////////////////////////////////////////////////////////////////////
  1201. DWORD CClusPropList::ScAddProp(
  1202. IN LPCWSTR pwszName,
  1203. IN DWORD nValue,
  1204. IN DWORD nPrevValue
  1205. )
  1206. {
  1207. ASSERT( pwszName != NULL );
  1208. DWORD _sc = ERROR_SUCCESS;
  1209. PCLUSPROP_PROPERTY_NAME _pName;
  1210. PCLUSPROP_DWORD _pValue;
  1211. if ( m_bAlwaysAddProp || ( nValue != nPrevValue ) )
  1212. {
  1213. DWORD _cbNameSize;
  1214. DWORD _cbValueSize;
  1215. //
  1216. // Calculate sizes and make sure we have a property list.
  1217. //
  1218. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1219. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1220. _cbValueSize = sizeof( CLUSPROP_DWORD )
  1221. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1222. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1223. if ( _sc == ERROR_SUCCESS )
  1224. {
  1225. //
  1226. // Set the property name.
  1227. //
  1228. _pName = m_cbhCurrentProp.pName;
  1229. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1230. m_cbhCurrentProp.pb += _cbNameSize;
  1231. //
  1232. // Set the property value.
  1233. //
  1234. _pValue = m_cbhCurrentProp.pDwordValue;
  1235. CopyProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, nValue );
  1236. m_cbhCurrentProp.pb += _cbValueSize;
  1237. //
  1238. // Increment the property count and buffer size.
  1239. //
  1240. m_cbhPropList.pList->nPropertyCount++;
  1241. m_cbDataSize += _cbNameSize + _cbValueSize;
  1242. } // if: ScAllocPropList successfully grew the proplist
  1243. } // if: the value has changed
  1244. return _sc;
  1245. } //*** CClusPropList::ScAddProp( DWORD )
  1246. #if CLUSAPI_VERSION >= 0x0500
  1247. /////////////////////////////////////////////////////////////////////////////
  1248. //++
  1249. //
  1250. // CClusPropList::ScAddProp
  1251. //
  1252. // Description:
  1253. // Add a LONG property to a property list if it has changed.
  1254. //
  1255. // Arguments:
  1256. // pwszName [IN] Name of the property.
  1257. // nValue [IN] Value of the property to set in the list.
  1258. // nPrevValue [IN] Previous value of the property.
  1259. //
  1260. // Return Value:
  1261. // None.
  1262. //
  1263. //--
  1264. /////////////////////////////////////////////////////////////////////////////
  1265. DWORD CClusPropList::ScAddProp(
  1266. IN LPCWSTR pwszName,
  1267. IN LONG nValue,
  1268. IN LONG nPrevValue
  1269. )
  1270. {
  1271. ASSERT( pwszName != NULL );
  1272. DWORD _sc = ERROR_SUCCESS;
  1273. PCLUSPROP_PROPERTY_NAME _pName;
  1274. PCLUSPROP_LONG _pValue;
  1275. if ( m_bAlwaysAddProp || ( nValue != nPrevValue ) )
  1276. {
  1277. DWORD _cbNameSize;
  1278. DWORD _cbValueSize;
  1279. //
  1280. // Calculate sizes and make sure we have a property list.
  1281. //
  1282. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1283. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1284. _cbValueSize = sizeof( CLUSPROP_LONG )
  1285. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1286. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1287. if ( _sc == ERROR_SUCCESS )
  1288. {
  1289. //
  1290. // Set the property name.
  1291. //
  1292. _pName = m_cbhCurrentProp.pName;
  1293. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1294. m_cbhCurrentProp.pb += _cbNameSize;
  1295. //
  1296. // Set the property value.
  1297. //
  1298. _pValue = m_cbhCurrentProp.pLongValue;
  1299. CopyProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, nValue );
  1300. m_cbhCurrentProp.pb += _cbValueSize;
  1301. //
  1302. // Increment the property count and buffer size.
  1303. //
  1304. m_cbhPropList.pList->nPropertyCount++;
  1305. m_cbDataSize += _cbNameSize + _cbValueSize;
  1306. } // if: ScAllocPropList successfully grew the proplist
  1307. } // if: the value has changed
  1308. return _sc;
  1309. } //*** CClusPropList::ScAddProp( LONG )
  1310. #endif // CLUSAPI_VERSION >= 0x0500
  1311. /////////////////////////////////////////////////////////////////////////////
  1312. //++
  1313. //
  1314. // CClusPropList::ScAddProp
  1315. //
  1316. // Description:
  1317. // Add a binary property to a property list if it has changed.
  1318. //
  1319. // Arguments:
  1320. // pwszName [IN] Name of the property.
  1321. // pbValue [IN] Value of the property to set in the list.
  1322. // cbValue [IN] Count of bytes in pbValue.
  1323. // pbPrevValue [IN] Previous value of the property.
  1324. // cbPrevValue [IN] Count of bytes in pbPrevValue.
  1325. //
  1326. // Return Value:
  1327. // None.
  1328. //
  1329. //--
  1330. /////////////////////////////////////////////////////////////////////////////
  1331. DWORD CClusPropList::ScAddProp(
  1332. IN LPCWSTR pwszName,
  1333. IN const PBYTE pbValue,
  1334. IN DWORD cbValue,
  1335. IN const PBYTE pbPrevValue,
  1336. IN DWORD cbPrevValue
  1337. )
  1338. {
  1339. ASSERT( pwszName != NULL );
  1340. DWORD _sc = ERROR_SUCCESS;
  1341. BOOL bChanged = FALSE;
  1342. PCLUSPROP_PROPERTY_NAME _pName;
  1343. PCLUSPROP_BINARY _pValue;
  1344. //
  1345. // Determine if the buffer has changed.
  1346. //
  1347. if ( m_bAlwaysAddProp || (cbValue != cbPrevValue) )
  1348. {
  1349. bChanged = TRUE;
  1350. } // if: always adding the property or the value size changed
  1351. else if ( ( cbValue != 0 ) && ( cbPrevValue != 0 ) )
  1352. {
  1353. bChanged = memcmp( pbValue, pbPrevValue, cbValue ) != 0;
  1354. } // else if: value length changed
  1355. if ( bChanged )
  1356. {
  1357. DWORD _cbNameSize;
  1358. DWORD _cbValueSize;
  1359. //
  1360. // Calculate sizes and make sure we have a property list.
  1361. //
  1362. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1363. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1364. _cbValueSize = sizeof( CLUSPROP_BINARY )
  1365. + ALIGN_CLUSPROP( cbValue )
  1366. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1367. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1368. if ( _sc == ERROR_SUCCESS )
  1369. {
  1370. //
  1371. // Set the property name.
  1372. //
  1373. _pName = m_cbhCurrentProp.pName;
  1374. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1375. m_cbhCurrentProp.pb += _cbNameSize;
  1376. //
  1377. // Set the property value.
  1378. //
  1379. _pValue = m_cbhCurrentProp.pBinaryValue;
  1380. CopyProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, pbValue, cbValue );
  1381. m_cbhCurrentProp.pb += _cbValueSize;
  1382. //
  1383. // Increment the property count and buffer size.
  1384. //
  1385. m_cbhPropList.pList->nPropertyCount++;
  1386. m_cbDataSize += _cbNameSize + _cbValueSize;
  1387. } // if: ScAllocPropList successfully grew the proplist
  1388. } // if: the value has changed
  1389. return _sc;
  1390. } //*** CClusPropList::ScAddProp( PBYTE )
  1391. /////////////////////////////////////////////////////////////////////////////
  1392. //++
  1393. //
  1394. // CClusPropList::ScAddProp
  1395. //
  1396. // Routine Description:
  1397. // Add a ULONGLONG property to a property list if it has changed.
  1398. //
  1399. // Arguments:
  1400. // pwszName [IN] Name of the property.
  1401. // ullValue [IN] Value of the property to set in the list.
  1402. // ullPrevValue [IN] Previous value of the property.
  1403. //
  1404. // Return Value:
  1405. // None.
  1406. //
  1407. //--
  1408. /////////////////////////////////////////////////////////////////////////////
  1409. DWORD CClusPropList::ScAddProp(
  1410. IN LPCWSTR pwszName,
  1411. IN ULONGLONG ullValue,
  1412. IN ULONGLONG ullPrevValue
  1413. )
  1414. {
  1415. ASSERT( pwszName != NULL );
  1416. DWORD _sc = ERROR_SUCCESS;
  1417. PCLUSPROP_PROPERTY_NAME _pName;
  1418. PCLUSPROP_ULARGE_INTEGER _pValue;
  1419. if ( m_bAlwaysAddProp || ( ullValue != ullPrevValue ) )
  1420. {
  1421. DWORD _cbNameSize;
  1422. DWORD _cbValueSize;
  1423. //
  1424. // Calculate sizes and make sure we have a property list.
  1425. //
  1426. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1427. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1428. _cbValueSize = sizeof( CLUSPROP_ULARGE_INTEGER )
  1429. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1430. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1431. if ( _sc == ERROR_SUCCESS )
  1432. {
  1433. //
  1434. // Set the property name.
  1435. //
  1436. _pName = m_cbhCurrentProp.pName;
  1437. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1438. m_cbhCurrentProp.pb += _cbNameSize;
  1439. //
  1440. // Set the property value.
  1441. //
  1442. _pValue = m_cbhCurrentProp.pULargeIntegerValue;
  1443. CopyProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, ullValue );
  1444. m_cbhCurrentProp.pb += _cbValueSize;
  1445. //
  1446. // Increment the property count and buffer size.
  1447. //
  1448. m_cbhPropList.pList->nPropertyCount++;
  1449. m_cbDataSize += _cbNameSize + _cbValueSize;
  1450. } // if: ScAllocPropList successfully grew the proplist
  1451. } // if: the value has changed
  1452. return _sc;
  1453. } //*** CClusPropList::ScAddProp( ULONGLONG )
  1454. /////////////////////////////////////////////////////////////////////////////
  1455. //++
  1456. //
  1457. // CClusPropList::ScSetPropToDefault
  1458. //
  1459. // Description:
  1460. // Add a property to the property list so that it will revert to its
  1461. // default value.
  1462. //
  1463. // Arguments:
  1464. // pwszName [IN] Name of the property.
  1465. // cpfPropFmt [IN] Format of property
  1466. //
  1467. // Return Value:
  1468. // None.
  1469. //
  1470. //--
  1471. /////////////////////////////////////////////////////////////////////////////
  1472. DWORD CClusPropList::ScSetPropToDefault(
  1473. IN LPCWSTR pwszName,
  1474. IN CLUSTER_PROPERTY_FORMAT cpfPropFmt
  1475. )
  1476. {
  1477. ASSERT( pwszName != NULL );
  1478. DWORD _sc = ERROR_SUCCESS;
  1479. DWORD _cbNameSize;
  1480. DWORD _cbValueSize;
  1481. PCLUSPROP_PROPERTY_NAME _pName;
  1482. PCLUSPROP_VALUE _pValue;
  1483. // Calculate sizes and make sure we have a property list.
  1484. _cbNameSize = sizeof( CLUSPROP_PROPERTY_NAME )
  1485. + ALIGN_CLUSPROP( (lstrlenW( pwszName ) + 1) * sizeof( WCHAR ) );
  1486. _cbValueSize = sizeof( CLUSPROP_BINARY )
  1487. + sizeof( CLUSPROP_SYNTAX ); // value list endmark
  1488. _sc = ScAllocPropList( _cbNameSize + _cbValueSize );
  1489. if ( _sc == ERROR_SUCCESS )
  1490. {
  1491. //
  1492. // Set the property name.
  1493. //
  1494. _pName = m_cbhCurrentProp.pName;
  1495. CopyProp( _pName, CLUSPROP_TYPE_NAME, pwszName );
  1496. m_cbhCurrentProp.pb += _cbNameSize;
  1497. //
  1498. // Set the property value.
  1499. //
  1500. _pValue = m_cbhCurrentProp.pValue;
  1501. CopyEmptyProp( _pValue, CLUSPROP_TYPE_LIST_VALUE, cpfPropFmt );
  1502. m_cbhCurrentProp.pb += _cbValueSize;
  1503. //
  1504. // Increment the property count and buffer size.
  1505. //
  1506. m_cbhPropList.pList->nPropertyCount++;
  1507. m_cbDataSize += _cbNameSize + _cbValueSize;
  1508. } // if:
  1509. return _sc;
  1510. } //*** CClusPropList::ScSetPropToDefault()
  1511. /////////////////////////////////////////////////////////////////////////////
  1512. //++
  1513. //
  1514. // CClusPropList::CopyProp
  1515. //
  1516. // Description:
  1517. // Copy a string property to a property structure.
  1518. //
  1519. // Arguments:
  1520. // pprop [OUT] Property structure to fill.
  1521. // cptPropType [IN] Type of string.
  1522. // psz [IN] String to copy.
  1523. // cbsz [IN] Count of bytes in pwsz string. If specified as 0,
  1524. // the the length will be determined by a call to strlen.
  1525. //
  1526. // Return Value:
  1527. // None.
  1528. //
  1529. //--
  1530. /////////////////////////////////////////////////////////////////////////////
  1531. void CClusPropList::CopyProp(
  1532. OUT PCLUSPROP_SZ pprop,
  1533. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1534. IN LPCWSTR psz,
  1535. IN size_t cbsz // = 0
  1536. )
  1537. {
  1538. ASSERT( pprop != NULL );
  1539. ASSERT( psz != NULL );
  1540. CLUSPROP_BUFFER_HELPER _cbhProps;
  1541. pprop->Syntax.wFormat = CLUSPROP_FORMAT_SZ;
  1542. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1543. if ( cbsz == 0 )
  1544. {
  1545. cbsz = (lstrlenW( psz ) + 1) * sizeof( WCHAR );
  1546. } // if: zero size specified
  1547. ASSERT( cbsz == (lstrlenW( psz ) + 1) * sizeof( WCHAR ) );
  1548. pprop->cbLength = cbsz;
  1549. lstrcpyW( pprop->sz, psz );
  1550. //
  1551. // Set an endmark.
  1552. //
  1553. _cbhProps.pStringValue = pprop;
  1554. _cbhProps.pb += sizeof( *_cbhProps.pStringValue ) + ALIGN_CLUSPROP( cbsz );
  1555. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1556. } //*** CClusPropList::CopyProp()
  1557. /////////////////////////////////////////////////////////////////////////////
  1558. //++
  1559. //
  1560. // CClusPropList::CopyMultiSzProp
  1561. //
  1562. // Description:
  1563. // Copy a MULTI_SZ string property to a property structure.
  1564. //
  1565. // Arguments:
  1566. // pprop [OUT] Property structure to fill.
  1567. // cptPropType [IN] Type of string.
  1568. // psz [IN] String to copy.
  1569. // cbsz [IN] Count of bytes in psz string. If specified as 0,
  1570. // the the length will be determined by calls to strlen.
  1571. //
  1572. // Return Value:
  1573. // None.
  1574. //
  1575. //--
  1576. /////////////////////////////////////////////////////////////////////////////
  1577. void CClusPropList::CopyMultiSzProp(
  1578. OUT PCLUSPROP_MULTI_SZ pprop,
  1579. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1580. IN LPCWSTR psz,
  1581. IN size_t cbsz
  1582. )
  1583. {
  1584. ASSERT( pprop != NULL );
  1585. ASSERT( psz != NULL );
  1586. CLUSPROP_BUFFER_HELPER _cbhProps;
  1587. pprop->Syntax.wFormat = CLUSPROP_FORMAT_MULTI_SZ;
  1588. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1589. if ( cbsz == 0 )
  1590. {
  1591. cbsz = (CchMultiSz( psz ) + 1) * sizeof( WCHAR );
  1592. } // if: zero size specified
  1593. ASSERT( cbsz == (CchMultiSz( psz ) + 1) * sizeof( WCHAR ) );
  1594. pprop->cbLength = cbsz;
  1595. CopyMemory( pprop->sz, psz, cbsz );
  1596. //
  1597. // Set an endmark.
  1598. //
  1599. _cbhProps.pMultiSzValue = pprop;
  1600. _cbhProps.pb += sizeof( *_cbhProps.pMultiSzValue ) + ALIGN_CLUSPROP( cbsz );
  1601. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1602. } //*** CClusPropList::CopyMultiSzProp()
  1603. /////////////////////////////////////////////////////////////////////////////
  1604. //++
  1605. //
  1606. // CClusPropList::CopyExpandSzProp
  1607. //
  1608. // Description:
  1609. // Copy an EXPAND_SZ string property to a property structure.
  1610. //
  1611. // Arguments:
  1612. // pprop [OUT] Property structure to fill.
  1613. // cptPropType [IN] Type of string.
  1614. // psz [IN] String to copy.
  1615. // cbsz [IN] Count of bytes in psz string.
  1616. //
  1617. // Return Value:
  1618. // None.
  1619. //
  1620. //--
  1621. /////////////////////////////////////////////////////////////////////////////
  1622. void CClusPropList::CopyExpandSzProp(
  1623. OUT PCLUSPROP_SZ pprop,
  1624. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1625. IN LPCWSTR psz,
  1626. IN size_t cbsz
  1627. )
  1628. {
  1629. ASSERT( pprop != NULL );
  1630. ASSERT( psz != NULL );
  1631. CLUSPROP_BUFFER_HELPER _cbhProps;
  1632. pprop->Syntax.wFormat = CLUSPROP_FORMAT_EXPAND_SZ;
  1633. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1634. if ( cbsz == 0 )
  1635. {
  1636. cbsz = (lstrlenW( psz ) + 1) * sizeof( WCHAR );
  1637. } // if: cbsz == 0
  1638. ASSERT( cbsz == (lstrlenW( psz ) + 1) * sizeof( WCHAR ) );
  1639. pprop->cbLength = cbsz;
  1640. lstrcpyW( pprop->sz, psz );
  1641. //
  1642. // Set an endmark.
  1643. //
  1644. _cbhProps.pStringValue = pprop;
  1645. _cbhProps.pb += sizeof( *_cbhProps.pStringValue ) + ALIGN_CLUSPROP( cbsz );
  1646. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1647. } //*** CClusPropList::CopyExpandSzProp()
  1648. /////////////////////////////////////////////////////////////////////////////
  1649. //++
  1650. //
  1651. // CClusPropList::CopyProp
  1652. //
  1653. // Description:
  1654. // Copy a DWORD property to a property structure.
  1655. //
  1656. // Arguments:
  1657. // pprop [OUT] Property structure to fill.
  1658. // cptPropType [IN] Type of DWORD.
  1659. // nValue [IN] Property value to copy.
  1660. //
  1661. // Return Value:
  1662. // None.
  1663. //
  1664. //--
  1665. /////////////////////////////////////////////////////////////////////////////
  1666. void CClusPropList::CopyProp(
  1667. OUT PCLUSPROP_DWORD pprop,
  1668. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1669. IN DWORD nValue
  1670. )
  1671. {
  1672. ASSERT( pprop != NULL );
  1673. CLUSPROP_BUFFER_HELPER _cbhProps;
  1674. pprop->Syntax.wFormat = CLUSPROP_FORMAT_DWORD;
  1675. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1676. pprop->cbLength = sizeof( DWORD );
  1677. pprop->dw = nValue;
  1678. //
  1679. // Set an endmark.
  1680. //
  1681. _cbhProps.pDwordValue = pprop;
  1682. _cbhProps.pb += sizeof( *_cbhProps.pDwordValue );
  1683. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1684. } //*** CClusPropList::CopyProp( DWORD )
  1685. #if CLUSAPI_VERSION >= 0x0500
  1686. /////////////////////////////////////////////////////////////////////////////
  1687. //++
  1688. //
  1689. // CClusPropList::CopyProp
  1690. //
  1691. // Description:
  1692. // Copy a LONG property to a property structure.
  1693. //
  1694. // Arguments:
  1695. // pprop [OUT] Property structure to fill.
  1696. // cptPropType [IN] Type of LONG.
  1697. // nValue [IN] Property value to copy.
  1698. //
  1699. // Return Value:
  1700. // None.
  1701. //
  1702. //--
  1703. /////////////////////////////////////////////////////////////////////////////
  1704. void CClusPropList::CopyProp(
  1705. OUT PCLUSPROP_LONG pprop,
  1706. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1707. IN LONG nValue
  1708. )
  1709. {
  1710. ASSERT( pprop != NULL );
  1711. CLUSPROP_BUFFER_HELPER _cbhProps;
  1712. pprop->Syntax.wFormat = CLUSPROP_FORMAT_LONG;
  1713. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1714. pprop->cbLength = sizeof( DWORD );
  1715. pprop->l = nValue;
  1716. //
  1717. // Set an endmark.
  1718. //
  1719. _cbhProps.pLongValue = pprop;
  1720. _cbhProps.pb += sizeof( *_cbhProps.pLongValue );
  1721. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1722. } //*** CClusPropList::CopyProp( LONG )
  1723. #endif // CLUSAPI_VERSION >= 0x0500
  1724. /////////////////////////////////////////////////////////////////////////////
  1725. //++
  1726. //
  1727. // CClusPropList::CopyProp
  1728. //
  1729. // Description:
  1730. // Copy a ULONGLONG property to a property structure.
  1731. //
  1732. // Arguments:
  1733. // pprop [OUT] Property structure to fill.
  1734. // proptype [IN] Type of LONG.
  1735. // nValue [IN] Property value to copy.
  1736. //
  1737. // Return Value:
  1738. // None.
  1739. //
  1740. //--
  1741. /////////////////////////////////////////////////////////////////////////////
  1742. void CClusPropList::CopyProp(
  1743. OUT PCLUSPROP_ULARGE_INTEGER pprop,
  1744. IN CLUSTER_PROPERTY_TYPE proptype,
  1745. IN ULONGLONG nValue
  1746. )
  1747. {
  1748. ASSERT( pprop != NULL );
  1749. CLUSPROP_BUFFER_HELPER _cbhProps;
  1750. pprop->Syntax.wFormat = CLUSPROP_FORMAT_ULARGE_INTEGER;
  1751. pprop->Syntax.wType = static_cast< WORD >( proptype );
  1752. pprop->cbLength = sizeof( ULONGLONG );
  1753. pprop->li.QuadPart = nValue;
  1754. //
  1755. // Set an endmark.
  1756. //
  1757. _cbhProps.pULargeIntegerValue = pprop;
  1758. _cbhProps.pb += sizeof( *_cbhProps.pULargeIntegerValue );
  1759. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1760. } //*** CClusPropList::CopyProp( ULONGLONG )
  1761. /////////////////////////////////////////////////////////////////////////////
  1762. //++
  1763. //
  1764. // CClusPropList::CopyProp
  1765. //
  1766. // Description:
  1767. // Copy a binary property to a property structure.
  1768. //
  1769. // Arguments:
  1770. // pprop [OUT] Property structure to fill.
  1771. // cptPropType [IN] Type of string.
  1772. // pb [IN] Block to copy.
  1773. // cbsz [IN] Count of bytes in pb buffer.
  1774. //
  1775. // Return Value:
  1776. // None.
  1777. //
  1778. //--
  1779. /////////////////////////////////////////////////////////////////////////////
  1780. void CClusPropList::CopyProp(
  1781. OUT PCLUSPROP_BINARY pprop,
  1782. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1783. IN const PBYTE pb,
  1784. IN size_t cb
  1785. )
  1786. {
  1787. ASSERT( pprop != NULL );
  1788. CLUSPROP_BUFFER_HELPER _cbhProps;
  1789. pprop->Syntax.wFormat = CLUSPROP_FORMAT_BINARY;
  1790. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1791. pprop->cbLength = cb;
  1792. if ( cb > 0 )
  1793. {
  1794. CopyMemory( pprop->rgb, pb, cb );
  1795. } // if: non-zero data length
  1796. //
  1797. // Set an endmark.
  1798. //
  1799. _cbhProps.pBinaryValue = pprop;
  1800. _cbhProps.pb += sizeof( *_cbhProps.pStringValue ) + ALIGN_CLUSPROP( cb );
  1801. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1802. } //*** CClusPropList::CopyProp( PBYTE )
  1803. /////////////////////////////////////////////////////////////////////////////
  1804. //++
  1805. //
  1806. // CClusPropList::CopyEmptyProp
  1807. //
  1808. // Description:
  1809. // Copy an empty property to a property structure.
  1810. //
  1811. // Arguments:
  1812. // pprop [OUT] Property structure to fill.
  1813. // cptPropType [IN] Type of property.
  1814. // cpfPropFmt [IN] Format of property.
  1815. //
  1816. // Return Value:
  1817. // None.
  1818. //
  1819. //--
  1820. /////////////////////////////////////////////////////////////////////////////
  1821. void CClusPropList::CopyEmptyProp(
  1822. OUT PCLUSPROP_VALUE pprop,
  1823. IN CLUSTER_PROPERTY_TYPE cptPropType,
  1824. IN CLUSTER_PROPERTY_FORMAT cptPropFmt
  1825. )
  1826. {
  1827. ASSERT( pprop != NULL );
  1828. CLUSPROP_BUFFER_HELPER _cbhProps;
  1829. pprop->Syntax.wFormat = static_cast< WORD >( cptPropFmt );
  1830. pprop->Syntax.wType = static_cast< WORD >( cptPropType );
  1831. pprop->cbLength = 0;
  1832. //
  1833. // Set an endmark.
  1834. //
  1835. _cbhProps.pValue = pprop;
  1836. _cbhProps.pb += sizeof( *_cbhProps.pValue );
  1837. _cbhProps.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  1838. } //*** CClusPropList::CopyEmptyProp()
  1839. /////////////////////////////////////////////////////////////////////////////
  1840. //++
  1841. //
  1842. // CClusPropList::ScGetNodeProperties
  1843. //
  1844. // Description:
  1845. // Get properties on a node.
  1846. //
  1847. // Arguments:
  1848. // hNode [IN] Handle for the node to get properties from.
  1849. // dwControlCode [IN] Control code for the request.
  1850. // hHostNode [IN] Handle for the node to direct this request to.
  1851. // Defaults to NULL.
  1852. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  1853. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  1854. //
  1855. // Return Value:
  1856. // None.
  1857. //
  1858. // Exceptions Thrown:
  1859. // Any exceptions CClusPropList::ScAllocPropList().
  1860. //
  1861. //--
  1862. /////////////////////////////////////////////////////////////////////////////
  1863. DWORD CClusPropList::ScGetNodeProperties(
  1864. IN HNODE hNode,
  1865. IN DWORD dwControlCode,
  1866. IN HNODE hHostNode,
  1867. IN LPVOID lpInBuffer,
  1868. IN DWORD cbInBufferSize
  1869. )
  1870. {
  1871. ASSERT( hNode != NULL );
  1872. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  1873. == (CLUS_OBJECT_NODE << CLUSCTL_OBJECT_SHIFT) );
  1874. DWORD _sc = ERROR_SUCCESS;
  1875. DWORD _cbProps = 256;
  1876. //
  1877. // Overwrite anything that may be in the buffer.
  1878. // Allows this class instance to be reused.
  1879. //
  1880. m_cbDataSize = 0;
  1881. //
  1882. // Get properties.
  1883. //
  1884. _sc = ScAllocPropList( _cbProps );
  1885. if ( _sc == ERROR_SUCCESS )
  1886. {
  1887. _sc = ClusterNodeControl(
  1888. hNode,
  1889. hHostNode,
  1890. dwControlCode,
  1891. lpInBuffer,
  1892. cbInBufferSize,
  1893. m_cbhPropList.pb,
  1894. m_cbBufferSize,
  1895. &_cbProps
  1896. );
  1897. if ( _sc == ERROR_MORE_DATA )
  1898. {
  1899. _sc = ScAllocPropList( _cbProps );
  1900. if ( _sc == ERROR_SUCCESS )
  1901. {
  1902. _sc = ClusterNodeControl(
  1903. hNode,
  1904. hHostNode,
  1905. dwControlCode,
  1906. lpInBuffer,
  1907. cbInBufferSize,
  1908. m_cbhPropList.pb,
  1909. m_cbBufferSize,
  1910. &_cbProps
  1911. );
  1912. } // if: ScAllocPropList succeeded
  1913. } // if: buffer too small
  1914. } // if: ScAllocPropList succeeded
  1915. if ( _sc != ERROR_SUCCESS )
  1916. {
  1917. DeletePropList();
  1918. } // if: error getting properties.
  1919. else
  1920. {
  1921. m_cbDataSize = _cbProps;
  1922. m_cbDataLeft = _cbProps;
  1923. } // else: no errors
  1924. return _sc;
  1925. } //*** CClusPropList::ScGetNodeProperties()
  1926. /////////////////////////////////////////////////////////////////////////////
  1927. //++
  1928. //
  1929. // CClusPropList::ScGetGroupProperties
  1930. //
  1931. // Description:
  1932. // Get properties on a group.
  1933. //
  1934. // Arguments:
  1935. // hGroup [IN] Handle for the group to get properties from.
  1936. // dwControlCode [IN] Control code for the request.
  1937. // hHostNode [IN] Handle for the node to direct this request to.
  1938. // Defaults to NULL.
  1939. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  1940. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  1941. //
  1942. // Return Value:
  1943. // None.
  1944. //
  1945. // Exceptions Thrown:
  1946. // Any exceptions CClusPropList::ScAllocPropList().
  1947. //
  1948. //--
  1949. /////////////////////////////////////////////////////////////////////////////
  1950. DWORD CClusPropList::ScGetGroupProperties(
  1951. IN HGROUP hGroup,
  1952. IN DWORD dwControlCode,
  1953. IN HNODE hHostNode,
  1954. IN LPVOID lpInBuffer,
  1955. IN DWORD cbInBufferSize
  1956. )
  1957. {
  1958. ASSERT( hGroup != NULL );
  1959. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  1960. == (CLUS_OBJECT_GROUP << CLUSCTL_OBJECT_SHIFT) );
  1961. DWORD _sc = ERROR_SUCCESS;
  1962. DWORD _cbProps = 256;
  1963. //
  1964. // Overwrite anything that may be in the buffer.
  1965. // Allows this class instance to be reused.
  1966. //
  1967. m_cbDataSize = 0;
  1968. //
  1969. // Get properties.
  1970. //
  1971. _sc = ScAllocPropList( _cbProps );
  1972. if ( _sc == ERROR_SUCCESS )
  1973. {
  1974. _sc = ClusterGroupControl(
  1975. hGroup,
  1976. hHostNode,
  1977. dwControlCode,
  1978. lpInBuffer,
  1979. cbInBufferSize,
  1980. m_cbhPropList.pb,
  1981. m_cbBufferSize,
  1982. &_cbProps
  1983. );
  1984. if ( _sc == ERROR_MORE_DATA )
  1985. {
  1986. _sc = ScAllocPropList( _cbProps );
  1987. if ( _sc == ERROR_SUCCESS )
  1988. {
  1989. _sc = ClusterGroupControl(
  1990. hGroup,
  1991. hHostNode,
  1992. dwControlCode,
  1993. lpInBuffer,
  1994. cbInBufferSize,
  1995. m_cbhPropList.pb,
  1996. m_cbBufferSize,
  1997. &_cbProps
  1998. );
  1999. } // if: ScAllocPropList succeeded
  2000. } // if: buffer too small
  2001. } // if: ScAllocPropList succeeded
  2002. if ( _sc != ERROR_SUCCESS )
  2003. {
  2004. DeletePropList();
  2005. } // if: error getting properties.
  2006. else
  2007. {
  2008. m_cbDataSize = _cbProps;
  2009. m_cbDataLeft = _cbProps;
  2010. } // else: no errors
  2011. return _sc;
  2012. } //*** CClusPropList::ScGetGroupProperties()
  2013. /////////////////////////////////////////////////////////////////////////////
  2014. //++
  2015. //
  2016. // CClusPropList::ScGetResourceProperties
  2017. //
  2018. // Description:
  2019. // Get properties on a resource.
  2020. //
  2021. // Arguments:
  2022. // hResource [IN] Handle for the resource to get properties from.
  2023. // dwControlCode [IN] Control code for the request.
  2024. // hHostNode [IN] Handle for the node to direct this request to.
  2025. // Defaults to NULL.
  2026. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  2027. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  2028. //
  2029. // Return Value:
  2030. // None.
  2031. //
  2032. // Exceptions Thrown:
  2033. // Any exceptions CClusPropList::ScAllocPropList().
  2034. //
  2035. //--
  2036. /////////////////////////////////////////////////////////////////////////////
  2037. DWORD CClusPropList::ScGetResourceProperties(
  2038. IN HRESOURCE hResource,
  2039. IN DWORD dwControlCode,
  2040. IN HNODE hHostNode,
  2041. IN LPVOID lpInBuffer,
  2042. IN DWORD cbInBufferSize
  2043. )
  2044. {
  2045. ASSERT( hResource != NULL );
  2046. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  2047. == (CLUS_OBJECT_RESOURCE << CLUSCTL_OBJECT_SHIFT) );
  2048. DWORD _sc = ERROR_SUCCESS;
  2049. DWORD _cbProps = 256;
  2050. //
  2051. // Overwrite anything that may be in the buffer.
  2052. // Allows this class instance to be reused.
  2053. //
  2054. m_cbDataSize = 0;
  2055. //
  2056. // Get properties.
  2057. //
  2058. _sc = ScAllocPropList( _cbProps );
  2059. if ( _sc == ERROR_SUCCESS )
  2060. {
  2061. _sc = ClusterResourceControl(
  2062. hResource,
  2063. hHostNode,
  2064. dwControlCode,
  2065. lpInBuffer,
  2066. cbInBufferSize,
  2067. m_cbhPropList.pb,
  2068. m_cbBufferSize,
  2069. &_cbProps
  2070. );
  2071. if ( _sc == ERROR_MORE_DATA )
  2072. {
  2073. _sc = ScAllocPropList( _cbProps );
  2074. if ( _sc == ERROR_SUCCESS )
  2075. {
  2076. _sc = ClusterResourceControl(
  2077. hResource,
  2078. hHostNode,
  2079. dwControlCode,
  2080. lpInBuffer,
  2081. cbInBufferSize,
  2082. m_cbhPropList.pb,
  2083. m_cbBufferSize,
  2084. &_cbProps
  2085. );
  2086. } // if: ScAllocPropList succeeded
  2087. } // if: buffer too small
  2088. } // if: ScAllocPropList succeeded
  2089. if ( _sc != ERROR_SUCCESS )
  2090. {
  2091. DeletePropList();
  2092. } // if: error getting properties.
  2093. else
  2094. {
  2095. m_cbDataSize = _cbProps;
  2096. m_cbDataLeft = _cbProps;
  2097. } // else: no errors
  2098. return _sc;
  2099. } //*** CClusPropList::ScGetResourceProperties()
  2100. /////////////////////////////////////////////////////////////////////////////
  2101. //++
  2102. //
  2103. // CClusPropList::ScGetResourceTypeProperties
  2104. //
  2105. // Description:
  2106. // Get properties on a resource type.
  2107. //
  2108. // Arguments:
  2109. // hCluster [IN] Handle for the cluster in which the resource
  2110. // type resides.
  2111. // pwszResTypeName [IN] Name of the resource type.
  2112. // dwControlCode [IN] Control code for the request.
  2113. // hHostNode [IN] Handle for the node to direct this request to.
  2114. // Defaults to NULL.
  2115. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  2116. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  2117. //
  2118. // Return Value:
  2119. // None.
  2120. //
  2121. // Exceptions Thrown:
  2122. // Any exceptions CClusPropList::ScAllocPropList().
  2123. //
  2124. //--
  2125. /////////////////////////////////////////////////////////////////////////////
  2126. DWORD CClusPropList::ScGetResourceTypeProperties(
  2127. IN HCLUSTER hCluster,
  2128. IN LPCWSTR pwszResTypeName,
  2129. IN DWORD dwControlCode,
  2130. IN HNODE hHostNode,
  2131. IN LPVOID lpInBuffer,
  2132. IN DWORD cbInBufferSize
  2133. )
  2134. {
  2135. ASSERT( hCluster != NULL );
  2136. ASSERT( pwszResTypeName != NULL );
  2137. ASSERT( *pwszResTypeName != L'\0' );
  2138. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  2139. == (CLUS_OBJECT_RESOURCE_TYPE << CLUSCTL_OBJECT_SHIFT) );
  2140. DWORD _sc = ERROR_SUCCESS;
  2141. DWORD _cbProps = 256;
  2142. //
  2143. // Overwrite anything that may be in the buffer.
  2144. // Allows this class instance to be reused.
  2145. //
  2146. m_cbDataSize = 0;
  2147. //
  2148. // Get properties.
  2149. //
  2150. _sc = ScAllocPropList( _cbProps );
  2151. if ( _sc == ERROR_SUCCESS )
  2152. {
  2153. _sc = ClusterResourceTypeControl(
  2154. hCluster,
  2155. pwszResTypeName,
  2156. hHostNode,
  2157. dwControlCode,
  2158. lpInBuffer,
  2159. cbInBufferSize,
  2160. m_cbhPropList.pb,
  2161. m_cbBufferSize,
  2162. &_cbProps
  2163. );
  2164. if ( _sc == ERROR_MORE_DATA )
  2165. {
  2166. _sc = ScAllocPropList( _cbProps );
  2167. if ( _sc == ERROR_SUCCESS )
  2168. {
  2169. _sc = ClusterResourceTypeControl(
  2170. hCluster,
  2171. pwszResTypeName,
  2172. hHostNode,
  2173. dwControlCode,
  2174. lpInBuffer,
  2175. cbInBufferSize,
  2176. m_cbhPropList.pb,
  2177. m_cbBufferSize,
  2178. &_cbProps
  2179. );
  2180. } // if: ScAllocPropList succeeded
  2181. } // if: buffer too small
  2182. } // if: ScAllocPropList succeeded
  2183. if ( _sc != ERROR_SUCCESS )
  2184. {
  2185. DeletePropList();
  2186. } // if: error getting properties.
  2187. else
  2188. {
  2189. m_cbDataSize = _cbProps;
  2190. m_cbDataLeft = _cbProps;
  2191. } // else: no errors
  2192. return _sc;
  2193. } //*** CClusPropList::ScGetResourceTypeProperties()
  2194. /////////////////////////////////////////////////////////////////////////////
  2195. //++
  2196. //
  2197. // CClusPropList::ScGetNetworkProperties
  2198. //
  2199. // Description:
  2200. // Get properties on a network.
  2201. //
  2202. // Arguments:
  2203. // hNetwork [IN] Handle for the network to get properties from.
  2204. // dwControlCode [IN] Control code for the request.
  2205. // hHostNode [IN] Handle for the node to direct this request to.
  2206. // Defaults to NULL.
  2207. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  2208. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  2209. //
  2210. // Return Value:
  2211. // None.
  2212. //
  2213. // Exceptions Thrown:
  2214. // Any exceptions CClusPropList::ScAllocPropList().
  2215. //
  2216. //--
  2217. /////////////////////////////////////////////////////////////////////////////
  2218. DWORD CClusPropList::ScGetNetworkProperties(
  2219. IN HNETWORK hNetwork,
  2220. IN DWORD dwControlCode,
  2221. IN HNODE hHostNode,
  2222. IN LPVOID lpInBuffer,
  2223. IN DWORD cbInBufferSize
  2224. )
  2225. {
  2226. ASSERT( hNetwork != NULL );
  2227. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  2228. == (CLUS_OBJECT_NETWORK << CLUSCTL_OBJECT_SHIFT) );
  2229. DWORD _sc = ERROR_SUCCESS;
  2230. DWORD _cbProps = 256;
  2231. //
  2232. // Overwrite anything that may be in the buffer.
  2233. // Allows this class instance to be reused.
  2234. //
  2235. m_cbDataSize = 0;
  2236. //
  2237. // Get properties.
  2238. //
  2239. _sc = ScAllocPropList( _cbProps );
  2240. if ( _sc == ERROR_SUCCESS )
  2241. {
  2242. _sc = ClusterNetworkControl(
  2243. hNetwork,
  2244. hHostNode,
  2245. dwControlCode,
  2246. lpInBuffer,
  2247. cbInBufferSize,
  2248. m_cbhPropList.pb,
  2249. m_cbBufferSize,
  2250. &_cbProps
  2251. );
  2252. if ( _sc == ERROR_MORE_DATA )
  2253. {
  2254. _sc = ScAllocPropList( _cbProps );
  2255. if ( _sc == ERROR_SUCCESS )
  2256. {
  2257. _sc = ClusterNetworkControl(
  2258. hNetwork,
  2259. hHostNode,
  2260. dwControlCode,
  2261. lpInBuffer,
  2262. cbInBufferSize,
  2263. m_cbhPropList.pb,
  2264. m_cbBufferSize,
  2265. &_cbProps
  2266. );
  2267. } // if: ScAllocPropList succeeded
  2268. } // if: buffer too small
  2269. } // if: ScAllocPropList succeeded
  2270. if ( _sc != ERROR_SUCCESS )
  2271. {
  2272. DeletePropList();
  2273. } // if: error getting private properties.
  2274. else
  2275. {
  2276. m_cbDataSize = _cbProps;
  2277. m_cbDataLeft = _cbProps;
  2278. } // else: no errors
  2279. return _sc;
  2280. } //*** CClusPropList::ScGetNetworkProperties()
  2281. /////////////////////////////////////////////////////////////////////////////
  2282. //++
  2283. //
  2284. // CClusPropList::ScGetNetInterfaceProperties
  2285. //
  2286. // Description:
  2287. // Get properties on a network interface.
  2288. //
  2289. // Arguments:
  2290. // hNetInterface [IN] Handle for the network interface to get properties from.
  2291. // dwControlCode [IN] Control code for the request.
  2292. // hHostNode [IN] Handle for the node to direct this request to.
  2293. // Defaults to NULL.
  2294. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  2295. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  2296. //
  2297. // Return Value:
  2298. // None.
  2299. //
  2300. // Exceptions Thrown:
  2301. // Any exceptions CClusPropList::ScAllocPropList().
  2302. //
  2303. //--
  2304. /////////////////////////////////////////////////////////////////////////////
  2305. DWORD CClusPropList::ScGetNetInterfaceProperties(
  2306. IN HNETINTERFACE hNetInterface,
  2307. IN DWORD dwControlCode,
  2308. IN HNODE hHostNode,
  2309. IN LPVOID lpInBuffer,
  2310. IN DWORD cbInBufferSize
  2311. )
  2312. {
  2313. ASSERT( hNetInterface != NULL );
  2314. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  2315. == (CLUS_OBJECT_NETINTERFACE << CLUSCTL_OBJECT_SHIFT) );
  2316. DWORD _sc= ERROR_SUCCESS;
  2317. DWORD _cbProps = 256;
  2318. //
  2319. // Overwrite anything that may be in the buffer.
  2320. // Allows this class instance to be reused.
  2321. //
  2322. m_cbDataSize = 0;
  2323. //
  2324. // Get properties.
  2325. //
  2326. _sc = ScAllocPropList( _cbProps );
  2327. if ( _sc == ERROR_SUCCESS )
  2328. {
  2329. _sc = ClusterNetInterfaceControl(
  2330. hNetInterface,
  2331. hHostNode,
  2332. dwControlCode,
  2333. lpInBuffer,
  2334. cbInBufferSize,
  2335. m_cbhPropList.pb,
  2336. m_cbBufferSize,
  2337. &_cbProps
  2338. );
  2339. if ( _sc == ERROR_MORE_DATA )
  2340. {
  2341. _sc = ScAllocPropList( _cbProps );
  2342. if ( _sc == ERROR_SUCCESS )
  2343. {
  2344. _sc = ClusterNetInterfaceControl(
  2345. hNetInterface,
  2346. hHostNode,
  2347. dwControlCode,
  2348. lpInBuffer,
  2349. cbInBufferSize,
  2350. m_cbhPropList.pb,
  2351. m_cbBufferSize,
  2352. &_cbProps
  2353. );
  2354. } // if: ScAllocPropList succeeded
  2355. } // if: buffer too small
  2356. } // if: ScAllocPropList succeeded
  2357. if ( _sc != ERROR_SUCCESS )
  2358. {
  2359. DeletePropList();
  2360. } // if: error getting private properties.
  2361. else
  2362. {
  2363. m_cbDataSize = _cbProps;
  2364. m_cbDataLeft = _cbProps;
  2365. } // else: no errors
  2366. return _sc;
  2367. } //*** CClusPropList::ScGetNetInterfaceProperties()
  2368. #if CLUSAPI_VERSION >= 0x0500
  2369. /////////////////////////////////////////////////////////////////////////////
  2370. //++
  2371. //
  2372. // CClusPropList::ScGetClusterProperties
  2373. //
  2374. // Description:
  2375. // Get properties on a cluster.
  2376. //
  2377. // Arguments:
  2378. // hCluster [IN] Handle for the cluster to get properties from.
  2379. // dwControlCode [IN] Control code for the request.
  2380. // hHostNode [IN] Handle for the node to direct this request to.
  2381. // Defaults to NULL.
  2382. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  2383. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  2384. //
  2385. // Return Value:
  2386. // None.
  2387. //
  2388. // Exceptions Thrown:
  2389. // Any exceptions CClusPropList::ScAllocPropList().
  2390. //
  2391. //--
  2392. /////////////////////////////////////////////////////////////////////////////
  2393. DWORD CClusPropList::ScGetClusterProperties(
  2394. IN HCLUSTER hCluster,
  2395. IN DWORD dwControlCode,
  2396. IN HNODE hHostNode,
  2397. IN LPVOID lpInBuffer,
  2398. IN DWORD cbInBufferSize
  2399. )
  2400. {
  2401. ASSERT( hCluster != NULL );
  2402. ASSERT( (dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  2403. == (CLUS_OBJECT_CLUSTER << CLUSCTL_OBJECT_SHIFT) );
  2404. DWORD _sc= ERROR_SUCCESS;
  2405. DWORD _cbProps = 256;
  2406. //
  2407. // Overwrite anything that may be in the buffer.
  2408. // Allows this class instance to be reused.
  2409. //
  2410. m_cbDataSize = 0;
  2411. //
  2412. // Get properties.
  2413. //
  2414. _sc = ScAllocPropList( _cbProps );
  2415. if ( _sc == ERROR_SUCCESS )
  2416. {
  2417. _sc = ClusterControl(
  2418. hCluster,
  2419. hHostNode,
  2420. dwControlCode,
  2421. lpInBuffer,
  2422. cbInBufferSize,
  2423. m_cbhPropList.pb,
  2424. m_cbBufferSize,
  2425. &_cbProps
  2426. );
  2427. if ( _sc == ERROR_MORE_DATA )
  2428. {
  2429. _sc = ScAllocPropList( _cbProps );
  2430. if ( _sc == ERROR_SUCCESS )
  2431. {
  2432. _sc = ClusterControl(
  2433. hCluster,
  2434. hHostNode,
  2435. dwControlCode,
  2436. lpInBuffer,
  2437. cbInBufferSize,
  2438. m_cbhPropList.pb,
  2439. m_cbBufferSize,
  2440. &_cbProps
  2441. );
  2442. } // if: ScAllocPropList succeeded
  2443. } // if: buffer too small
  2444. } // if: ScAllocPropList succeeded
  2445. if ( _sc != ERROR_SUCCESS )
  2446. {
  2447. DeletePropList();
  2448. } // if: error getting private properties.
  2449. else
  2450. {
  2451. m_cbDataSize = _cbProps;
  2452. m_cbDataLeft = _cbProps;
  2453. } // else: no errors
  2454. return _sc;
  2455. } //*** CClusPropList::ScGetClusterProperties()
  2456. #endif // CLUSAPI_VERSION >= 0x0500