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.

1133 lines
28 KiB

  1. /*++
  2. Copyright (c) 1997-1999 Microsoft Corporation
  3. Module Name:
  4. ioctl.c
  5. Abstract:
  6. Node control functions.
  7. Author:
  8. John Vert (jvert) 2-Mar-1997
  9. Revision History:
  10. --*/
  11. #include "nmp.h"
  12. //
  13. // Node Common properties.
  14. //
  15. //
  16. // Read-Write Common Properties.
  17. //
  18. RESUTIL_PROPERTY_ITEM
  19. NmpNodeCommonProperties[] = {
  20. { CLUSREG_NAME_NODE_DESC, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0 },
  21. { CLUSREG_NAME_CLUS_EVTLOG_PROPAGATION, NULL, CLUSPROP_FORMAT_DWORD, 1, 0, 1, 0},
  22. { NULL, NULL, 0, 0, 0, 0, 0 } };
  23. //
  24. // Read-Only Common Properties.
  25. //
  26. RESUTIL_PROPERTY_ITEM
  27. NmpNodeROCommonProperties[] = {
  28. { CLUSREG_NAME_NODE_NAME, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY },
  29. { CLUSREG_NAME_NODE_HIGHEST_VERSION, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY },
  30. { CLUSREG_NAME_NODE_LOWEST_VERSION, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY },
  31. { CLUSREG_NAME_NODE_MAJOR_VERSION, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY},
  32. { CLUSREG_NAME_NODE_MINOR_VERSION, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY},
  33. { CLUSREG_NAME_NODE_BUILD_NUMBER, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY},
  34. { CLUSREG_NAME_NODE_CSDVERSION, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY},
  35. { NULL, NULL, 0, 0, 0, 0, 0 } };
  36. //
  37. // Cluster registry API function pointers.
  38. //
  39. CLUSTER_REG_APIS
  40. NmpClusterRegApis = {
  41. (PFNCLRTLCREATEKEY) DmRtlCreateKey,
  42. (PFNCLRTLOPENKEY) DmRtlOpenKey,
  43. (PFNCLRTLCLOSEKEY) DmCloseKey,
  44. (PFNCLRTLSETVALUE) DmSetValue,
  45. (PFNCLRTLQUERYVALUE) DmQueryValue,
  46. (PFNCLRTLENUMVALUE) DmEnumValue,
  47. (PFNCLRTLDELETEVALUE) DmDeleteValue,
  48. NULL,
  49. NULL,
  50. NULL
  51. };
  52. //
  53. // Local Functions
  54. //
  55. DWORD
  56. NmpNodeControl(
  57. IN PNM_NODE Node,
  58. IN DWORD ControlCode,
  59. IN PUCHAR InBuffer,
  60. IN DWORD InBufferSize,
  61. OUT PUCHAR OutBuffer,
  62. IN DWORD OutBufferSize,
  63. OUT LPDWORD BytesReturned,
  64. OUT LPDWORD Required
  65. );
  66. DWORD
  67. NmpNodeEnumCommonProperties(
  68. OUT PVOID OutBuffer,
  69. IN DWORD OutBufferSize,
  70. OUT LPDWORD BytesReturned,
  71. OUT LPDWORD Required
  72. );
  73. DWORD
  74. NmpNodeGetCommonProperties(
  75. IN PNM_NODE Node,
  76. IN BOOL ReadOnly,
  77. IN HDMKEY RegistryKey,
  78. OUT PVOID OutBuffer,
  79. IN DWORD OutBufferSize,
  80. OUT LPDWORD BytesReturned,
  81. OUT LPDWORD Required
  82. );
  83. DWORD
  84. NmpNodeValidateCommonProperties(
  85. IN PNM_NODE Node,
  86. IN HDMKEY RegistryKey,
  87. IN PVOID InBuffer,
  88. IN DWORD InBufferSize
  89. );
  90. DWORD
  91. NmpNodeSetCommonProperties(
  92. IN PNM_NODE Node,
  93. IN HDMKEY RegistryKey,
  94. IN PVOID InBuffer,
  95. IN DWORD InBufferSize
  96. );
  97. DWORD
  98. NmpNodeEnumPrivateProperties(
  99. IN PNM_NODE Node,
  100. IN HDMKEY RegistryKey,
  101. OUT PVOID OutBuffer,
  102. IN DWORD OutBufferSize,
  103. OUT LPDWORD BytesReturned,
  104. OUT LPDWORD Required
  105. );
  106. DWORD
  107. NmpNodeGetPrivateProperties(
  108. IN PNM_NODE Node,
  109. IN HDMKEY RegistryKey,
  110. OUT PVOID OutBuffer,
  111. IN DWORD OutBufferSize,
  112. OUT LPDWORD BytesReturned,
  113. OUT LPDWORD Required
  114. );
  115. DWORD
  116. NmpNodeValidatePrivateProperties(
  117. IN PNM_NODE Node,
  118. IN HDMKEY RegistryKey,
  119. IN PVOID InBuffer,
  120. IN DWORD InBufferSize
  121. );
  122. DWORD
  123. NmpNodeSetPrivateProperties(
  124. IN PNM_NODE Node,
  125. IN HDMKEY RegistryKey,
  126. IN PVOID InBuffer,
  127. IN DWORD InBufferSize
  128. );
  129. DWORD
  130. NmpNodeGetFlags(
  131. IN PNM_NODE Node,
  132. IN HDMKEY RegistryKey,
  133. OUT PVOID OutBuffer,
  134. IN DWORD OutBufferSize,
  135. OUT LPDWORD BytesReturned,
  136. OUT LPDWORD Required
  137. );
  138. DWORD
  139. WINAPI
  140. NmNodeControl(
  141. IN PNM_NODE Node,
  142. IN PNM_NODE HostNode OPTIONAL,
  143. IN DWORD ControlCode,
  144. IN PUCHAR InBuffer,
  145. IN DWORD InBufferSize,
  146. OUT PUCHAR OutBuffer,
  147. IN DWORD OutBufferSize,
  148. OUT LPDWORD BytesReturned,
  149. OUT LPDWORD Required
  150. )
  151. /*++
  152. Routine Description:
  153. Provides for arbitrary communication and control between an application
  154. and a specific instance of a node.
  155. Arguments:
  156. Node - Supplies the node to be controlled.
  157. HostNode - Supplies the host node on which the resource control should
  158. be delivered. If this is NULL, the local node is used. Not honored!
  159. ControlCode- Supplies the control code that defines the
  160. structure and action of the resource control.
  161. Values of ControlCode between 0 and 0x10000000 are reserved
  162. for future definition and use by Microsoft. All other values
  163. are available for use by ISVs
  164. InBuffer- Supplies a pointer to the input buffer to be passed
  165. to the resource.
  166. InBufferSize- Supplies the size, in bytes, of the data pointed
  167. to by lpInBuffer..
  168. OutBuffer- Supplies a pointer to the output buffer to be
  169. filled in by the resource..
  170. OutBufferSize- Supplies the size, in bytes, of the available
  171. space pointed to by lpOutBuffer.
  172. BytesReturned - Returns the number of bytes of lpOutBuffer
  173. actually filled in by the resource..
  174. Required - Returns the number of bytes if the OutBuffer is not big
  175. enough.
  176. Return Value:
  177. ERROR_SUCCESS if successful
  178. Win32 error code otherwise
  179. --*/
  180. {
  181. DWORD status;
  182. //
  183. // Cluster service ioctls were designed to have access modes, e.g.
  184. // read-only, read-write, etc. These access modes are not implemented.
  185. // If eventually they are implemented, an access mode check should be
  186. // placed here.
  187. //
  188. if ( CLUSCTL_GET_CONTROL_OBJECT( ControlCode ) != CLUS_OBJECT_NODE ) {
  189. return(ERROR_INVALID_FUNCTION);
  190. }
  191. if (NmpEnterApi(NmStateOnline)) {
  192. status = NmpNodeControl(
  193. Node,
  194. ControlCode,
  195. InBuffer,
  196. InBufferSize,
  197. OutBuffer,
  198. OutBufferSize,
  199. BytesReturned,
  200. Required
  201. );
  202. NmpLeaveApi();
  203. }
  204. else {
  205. status = ERROR_NODE_NOT_AVAILABLE;
  206. ClRtlLogPrint(LOG_NOISE,
  207. "[NM] Not in valid state to process NodeControl request.\n"
  208. );
  209. }
  210. return(status);
  211. } // NmNodeControl
  212. DWORD
  213. NmpNodeControl(
  214. IN PNM_NODE Node,
  215. IN DWORD ControlCode,
  216. IN PUCHAR InBuffer,
  217. IN DWORD InBufferSize,
  218. OUT PUCHAR OutBuffer,
  219. IN DWORD OutBufferSize,
  220. OUT LPDWORD BytesReturned,
  221. OUT LPDWORD Required
  222. )
  223. /*++
  224. Routine Description:
  225. Provides for arbitrary communication and control between an application
  226. and a specific instance of a node.
  227. Arguments:
  228. Node - Supplies the node to be controlled.
  229. ControlCode- Supplies the control code that defines the
  230. structure and action of the node control.
  231. Values of ControlCode between 0 and 0x10000000 are reserved
  232. for future definition and use by Microsoft. All other values
  233. are available for use by ISVs
  234. InBuffer- Supplies a pointer to the input buffer to be passed
  235. to the node.
  236. InBufferSize- Supplies the size, in bytes, of the data pointed
  237. to by lpInBuffer.
  238. OutBuffer- Supplies a pointer to the output buffer to be
  239. filled in by the node.
  240. OutBufferSize- Supplies the size, in bytes, of the available
  241. space pointed to by lpOutBuffer.
  242. BytesReturned - Returns the number of bytes of lpOutBuffer
  243. actually filled in by the node.
  244. Required - Returns the number of bytes if the OutBuffer is not big
  245. enough.
  246. Return Value:
  247. ERROR_SUCCESS if successful
  248. Win32 error code otherwise
  249. --*/
  250. {
  251. DWORD status;
  252. HDMKEY nodeKey;
  253. CLUSPROP_BUFFER_HELPER props;
  254. DWORD bufSize;
  255. nodeKey = DmOpenKey( DmNodesKey,
  256. OmObjectId( Node ),
  257. MAXIMUM_ALLOWED
  258. );
  259. if ( nodeKey == NULL ) {
  260. return(GetLastError());
  261. }
  262. switch ( ControlCode ) {
  263. case CLUSCTL_NODE_UNKNOWN:
  264. *BytesReturned = 0;
  265. status = ERROR_SUCCESS;
  266. break;
  267. case CLUSCTL_NODE_GET_NAME:
  268. if ( OmObjectName( Node ) == NULL ) {
  269. return(ERROR_NOT_READY);
  270. }
  271. props.pb = OutBuffer;
  272. bufSize = (lstrlenW( OmObjectName( Node ) ) + 1) * sizeof(WCHAR);
  273. if ( bufSize > OutBufferSize ) {
  274. *Required = bufSize;
  275. *BytesReturned = 0;
  276. status = ERROR_MORE_DATA;
  277. } else {
  278. lstrcpyW( props.psz, OmObjectName( Node ) );
  279. *BytesReturned = bufSize;
  280. *Required = 0;
  281. status = ERROR_SUCCESS;
  282. }
  283. break;
  284. case CLUSCTL_NODE_GET_ID:
  285. if ( OmObjectId( Node ) == NULL ) {
  286. return(ERROR_NOT_READY);
  287. }
  288. props.pb = OutBuffer;
  289. bufSize = (lstrlenW( OmObjectId( Node ) ) + 1) * sizeof(WCHAR);
  290. if ( bufSize > OutBufferSize ) {
  291. *Required = bufSize;
  292. *BytesReturned = 0;
  293. status = ERROR_MORE_DATA;
  294. } else {
  295. lstrcpyW( props.psz, OmObjectId( Node ) );
  296. *BytesReturned = bufSize;
  297. *Required = 0;
  298. status = ERROR_SUCCESS;
  299. }
  300. break;
  301. case CLUSCTL_NODE_ENUM_COMMON_PROPERTIES:
  302. status = NmpNodeEnumCommonProperties( OutBuffer,
  303. OutBufferSize,
  304. BytesReturned,
  305. Required );
  306. break;
  307. case CLUSCTL_NODE_GET_RO_COMMON_PROPERTIES:
  308. status = NmpNodeGetCommonProperties( Node,
  309. TRUE, // ReadOnly
  310. nodeKey,
  311. OutBuffer,
  312. OutBufferSize,
  313. BytesReturned,
  314. Required );
  315. break;
  316. case CLUSCTL_NODE_GET_COMMON_PROPERTIES:
  317. status = NmpNodeGetCommonProperties( Node,
  318. FALSE, // ReadOnly
  319. nodeKey,
  320. OutBuffer,
  321. OutBufferSize,
  322. BytesReturned,
  323. Required );
  324. break;
  325. case CLUSCTL_NODE_VALIDATE_COMMON_PROPERTIES:
  326. status = NmpNodeValidateCommonProperties( Node,
  327. nodeKey,
  328. InBuffer,
  329. InBufferSize );
  330. break;
  331. case CLUSCTL_NODE_SET_COMMON_PROPERTIES:
  332. status = NmpNodeSetCommonProperties( Node,
  333. nodeKey,
  334. InBuffer,
  335. InBufferSize );
  336. break;
  337. case CLUSCTL_NODE_ENUM_PRIVATE_PROPERTIES:
  338. status = NmpNodeEnumPrivateProperties( Node,
  339. nodeKey,
  340. OutBuffer,
  341. OutBufferSize,
  342. BytesReturned,
  343. Required );
  344. break;
  345. case CLUSCTL_NODE_GET_RO_PRIVATE_PROPERTIES:
  346. if ( OutBufferSize < sizeof(DWORD) ) {
  347. *BytesReturned = 0;
  348. *Required = sizeof(DWORD);
  349. if ( OutBuffer == NULL ) {
  350. status = ERROR_SUCCESS;
  351. } else {
  352. status = ERROR_MORE_DATA;
  353. }
  354. } else {
  355. LPDWORD ptrDword = (LPDWORD) OutBuffer;
  356. *ptrDword = 0;
  357. *BytesReturned = sizeof(DWORD);
  358. status = ERROR_SUCCESS;
  359. }
  360. break;
  361. case CLUSCTL_NODE_GET_PRIVATE_PROPERTIES:
  362. status = NmpNodeGetPrivateProperties( Node,
  363. nodeKey,
  364. OutBuffer,
  365. OutBufferSize,
  366. BytesReturned,
  367. Required );
  368. break;
  369. case CLUSCTL_NODE_VALIDATE_PRIVATE_PROPERTIES:
  370. status = NmpNodeValidatePrivateProperties( Node,
  371. nodeKey,
  372. InBuffer,
  373. InBufferSize );
  374. break;
  375. case CLUSCTL_NODE_SET_PRIVATE_PROPERTIES:
  376. status = NmpNodeSetPrivateProperties( Node,
  377. nodeKey,
  378. InBuffer,
  379. InBufferSize );
  380. break;
  381. case CLUSCTL_NODE_GET_CHARACTERISTICS:
  382. if ( OutBufferSize < sizeof(DWORD) ) {
  383. *BytesReturned = 0;
  384. *Required = sizeof(DWORD);
  385. if ( OutBuffer == NULL ) {
  386. status = ERROR_SUCCESS;
  387. } else {
  388. status = ERROR_MORE_DATA;
  389. }
  390. } else {
  391. *BytesReturned = sizeof(DWORD);
  392. *(LPDWORD)OutBuffer = 0;
  393. status = ERROR_SUCCESS;
  394. }
  395. break;
  396. case CLUSCTL_NODE_GET_FLAGS:
  397. status = NmpNodeGetFlags( Node,
  398. nodeKey,
  399. OutBuffer,
  400. OutBufferSize,
  401. BytesReturned,
  402. Required );
  403. break;
  404. default:
  405. status = ERROR_INVALID_FUNCTION;
  406. break;
  407. }
  408. DmCloseKey( nodeKey );
  409. return(status);
  410. } // NmpNodeControl
  411. DWORD
  412. NmpNodeEnumCommonProperties(
  413. OUT PVOID OutBuffer,
  414. IN DWORD OutBufferSize,
  415. OUT LPDWORD BytesReturned,
  416. OUT LPDWORD Required
  417. )
  418. /*++
  419. Routine Description:
  420. Enumerates the common property names for a given node.
  421. Arguments:
  422. OutBuffer - Supplies the output buffer.
  423. OutBufferSize - Supplies the size of the output buffer.
  424. BytesReturned - The number of bytes returned in OutBuffer.
  425. Required - The required number of bytes if OutBuffer is too small.
  426. Return Value:
  427. ERROR_SUCCESS if successful.
  428. A Win32 error code on failure.
  429. --*/
  430. {
  431. DWORD status;
  432. //
  433. // Get the common properties.
  434. //
  435. status = ClRtlEnumProperties( NmpNodeCommonProperties,
  436. OutBuffer,
  437. OutBufferSize,
  438. BytesReturned,
  439. Required );
  440. return(status);
  441. } // NmpNodeEnumCommonProperties
  442. DWORD
  443. NmpNodeGetCommonProperties(
  444. IN PNM_NODE Node,
  445. IN BOOL ReadOnly,
  446. IN HDMKEY RegistryKey,
  447. OUT PVOID OutBuffer,
  448. IN DWORD OutBufferSize,
  449. OUT LPDWORD BytesReturned,
  450. OUT LPDWORD Required
  451. )
  452. /*++
  453. Routine Description:
  454. Gets the common properties for a given node.
  455. Arguments:
  456. Node - Supplies the node.
  457. ReadOnly - TRUE if the read-only properties should be read. FALSE otherwise.
  458. RegistryKey - Supplies the registry key for this node.
  459. OutBuffer - Supplies the output buffer.
  460. OutBufferSize - Supplies the size of the output buffer.
  461. BytesReturned - The number of bytes returned in OutBuffer.
  462. Required - The required number of bytes if OutBuffer is too small.
  463. Return Value:
  464. ERROR_SUCCESS if successful.
  465. A Win32 error code on failure.
  466. --*/
  467. {
  468. DWORD status;
  469. PRESUTIL_PROPERTY_ITEM propertyTable;
  470. if ( ReadOnly ) {
  471. propertyTable = NmpNodeROCommonProperties;
  472. } else {
  473. propertyTable = NmpNodeCommonProperties;
  474. }
  475. //
  476. // Get the common properties.
  477. //
  478. status = ClRtlGetProperties( RegistryKey,
  479. &NmpClusterRegApis,
  480. propertyTable,
  481. OutBuffer,
  482. OutBufferSize,
  483. BytesReturned,
  484. Required );
  485. return(status);
  486. } // NmpNodeGetCommonProperties
  487. DWORD
  488. NmpNodeValidateCommonProperties(
  489. IN PNM_NODE Node,
  490. IN HDMKEY RegistryKey,
  491. IN PVOID InBuffer,
  492. IN DWORD InBufferSize
  493. )
  494. /*++
  495. Routine Description:
  496. Validates the common properties for a given node.
  497. Arguments:
  498. Node - Supplies the node object.
  499. InBuffer - Supplies the input buffer.
  500. InBufferSize - Supplies the size of the input buffer.
  501. Return Value:
  502. ERROR_SUCCESS if successful.
  503. A Win32 error code on failure.
  504. --*/
  505. {
  506. DWORD status;
  507. //
  508. // Validate the property list.
  509. //
  510. status = ClRtlVerifyPropertyTable( NmpNodeCommonProperties,
  511. NULL, // Reserved
  512. FALSE, // Don't allow unknowns
  513. InBuffer,
  514. InBufferSize,
  515. NULL );
  516. if ( status != ERROR_SUCCESS ) {
  517. ClRtlLogPrint( LOG_CRITICAL,
  518. "[NM] ValidateCommonProperties, error in verify routine.\n");
  519. }
  520. return(status);
  521. } // NmpNodeValidateCommonProperties
  522. DWORD
  523. NmpNodeSetCommonProperties(
  524. IN PNM_NODE Node,
  525. IN HDMKEY RegistryKey,
  526. IN PVOID InBuffer,
  527. IN DWORD InBufferSize
  528. )
  529. /*++
  530. Routine Description:
  531. Sets the common properties for a given node.
  532. Arguments:
  533. Node - Supplies the node object.
  534. InBuffer - Supplies the input buffer.
  535. InBufferSize - Supplies the size of the input buffer.
  536. Return Value:
  537. ERROR_SUCCESS if successful.
  538. A Win32 error code on failure.
  539. --*/
  540. {
  541. DWORD status;
  542. //
  543. // Validate the property list.
  544. //
  545. status = ClRtlVerifyPropertyTable( NmpNodeCommonProperties,
  546. NULL, // Reserved
  547. FALSE, // Don't allow unknowns
  548. InBuffer,
  549. InBufferSize,
  550. NULL );
  551. if ( status == ERROR_SUCCESS ) {
  552. status = ClRtlSetPropertyTable( NULL,
  553. RegistryKey,
  554. &NmpClusterRegApis,
  555. NmpNodeCommonProperties,
  556. NULL, // Reserved
  557. FALSE, // Don't allow unknowns
  558. InBuffer,
  559. InBufferSize,
  560. FALSE, // bForceWrite
  561. NULL );
  562. if ( status != ERROR_SUCCESS ) {
  563. ClRtlLogPrint( LOG_CRITICAL,
  564. "[NM] SetCommonProperties, error in set routine.\n");
  565. }
  566. } else {
  567. ClRtlLogPrint( LOG_CRITICAL,
  568. "[NM] SetCommonProperties, error in verify routine.\n");
  569. }
  570. return(status);
  571. } // NmpNodeSetCommonProperties
  572. DWORD
  573. NmpNodeEnumPrivateProperties(
  574. IN PNM_NODE Node,
  575. IN HDMKEY RegistryKey,
  576. OUT PVOID OutBuffer,
  577. IN DWORD OutBufferSize,
  578. OUT LPDWORD BytesReturned,
  579. OUT LPDWORD Required
  580. )
  581. /*++
  582. Routine Description:
  583. Enumerates the private property names for a given node.
  584. Arguments:
  585. Node - Supplies the node object.
  586. RegistryKey - Registry key for the node.
  587. OutBuffer - Supplies the output buffer.
  588. OutBufferSize - Supplies the size of the output buffer.
  589. BytesReturned - The number of bytes returned in OutBuffer.
  590. Required - The required number of bytes if OutBuffer is too small.
  591. Return Value:
  592. ERROR_SUCCESS if successful.
  593. A Win32 error code on failure.
  594. --*/
  595. {
  596. DWORD status;
  597. HDMKEY parametersKey;
  598. DWORD totalBufferSize = 0;
  599. *BytesReturned = 0;
  600. *Required = 0;
  601. //
  602. // Clear the output buffer
  603. //
  604. ZeroMemory( OutBuffer, OutBufferSize );
  605. //
  606. // Open the cluster node parameters key.
  607. //
  608. parametersKey = DmOpenKey( RegistryKey,
  609. CLUSREG_KEYNAME_PARAMETERS,
  610. MAXIMUM_ALLOWED );
  611. if ( parametersKey == NULL ) {
  612. status = GetLastError();
  613. if ( status == ERROR_FILE_NOT_FOUND ) {
  614. status = ERROR_SUCCESS;
  615. }
  616. return(status);
  617. }
  618. //
  619. // Enum the private properties for the node.
  620. //
  621. status = ClRtlEnumPrivateProperties( parametersKey,
  622. &NmpClusterRegApis,
  623. OutBuffer,
  624. OutBufferSize,
  625. BytesReturned,
  626. Required );
  627. DmCloseKey( parametersKey );
  628. return(status);
  629. } // NmpNodeEnumPrivateProperties
  630. DWORD
  631. NmpNodeGetPrivateProperties(
  632. IN PNM_NODE Node,
  633. IN HDMKEY RegistryKey,
  634. OUT PVOID OutBuffer,
  635. IN DWORD OutBufferSize,
  636. OUT LPDWORD BytesReturned,
  637. OUT LPDWORD Required
  638. )
  639. /*++
  640. Routine Description:
  641. Gets the private properties for a given node.
  642. Arguments:
  643. Node - Supplies the node object.
  644. OutBuffer - Supplies the output buffer.
  645. OutBufferSize - Supplies the size of the output buffer.
  646. BytesReturned - The number of bytes returned in OutBuffer.
  647. Required - The required number of bytes if OutBuffer is too small.
  648. Return Value:
  649. ERROR_SUCCESS if successful.
  650. A Win32 error code on failure.
  651. --*/
  652. {
  653. DWORD status;
  654. HDMKEY parametersKey;
  655. DWORD totalBufferSize = 0;
  656. *BytesReturned = 0;
  657. *Required = 0;
  658. //
  659. // Clear the output buffer
  660. //
  661. ZeroMemory( OutBuffer, OutBufferSize );
  662. //
  663. // Open the cluster node parameters key.
  664. //
  665. parametersKey = DmOpenKey( RegistryKey,
  666. CLUSREG_KEYNAME_PARAMETERS,
  667. MAXIMUM_ALLOWED );
  668. if ( parametersKey == NULL ) {
  669. status = GetLastError();
  670. if ( status == ERROR_FILE_NOT_FOUND ) {
  671. //
  672. // If we don't have a parameters key, then return an
  673. // item count of 0 and an endmark.
  674. //
  675. totalBufferSize = sizeof(DWORD) + sizeof(CLUSPROP_SYNTAX);
  676. if ( OutBufferSize < totalBufferSize ) {
  677. *Required = totalBufferSize;
  678. status = ERROR_MORE_DATA;
  679. } else {
  680. // This is somewhat redundant since we zero the
  681. // buffer above, but it's here for clarity.
  682. CLUSPROP_BUFFER_HELPER buf;
  683. buf.pb = OutBuffer;
  684. buf.pList->nPropertyCount = 0;
  685. buf.pdw++;
  686. buf.pSyntax->dw = CLUSPROP_SYNTAX_ENDMARK;
  687. *BytesReturned = totalBufferSize;
  688. status = ERROR_SUCCESS;
  689. }
  690. }
  691. return(status);
  692. }
  693. //
  694. // Get private properties for the node.
  695. //
  696. status = ClRtlGetPrivateProperties( parametersKey,
  697. &NmpClusterRegApis,
  698. OutBuffer,
  699. OutBufferSize,
  700. BytesReturned,
  701. Required );
  702. DmCloseKey( parametersKey );
  703. return(status);
  704. } // NmpNodeGetPrivateProperties
  705. DWORD
  706. NmpNodeValidatePrivateProperties(
  707. IN PNM_NODE Node,
  708. IN HDMKEY RegistryKey,
  709. IN PVOID InBuffer,
  710. IN DWORD InBufferSize
  711. )
  712. /*++
  713. Routine Description:
  714. Validates the private properties for a given node.
  715. Arguments:
  716. Node - Supplies the node object.
  717. RegistryKey - Registry key for the node.
  718. InBuffer - Supplies the input buffer.
  719. InBufferSize - Supplies the size of the input buffer.
  720. Return Value:
  721. ERROR_SUCCESS if successful.
  722. A Win32 error code on failure.
  723. --*/
  724. {
  725. DWORD status;
  726. //
  727. // Validate the property list.
  728. //
  729. status = ClRtlVerifyPrivatePropertyList( InBuffer,
  730. InBufferSize );
  731. return(status);
  732. } // NmpNodeValidatePrivateProperties
  733. DWORD
  734. NmpNodeSetPrivateProperties(
  735. IN PNM_NODE Node,
  736. IN HDMKEY RegistryKey,
  737. IN PVOID InBuffer,
  738. IN DWORD InBufferSize
  739. )
  740. /*++
  741. Routine Description:
  742. Sets the private properties for a given node.
  743. Arguments:
  744. Node - Supplies the node object.
  745. RegistryKey - Registry key for the node.
  746. InBuffer - Supplies the input buffer.
  747. InBufferSize - Supplies the size of the input buffer.
  748. Return Value:
  749. ERROR_SUCCESS if successful.
  750. A Win32 error code on failure.
  751. --*/
  752. {
  753. DWORD status;
  754. HDMKEY parametersKey;
  755. DWORD disposition;
  756. //
  757. // Validate the property list.
  758. //
  759. status = ClRtlVerifyPrivatePropertyList( InBuffer,
  760. InBufferSize );
  761. if ( status == ERROR_SUCCESS ) {
  762. //
  763. // Open the cluster node\xx\parameters key
  764. //
  765. parametersKey = DmOpenKey( RegistryKey,
  766. CLUSREG_KEYNAME_PARAMETERS,
  767. MAXIMUM_ALLOWED );
  768. if ( parametersKey == NULL ) {
  769. status = GetLastError();
  770. if ( status == ERROR_FILE_NOT_FOUND ) {
  771. //
  772. // Try to create the parameters key.
  773. //
  774. parametersKey = DmCreateKey( RegistryKey,
  775. CLUSREG_KEYNAME_PARAMETERS,
  776. 0,
  777. KEY_READ | KEY_WRITE,
  778. NULL,
  779. &disposition );
  780. if ( parametersKey == NULL ) {
  781. status = GetLastError();
  782. return(status);
  783. }
  784. }
  785. }
  786. status = ClRtlSetPrivatePropertyList( NULL, // IN HANDLE hXsaction
  787. parametersKey,
  788. &NmpClusterRegApis,
  789. InBuffer,
  790. InBufferSize );
  791. DmCloseKey( parametersKey );
  792. }
  793. return(status);
  794. } // NmpNodeSetPrivateProperties
  795. DWORD
  796. NmpNodeGetFlags(
  797. IN PNM_NODE Node,
  798. IN HDMKEY RegistryKey,
  799. OUT PVOID OutBuffer,
  800. IN DWORD OutBufferSize,
  801. OUT LPDWORD BytesReturned,
  802. OUT LPDWORD Required
  803. )
  804. /*++
  805. Routine Description:
  806. Gets the flags for a given node.
  807. Arguments:
  808. Node - Supplies the node.
  809. RegistryKey - Registry key for the node.
  810. OutBuffer - Supplies the output buffer.
  811. OutBufferSize - Supplies the size of the output buffer.
  812. BytesReturned - The number of bytes returned in OutBuffer.
  813. Required - The required number of bytes if OutBuffer is too small.
  814. Return Value:
  815. ERROR_SUCCESS if successful.
  816. A Win32 error code on failure.
  817. --*/
  818. {
  819. DWORD status;
  820. *BytesReturned = 0;
  821. if ( OutBufferSize < sizeof(DWORD) ) {
  822. *Required = sizeof(DWORD);
  823. if ( OutBuffer == NULL ) {
  824. status = ERROR_SUCCESS;
  825. } else {
  826. status = ERROR_MORE_DATA;
  827. }
  828. } else {
  829. DWORD valueType;
  830. //
  831. // Read the Flags value for the node.
  832. //
  833. *BytesReturned = OutBufferSize;
  834. status = DmQueryValue( RegistryKey,
  835. CLUSREG_NAME_FLAGS,
  836. &valueType,
  837. OutBuffer,
  838. BytesReturned );
  839. if ( status == ERROR_FILE_NOT_FOUND ) {
  840. *BytesReturned = sizeof(DWORD);
  841. *(LPDWORD)OutBuffer = 0;
  842. status = ERROR_SUCCESS;
  843. }
  844. }
  845. return(status);
  846. } // NmpNodeGetFlags