Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

983 lines
25 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright (c) 1996-1997 Microsoft Corporation
  4. //
  5. // Module Name:
  6. // PropList.cpp
  7. //
  8. // Abstract:
  9. // Implementation of the CClusPropList class.
  10. //
  11. // Author:
  12. // David Potter (davidp) February 24, 1997
  13. //
  14. // Revision History:
  15. //
  16. // Notes:
  17. //
  18. /////////////////////////////////////////////////////////////////////////////
  19. #include "stdafx.h"
  20. #include "PropList.h"
  21. #include "BarfClus.h"
  22. #ifdef _DEBUG
  23. #define new DEBUG_NEW
  24. #undef THIS_FILE
  25. static char THIS_FILE[] = __FILE__;
  26. #endif
  27. /////////////////////////////////////////////////////////////////////////////
  28. // Constant Definitions
  29. /////////////////////////////////////////////////////////////////////////////
  30. #define BUFFER_GROWTH_FACTOR 256
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CClusPropList class
  33. /////////////////////////////////////////////////////////////////////////////
  34. IMPLEMENT_DYNAMIC(CClusPropList, CObject)
  35. /////////////////////////////////////////////////////////////////////////////
  36. //++
  37. //
  38. // CClusPropList::CClusPropList
  39. //
  40. // Routine Description:
  41. // Default constructor.
  42. //
  43. // Arguments:
  44. // None.
  45. //
  46. // Return Value:
  47. // None.
  48. //
  49. //--
  50. /////////////////////////////////////////////////////////////////////////////
  51. CClusPropList::CClusPropList(IN BOOL bAlwaysAddProp)
  52. {
  53. m_proplist.pList = NULL;
  54. m_propCurrent.pb = NULL;
  55. m_cbBufferSize = 0;
  56. m_cbDataSize = 0;
  57. m_bAlwaysAddProp = bAlwaysAddProp;
  58. } //*** CClusPropList::CClusPropList();
  59. /////////////////////////////////////////////////////////////////////////////
  60. //++
  61. //
  62. // CClusPropList::~CClusPropList
  63. //
  64. // Routine Description:
  65. // Destructor.
  66. //
  67. // Arguments:
  68. // None.
  69. //
  70. // Return Value:
  71. // None.
  72. //
  73. //--
  74. /////////////////////////////////////////////////////////////////////////////
  75. CClusPropList::~CClusPropList(void)
  76. {
  77. delete [] m_proplist.pb;
  78. } //*** CClusPropList::~CClusPropList();
  79. /////////////////////////////////////////////////////////////////////////////
  80. //++
  81. //
  82. // CClusPropList::AddProp
  83. //
  84. // Routine Description:
  85. // Add a string property to a property list if it has changed.
  86. //
  87. // Arguments:
  88. // pwszName [IN] Name of the property.
  89. // rstrValue [IN] Value of the property to set in the list.
  90. // rstrPrevValue [IN] Previous value of the property.
  91. //
  92. // Return Value:
  93. // None.
  94. //
  95. //--
  96. /////////////////////////////////////////////////////////////////////////////
  97. void CClusPropList::AddProp(
  98. IN LPCWSTR pwszName,
  99. IN const CString & rstrValue,
  100. IN const CString & rstrPrevValue
  101. )
  102. {
  103. PCLUSPROP_PROPERTY_NAME pName;
  104. PCLUSPROP_SZ pValue;
  105. ASSERT(pwszName != NULL);
  106. if (m_bAlwaysAddProp || (rstrValue != rstrPrevValue))
  107. {
  108. DWORD cbNameSize;
  109. DWORD cbValueSize;
  110. // Calculate sizes and make sure we have a property list.
  111. cbNameSize = sizeof(CLUSPROP_PROPERTY_NAME)
  112. + ALIGN_CLUSPROP((lstrlenW(pwszName) + 1) * sizeof(WCHAR));
  113. cbValueSize = sizeof(CLUSPROP_SZ)
  114. + ALIGN_CLUSPROP((rstrValue.GetLength() + 1) * sizeof(WCHAR))
  115. + sizeof(CLUSPROP_SYNTAX); // value list endmark
  116. AllocPropList(cbNameSize + cbValueSize);
  117. // Set the property name.
  118. pName = m_propCurrent.pName;
  119. CopyProp(pName, CLUSPROP_TYPE_NAME, pwszName);
  120. m_propCurrent.pb += cbNameSize;
  121. // Set the property value.
  122. pValue = m_propCurrent.pStringValue;
  123. CopyProp(pValue, CLUSPROP_TYPE_LIST_VALUE, rstrValue);
  124. m_propCurrent.pb += cbValueSize;
  125. // Increment the property count and buffer size.
  126. m_proplist.pList->nPropertyCount++;
  127. m_cbDataSize += cbNameSize + cbValueSize;
  128. } // if: the value has changed
  129. } //*** CClusPropList::AddProp(CString)
  130. /////////////////////////////////////////////////////////////////////////////
  131. //++
  132. //
  133. // CClusPropList::AddProp
  134. //
  135. // Routine Description:
  136. // Add a DWORD property to a property list if it has changed.
  137. //
  138. // Arguments:
  139. // pwszName [IN] Name of the property.
  140. // dwValue [IN] Value of the property to set in the list.
  141. // dwPrevValue [IN] Previous value of the property.
  142. //
  143. // Return Value:
  144. // None.
  145. //
  146. //--
  147. /////////////////////////////////////////////////////////////////////////////
  148. void CClusPropList::AddProp(
  149. IN LPCWSTR pwszName,
  150. IN DWORD dwValue,
  151. IN DWORD dwPrevValue
  152. )
  153. {
  154. PCLUSPROP_PROPERTY_NAME pName;
  155. PCLUSPROP_DWORD pValue;
  156. ASSERT(pwszName != NULL);
  157. if (m_bAlwaysAddProp || (dwValue != dwPrevValue))
  158. {
  159. DWORD cbNameSize;
  160. DWORD cbValueSize;
  161. // Calculate sizes and make sure we have a property list.
  162. cbNameSize = sizeof(CLUSPROP_PROPERTY_NAME)
  163. + ALIGN_CLUSPROP((lstrlenW(pwszName) + 1) * sizeof(WCHAR));
  164. cbValueSize = sizeof(CLUSPROP_DWORD)
  165. + sizeof(CLUSPROP_SYNTAX); // value list endmark
  166. AllocPropList(cbNameSize + cbValueSize);
  167. // Set the property name.
  168. pName = m_propCurrent.pName;
  169. CopyProp(pName, CLUSPROP_TYPE_NAME, pwszName);
  170. m_propCurrent.pb += cbNameSize;
  171. // Set the property value.
  172. pValue = m_propCurrent.pDwordValue;
  173. CopyProp(pValue, CLUSPROP_TYPE_LIST_VALUE, dwValue);
  174. m_propCurrent.pb += cbValueSize;
  175. // Increment the property count and buffer size.
  176. m_proplist.pList->nPropertyCount++;
  177. m_cbDataSize += cbNameSize + cbValueSize;
  178. } // if: the value has changed
  179. } //*** CClusPropList::AddProp(DWORD)
  180. /////////////////////////////////////////////////////////////////////////////
  181. //++
  182. //
  183. // CClusPropList::AddProp
  184. //
  185. // Routine Description:
  186. // Add a binary property to a property list if it has changed.
  187. //
  188. // Arguments:
  189. // pwszName [IN] Name of the property.
  190. // pbValue [IN] Value of the property to set in the list.
  191. // cbValue [IN] Count of bytes in pbValue.
  192. // pbPrevValue [IN] Previous value of the property.
  193. // cbPrevValue [IN] Count of bytes in pbPrevValue.
  194. //
  195. // Return Value:
  196. // None.
  197. //
  198. //--
  199. /////////////////////////////////////////////////////////////////////////////
  200. void CClusPropList::AddProp(
  201. IN LPCWSTR pwszName,
  202. IN const PBYTE pbValue,
  203. IN DWORD cbValue,
  204. IN const PBYTE pbPrevValue,
  205. IN DWORD cbPrevValue
  206. )
  207. {
  208. BOOL bChanged = FALSE;
  209. PCLUSPROP_PROPERTY_NAME pName;
  210. PCLUSPROP_BINARY pValue;
  211. ASSERT(pwszName != NULL);
  212. ASSERT(((cbValue == 0) && (cbPrevValue == 0)) || (pbValue != pbPrevValue));
  213. // Determine if the buffer has changed.
  214. if (m_bAlwaysAddProp || (cbValue != cbPrevValue))
  215. bChanged = TRUE;
  216. else if (!((cbValue == 0) && (cbPrevValue == 0)))
  217. bChanged = memcmp(pbValue, pbPrevValue, cbValue) == 0;
  218. if (bChanged)
  219. {
  220. DWORD cbNameSize;
  221. DWORD cbValueSize;
  222. // Calculate sizes and make sure we have a property list.
  223. cbNameSize = sizeof(CLUSPROP_PROPERTY_NAME)
  224. + ALIGN_CLUSPROP((lstrlenW(pwszName) + 1) * sizeof(WCHAR));
  225. cbValueSize = sizeof(CLUSPROP_BINARY)
  226. + ALIGN_CLUSPROP(cbValue)
  227. + sizeof(CLUSPROP_SYNTAX); // value list endmark
  228. AllocPropList(cbNameSize + cbValueSize);
  229. // Set the property name.
  230. pName = m_propCurrent.pName;
  231. CopyProp(pName, CLUSPROP_TYPE_NAME, pwszName);
  232. m_propCurrent.pb += cbNameSize;
  233. // Set the property value.
  234. pValue = m_propCurrent.pBinaryValue;
  235. CopyProp(pValue, CLUSPROP_TYPE_LIST_VALUE, pbValue, cbValue);
  236. m_propCurrent.pb += cbValueSize;
  237. // Increment the property count and buffer size.
  238. m_proplist.pList->nPropertyCount++;
  239. m_cbDataSize += cbNameSize + cbValueSize;
  240. } // if: the value changed
  241. } //*** CClusPropList::AddProp(PBYTE)
  242. /////////////////////////////////////////////////////////////////////////////
  243. //++
  244. //
  245. // CClusPropList::CopyProp
  246. //
  247. // Routine Description:
  248. // Copy a string property to a property structure.
  249. //
  250. // Arguments:
  251. // pprop [OUT] Property structure to fill.
  252. // proptype [IN] Type of string.
  253. // pwsz [IN] String to copy.
  254. // cbsz [IN] Count of bytes in pwsz string.
  255. //
  256. // Return Value:
  257. // None.
  258. //
  259. //--
  260. /////////////////////////////////////////////////////////////////////////////
  261. void CClusPropList::CopyProp(
  262. OUT PCLUSPROP_SZ pprop,
  263. IN CLUSTER_PROPERTY_TYPE proptype,
  264. IN LPCWSTR pwsz,
  265. IN DWORD cbsz
  266. )
  267. {
  268. CLUSPROP_BUFFER_HELPER props;
  269. ASSERT(pprop != NULL);
  270. ASSERT(pwsz != NULL);
  271. pprop->Syntax.wFormat = CLUSPROP_FORMAT_SZ;
  272. pprop->Syntax.wType = (WORD) proptype;
  273. if (cbsz == 0)
  274. cbsz = (lstrlenW(pwsz) + 1) * sizeof(WCHAR);
  275. ASSERT(cbsz == (lstrlenW(pwsz) + 1) * sizeof(WCHAR));
  276. pprop->cbLength = cbsz;
  277. lstrcpyW(pprop->sz, pwsz);
  278. // Set an endmark.
  279. props.pStringValue = pprop;
  280. props.pb += sizeof(*props.pStringValue) + ALIGN_CLUSPROP(cbsz);
  281. props.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  282. } //*** CClusPropList::CopyProp(CString)
  283. /////////////////////////////////////////////////////////////////////////////
  284. //++
  285. //
  286. // CClusPropList::CopyProp
  287. //
  288. // Routine Description:
  289. // Copy a DWORD property to a property structure.
  290. //
  291. // Arguments:
  292. // pprop [OUT] Property structure to fill.
  293. // proptype [IN] Type of DWORD.
  294. // dw [IN] DWORD to copy.
  295. //
  296. // Return Value:
  297. // None.
  298. //
  299. //--
  300. /////////////////////////////////////////////////////////////////////////////
  301. void CClusPropList::CopyProp(
  302. OUT PCLUSPROP_DWORD pprop,
  303. IN CLUSTER_PROPERTY_TYPE proptype,
  304. IN DWORD dw
  305. )
  306. {
  307. CLUSPROP_BUFFER_HELPER props;
  308. ASSERT(pprop != NULL);
  309. pprop->Syntax.wFormat = CLUSPROP_FORMAT_DWORD;
  310. pprop->Syntax.wType = (WORD) proptype;
  311. pprop->cbLength = sizeof(DWORD);
  312. pprop->dw = dw;
  313. // Set an endmark.
  314. props.pDwordValue = pprop;
  315. props.pb += sizeof(*props.pDwordValue);
  316. props.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  317. } //*** CClusPropList::CopyProp(DWORD)
  318. /////////////////////////////////////////////////////////////////////////////
  319. //++
  320. //
  321. // CClusPropList::CopyProp
  322. //
  323. // Routine Description:
  324. // Copy a binary property to a property structure.
  325. //
  326. // Arguments:
  327. // pprop [OUT] Property structure to fill.
  328. // proptype [IN] Type of string.
  329. // pb [IN] Block to copy.
  330. // cbsz [IN] Count of bytes in pb buffer.
  331. //
  332. // Return Value:
  333. // None.
  334. //
  335. //--
  336. /////////////////////////////////////////////////////////////////////////////
  337. void CClusPropList::CopyProp(
  338. OUT PCLUSPROP_BINARY pprop,
  339. IN CLUSTER_PROPERTY_TYPE proptype,
  340. IN const PBYTE pb,
  341. IN DWORD cb
  342. )
  343. {
  344. CLUSPROP_BUFFER_HELPER props;
  345. ASSERT(pprop != NULL);
  346. pprop->Syntax.wFormat = CLUSPROP_FORMAT_BINARY;
  347. pprop->Syntax.wType = (WORD) proptype;
  348. pprop->cbLength = cb;
  349. if (cb > 0)
  350. CopyMemory(pprop->rgb, pb, cb);
  351. // Set an endmark.
  352. props.pBinaryValue = pprop;
  353. props.pb += sizeof(*props.pStringValue) + ALIGN_CLUSPROP(cb);
  354. props.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  355. } //*** CClusPropList::CopyProp(PBYTE)
  356. /////////////////////////////////////////////////////////////////////////////
  357. //++
  358. //
  359. // CClusPropList::AllocPropList
  360. //
  361. // Routine Description:
  362. // Allocate a property list buffer that's big enough to hold the next
  363. // property.
  364. //
  365. // Arguments:
  366. // cbMinimum [IN] Minimum size of the property list.
  367. //
  368. // Return Value:
  369. // None.
  370. //
  371. // Exceptions Thrown:
  372. // Any exceptions thrown by BYTE::operator new().
  373. //
  374. //--
  375. /////////////////////////////////////////////////////////////////////////////
  376. void CClusPropList::AllocPropList(
  377. IN DWORD cbMinimum
  378. )
  379. {
  380. DWORD cbTotal;
  381. ASSERT(cbMinimum > 0);
  382. // Add the size of the item count and final endmark.
  383. cbMinimum += sizeof(DWORD) + sizeof(CLUSPROP_SYNTAX);
  384. cbTotal = m_cbDataSize + cbMinimum;
  385. if (m_cbBufferSize < cbTotal)
  386. {
  387. PBYTE pbNewProplist;
  388. cbMinimum = max(BUFFER_GROWTH_FACTOR, cbMinimum);
  389. cbTotal = m_cbDataSize + cbMinimum;
  390. // Allocate and zero a new buffer.
  391. pbNewProplist = new BYTE[cbTotal];
  392. ZeroMemory(pbNewProplist, cbTotal);
  393. // If there was a previous buffer, copy it and the delete it.
  394. if (m_proplist.pb != NULL)
  395. {
  396. if (m_cbDataSize != 0)
  397. CopyMemory(pbNewProplist, m_proplist.pb, m_cbDataSize);
  398. delete [] m_proplist.pb;
  399. m_propCurrent.pb = pbNewProplist + (m_propCurrent.pb - m_proplist.pb);
  400. } // if: there was a previous buffer
  401. else
  402. m_propCurrent.pb = pbNewProplist + sizeof(DWORD); // move past prop count
  403. // Save the new buffer.
  404. m_proplist.pb = pbNewProplist;
  405. m_cbBufferSize = cbTotal;
  406. } // if: buffer isn't big enough
  407. } //*** CClusPropList::AllocPropList(PBYTE)
  408. /////////////////////////////////////////////////////////////////////////////
  409. //++
  410. //
  411. // CClusPropList::DwGetNodeProperties
  412. //
  413. // Routine Description:
  414. // Get properties on a node.
  415. //
  416. // Arguments:
  417. // hNode [IN] Handle for the node to get properties from.
  418. // dwControlCode [IN] Control code for the request.
  419. // hHostNode [IN] Handle for the node to direct this request to.
  420. // Defaults to NULL.
  421. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  422. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  423. //
  424. // Return Value:
  425. // None.
  426. //
  427. // Exceptions Thrown:
  428. // Any exceptions CClusPropList::AllocPropList().
  429. //
  430. //--
  431. /////////////////////////////////////////////////////////////////////////////
  432. DWORD CClusPropList::DwGetNodeProperties(
  433. IN HNODE hNode,
  434. IN DWORD dwControlCode,
  435. IN HNODE hHostNode,
  436. IN LPVOID lpInBuffer,
  437. IN DWORD cbInBufferSize
  438. )
  439. {
  440. DWORD dwStatus;
  441. DWORD cbProps = 256;
  442. ASSERT(hNode != NULL);
  443. ASSERT((dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  444. == (CLUS_OBJECT_NODE << CLUSCTL_OBJECT_SHIFT));
  445. ASSERT(m_proplist.pb == NULL);
  446. ASSERT(m_propCurrent.pb == NULL);
  447. ASSERT(m_cbBufferSize == 0);
  448. ASSERT(m_cbDataSize == 0);
  449. do
  450. {
  451. // Allocate a default-sized buffer.
  452. try
  453. {
  454. AllocPropList(cbProps);
  455. } // try
  456. catch (CMemoryException * pme)
  457. {
  458. pme->Delete();
  459. return ERROR_NOT_ENOUGH_MEMORY;
  460. } // catch: CMemoryException
  461. // Get properties.
  462. dwStatus = ClusterNodeControl(
  463. hNode,
  464. hHostNode,
  465. dwControlCode,
  466. lpInBuffer,
  467. cbInBufferSize,
  468. m_proplist.pb,
  469. m_cbBufferSize,
  470. &cbProps
  471. );
  472. } while (dwStatus == ERROR_MORE_DATA);
  473. if (dwStatus != ERROR_SUCCESS)
  474. {
  475. delete [] m_proplist.pb;
  476. m_proplist.pb = NULL;
  477. m_propCurrent.pb = NULL;
  478. m_cbBufferSize = 0;
  479. m_cbDataSize = 0;
  480. } // if: error getting private properties.
  481. else
  482. m_cbDataSize = cbProps;
  483. return dwStatus;
  484. } //*** CClusPropList::DwGetNodeProperties()
  485. /////////////////////////////////////////////////////////////////////////////
  486. //++
  487. //
  488. // CClusPropList::DwGetGroupProperties
  489. //
  490. // Routine Description:
  491. // Get properties on a group.
  492. //
  493. // Arguments:
  494. // hGroup [IN] Handle for the group to get properties from.
  495. // dwControlCode [IN] Control code for the request.
  496. // hHostNode [IN] Handle for the node to direct this request to.
  497. // Defaults to NULL.
  498. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  499. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  500. //
  501. // Return Value:
  502. // None.
  503. //
  504. // Exceptions Thrown:
  505. // Any exceptions CClusPropList::AllocPropList().
  506. //
  507. //--
  508. /////////////////////////////////////////////////////////////////////////////
  509. DWORD CClusPropList::DwGetGroupProperties(
  510. IN HGROUP hGroup,
  511. IN DWORD dwControlCode,
  512. IN HNODE hHostNode,
  513. IN LPVOID lpInBuffer,
  514. IN DWORD cbInBufferSize
  515. )
  516. {
  517. DWORD dwStatus;
  518. DWORD cbProps = 256;
  519. ASSERT(hGroup != NULL);
  520. ASSERT((dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  521. == (CLUS_OBJECT_GROUP << CLUSCTL_OBJECT_SHIFT));
  522. ASSERT(m_proplist.pb == NULL);
  523. ASSERT(m_propCurrent.pb == NULL);
  524. ASSERT(m_cbBufferSize == 0);
  525. ASSERT(m_cbDataSize == 0);
  526. do
  527. {
  528. // Allocate a default-sized buffer.
  529. try
  530. {
  531. AllocPropList(cbProps);
  532. } // try
  533. catch (CMemoryException * pme)
  534. {
  535. pme->Delete();
  536. return ERROR_NOT_ENOUGH_MEMORY;
  537. } // catch: CMemoryException
  538. // Get properties.
  539. dwStatus = ClusterGroupControl(
  540. hGroup,
  541. hHostNode,
  542. dwControlCode,
  543. lpInBuffer,
  544. cbInBufferSize,
  545. m_proplist.pb,
  546. m_cbBufferSize,
  547. &cbProps
  548. );
  549. } while (dwStatus == ERROR_MORE_DATA);
  550. if (dwStatus != ERROR_SUCCESS)
  551. {
  552. delete [] m_proplist.pb;
  553. m_proplist.pb = NULL;
  554. m_propCurrent.pb = NULL;
  555. m_cbBufferSize = 0;
  556. m_cbDataSize = 0;
  557. } // if: error getting private properties.
  558. else
  559. m_cbDataSize = cbProps;
  560. return dwStatus;
  561. } //*** CClusPropList::DwGetGroupProperties()
  562. /////////////////////////////////////////////////////////////////////////////
  563. //++
  564. //
  565. // CClusPropList::DwGetResourceProperties
  566. //
  567. // Routine Description:
  568. // Get properties on a resource.
  569. //
  570. // Arguments:
  571. // hResource [IN] Handle for the resource to get properties from.
  572. // dwControlCode [IN] Control code for the request.
  573. // hHostNode [IN] Handle for the node to direct this request to.
  574. // Defaults to NULL.
  575. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  576. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  577. //
  578. // Return Value:
  579. // None.
  580. //
  581. // Exceptions Thrown:
  582. // Any exceptions CClusPropList::AllocPropList().
  583. //
  584. //--
  585. /////////////////////////////////////////////////////////////////////////////
  586. DWORD CClusPropList::DwGetResourceProperties(
  587. IN HRESOURCE hResource,
  588. IN DWORD dwControlCode,
  589. IN HNODE hHostNode,
  590. IN LPVOID lpInBuffer,
  591. IN DWORD cbInBufferSize
  592. )
  593. {
  594. DWORD dwStatus;
  595. DWORD cbProps = 256;
  596. ASSERT(hResource != NULL);
  597. ASSERT((dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  598. == (CLUS_OBJECT_RESOURCE << CLUSCTL_OBJECT_SHIFT));
  599. ASSERT(m_proplist.pb == NULL);
  600. ASSERT(m_propCurrent.pb == NULL);
  601. ASSERT(m_cbBufferSize == 0);
  602. ASSERT(m_cbDataSize == 0);
  603. do
  604. {
  605. // Allocate a default-sized buffer.
  606. try
  607. {
  608. AllocPropList(cbProps);
  609. } // try
  610. catch (CMemoryException * pme)
  611. {
  612. pme->Delete();
  613. return ERROR_NOT_ENOUGH_MEMORY;
  614. } // catch: CMemoryException
  615. // Get properties.
  616. dwStatus = ClusterResourceControl(
  617. hResource,
  618. hHostNode,
  619. dwControlCode,
  620. lpInBuffer,
  621. cbInBufferSize,
  622. m_proplist.pb,
  623. m_cbBufferSize,
  624. &cbProps
  625. );
  626. } while (dwStatus == ERROR_MORE_DATA);
  627. if (dwStatus != ERROR_SUCCESS)
  628. {
  629. delete [] m_proplist.pb;
  630. m_proplist.pb = NULL;
  631. m_propCurrent.pb = NULL;
  632. m_cbBufferSize = 0;
  633. m_cbDataSize = 0;
  634. } // if: error getting private properties.
  635. else
  636. m_cbDataSize = cbProps;
  637. return dwStatus;
  638. } //*** CClusPropList::DwGetResourceProperties()
  639. /////////////////////////////////////////////////////////////////////////////
  640. //++
  641. //
  642. // CClusPropList::DwGetResourceTypeProperties
  643. //
  644. // Routine Description:
  645. // Get properties on a resource type.
  646. //
  647. // Arguments:
  648. // hCluster [IN] Handle for the cluster in which the resource
  649. // type resides.
  650. // pwszResTypeName [IN] Name of the resource type.
  651. // dwControlCode [IN] Control code for the request.
  652. // hHostNode [IN] Handle for the node to direct this request to.
  653. // Defaults to NULL.
  654. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  655. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  656. //
  657. // Return Value:
  658. // None.
  659. //
  660. // Exceptions Thrown:
  661. // Any exceptions CClusPropList::AllocPropList().
  662. //
  663. //--
  664. /////////////////////////////////////////////////////////////////////////////
  665. DWORD CClusPropList::DwGetResourceTypeProperties(
  666. IN HCLUSTER hCluster,
  667. IN LPCWSTR pwszResTypeName,
  668. IN DWORD dwControlCode,
  669. IN HNODE hHostNode,
  670. IN LPVOID lpInBuffer,
  671. IN DWORD cbInBufferSize
  672. )
  673. {
  674. DWORD dwStatus;
  675. DWORD cbProps = 256;
  676. ASSERT(hCluster != NULL);
  677. ASSERT(pwszResTypeName != NULL);
  678. ASSERT(*pwszResTypeName != L'\0');
  679. ASSERT((dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  680. == (CLUS_OBJECT_RESOURCE_TYPE << CLUSCTL_OBJECT_SHIFT));
  681. ASSERT(m_proplist.pb == NULL);
  682. ASSERT(m_propCurrent.pb == NULL);
  683. ASSERT(m_cbBufferSize == 0);
  684. ASSERT(m_cbDataSize == 0);
  685. do
  686. {
  687. // Allocate a default-sized buffer.
  688. try
  689. {
  690. AllocPropList(cbProps);
  691. } // try
  692. catch (CMemoryException * pme)
  693. {
  694. pme->Delete();
  695. return ERROR_NOT_ENOUGH_MEMORY;
  696. } // catch: CMemoryException
  697. // Get properties.
  698. dwStatus = ClusterResourceTypeControl(
  699. hCluster,
  700. pwszResTypeName,
  701. hHostNode,
  702. dwControlCode,
  703. lpInBuffer,
  704. cbInBufferSize,
  705. m_proplist.pb,
  706. m_cbBufferSize,
  707. &cbProps
  708. );
  709. } while (dwStatus == ERROR_MORE_DATA);
  710. if (dwStatus != ERROR_SUCCESS)
  711. {
  712. delete [] m_proplist.pb;
  713. m_proplist.pb = NULL;
  714. m_propCurrent.pb = NULL;
  715. m_cbBufferSize = 0;
  716. m_cbDataSize = 0;
  717. } // if: error getting private properties.
  718. else
  719. m_cbDataSize = cbProps;
  720. return dwStatus;
  721. } //*** CClusPropList::DwGetResourceTypeProperties()
  722. /////////////////////////////////////////////////////////////////////////////
  723. //++
  724. //
  725. // CClusPropList::DwGetNetworkProperties
  726. //
  727. // Routine Description:
  728. // Get properties on a network.
  729. //
  730. // Arguments:
  731. // hNetwork [IN] Handle for the network to get properties from.
  732. // dwControlCode [IN] Control code for the request.
  733. // hHostNode [IN] Handle for the node to direct this request to.
  734. // Defaults to NULL.
  735. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  736. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  737. //
  738. // Return Value:
  739. // None.
  740. //
  741. // Exceptions Thrown:
  742. // Any exceptions CClusPropList::AllocPropList().
  743. //
  744. //--
  745. /////////////////////////////////////////////////////////////////////////////
  746. DWORD CClusPropList::DwGetNetworkProperties(
  747. IN HNETWORK hNetwork,
  748. IN DWORD dwControlCode,
  749. IN HNODE hHostNode,
  750. IN LPVOID lpInBuffer,
  751. IN DWORD cbInBufferSize
  752. )
  753. {
  754. DWORD dwStatus;
  755. DWORD cbProps = 256;
  756. ASSERT(hNetwork != NULL);
  757. ASSERT((dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  758. == (CLUS_OBJECT_NETWORK << CLUSCTL_OBJECT_SHIFT));
  759. ASSERT(m_proplist.pb == NULL);
  760. ASSERT(m_propCurrent.pb == NULL);
  761. ASSERT(m_cbBufferSize == 0);
  762. ASSERT(m_cbDataSize == 0);
  763. do
  764. {
  765. // Allocate a default-sized buffer.
  766. try
  767. {
  768. AllocPropList(cbProps);
  769. } // try
  770. catch (CMemoryException * pme)
  771. {
  772. pme->Delete();
  773. return ERROR_NOT_ENOUGH_MEMORY;
  774. } // catch: CMemoryException
  775. // Get properties.
  776. dwStatus = ClusterNetworkControl(
  777. hNetwork,
  778. hHostNode,
  779. dwControlCode,
  780. lpInBuffer,
  781. cbInBufferSize,
  782. m_proplist.pb,
  783. m_cbBufferSize,
  784. &cbProps
  785. );
  786. } while (dwStatus == ERROR_MORE_DATA);
  787. if (dwStatus != ERROR_SUCCESS)
  788. {
  789. delete [] m_proplist.pb;
  790. m_proplist.pb = NULL;
  791. m_propCurrent.pb = NULL;
  792. m_cbBufferSize = 0;
  793. m_cbDataSize = 0;
  794. } // if: error getting private properties.
  795. else
  796. m_cbDataSize = cbProps;
  797. return dwStatus;
  798. } //*** CClusPropList::DwGetNetworkProperties()
  799. /////////////////////////////////////////////////////////////////////////////
  800. //++
  801. //
  802. // CClusPropList::DwGetNetInterfaceProperties
  803. //
  804. // Routine Description:
  805. // Get properties on a network interface.
  806. //
  807. // Arguments:
  808. // hNetInterface [IN] Handle for the network interface to get properties from.
  809. // dwControlCode [IN] Control code for the request.
  810. // hHostNode [IN] Handle for the node to direct this request to.
  811. // Defaults to NULL.
  812. // lpInBuffer [IN] Input buffer for the request. Defaults to NULL.
  813. // cbInBufferSize [IN] Size of the input buffer. Defaults to 0.
  814. //
  815. // Return Value:
  816. // None.
  817. //
  818. // Exceptions Thrown:
  819. // Any exceptions CClusPropList::AllocPropList().
  820. //
  821. //--
  822. /////////////////////////////////////////////////////////////////////////////
  823. DWORD CClusPropList::DwGetNetInterfaceProperties(
  824. IN HNETINTERFACE hNetInterface,
  825. IN DWORD dwControlCode,
  826. IN HNODE hHostNode,
  827. IN LPVOID lpInBuffer,
  828. IN DWORD cbInBufferSize
  829. )
  830. {
  831. DWORD dwStatus;
  832. DWORD cbProps = 256;
  833. ASSERT(hNetInterface != NULL);
  834. ASSERT((dwControlCode & (CLUSCTL_OBJECT_MASK << CLUSCTL_OBJECT_SHIFT))
  835. == (CLUS_OBJECT_NETINTERFACE << CLUSCTL_OBJECT_SHIFT));
  836. ASSERT(m_proplist.pb == NULL);
  837. ASSERT(m_propCurrent.pb == NULL);
  838. ASSERT(m_cbBufferSize == 0);
  839. ASSERT(m_cbDataSize == 0);
  840. do
  841. {
  842. // Allocate a default-sized buffer.
  843. try
  844. {
  845. AllocPropList(cbProps);
  846. } // try
  847. catch (CMemoryException * pme)
  848. {
  849. pme->Delete();
  850. return ERROR_NOT_ENOUGH_MEMORY;
  851. } // catch: CMemoryException
  852. // Get properties.
  853. dwStatus = ClusterNetInterfaceControl(
  854. hNetInterface,
  855. hHostNode,
  856. dwControlCode,
  857. lpInBuffer,
  858. cbInBufferSize,
  859. m_proplist.pb,
  860. m_cbBufferSize,
  861. &cbProps
  862. );
  863. } while (dwStatus == ERROR_MORE_DATA);
  864. if (dwStatus != ERROR_SUCCESS)
  865. {
  866. delete [] m_proplist.pb;
  867. m_proplist.pb = NULL;
  868. m_propCurrent.pb = NULL;
  869. m_cbBufferSize = 0;
  870. m_cbDataSize = 0;
  871. } // if: error getting private properties.
  872. else
  873. m_cbDataSize = cbProps;
  874. return dwStatus;
  875. } //*** CClusPropList::DwGetNetInterfaceProperties()