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.

1718 lines
48 KiB

  1. /*++
  2. Copyright (c) 1996-1997 Microsoft Corporation
  3. Module Name:
  4. property.c
  5. Abstract:
  6. Implements the management of resource and resource type properties.
  7. Author:
  8. Rod Gamache (rodga) 7-Jan-1996
  9. Revision History:
  10. --*/
  11. #define UNICODE 1
  12. #include "resmonp.h"
  13. #include "clusudef.h"
  14. #define RESMON_MODULE RESMON_MODULE_PROPERTY
  15. #define MAX_DWORD ((DWORD)-1)
  16. #define PARAMETERS_KEY CLUSREG_KEYNAME_PARAMETERS
  17. #define RESOURCE_TYPES_KEY CLUSREG_KEYNAME_RESOURCE_TYPES
  18. const WCHAR cszName[] = CLUSREG_NAME_RES_NAME;
  19. typedef struct _COMMON_RES_PARAMS {
  20. LPWSTR lpszResType;
  21. LPWSTR lpszDescription;
  22. LPWSTR lpszDebugPrefix;
  23. DWORD dwSeparateMonitor;
  24. DWORD dwPersistentState;
  25. DWORD dwLooksAlive;
  26. DWORD dwIsAlive;
  27. DWORD dwRestartAction;
  28. DWORD dwRestartThreshold;
  29. DWORD dwRestartPeriod;
  30. DWORD dwRetryPeriodOnFailure;
  31. DWORD dwPendingTimeout;
  32. DWORD dwLoadBalStartup;
  33. DWORD dwLoadBalSample;
  34. DWORD dwLoadBalAnalysis;
  35. DWORD dwLoadBalProcessor;
  36. DWORD dwLoadBalMemory;
  37. } COMMON_RES_PARAMS, *PCOMMON_RES_PARAMS;
  38. //
  39. // Resource Common properties.
  40. //
  41. //
  42. // Read-Write Resource Common Properties.
  43. //
  44. RESUTIL_PROPERTY_ITEM
  45. RmpResourceCommonProperties[] = {
  46. { CLUSREG_NAME_RES_TYPE, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0, FIELD_OFFSET(COMMON_RES_PARAMS, lpszResType) },
  47. { CLUSREG_NAME_RES_DESC, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0, FIELD_OFFSET(COMMON_RES_PARAMS, lpszDescription) },
  48. { CLUSREG_NAME_RES_DEBUG_PREFIX, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0, FIELD_OFFSET(COMMON_RES_PARAMS, lpszDebugPrefix) },
  49. { CLUSREG_NAME_RES_SEPARATE_MONITOR, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 1, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwSeparateMonitor) },
  50. { CLUSREG_NAME_RES_PERSISTENT_STATE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_PERSISTENT_STATE, CLUSTER_RESOURCE_MINIMUM_PERSISTENT_STATE, CLUSTER_RESOURCE_MAXIMUM_PERSISTENT_STATE, RESUTIL_PROPITEM_SIGNED, FIELD_OFFSET(COMMON_RES_PARAMS, dwPersistentState) },
  51. { CLUSREG_NAME_RES_LOOKS_ALIVE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_LOOKS_ALIVE, CLUSTER_RESOURCE_MINIMUM_LOOKS_ALIVE, CLUSTER_RESOURCE_MAXIMUM_LOOKS_ALIVE, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwLooksAlive) },
  52. { CLUSREG_NAME_RES_IS_ALIVE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_IS_ALIVE, CLUSTER_RESOURCE_MINIMUM_IS_ALIVE, CLUSTER_RESOURCE_MAXIMUM_IS_ALIVE, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwIsAlive) },
  53. { CLUSREG_NAME_RES_RESTART_ACTION, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_RESTART_ACTION, 0, CLUSTER_RESOURCE_MAXIMUM_RESTART_ACTION, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwRestartAction) },
  54. { CLUSREG_NAME_RES_RESTART_THRESHOLD, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_RESTART_THRESHOLD, CLUSTER_RESOURCE_MINIMUM_RESTART_THRESHOLD, CLUSTER_RESOURCE_MAXIMUM_RESTART_THRESHOLD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwRestartThreshold) },
  55. { CLUSREG_NAME_RES_RESTART_PERIOD, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_RESTART_PERIOD, CLUSTER_RESOURCE_MINIMUM_RESTART_PERIOD, CLUSTER_RESOURCE_MAXIMUM_RESTART_PERIOD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwRestartPeriod) },
  56. { CLUSREG_NAME_RES_RETRY_PERIOD_ON_FAILURE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_RETRY_PERIOD_ON_FAILURE, 0, MAX_DWORD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwRetryPeriodOnFailure) },
  57. { CLUSREG_NAME_RES_PENDING_TIMEOUT, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_PENDING_TIMEOUT, CLUSTER_RESOURCE_MINIMUM_PENDING_TIMEOUT, CLUSTER_RESOURCE_MAXIMUM_PENDING_TIMEOUT, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwPendingTimeout) },
  58. { CLUSREG_NAME_RES_LOADBAL_STARTUP, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_LOADBAL_STARTUP, 0, MAX_DWORD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwLoadBalStartup) },
  59. { CLUSREG_NAME_RES_LOADBAL_SAMPLE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_LOADBAL_SAMPLE, 0, MAX_DWORD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwLoadBalSample) },
  60. { CLUSREG_NAME_RES_LOADBAL_ANALYSIS, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_LOADBAL_ANALYSIS, 0, MAX_DWORD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwLoadBalAnalysis) },
  61. { CLUSREG_NAME_RES_LOADBAL_PROCESSOR, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, MAX_DWORD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwLoadBalProcessor) },
  62. { CLUSREG_NAME_RES_LOADBAL_MEMORY, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, MAX_DWORD, 0, FIELD_OFFSET(COMMON_RES_PARAMS, dwLoadBalMemory) },
  63. { 0 }
  64. };
  65. //
  66. // Read-Only Resource Common Properties.
  67. //
  68. RESUTIL_PROPERTY_ITEM
  69. RmpResourceROCommonProperties[] = {
  70. { CLUSREG_NAME_RES_NAME, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY },
  71. // { CLUSREG_NAME_RES_DEPENDS_ON, NULL, CLUSPROP_FORMAT_MULTI_SZ, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY },
  72. // { CLUSREG_NAME_RES_POSSIBLE_OWNERS, NULL, CLUSPROP_FORMAT_MULTI_SZ, 0, 0, 0, RESUTIL_PROPITEM_READ_ONLY },
  73. { 0 }
  74. };
  75. //
  76. // Resource Type Common properties
  77. //
  78. //
  79. // Read-Write Resource Type Common Properties.
  80. //
  81. RESUTIL_PROPERTY_ITEM
  82. RmpResourceTypeCommonProperties[] = {
  83. { CLUSREG_NAME_RESTYPE_NAME, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0 },
  84. { CLUSREG_NAME_RESTYPE_DESC, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0 },
  85. { CLUSREG_NAME_RESTYPE_DEBUG_PREFIX, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0 },
  86. { CLUSREG_NAME_RESTYPE_DEBUG_CTRLFUNC, NULL, CLUSPROP_FORMAT_DWORD, 0, 0, 1, 0 },
  87. { CLUSREG_NAME_ADMIN_EXT, NULL, CLUSPROP_FORMAT_MULTI_SZ, 0, 0, 0, 0 },
  88. { CLUSREG_NAME_RESTYPE_LOOKS_ALIVE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_LOOKS_ALIVE, CLUSTER_RESOURCE_MINIMUM_LOOKS_ALIVE, CLUSTER_RESOURCE_MAXIMUM_LOOKS_ALIVE, 0 },
  89. { CLUSREG_NAME_RESTYPE_IS_ALIVE, NULL, CLUSPROP_FORMAT_DWORD, CLUSTER_RESOURCE_DEFAULT_IS_ALIVE, CLUSTER_RESOURCE_MINIMUM_IS_ALIVE, CLUSTER_RESOURCE_MAXIMUM_IS_ALIVE, 0 },
  90. { 0 }
  91. };
  92. //
  93. // Read-Only Resource Type Common Properties.
  94. //
  95. RESUTIL_PROPERTY_ITEM
  96. RmpResourceTypeROCommonProperties[] = {
  97. { CLUSREG_NAME_RESTYPE_DLL_NAME, NULL, CLUSPROP_FORMAT_SZ, 0, 0, 0, 0 },
  98. { 0 }
  99. };
  100. //
  101. // Local functions
  102. //
  103. DWORD
  104. RmpCheckCommonProperties(
  105. IN PRESOURCE pResource,
  106. IN PCOMMON_RES_PARAMS pCommonParams
  107. );
  108. DWORD
  109. RmpResourceEnumCommonProperties(
  110. OUT PVOID OutBuffer,
  111. IN DWORD OutBufferSize,
  112. OUT LPDWORD BytesReturned,
  113. OUT LPDWORD Required
  114. )
  115. /*++
  116. Routine Description:
  117. Enumerates the common property names for a given resource.
  118. Arguments:
  119. OutBuffer - Supplies the output buffer.
  120. OutBufferSize - Supplies the size of the output buffer.
  121. BytesReturned - The number of bytes returned in OutBuffer.
  122. Required - The required number of bytes if OutBuffer is too small.
  123. Return Value:
  124. ERROR_SUCCESS if successful.
  125. A Win32 error code on failure.
  126. --*/
  127. {
  128. DWORD status;
  129. //
  130. // Enumerate the common properties.
  131. //
  132. status = ResUtilEnumProperties( RmpResourceCommonProperties,
  133. OutBuffer,
  134. OutBufferSize,
  135. BytesReturned,
  136. Required );
  137. return(status);
  138. } // RmpResourceEnumCommonProperties
  139. DWORD
  140. RmpResourceGetCommonProperties(
  141. IN PRESOURCE Resource,
  142. IN BOOL ReadOnly,
  143. OUT PVOID OutBuffer,
  144. IN DWORD OutBufferSize,
  145. OUT LPDWORD BytesReturned,
  146. OUT LPDWORD Required
  147. )
  148. /*++
  149. Routine Description:
  150. Gets the common properties for a given resource.
  151. Arguments:
  152. Resource - Supplies the resource.
  153. ReadOnly - TRUE to get the Read-Only Common Properties. FALSE otherwise.
  154. OutBuffer - Supplies the output buffer.
  155. OutBufferSize - Supplies the size of the output buffer.
  156. BytesReturned - The number of bytes returned in OutBuffer.
  157. Required - The required number of bytes if OutBuffer is too small.
  158. Return Value:
  159. ERROR_SUCCESS if successful.
  160. A Win32 error code on failure.
  161. --*/
  162. {
  163. DWORD status;
  164. HKEY resKey;
  165. PRESUTIL_PROPERTY_ITEM propertyTable;
  166. //
  167. // Clear the output buffer. Since this is an internal interface, we trust that
  168. // OutBuffer and OutBufferSize are valid.
  169. //
  170. if ( OutBufferSize != 0 ) {
  171. ZeroMemory( OutBuffer, OutBufferSize );
  172. }
  173. if ( ReadOnly ) {
  174. propertyTable = RmpResourceROCommonProperties;
  175. } else {
  176. propertyTable = RmpResourceCommonProperties;
  177. }
  178. //
  179. // Open the cluster resource key
  180. //
  181. status = ClusterRegOpenKey( RmpResourcesKey,
  182. Resource->ResourceId,
  183. KEY_READ,
  184. &resKey );
  185. if ( status != ERROR_SUCCESS ) {
  186. *BytesReturned = 0;
  187. *Required = 0;
  188. return(status);
  189. }
  190. //
  191. // Get the common properties.
  192. //
  193. status = ResUtilGetProperties( resKey,
  194. propertyTable,
  195. OutBuffer,
  196. OutBufferSize,
  197. BytesReturned,
  198. Required );
  199. ClusterRegCloseKey( resKey );
  200. return(status);
  201. } // RmpResourceGetCommonProperties
  202. DWORD
  203. RmpResourceValidateCommonProperties(
  204. IN PRESOURCE Resource,
  205. IN PVOID InBuffer,
  206. IN DWORD InBufferSize
  207. )
  208. /*++
  209. Routine Description:
  210. Validates the common properties for a given resource.
  211. Arguments:
  212. Resource - Supplies the resource.
  213. InBuffer - Supplies the input buffer.
  214. InBufferSize - Supplies the size of the input buffer.
  215. Return Value:
  216. ERROR_SUCCESS if successful.
  217. A Win32 error code on failure.
  218. --*/
  219. {
  220. DWORD status;
  221. COMMON_RES_PARAMS CommonProps;
  222. ZeroMemory( &CommonProps, sizeof ( COMMON_RES_PARAMS ) );
  223. //
  224. // Validate the property list.
  225. //
  226. status = ResUtilVerifyPropertyTable( RmpResourceCommonProperties,
  227. NULL, // Reserved
  228. FALSE, // Don't allow unknowns
  229. InBuffer,
  230. InBufferSize,
  231. ( LPBYTE ) &CommonProps );
  232. if ( status != ERROR_SUCCESS ) {
  233. ClRtlLogPrint(LOG_UNUSUAL,
  234. "[RM] RmpResourceValidateCommonProperties, Error %1!d! in verify routine for resource %2!ws!\n",
  235. status,
  236. Resource->ResourceName);
  237. } else {
  238. //
  239. // Chittur Subbaraman (chitturs) - 5/7/99
  240. //
  241. // Validate the values of the common properties supplied
  242. //
  243. status = RmpCheckCommonProperties( Resource, &CommonProps );
  244. if ( status != ERROR_SUCCESS ) {
  245. ClRtlLogPrint(LOG_UNUSUAL,
  246. "[RM] RmpResourceValidateCommonProperties, Error %1!d! in "
  247. "checking routine for resource %2!ws!\n",
  248. status,
  249. Resource->ResourceName);
  250. }
  251. }
  252. ResUtilFreeParameterBlock(( LPBYTE ) &CommonProps,
  253. NULL,
  254. RmpResourceCommonProperties
  255. );
  256. return(status);
  257. } // RmpResourceValidateCommonProperties
  258. DWORD
  259. RmpResourceSetCommonProperties(
  260. IN PRESOURCE Resource,
  261. IN PVOID InBuffer,
  262. IN DWORD InBufferSize
  263. )
  264. /*++
  265. Routine Description:
  266. Sets the common properties for a given resource.
  267. Arguments:
  268. Resource - Supplies the resource.
  269. InBuffer - Supplies the input buffer.
  270. InBufferSize - Supplies the size of the input buffer.
  271. Return Value:
  272. ERROR_SUCCESS if successful.
  273. A Win32 error code on failure.
  274. --*/
  275. {
  276. DWORD status;
  277. HKEY resKey = NULL;
  278. DWORD oldSeparateMonitor;
  279. DWORD newSeparateMonitor;
  280. COMMON_RES_PARAMS CommonProps;
  281. ZeroMemory( &CommonProps, sizeof ( COMMON_RES_PARAMS ) );
  282. //
  283. // Validate the property list.
  284. //
  285. status = ResUtilVerifyPropertyTable( RmpResourceCommonProperties,
  286. NULL, // Reserved
  287. FALSE, // Don't allow unknowns
  288. InBuffer,
  289. InBufferSize,
  290. ( LPBYTE ) &CommonProps );
  291. if ( status == ERROR_SUCCESS ) {
  292. //
  293. // Chittur Subbaraman (chitturs) - 5/7/99
  294. //
  295. // Validate the values of the common properties supplied
  296. //
  297. status = RmpCheckCommonProperties( Resource, &CommonProps );
  298. if ( status != ERROR_SUCCESS ) {
  299. ClRtlLogPrint(LOG_UNUSUAL,
  300. "[RM] RmpResourceSetCommonProperties, Error %1!d! in "
  301. "checking routine for resource %2!ws!\n",
  302. status,
  303. Resource->ResourceName);
  304. goto FnExit;
  305. }
  306. //
  307. // Open the cluster resource key
  308. //
  309. status = ClusterRegOpenKey( RmpResourcesKey,
  310. Resource->ResourceId,
  311. KEY_READ,
  312. &resKey );
  313. if ( status != ERROR_SUCCESS ) {
  314. goto FnExit;
  315. }
  316. //
  317. // Get the current SeparateMonitor value.
  318. //
  319. status = ResUtilGetDwordValue( resKey,
  320. CLUSREG_NAME_RES_SEPARATE_MONITOR,
  321. &oldSeparateMonitor,
  322. 0 );
  323. if ( status != ERROR_SUCCESS ) {
  324. ClRtlLogPrint(LOG_UNUSUAL,
  325. "[RM] RmpResourceSetCommonProperties, error %1!d! in getting "
  326. "'SeparateMonitor' value for resource %2!ws!.\n",
  327. status,
  328. Resource->ResourceName);
  329. goto FnExit;
  330. }
  331. status = ResUtilSetPropertyTable( resKey,
  332. RmpResourceCommonProperties,
  333. NULL, // Reserved
  334. FALSE, // Don't allow unknowns
  335. InBuffer,
  336. InBufferSize,
  337. NULL );
  338. if ( status != ERROR_SUCCESS ) {
  339. ClRtlLogPrint(LOG_UNUSUAL,
  340. "[RM] RmpResourceSetCommonProperties, Error %1!d! in set routine for resource %2!ws!.\n",
  341. status,
  342. Resource->ResourceName);
  343. } else {
  344. //
  345. // Get the new SeparateMonitor value. If it changed, return a
  346. // different error code.
  347. //
  348. status = ResUtilGetDwordValue( resKey,
  349. CLUSREG_NAME_RES_SEPARATE_MONITOR,
  350. &newSeparateMonitor,
  351. 0 );
  352. if ( status == ERROR_SUCCESS ) {
  353. if ( oldSeparateMonitor != newSeparateMonitor ) {
  354. status = ERROR_RESOURCE_PROPERTIES_STORED;
  355. }
  356. }
  357. }
  358. } else {
  359. ClRtlLogPrint(LOG_UNUSUAL,
  360. "[RM] RmpResourceSetCommonProperties, error %1!d! in verify routine for resource %2!ws!.\n",
  361. status,
  362. Resource->ResourceName);
  363. }
  364. FnExit:
  365. ResUtilFreeParameterBlock(( LPBYTE ) &CommonProps,
  366. NULL,
  367. RmpResourceCommonProperties
  368. );
  369. if ( resKey != NULL ) {
  370. ClusterRegCloseKey( resKey );
  371. }
  372. return( status );
  373. } // RmpResourceSetCommonProperties
  374. DWORD
  375. RmpResourceEnumPrivateProperties(
  376. IN PRESOURCE Resource,
  377. OUT PVOID OutBuffer,
  378. IN DWORD OutBufferSize,
  379. OUT LPDWORD BytesReturned,
  380. OUT LPDWORD Required
  381. )
  382. /*++
  383. Routine Description:
  384. Enumerates the private property names for a given resource.
  385. Arguments:
  386. Resource - Supplies the resource.
  387. OutBuffer - Supplies the output buffer.
  388. OutBufferSize - Supplies the size of the output buffer.
  389. BytesReturned - The number of bytes returned in OutBuffer.
  390. Required - The required number of bytes if OutBuffer is too small.
  391. Return Value:
  392. ERROR_SUCCESS if successful.
  393. A Win32 error code on failure.
  394. --*/
  395. {
  396. DWORD status;
  397. HKEY resKey;
  398. WCHAR PrivateProperties[] = L"12345678-1234-1234-1234-123456789012\\Parameters";
  399. *BytesReturned = 0;
  400. *Required = 0;
  401. //
  402. // Copy the ResourceId for opening the private properties.
  403. //
  404. CL_ASSERT( lstrlenW( Resource->ResourceId ) == (32+4) );
  405. MoveMemory( PrivateProperties,
  406. Resource->ResourceId,
  407. lstrlenW( Resource->ResourceId ) * sizeof(WCHAR) );
  408. //
  409. // Open the cluster resource key
  410. //
  411. status = ClusterRegOpenKey( RmpResourcesKey,
  412. PrivateProperties,
  413. KEY_READ,
  414. &resKey );
  415. if ( status != ERROR_SUCCESS ) {
  416. return(status);
  417. }
  418. //
  419. // Enumerate the private properties.
  420. //
  421. status = ResUtilEnumPrivateProperties( resKey,
  422. OutBuffer,
  423. OutBufferSize,
  424. BytesReturned,
  425. Required );
  426. ClusterRegCloseKey( resKey );
  427. return(status);
  428. } // RmpResourceEnumPrivateProperties
  429. DWORD
  430. RmpResourceGetPrivateProperties(
  431. IN PRESOURCE Resource,
  432. OUT PVOID OutBuffer,
  433. IN DWORD OutBufferSize,
  434. OUT LPDWORD BytesReturned,
  435. OUT LPDWORD Required
  436. )
  437. /*++
  438. Routine Description:
  439. Gets the private properties for a given resource.
  440. Arguments:
  441. Resource - Supplies the resource.
  442. OutBuffer - Supplies the output buffer.
  443. OutBufferSize - Supplies the size of the output buffer.
  444. BytesReturned - The number of bytes returned in OutBuffer.
  445. Required - The required number of bytes if OutBuffer is too small.
  446. Return Value:
  447. ERROR_SUCCESS if successful.
  448. A Win32 error code on failure.
  449. --*/
  450. {
  451. DWORD status;
  452. HKEY resKey;
  453. WCHAR PrivateProperties[] = L"12345678-1234-1234-1234-123456789012\\Parameters";
  454. *BytesReturned = 0;
  455. *Required = 0;
  456. //
  457. // Copy the ResourceId for opening the private properties.
  458. //
  459. CL_ASSERT( lstrlenW( Resource->ResourceId ) == (32+4) );
  460. MoveMemory( PrivateProperties,
  461. Resource->ResourceId,
  462. lstrlenW( Resource->ResourceId ) * sizeof(WCHAR) );
  463. //
  464. // Open the cluster resource key
  465. //
  466. status = ClusterRegOpenKey( RmpResourcesKey,
  467. PrivateProperties,
  468. KEY_READ,
  469. &resKey );
  470. if ( status != ERROR_SUCCESS ) {
  471. if ( status == ERROR_FILE_NOT_FOUND ) {
  472. if ( OutBufferSize < sizeof( DWORD ) ) {
  473. *Required = 4;
  474. } else {
  475. *((LPDWORD) OutBuffer) = 0;
  476. *BytesReturned = sizeof( DWORD );
  477. }
  478. status = ERROR_SUCCESS;
  479. }
  480. return(status);
  481. }
  482. //
  483. // Get private properties for the resource.
  484. //
  485. status = ResUtilGetPrivateProperties( resKey,
  486. OutBuffer,
  487. OutBufferSize,
  488. BytesReturned,
  489. Required );
  490. ClusterRegCloseKey( resKey );
  491. return(status);
  492. } // RmpResourceGetPrivateProperties
  493. DWORD
  494. RmpResourceValidatePrivateProperties(
  495. IN PRESOURCE Resource,
  496. IN PVOID InBuffer,
  497. IN DWORD InBufferSize
  498. )
  499. /*++
  500. Routine Description:
  501. Validates the private properties for a given resource.
  502. Arguments:
  503. Resource - Supplies the resource.
  504. InBuffer - Supplies the input buffer.
  505. InBufferSize - Supplies the size of the input buffer.
  506. Return Value:
  507. ERROR_SUCCESS if successful.
  508. A Win32 error code on failure.
  509. --*/
  510. {
  511. DWORD status;
  512. //
  513. // Validate the property list.
  514. //
  515. status = ResUtilVerifyPrivatePropertyList( InBuffer,
  516. InBufferSize );
  517. return(status);
  518. } // RmpResourceValidatePrivateProperties
  519. DWORD
  520. RmpResourceSetPrivateProperties(
  521. IN PRESOURCE Resource,
  522. IN PVOID InBuffer,
  523. IN DWORD InBufferSize
  524. )
  525. /*++
  526. Routine Description:
  527. Sets the private properties for a given resource.
  528. Arguments:
  529. Resource - Supplies the resource.
  530. InBuffer - Supplies the input buffer.
  531. InBufferSize - Supplies the size of the input buffer.
  532. Return Value:
  533. ERROR_SUCCESS if successful.
  534. A Win32 error code on failure.
  535. --*/
  536. {
  537. DWORD status;
  538. HKEY resKey;
  539. WCHAR PrivateProperties[] = L"12345678-1234-1234-1234-123456789012\\Parameters";
  540. //
  541. // Validate the property list.
  542. //
  543. status = ResUtilVerifyPrivatePropertyList( InBuffer,
  544. InBufferSize );
  545. if ( status == ERROR_SUCCESS ) {
  546. //
  547. // Copy the ResourceId for opening the private properties.
  548. //
  549. CL_ASSERT( lstrlenW( Resource->ResourceId ) == (32+4) );
  550. MoveMemory( PrivateProperties,
  551. Resource->ResourceId,
  552. lstrlenW(Resource->ResourceId) * sizeof(WCHAR) );
  553. //
  554. // Open the cluster resource key
  555. //
  556. status = ClusterRegOpenKey( RmpResourcesKey,
  557. PrivateProperties,
  558. KEY_READ,
  559. &resKey );
  560. if ( status != ERROR_SUCCESS ) {
  561. return(status);
  562. }
  563. status = ResUtilSetPrivatePropertyList( resKey,
  564. InBuffer,
  565. InBufferSize );
  566. ClusterRegCloseKey( resKey );
  567. }
  568. return(status);
  569. } // RmpResourceSetPrivateProperties
  570. DWORD
  571. RmpResourceGetFlags(
  572. IN PRESOURCE Resource,
  573. OUT PVOID OutBuffer,
  574. IN DWORD OutBufferSize,
  575. OUT LPDWORD BytesReturned,
  576. OUT LPDWORD Required
  577. )
  578. /*++
  579. Routine Description:
  580. Gets the flags for a given resource.
  581. Arguments:
  582. Resource - Supplies the resource.
  583. OutBuffer - Supplies the output buffer.
  584. OutBufferSize - Supplies the size of the output buffer.
  585. BytesReturned - The number of bytes returned in OutBuffer.
  586. Required - The required number of bytes if OutBuffer is too small.
  587. Return Value:
  588. ERROR_SUCCESS if successful.
  589. A Win32 error code on failure.
  590. --*/
  591. {
  592. DWORD status;
  593. *BytesReturned = 0;
  594. if ( OutBufferSize < sizeof(DWORD) ) {
  595. *Required = sizeof(DWORD);
  596. if ( OutBuffer == NULL ) {
  597. status = ERROR_SUCCESS;
  598. } else {
  599. status = ERROR_MORE_DATA;
  600. }
  601. } else {
  602. HKEY resKey;
  603. DWORD valueType;
  604. //
  605. // Open the cluster resource key
  606. //
  607. status = ClusterRegOpenKey( RmpResourcesKey,
  608. Resource->ResourceId,
  609. KEY_READ,
  610. &resKey );
  611. if ( status == ERROR_SUCCESS ) {
  612. //
  613. // Read the Flags value for the resource.
  614. //
  615. *BytesReturned = OutBufferSize;
  616. status = ClusterRegQueryValue( resKey,
  617. CLUSREG_NAME_FLAGS,
  618. &valueType,
  619. OutBuffer,
  620. BytesReturned );
  621. ClusterRegCloseKey( resKey );
  622. if ( status == ERROR_FILE_NOT_FOUND ) {
  623. *BytesReturned = sizeof(DWORD);
  624. *(LPDWORD)OutBuffer = 0;
  625. status = ERROR_SUCCESS;
  626. }
  627. }
  628. }
  629. return(status);
  630. } // RmpResourceGetFlags
  631. DWORD
  632. RmpResourceTypeEnumCommonProperties(
  633. IN LPCWSTR ResourceTypeName,
  634. OUT PVOID OutBuffer,
  635. IN DWORD OutBufferSize,
  636. OUT LPDWORD BytesReturned,
  637. OUT LPDWORD Required
  638. )
  639. /*++
  640. Routine Description:
  641. Enumerates the common property names for a given resource type.
  642. Arguments:
  643. ResourceTypeName - Supplies the resource type's name.
  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. //
  655. // Enumerate the common properties.
  656. //
  657. status = ResUtilEnumProperties( RmpResourceTypeCommonProperties,
  658. OutBuffer,
  659. OutBufferSize,
  660. BytesReturned,
  661. Required );
  662. return(status);
  663. } // RmpResourceTypeEnumCommonProperties
  664. DWORD
  665. RmpResourceTypeGetCommonProperties(
  666. IN LPCWSTR ResourceTypeName,
  667. IN BOOL ReadOnly,
  668. OUT PVOID OutBuffer,
  669. IN DWORD OutBufferSize,
  670. OUT LPDWORD BytesReturned,
  671. OUT LPDWORD Required
  672. )
  673. /*++
  674. Routine Description:
  675. Gets the common properties for a given resource type.
  676. Arguments:
  677. ResourceTypeName - Supplies the resource type name.
  678. OutBuffer - Supplies the output buffer.
  679. OutBufferSize - Supplies the size of the output buffer.
  680. BytesReturned - The number of bytes returned in OutBuffer.
  681. Required - The required number of bytes if OutBuffer is too small.
  682. Return Value:
  683. ERROR_SUCCESS if successful.
  684. A Win32 error code on failure.
  685. --*/
  686. {
  687. DWORD status;
  688. HKEY resourceTypesKey;
  689. HKEY resTypeKey;
  690. PRESUTIL_PROPERTY_ITEM propertyTable;
  691. *BytesReturned = 0;
  692. *Required = 0;
  693. //
  694. // Clear the output buffer
  695. //
  696. ZeroMemory( OutBuffer, OutBufferSize );
  697. if ( ReadOnly ) {
  698. propertyTable = RmpResourceTypeROCommonProperties;
  699. } else {
  700. propertyTable = RmpResourceTypeCommonProperties;
  701. }
  702. //
  703. // Open the specific cluster ResourceType key
  704. //
  705. status = ClusterRegOpenKey( RmpResTypesKey,
  706. ResourceTypeName,
  707. KEY_READ,
  708. &resTypeKey );
  709. if ( status != ERROR_SUCCESS ) {
  710. return(status);
  711. }
  712. //
  713. // Get the common properties.
  714. //
  715. status = ResUtilGetProperties( resTypeKey,
  716. propertyTable,
  717. OutBuffer,
  718. OutBufferSize,
  719. BytesReturned,
  720. Required );
  721. ClusterRegCloseKey( resTypeKey );
  722. return(status);
  723. } // RmpResourceTypeGetCommonProperties
  724. DWORD
  725. RmpResourceTypeValidateCommonProperties(
  726. IN LPCWSTR ResourceTypeName,
  727. IN PVOID InBuffer,
  728. IN DWORD InBufferSize
  729. )
  730. /*++
  731. Routine Description:
  732. Validates the common properties for a given resource type.
  733. Arguments:
  734. ResourceTypeName - Supplies the resource type name.
  735. InBuffer - Supplies the input buffer.
  736. InBufferSize - Supplies the size of the input buffer.
  737. Return Value:
  738. ERROR_SUCCESS if successful.
  739. A Win32 error code on failure.
  740. --*/
  741. {
  742. DWORD status;
  743. //
  744. // Validate the property list.
  745. //
  746. status = ResUtilVerifyPropertyTable( RmpResourceTypeCommonProperties,
  747. NULL, // Reserved
  748. FALSE, // Don't allow unknowns
  749. InBuffer,
  750. InBufferSize,
  751. NULL );
  752. if ( status != ERROR_SUCCESS ) {
  753. ClRtlLogPrint(LOG_UNUSUAL,
  754. "[RM] RmpResourceTypeValidateCommonProperties, error in verify routine.\n");
  755. }
  756. return(status);
  757. } // RmpResourceTypeValidateCommonProperties
  758. DWORD
  759. RmpResourceTypeSetCommonProperties(
  760. IN LPCWSTR ResourceTypeName,
  761. IN PVOID InBuffer,
  762. IN DWORD InBufferSize
  763. )
  764. /*++
  765. Routine Description:
  766. Sets the common properties for a given resource type.
  767. Arguments:
  768. ResourceTypeName - Supplies the resource type name.
  769. InBuffer - Supplies the input buffer.
  770. InBufferSize - Supplies the size of the input buffer.
  771. Return Value:
  772. ERROR_SUCCESS if successful.
  773. A Win32 error code on failure.
  774. --*/
  775. {
  776. DWORD status;
  777. HKEY resourceTypesKey;
  778. HKEY resTypeKey;
  779. //
  780. // Validate the property list.
  781. //
  782. status = ResUtilVerifyPropertyTable( RmpResourceTypeCommonProperties,
  783. NULL, // Reserved
  784. FALSE, // Don't allow unknowns
  785. InBuffer,
  786. InBufferSize,
  787. NULL );
  788. if ( status == ERROR_SUCCESS ) {
  789. //
  790. // Open the specific cluster resource type key
  791. //
  792. status = ClusterRegOpenKey( RmpResTypesKey,
  793. ResourceTypeName,
  794. KEY_READ,
  795. &resTypeKey );
  796. if ( status != ERROR_SUCCESS ) {
  797. ClRtlLogPrint(LOG_UNUSUAL,
  798. "[RM] Failed to open ResourceTypes\\%1 cluster registry key, error %2!u!.\n",
  799. ResourceTypeName,
  800. status);
  801. return(status);
  802. }
  803. status = ResUtilSetPropertyTable( resTypeKey,
  804. RmpResourceTypeCommonProperties,
  805. NULL, // Reserved
  806. FALSE, // Don't allow unknowns
  807. InBuffer,
  808. InBufferSize,
  809. NULL );
  810. ClusterRegCloseKey( resTypeKey );
  811. if ( status != ERROR_SUCCESS ) {
  812. ClRtlLogPrint( LOG_UNUSUAL, "[RM] RmpResourceTypeSetCommonProperties, error in set routine.\n");
  813. }
  814. } else {
  815. ClRtlLogPrint( LOG_UNUSUAL, "[RM] RmpResourceTypeSetCommonProperties, error in verify routine.\n");
  816. }
  817. return(status);
  818. } // RmpResourceTypeSetCommonProperties
  819. DWORD
  820. RmpResourceTypeEnumPrivateProperties(
  821. IN LPCWSTR ResourceTypeName,
  822. OUT PVOID OutBuffer,
  823. IN DWORD OutBufferSize,
  824. OUT LPDWORD BytesReturned,
  825. OUT LPDWORD Required
  826. )
  827. /*++
  828. Routine Description:
  829. Enumerates the private property names for a given resource type.
  830. Arguments:
  831. ResourceTypeName - Supplies the resource type's name.
  832. OutBuffer - Supplies the output buffer.
  833. OutBufferSize - Supplies the size of the output buffer.
  834. BytesReturned - The number of bytes returned in OutBuffer.
  835. Required - The required number of bytes if OutBuffer is too small.
  836. Return Value:
  837. ERROR_SUCCESS if successful.
  838. A Win32 error code on failure.
  839. --*/
  840. {
  841. DWORD status;
  842. HKEY resTypeKey;
  843. DWORD nameLength;
  844. LPWSTR name;
  845. *BytesReturned = 0;
  846. *Required = 0;
  847. //
  848. // Create name to open
  849. //
  850. nameLength = lstrlenW( ResourceTypeName ) + sizeof( PARAMETERS_KEY ) + 1;
  851. name = RmpAlloc( nameLength * sizeof(WCHAR) );
  852. if ( name == NULL ) {
  853. return(ERROR_NOT_ENOUGH_MEMORY);
  854. }
  855. wsprintfW( name, L"%ws\\%ws", ResourceTypeName, PARAMETERS_KEY );
  856. //
  857. // Open the specific cluster ResourceType key
  858. //
  859. status = ClusterRegOpenKey( RmpResTypesKey,
  860. name,
  861. KEY_READ,
  862. &resTypeKey );
  863. RmpFree( name );
  864. if ( status != ERROR_SUCCESS ) {
  865. if ( status == ERROR_FILE_NOT_FOUND ) {
  866. status = ERROR_SUCCESS;
  867. }
  868. return(status);
  869. }
  870. //
  871. // Enumerate the private properties.
  872. //
  873. status = ResUtilEnumPrivateProperties( resTypeKey,
  874. OutBuffer,
  875. OutBufferSize,
  876. BytesReturned,
  877. Required );
  878. ClusterRegCloseKey( resTypeKey );
  879. return(status);
  880. } // RmpResourceTypeEnumPrivateProperties
  881. DWORD
  882. RmpResourceTypeGetPrivateProperties(
  883. IN LPCWSTR ResourceTypeName,
  884. OUT PVOID OutBuffer,
  885. IN DWORD OutBufferSize,
  886. OUT LPDWORD BytesReturned,
  887. OUT LPDWORD Required
  888. )
  889. /*++
  890. Routine Description:
  891. Gets the private properties for a given resource.
  892. Arguments:
  893. ResourceTypeName - Supplies the resource type name.
  894. OutBuffer - Supplies the output buffer.
  895. OutBufferSize - Supplies the size of the output buffer.
  896. BytesReturned - The number of bytes returned in OutBuffer.
  897. Required - The required number of bytes if OutBuffer is too small.
  898. Return Value:
  899. ERROR_SUCCESS if successful.
  900. A Win32 error code on failure.
  901. --*/
  902. {
  903. DWORD status;
  904. HKEY resTypeKey;
  905. DWORD nameLength;
  906. LPWSTR name;
  907. *BytesReturned = 0;
  908. *Required = 0;
  909. //
  910. // Create name to open
  911. //
  912. nameLength = lstrlenW( ResourceTypeName ) + sizeof( PARAMETERS_KEY ) + 1;
  913. name = RmpAlloc( nameLength * sizeof(WCHAR) );
  914. if ( name == NULL ) {
  915. return(ERROR_NOT_ENOUGH_MEMORY);
  916. }
  917. wsprintfW( name, L"%ws\\%ws", ResourceTypeName, PARAMETERS_KEY );
  918. //
  919. // Open the specific cluster ResourceType key
  920. //
  921. status = ClusterRegOpenKey( RmpResTypesKey,
  922. name,
  923. KEY_READ,
  924. &resTypeKey );
  925. RmpFree( name );
  926. if ( status != ERROR_SUCCESS ) {
  927. if ( status == ERROR_FILE_NOT_FOUND ) {
  928. if ( OutBufferSize < sizeof( DWORD ) ) {
  929. *Required = 4;
  930. } else {
  931. *((LPDWORD) OutBuffer) = 0;
  932. *BytesReturned = sizeof( DWORD );
  933. }
  934. status = ERROR_SUCCESS;
  935. }
  936. return(status);
  937. }
  938. //
  939. // Get private properties for the resource type.
  940. //
  941. status = ResUtilGetPrivateProperties( resTypeKey,
  942. OutBuffer,
  943. OutBufferSize,
  944. BytesReturned,
  945. Required );
  946. ClusterRegCloseKey( resTypeKey );
  947. return(status);
  948. } // RmpResourceTypeGetPrivateProperties
  949. DWORD
  950. RmpResourceTypeValidatePrivateProperties(
  951. IN LPCWSTR ResourceTypeName,
  952. IN PVOID InBuffer,
  953. IN DWORD InBufferSize
  954. )
  955. /*++
  956. Routine Description:
  957. Validates the private properties for a given resource.
  958. Arguments:
  959. ResourceTypeName - Supplies the resource type name.
  960. InBuffer - Supplies the input buffer.
  961. InBufferSize - Supplies the size of the input buffer.
  962. Return Value:
  963. ERROR_SUCCESS if successful.
  964. A Win32 error code on failure.
  965. --*/
  966. {
  967. DWORD status;
  968. //
  969. // Validate the property list.
  970. //
  971. status = ResUtilVerifyPrivatePropertyList( InBuffer,
  972. InBufferSize );
  973. return(status);
  974. } // RmpResourceTypeValidatePrivateProperties
  975. DWORD
  976. RmpResourceTypeSetPrivateProperties(
  977. IN LPCWSTR ResourceTypeName,
  978. IN PVOID InBuffer,
  979. IN DWORD InBufferSize
  980. )
  981. /*++
  982. Routine Description:
  983. Sets the private properties for a given resource.
  984. Arguments:
  985. ResourceTypeName - Supplies the resource type name.
  986. InBuffer - Supplies the input buffer.
  987. InBufferSize - Supplies the size of the input buffer.
  988. Return Value:
  989. ERROR_SUCCESS if successful.
  990. A Win32 error code on failure.
  991. --*/
  992. {
  993. DWORD status;
  994. HKEY resourceTypesKey;
  995. HKEY resTypeKey;
  996. LPWSTR name;
  997. DWORD length;
  998. DWORD disposition;
  999. //
  1000. // Validate the property list.
  1001. //
  1002. status = ResUtilVerifyPrivatePropertyList( InBuffer,
  1003. InBufferSize );
  1004. if ( status == ERROR_SUCCESS ) {
  1005. //
  1006. // Create name to open
  1007. //
  1008. length = lstrlenW( ResourceTypeName ) + 1;
  1009. name = RmpAlloc( length * sizeof(WCHAR) );
  1010. if ( name == NULL ) {
  1011. return(ERROR_NOT_ENOUGH_MEMORY);
  1012. }
  1013. lstrcpyW( name, ResourceTypeName );
  1014. //
  1015. // Open the specific cluster ResourceType key
  1016. //
  1017. status = ClusterRegOpenKey( RmpResTypesKey,
  1018. name,
  1019. KEY_READ,
  1020. &resourceTypesKey );
  1021. RmpFree( name );
  1022. if ( status != ERROR_SUCCESS ) {
  1023. if ( status == ERROR_FILE_NOT_FOUND ) {
  1024. status = ERROR_SUCCESS;
  1025. }
  1026. return(status);
  1027. }
  1028. //
  1029. // Open the parameters key
  1030. //
  1031. status = ClusterRegOpenKey( resourceTypesKey,
  1032. PARAMETERS_KEY,
  1033. KEY_READ,
  1034. &resTypeKey );
  1035. if ( status != ERROR_SUCCESS ) {
  1036. if ( status == ERROR_FILE_NOT_FOUND ) {
  1037. //
  1038. // Try to create the parameters key.
  1039. //
  1040. status = ClusterRegCreateKey( resourceTypesKey,
  1041. PARAMETERS_KEY,
  1042. 0,
  1043. KEY_READ | KEY_WRITE,
  1044. NULL,
  1045. &resTypeKey,
  1046. &disposition );
  1047. if ( status != ERROR_SUCCESS ) {
  1048. ClusterRegCloseKey( resourceTypesKey );
  1049. return(status);
  1050. }
  1051. }
  1052. }
  1053. if ( status == ERROR_SUCCESS ) {
  1054. status = ResUtilSetPrivatePropertyList( resTypeKey,
  1055. InBuffer,
  1056. InBufferSize );
  1057. ClusterRegCloseKey( resTypeKey );
  1058. }
  1059. ClusterRegCloseKey( resourceTypesKey );
  1060. }
  1061. return(status);
  1062. } // RmpResourceTypeSetPrivateProperties
  1063. DWORD
  1064. RmpResourceTypeGetFlags(
  1065. IN LPCWSTR ResourceTypeName,
  1066. OUT PVOID OutBuffer,
  1067. IN DWORD OutBufferSize,
  1068. OUT LPDWORD BytesReturned,
  1069. OUT LPDWORD Required
  1070. )
  1071. /*++
  1072. Routine Description:
  1073. Gets the flags for a given resource type.
  1074. Arguments:
  1075. ResourceTypeName - Supplies the resource type name.
  1076. OutBuffer - Supplies the output buffer.
  1077. OutBufferSize - Supplies the size of the output buffer.
  1078. BytesReturned - The number of bytes returned in OutBuffer.
  1079. Required - The required number of bytes if OutBuffer is too small.
  1080. Return Value:
  1081. ERROR_SUCCESS if successful.
  1082. A Win32 error code on failure.
  1083. --*/
  1084. {
  1085. DWORD status;
  1086. *BytesReturned = 0;
  1087. if ( OutBufferSize < sizeof(DWORD) ) {
  1088. *Required = sizeof(DWORD);
  1089. if ( OutBuffer == NULL ) {
  1090. status = ERROR_SUCCESS;
  1091. } else {
  1092. status = ERROR_MORE_DATA;
  1093. }
  1094. } else {
  1095. HKEY resourceTypesKey;
  1096. HKEY resTypeKey;
  1097. DWORD valueType;
  1098. //
  1099. // Open the specific cluster ResourceType key
  1100. //
  1101. status = ClusterRegOpenKey( RmpResTypesKey,
  1102. ResourceTypeName,
  1103. KEY_READ,
  1104. &resTypeKey );
  1105. if ( status == ERROR_SUCCESS ) {
  1106. //
  1107. // Read the Flags value for the resource type.
  1108. //
  1109. *BytesReturned = OutBufferSize;
  1110. status = ClusterRegQueryValue( resTypeKey,
  1111. CLUSREG_NAME_FLAGS,
  1112. &valueType,
  1113. OutBuffer,
  1114. BytesReturned );
  1115. ClusterRegCloseKey( resTypeKey );
  1116. if ( status == ERROR_FILE_NOT_FOUND ) {
  1117. *(LPDWORD)OutBuffer = 0;
  1118. *BytesReturned = sizeof(DWORD);
  1119. status = ERROR_SUCCESS;
  1120. }
  1121. }
  1122. }
  1123. return(status);
  1124. } // RmpResourceTypeGetFlags
  1125. DWORD
  1126. RmpCheckCommonProperties(
  1127. IN PRESOURCE pResource,
  1128. IN PCOMMON_RES_PARAMS pCommonParams
  1129. )
  1130. /*++
  1131. Routine Description:
  1132. Checks and validates the supplied values of common properties.
  1133. Arguments:
  1134. pResource - Pointer to the resource.
  1135. pCommonParams - The parameter block supplied by the user.
  1136. Return Value:
  1137. ERROR_SUCCESS if successful.
  1138. A Win32 error code on failure.
  1139. --*/
  1140. {
  1141. DWORD dwStatus;
  1142. COMMON_RES_PARAMS
  1143. currentCommonParams;
  1144. LPBYTE pBuffer = NULL;
  1145. DWORD dwBytesReturned = 0;
  1146. DWORD dwBytesRequired = 0;
  1147. //
  1148. // Chittur Subbaraman (chitturs) - 5/7/99
  1149. //
  1150. // This function verifies whether the common property values
  1151. // that are supplied by the user are valid.
  1152. //
  1153. ZeroMemory( &currentCommonParams, sizeof ( COMMON_RES_PARAMS ) );
  1154. //
  1155. // First check whether the user has supplied two conflicting
  1156. // parameter values.
  1157. //
  1158. if ( ( pCommonParams->dwRetryPeriodOnFailure != 0 ) &&
  1159. ( pCommonParams->dwRestartPeriod != 0 ) &&
  1160. ( pCommonParams->dwRetryPeriodOnFailure <
  1161. pCommonParams->dwRestartPeriod ) )
  1162. {
  1163. dwStatus = ERROR_INVALID_PARAMETER;
  1164. ClRtlLogPrint(LOG_UNUSUAL,
  1165. "[RM] RmpCheckCommonProperties, Invalid parameters supplied: "
  1166. "RetryPeriod=%1!d! < RestartPeriod=%2!d! for resource %3!ws!\n",
  1167. pCommonParams->dwRetryPeriodOnFailure,
  1168. pCommonParams->dwRestartPeriod,
  1169. pResource->ResourceName);
  1170. goto FnExit;
  1171. }
  1172. //
  1173. // Get the buffer size for common properties list.
  1174. //
  1175. dwStatus = RmpResourceGetCommonProperties( pResource,
  1176. FALSE,
  1177. NULL,
  1178. 0,
  1179. &dwBytesReturned,
  1180. &dwBytesRequired
  1181. );
  1182. if ( dwStatus != ERROR_SUCCESS )
  1183. {
  1184. ClRtlLogPrint(LOG_UNUSUAL,
  1185. "[RM] RmpCheckCommonProperties: Error %1!d! in getting props for resource %2!ws! (1st time)\n",
  1186. dwStatus,
  1187. pResource->ResourceName);
  1188. goto FnExit;
  1189. }
  1190. pBuffer = LocalAlloc( LMEM_FIXED, dwBytesRequired + 10 );
  1191. if ( pBuffer == NULL )
  1192. {
  1193. ClRtlLogPrint(LOG_UNUSUAL,
  1194. "[RM] RmpCheckCommonProperties: Error %1!d! in mem alloc for resource %2!ws!\n",
  1195. dwStatus,
  1196. pResource->ResourceName);
  1197. goto FnExit;
  1198. }
  1199. //
  1200. // Get all the common properties from the cluster database
  1201. //
  1202. dwStatus = RmpResourceGetCommonProperties( pResource,
  1203. FALSE,
  1204. pBuffer,
  1205. dwBytesRequired + 10,
  1206. &dwBytesReturned,
  1207. &dwBytesReturned
  1208. );
  1209. if ( dwStatus != ERROR_SUCCESS )
  1210. {
  1211. ClRtlLogPrint(LOG_UNUSUAL,
  1212. "[RM] RmpCheckCommonProperties: Error %1!d! in getting props for resource %2!ws! (2nd time)\n",
  1213. dwStatus,
  1214. pResource->ResourceName);
  1215. goto FnExit;
  1216. }
  1217. //
  1218. // Get the parameter block from the common properties list
  1219. //
  1220. dwStatus = ResUtilVerifyPropertyTable( RmpResourceCommonProperties,
  1221. NULL, // Reserved
  1222. FALSE, // Don't allow unknowns
  1223. pBuffer,
  1224. dwBytesRequired + 10,
  1225. ( LPBYTE ) &currentCommonParams );
  1226. if ( dwStatus != ERROR_SUCCESS )
  1227. {
  1228. ClRtlLogPrint(LOG_UNUSUAL,
  1229. "[RM] RmpCheckCommonProperties: Error %1!d! in verifying props for resource %2!ws!\n",
  1230. dwStatus,
  1231. pResource->ResourceName);
  1232. goto FnExit;
  1233. }
  1234. //
  1235. // Check whether the RetryPeriodOnFailure is >= RestartPeriod
  1236. //
  1237. if ( ( ( pCommonParams->dwRetryPeriodOnFailure != 0 ) &&
  1238. ( pCommonParams->dwRetryPeriodOnFailure <
  1239. currentCommonParams.dwRestartPeriod ) ) ||
  1240. ( ( pCommonParams->dwRestartPeriod != 0 ) &&
  1241. ( currentCommonParams.dwRetryPeriodOnFailure <
  1242. pCommonParams->dwRestartPeriod ) ) )
  1243. {
  1244. dwStatus = ERROR_INVALID_PARAMETER;
  1245. ClRtlLogPrint(LOG_UNUSUAL,
  1246. "[RM] RmpCheckCommonProperties, Invalid IN params for resource %5!ws!: "
  1247. "Supplied Retry Period=%1!d!\n"
  1248. "[RM] Restart Period (DB)=%2!d!, RetryPeriod (DB)=%3!d!, Supplied Restart Period=%4!d! \n",
  1249. pCommonParams->dwRetryPeriodOnFailure,
  1250. currentCommonParams.dwRestartPeriod,
  1251. currentCommonParams.dwRetryPeriodOnFailure,
  1252. pCommonParams->dwRestartPeriod,
  1253. pResource->ResourceName);
  1254. goto FnExit;
  1255. }
  1256. FnExit:
  1257. LocalFree( pBuffer );
  1258. ResUtilFreeParameterBlock(( LPBYTE ) &currentCommonParams,
  1259. NULL,
  1260. RmpResourceCommonProperties
  1261. );
  1262. return( dwStatus );
  1263. } // RmpCheckCommonProperties