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.

816 lines
11 KiB

  1. /*++
  2. Copyright (c) 1992-2000 Microsoft Corporation
  3. Module Name:
  4. regkey.hxx
  5. Abstract:
  6. This module contains the declarations for the REGISTRY_KEY_INFO class.
  7. REGISTRY_KEY_INFO is class that contains all the information of a
  8. registry key, sucha as:
  9. -Key Name
  10. -Title Index
  11. -Class
  12. -Security Attribute
  13. -Last Write Time
  14. -Number of Sub-keys
  15. -Number of Value Entries
  16. A REGISTRY_KEY_INFO object is reinitializable.
  17. Author:
  18. Jaime Sasson (jaimes) 01-Mar-1992
  19. Environment:
  20. Ulib, User Mode
  21. --*/
  22. #if !defined( _REGISTRY_KEY_INFO_ )
  23. #define _REGISTRY_KEY_INFO_
  24. #include "ulib.hxx"
  25. #include "wstring.hxx"
  26. #if !defined( _AUTOCHECK_ )
  27. #include "timeinfo.hxx"
  28. #endif
  29. DECLARE_CLASS( REGISTRY );
  30. DECLARE_CLASS( REGISTRY_KEY_INFO );
  31. #if defined( _AUTOCHECK_ )
  32. #define PSECURITY_ATTRIBUTES PVOID
  33. #endif
  34. class REGISTRY_KEY_INFO : public OBJECT {
  35. FRIEND class REGISTRY;
  36. public:
  37. DECLARE_CONSTRUCTOR( REGISTRY_KEY_INFO );
  38. DECLARE_CAST_MEMBER_FUNCTION( REGISTRY_KEY_INFO );
  39. VIRTUAL
  40. ~REGISTRY_KEY_INFO(
  41. );
  42. NONVIRTUAL
  43. BOOLEAN
  44. Initialize(
  45. IN PCWSTRING KeyName,
  46. IN PCWSTRING ParentName,
  47. IN ULONG TitleIndex,
  48. IN PCWSTRING Class,
  49. IN PSECURITY_ATTRIBUTES SecurityAttributes DEFAULT NULL
  50. );
  51. NONVIRTUAL
  52. PCWSTRING
  53. GetClass(
  54. ) CONST;
  55. #if !defined( _AUTOCHECK_ )
  56. NONVIRTUAL
  57. PCTIMEINFO
  58. GetLastWriteTime(
  59. ) CONST;
  60. #endif
  61. NONVIRTUAL
  62. PCWSTRING
  63. GetName(
  64. ) CONST;
  65. NONVIRTUAL
  66. ULONG
  67. GetNumberOfSubKeys(
  68. ) CONST;
  69. NONVIRTUAL
  70. ULONG
  71. GetNumberOfValues(
  72. ) CONST;
  73. NONVIRTUAL
  74. PCWSTRING
  75. GetParentName(
  76. ) CONST;
  77. #if !defined( _AUTOCHECK )
  78. NONVIRTUAL
  79. PSECURITY_ATTRIBUTES
  80. GetSecurityAttributes(
  81. ) CONST;
  82. #endif
  83. NONVIRTUAL
  84. ULONG
  85. GetTitleIndex(
  86. ) CONST;
  87. NONVIRTUAL
  88. BOOLEAN
  89. IsKeyInitialized(
  90. ) CONST;
  91. #if DBG
  92. NONVIRTUAL
  93. VOID
  94. DbgPrintKeyInfo(
  95. );
  96. #endif // DBG
  97. private:
  98. NONVIRTUAL // Only REGISTRY can access it
  99. BOOLEAN
  100. Initialize(
  101. );
  102. NONVIRTUAL
  103. VOID
  104. Construct(
  105. );
  106. NONVIRTUAL
  107. VOID
  108. Destroy(
  109. );
  110. NONVIRTUAL
  111. BOOLEAN
  112. PutClass(
  113. IN PCWSTRING Class
  114. );
  115. #if !defined( _AUTOCHECK_ )
  116. NONVIRTUAL
  117. VOID
  118. PutLastWriteTime(
  119. IN PCTIMEINFO LastWriteTime
  120. );
  121. #endif
  122. NONVIRTUAL
  123. BOOLEAN
  124. PutName(
  125. IN PCWSTRING Name
  126. );
  127. NONVIRTUAL
  128. BOOLEAN
  129. PutParentName(
  130. IN PCWSTRING ParentName
  131. );
  132. #if !defined( _AUTOCHECK )
  133. NONVIRTUAL
  134. BOOLEAN
  135. PutSecurityAttributes(
  136. IN PSECURITY_ATTRIBUTES SecurityAttributes
  137. );
  138. #endif
  139. #if defined( _AUTOCHECK_ )
  140. NONVIRTUAL
  141. VOID
  142. SetLastWriteTime(
  143. IN TIME LastWriteTime
  144. );
  145. #endif
  146. NONVIRTUAL
  147. VOID
  148. SetKeyInitializedFlag(
  149. IN BOOLEAN Initialized
  150. );
  151. NONVIRTUAL
  152. VOID
  153. SetNumberOfSubKeys(
  154. IN ULONG NumberOfSubKeys
  155. );
  156. NONVIRTUAL
  157. VOID
  158. SetNumberOfValues(
  159. IN ULONG NumberOfValues
  160. );
  161. NONVIRTUAL
  162. VOID
  163. SetTitleIndex(
  164. IN ULONG TitleIndex
  165. );
  166. DSTRING _Name;
  167. DSTRING _ParentName;
  168. ULONG _TitleIndex;
  169. DSTRING _Class;
  170. ULONG _NumberOfSubKeys;
  171. ULONG _NumberOfValues;
  172. BOOLEAN _KeyIsCompletelyInitialized;
  173. #if defined( _AUTOCHECK_ )
  174. TIME _LastWriteTime;
  175. #else
  176. TIMEINFO _LastWriteTime;
  177. SECURITY_ATTRIBUTES _SecurityAttributes;
  178. #endif
  179. };
  180. INLINE
  181. PCWSTRING
  182. REGISTRY_KEY_INFO::GetClass(
  183. ) CONST
  184. /*++
  185. Routine Description:
  186. Return the class of a key.
  187. Arguments:
  188. None.
  189. Return Value:
  190. PCWSTRING - Pointer to a WSTRING object that contains the key class.
  191. --*/
  192. {
  193. return( &_Class );
  194. }
  195. #if !defined( _AUTOCHECK_ )
  196. INLINE
  197. PCTIMEINFO
  198. REGISTRY_KEY_INFO::GetLastWriteTime(
  199. ) CONST
  200. /*++
  201. Routine Description:
  202. Return the Last Write Time of a key.
  203. Arguments:
  204. None.
  205. Return Value:
  206. PCTIMEINFO - Pointer to a TIMEINFO object that contains the Last Write Time
  207. of the key.
  208. --*/
  209. {
  210. return( &_LastWriteTime );
  211. }
  212. #endif
  213. INLINE
  214. PCWSTRING
  215. REGISTRY_KEY_INFO::GetName(
  216. ) CONST
  217. /*++
  218. Routine Description:
  219. Return the name of a key (relative to its parent).
  220. Arguments:
  221. None.
  222. Return Value:
  223. PCWSTRING - Pointer to a WSTRING object that contains the key name.
  224. --*/
  225. {
  226. return( &_Name );
  227. }
  228. INLINE
  229. PCWSTRING
  230. REGISTRY_KEY_INFO::GetParentName(
  231. ) CONST
  232. /*++
  233. Routine Description:
  234. Return the name of parent of this key ( full name ).
  235. Arguments:
  236. None.
  237. Return Value:
  238. PCWSTRING - Pointer to a WSTRING object that contains the parent's name.
  239. --*/
  240. {
  241. return( &_ParentName );
  242. }
  243. INLINE
  244. ULONG
  245. REGISTRY_KEY_INFO::GetNumberOfSubKeys(
  246. ) CONST
  247. /*++
  248. Routine Description:
  249. Return the number of subkeys in the key.
  250. Arguments:
  251. None.
  252. Return Value:
  253. ULONG - The number of subkeys.
  254. --*/
  255. {
  256. return( _NumberOfSubKeys );
  257. }
  258. INLINE
  259. ULONG
  260. REGISTRY_KEY_INFO::GetNumberOfValues(
  261. ) CONST
  262. /*++
  263. Routine Description:
  264. Return the number of value entries in the key.
  265. Arguments:
  266. None.
  267. Return Value:
  268. ULONG - The number of value entries.
  269. --*/
  270. {
  271. return( _NumberOfValues );
  272. }
  273. #if !defined( _AUTOCHECK_ )
  274. INLINE
  275. PSECURITY_ATTRIBUTES
  276. REGISTRY_KEY_INFO::GetSecurityAttributes(
  277. ) CONST
  278. /*++
  279. Routine Description:
  280. Return the security attributes of the key.
  281. Arguments:
  282. None.
  283. Return Value:
  284. PVOID - Pointer to the security attribute
  285. --*/
  286. {
  287. return( (PSECURITY_ATTRIBUTES)&_SecurityAttributes );
  288. }
  289. #endif
  290. INLINE
  291. ULONG
  292. REGISTRY_KEY_INFO::GetTitleIndex(
  293. ) CONST
  294. /*++
  295. Routine Description:
  296. Return the title index of the key.
  297. Arguments:
  298. None.
  299. Return Value:
  300. ULONG - The title index.
  301. --*/
  302. {
  303. return( _TitleIndex );
  304. }
  305. INLINE
  306. BOOLEAN
  307. REGISTRY_KEY_INFO::IsKeyInitialized(
  308. ) CONST
  309. /*++
  310. Routine Description:
  311. Inform the caller if the object is completely initialized.
  312. This object will be completly initialized only if the registry
  313. class was able to query the key to retrieve its calss and last
  314. write time.
  315. Arguments:
  316. None.
  317. Return Value:
  318. BOOLEAN - Returns TRUE if the key is initialized, or FALSE otherwise.
  319. --*/
  320. {
  321. return( _KeyIsCompletelyInitialized );
  322. }
  323. INLINE
  324. BOOLEAN
  325. REGISTRY_KEY_INFO::PutClass(
  326. IN PCWSTRING Class
  327. )
  328. /*++
  329. Routine Description:
  330. Initialize the variable _Class.
  331. Arguments:
  332. Class - Pointer to a WSTRING object that contains the key class.
  333. Return Value:
  334. None.
  335. --*/
  336. {
  337. DebugPtrAssert( Class );
  338. return( _Class.Initialize( Class ) );
  339. }
  340. #if !defined( _AUTOCHECK_ )
  341. INLINE
  342. VOID
  343. REGISTRY_KEY_INFO::PutLastWriteTime(
  344. IN PCTIMEINFO LastWriteTime
  345. )
  346. /*++
  347. Routine Description:
  348. Initialize the variable _LastWriteTime.
  349. Arguments:
  350. LastWriteTime - Pointer to a TIMEINFO object that contains the
  351. LastWriteTime of the key.
  352. Return Value:
  353. None.
  354. --*/
  355. {
  356. DebugPtrAssert( LastWriteTime );
  357. _LastWriteTime.Initialize( LastWriteTime );
  358. }
  359. #endif
  360. #if defined( _AUTOCHECK_ )
  361. INLINE
  362. VOID
  363. REGISTRY_KEY_INFO::SetLastWriteTime(
  364. IN TIME LastWriteTime
  365. )
  366. /*++
  367. Routine Description:
  368. Initialize the variable _LastWriteTime.
  369. Arguments:
  370. LastWriteTime - Pointer to a TIMEINFO object that contains the
  371. LastWriteTime of the key.
  372. Return Value:
  373. None.
  374. --*/
  375. {
  376. _LastWriteTime = LastWriteTime;
  377. }
  378. #endif
  379. INLINE
  380. BOOLEAN
  381. REGISTRY_KEY_INFO::PutName(
  382. IN PCWSTRING Name
  383. )
  384. /*++
  385. Routine Description:
  386. Initialize the key name.
  387. Arguments:
  388. Name - Pointer to a WSTRING object that contains the key name.
  389. Return Value:
  390. None.
  391. --*/
  392. {
  393. DebugPtrAssert( Name );
  394. return( _Name.Initialize( Name ) );
  395. }
  396. INLINE
  397. BOOLEAN
  398. REGISTRY_KEY_INFO::PutParentName(
  399. IN PCWSTRING ParentName
  400. )
  401. /*++
  402. Routine Description:
  403. Initialize the parent name.
  404. Arguments:
  405. Name - Pointer to a WSTRING object that contains the parent name.
  406. Return Value:
  407. None.
  408. --*/
  409. {
  410. DebugPtrAssert( ParentName );
  411. return( _ParentName.Initialize( ParentName ) );
  412. }
  413. INLINE
  414. VOID
  415. REGISTRY_KEY_INFO::SetKeyInitializedFlag(
  416. IN BOOLEAN Initialized
  417. )
  418. /*++
  419. Routine Description:
  420. Initializes the flag that indicates whether the key is completely
  421. initialized. That is, the registry class was able to query the value,
  422. and its last write time is initialized.
  423. Arguments:
  424. Initialized - A flag that indicates whether the key is completely
  425. initialized.
  426. Return Value:
  427. None.
  428. --*/
  429. {
  430. _KeyIsCompletelyInitialized = Initialized;
  431. }
  432. INLINE
  433. VOID
  434. REGISTRY_KEY_INFO::SetNumberOfSubKeys(
  435. IN ULONG NumberOfSubKeys
  436. )
  437. /*++
  438. Routine Description:
  439. Initialize the variable NumberOfSubKeys.
  440. Arguments:
  441. NumberOfSubkeys - The number of subkeys.
  442. Return Value:
  443. None.
  444. --*/
  445. {
  446. _NumberOfSubKeys = NumberOfSubKeys;
  447. }
  448. INLINE
  449. VOID
  450. REGISTRY_KEY_INFO::SetNumberOfValues(
  451. IN ULONG NumberOfValues
  452. )
  453. /*++
  454. Routine Description:
  455. Initialize the variable _NumberOfValues.
  456. Arguments:
  457. NumberOfValues - The number of value entries in the key.
  458. Return Value:
  459. None.
  460. --*/
  461. {
  462. _NumberOfValues = NumberOfValues;
  463. }
  464. INLINE
  465. VOID
  466. REGISTRY_KEY_INFO::SetTitleIndex(
  467. IN ULONG TitleIndex
  468. )
  469. /*++
  470. Routine Description:
  471. Initialize the variable _TitleIndex.
  472. Arguments:
  473. TitleIndex - Title index of the key.
  474. Return Value:
  475. None.
  476. --*/
  477. {
  478. _TitleIndex = TitleIndex;
  479. }
  480. #endif // _REGISTRY_KEY_INFO_