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.

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