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.

627 lines
15 KiB

  1. /*++ BUILD Version: 0009 // Increment this if a change has global effects
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. ntregapi.h
  5. Abstract:
  6. This module contains the registration apis and related structures,
  7. in the forms for use with the Nt api set (as opposed to the win api set).
  8. Author:
  9. Bryan M. Willman (bryanwi) 26-Aug-1991
  10. Revision History:
  11. --*/
  12. #ifndef _NTREGAPI_
  13. #define _NTREGAPI_
  14. #if _MSC_VER > 1000
  15. #pragma once
  16. #endif
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. //
  21. // begin_winnt
  22. //
  23. // begin_ntddk begin_wdm begin_nthal
  24. //
  25. // Registry Specific Access Rights.
  26. //
  27. #define KEY_QUERY_VALUE (0x0001)
  28. #define KEY_SET_VALUE (0x0002)
  29. #define KEY_CREATE_SUB_KEY (0x0004)
  30. #define KEY_ENUMERATE_SUB_KEYS (0x0008)
  31. #define KEY_NOTIFY (0x0010)
  32. #define KEY_CREATE_LINK (0x0020)
  33. #define KEY_WOW64_32KEY (0x0200)
  34. #define KEY_WOW64_64KEY (0x0100)
  35. #define KEY_WOW64_RES (0x0300)
  36. #define KEY_READ ((STANDARD_RIGHTS_READ |\
  37. KEY_QUERY_VALUE |\
  38. KEY_ENUMERATE_SUB_KEYS |\
  39. KEY_NOTIFY) \
  40. & \
  41. (~SYNCHRONIZE))
  42. #define KEY_WRITE ((STANDARD_RIGHTS_WRITE |\
  43. KEY_SET_VALUE |\
  44. KEY_CREATE_SUB_KEY) \
  45. & \
  46. (~SYNCHRONIZE))
  47. #define KEY_EXECUTE ((KEY_READ) \
  48. & \
  49. (~SYNCHRONIZE))
  50. #define KEY_ALL_ACCESS ((STANDARD_RIGHTS_ALL |\
  51. KEY_QUERY_VALUE |\
  52. KEY_SET_VALUE |\
  53. KEY_CREATE_SUB_KEY |\
  54. KEY_ENUMERATE_SUB_KEYS |\
  55. KEY_NOTIFY |\
  56. KEY_CREATE_LINK) \
  57. & \
  58. (~SYNCHRONIZE))
  59. //
  60. // Open/Create Options
  61. //
  62. #define REG_OPTION_RESERVED (0x00000000L) // Parameter is reserved
  63. #define REG_OPTION_NON_VOLATILE (0x00000000L) // Key is preserved
  64. // when system is rebooted
  65. #define REG_OPTION_VOLATILE (0x00000001L) // Key is not preserved
  66. // when system is rebooted
  67. #define REG_OPTION_CREATE_LINK (0x00000002L) // Created key is a
  68. // symbolic link
  69. #define REG_OPTION_BACKUP_RESTORE (0x00000004L) // open for backup or restore
  70. // special access rules
  71. // privilege required
  72. #define REG_OPTION_OPEN_LINK (0x00000008L) // Open symbolic link
  73. #define REG_LEGAL_OPTION \
  74. (REG_OPTION_RESERVED |\
  75. REG_OPTION_NON_VOLATILE |\
  76. REG_OPTION_VOLATILE |\
  77. REG_OPTION_CREATE_LINK |\
  78. REG_OPTION_BACKUP_RESTORE |\
  79. REG_OPTION_OPEN_LINK)
  80. //
  81. // Key creation/open disposition
  82. //
  83. #define REG_CREATED_NEW_KEY (0x00000001L) // New Registry Key created
  84. #define REG_OPENED_EXISTING_KEY (0x00000002L) // Existing Key opened
  85. //
  86. // hive format to be used by Reg(Nt)SaveKeyEx
  87. //
  88. #define REG_STANDARD_FORMAT 1
  89. #define REG_LATEST_FORMAT 2
  90. #define REG_NO_COMPRESSION 4
  91. //
  92. // Key restore flags
  93. //
  94. #define REG_WHOLE_HIVE_VOLATILE (0x00000001L) // Restore whole hive volatile
  95. #define REG_REFRESH_HIVE (0x00000002L) // Unwind changes to last flush
  96. #define REG_NO_LAZY_FLUSH (0x00000004L) // Never lazy flush this hive
  97. #define REG_FORCE_RESTORE (0x00000008L) // Force the restore process even when we have open handles on subkeys
  98. // end_ntddk end_wdm end_nthal
  99. //
  100. // Notify filter values
  101. //
  102. #define REG_NOTIFY_CHANGE_NAME (0x00000001L) // Create or delete (child)
  103. #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
  104. #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L) // time stamp
  105. #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
  106. #define REG_LEGAL_CHANGE_FILTER \
  107. (REG_NOTIFY_CHANGE_NAME |\
  108. REG_NOTIFY_CHANGE_ATTRIBUTES |\
  109. REG_NOTIFY_CHANGE_LAST_SET |\
  110. REG_NOTIFY_CHANGE_SECURITY)
  111. //
  112. // end_winnt
  113. //
  114. // Boot condition flags (for NtInitializeRegistry)
  115. #define REG_INIT_BOOT_SM (0x0000) // Init called from SM after Autocheck, etc.
  116. #define REG_INIT_BOOT_SETUP (0x0001) // Init called from text-mode setup
  117. //
  118. // Values to indicate that a standard Boot has been accepted by the Service Controller.
  119. // The Boot information will be saved by NtInitializeRegistry to a registry ControlSet with an
  120. //
  121. // ID = [Given Boot Condition Value] - REG_INIT_BOOT_ACCEPTED_BASE
  122. //
  123. #define REG_INIT_BOOT_ACCEPTED_BASE (0x0002)
  124. #define REG_INIT_BOOT_ACCEPTED_MAX REG_INIT_BOOT_ACCEPTED_BASE + 999
  125. #define REG_INIT_MAX_VALID_CONDITION REG_INIT_BOOT_ACCEPTED_MAX
  126. //
  127. // registry limits for value name and key name
  128. //
  129. #define REG_MAX_KEY_VALUE_NAME_LENGTH 32767 // 32k - sanity limit for value name
  130. #define REG_MAX_KEY_NAME_LENGTH 512 // allow for 256 unicode, as promise
  131. // begin_ntddk begin_wdm begin_nthal
  132. //
  133. // Key query structures
  134. //
  135. typedef struct _KEY_BASIC_INFORMATION {
  136. LARGE_INTEGER LastWriteTime;
  137. ULONG TitleIndex;
  138. ULONG NameLength;
  139. WCHAR Name[1]; // Variable length string
  140. } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
  141. typedef struct _KEY_NODE_INFORMATION {
  142. LARGE_INTEGER LastWriteTime;
  143. ULONG TitleIndex;
  144. ULONG ClassOffset;
  145. ULONG ClassLength;
  146. ULONG NameLength;
  147. WCHAR Name[1]; // Variable length string
  148. // Class[1]; // Variable length string not declared
  149. } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
  150. typedef struct _KEY_FULL_INFORMATION {
  151. LARGE_INTEGER LastWriteTime;
  152. ULONG TitleIndex;
  153. ULONG ClassOffset;
  154. ULONG ClassLength;
  155. ULONG SubKeys;
  156. ULONG MaxNameLen;
  157. ULONG MaxClassLen;
  158. ULONG Values;
  159. ULONG MaxValueNameLen;
  160. ULONG MaxValueDataLen;
  161. WCHAR Class[1]; // Variable length
  162. } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
  163. // end_wdm
  164. typedef struct _KEY_NAME_INFORMATION {
  165. ULONG NameLength;
  166. WCHAR Name[1]; // Variable length string
  167. } KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
  168. typedef struct _KEY_CACHED_INFORMATION {
  169. LARGE_INTEGER LastWriteTime;
  170. ULONG TitleIndex;
  171. ULONG SubKeys;
  172. ULONG MaxNameLen;
  173. ULONG Values;
  174. ULONG MaxValueNameLen;
  175. ULONG MaxValueDataLen;
  176. ULONG NameLength;
  177. WCHAR Name[1]; // Variable length string
  178. } KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
  179. typedef struct _KEY_FLAGS_INFORMATION {
  180. ULONG UserFlags;
  181. } KEY_FLAGS_INFORMATION, *PKEY_FLAGS_INFORMATION;
  182. // begin_wdm
  183. typedef enum _KEY_INFORMATION_CLASS {
  184. KeyBasicInformation,
  185. KeyNodeInformation,
  186. KeyFullInformation
  187. // end_wdm
  188. ,
  189. KeyNameInformation,
  190. KeyCachedInformation,
  191. KeyFlagsInformation
  192. // begin_wdm
  193. } KEY_INFORMATION_CLASS;
  194. typedef struct _KEY_WRITE_TIME_INFORMATION {
  195. LARGE_INTEGER LastWriteTime;
  196. } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
  197. typedef struct _KEY_USER_FLAGS_INFORMATION {
  198. ULONG UserFlags;
  199. } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
  200. typedef enum _KEY_SET_INFORMATION_CLASS {
  201. KeyWriteTimeInformation,
  202. KeyUserFlagsInformation
  203. } KEY_SET_INFORMATION_CLASS;
  204. //
  205. // Value entry query structures
  206. //
  207. typedef struct _KEY_VALUE_BASIC_INFORMATION {
  208. ULONG TitleIndex;
  209. ULONG Type;
  210. ULONG NameLength;
  211. WCHAR Name[1]; // Variable size
  212. } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
  213. typedef struct _KEY_VALUE_FULL_INFORMATION {
  214. ULONG TitleIndex;
  215. ULONG Type;
  216. ULONG DataOffset;
  217. ULONG DataLength;
  218. ULONG NameLength;
  219. WCHAR Name[1]; // Variable size
  220. // Data[1]; // Variable size data not declared
  221. } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
  222. typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
  223. ULONG TitleIndex;
  224. ULONG Type;
  225. ULONG DataLength;
  226. UCHAR Data[1]; // Variable size
  227. } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
  228. typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
  229. ULONG Type;
  230. ULONG DataLength;
  231. UCHAR Data[1]; // Variable size
  232. } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
  233. typedef struct _KEY_VALUE_ENTRY {
  234. PUNICODE_STRING ValueName;
  235. ULONG DataLength;
  236. ULONG DataOffset;
  237. ULONG Type;
  238. } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
  239. typedef enum _KEY_VALUE_INFORMATION_CLASS {
  240. KeyValueBasicInformation,
  241. KeyValueFullInformation,
  242. KeyValuePartialInformation,
  243. KeyValueFullInformationAlign64,
  244. KeyValuePartialInformationAlign64
  245. } KEY_VALUE_INFORMATION_CLASS;
  246. // end_ntddk end_wdm end_nthal
  247. //
  248. // Notify return structures
  249. //
  250. typedef enum _REG_ACTION {
  251. KeyAdded,
  252. KeyRemoved,
  253. KeyModified
  254. } REG_ACTION;
  255. typedef struct _REG_NOTIFY_INFORMATION {
  256. ULONG NextEntryOffset;
  257. REG_ACTION Action;
  258. ULONG KeyLength;
  259. WCHAR Key[1]; // Variable size
  260. } REG_NOTIFY_INFORMATION, *PREG_NOTIFY_INFORMATION;
  261. //
  262. // Nt level registry API calls
  263. //
  264. NTSYSCALLAPI
  265. NTSTATUS
  266. NTAPI
  267. NtCreateKey(
  268. OUT PHANDLE KeyHandle,
  269. IN ACCESS_MASK DesiredAccess,
  270. IN POBJECT_ATTRIBUTES ObjectAttributes,
  271. IN ULONG TitleIndex,
  272. IN PUNICODE_STRING Class OPTIONAL,
  273. IN ULONG CreateOptions,
  274. OUT PULONG Disposition OPTIONAL
  275. );
  276. NTSYSCALLAPI
  277. NTSTATUS
  278. NTAPI
  279. NtDeleteKey(
  280. IN HANDLE KeyHandle
  281. );
  282. NTSYSCALLAPI
  283. NTSTATUS
  284. NTAPI
  285. NtDeleteValueKey(
  286. IN HANDLE KeyHandle,
  287. IN PUNICODE_STRING ValueName
  288. );
  289. NTSYSCALLAPI
  290. NTSTATUS
  291. NTAPI
  292. NtEnumerateKey(
  293. IN HANDLE KeyHandle,
  294. IN ULONG Index,
  295. IN KEY_INFORMATION_CLASS KeyInformationClass,
  296. OUT PVOID KeyInformation,
  297. IN ULONG Length,
  298. OUT PULONG ResultLength
  299. );
  300. NTSYSCALLAPI
  301. NTSTATUS
  302. NTAPI
  303. NtEnumerateValueKey(
  304. IN HANDLE KeyHandle,
  305. IN ULONG Index,
  306. IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
  307. OUT PVOID KeyValueInformation,
  308. IN ULONG Length,
  309. OUT PULONG ResultLength
  310. );
  311. NTSYSCALLAPI
  312. NTSTATUS
  313. NTAPI
  314. NtFlushKey(
  315. IN HANDLE KeyHandle
  316. );
  317. NTSYSCALLAPI
  318. NTSTATUS
  319. NTAPI
  320. NtInitializeRegistry(
  321. IN USHORT BootCondition
  322. );
  323. NTSYSCALLAPI
  324. NTSTATUS
  325. NTAPI
  326. NtNotifyChangeKey(
  327. IN HANDLE KeyHandle,
  328. IN HANDLE Event OPTIONAL,
  329. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  330. IN PVOID ApcContext OPTIONAL,
  331. OUT PIO_STATUS_BLOCK IoStatusBlock,
  332. IN ULONG CompletionFilter,
  333. IN BOOLEAN WatchTree,
  334. OUT PVOID Buffer,
  335. IN ULONG BufferSize,
  336. IN BOOLEAN Asynchronous
  337. );
  338. NTSYSCALLAPI
  339. NTSTATUS
  340. NTAPI
  341. NtNotifyChangeMultipleKeys(
  342. IN HANDLE MasterKeyHandle,
  343. IN ULONG Count,
  344. IN OBJECT_ATTRIBUTES SlaveObjects[],
  345. IN HANDLE Event OPTIONAL,
  346. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  347. IN PVOID ApcContext OPTIONAL,
  348. OUT PIO_STATUS_BLOCK IoStatusBlock,
  349. IN ULONG CompletionFilter,
  350. IN BOOLEAN WatchTree,
  351. OUT PVOID Buffer,
  352. IN ULONG BufferSize,
  353. IN BOOLEAN Asynchronous
  354. );
  355. NTSYSCALLAPI
  356. NTSTATUS
  357. NTAPI
  358. NtLoadKey(
  359. IN POBJECT_ATTRIBUTES TargetKey,
  360. IN POBJECT_ATTRIBUTES SourceFile
  361. );
  362. NTSYSCALLAPI
  363. NTSTATUS
  364. NTAPI
  365. NtLoadKey2(
  366. IN POBJECT_ATTRIBUTES TargetKey,
  367. IN POBJECT_ATTRIBUTES SourceFile,
  368. IN ULONG Flags
  369. );
  370. NTSYSCALLAPI
  371. NTSTATUS
  372. NTAPI
  373. NtOpenKey(
  374. OUT PHANDLE KeyHandle,
  375. IN ACCESS_MASK DesiredAccess,
  376. IN POBJECT_ATTRIBUTES ObjectAttributes
  377. );
  378. NTSYSCALLAPI
  379. NTSTATUS
  380. NTAPI
  381. NtQueryKey(
  382. IN HANDLE KeyHandle,
  383. IN KEY_INFORMATION_CLASS KeyInformationClass,
  384. OUT PVOID KeyInformation,
  385. IN ULONG Length,
  386. OUT PULONG ResultLength
  387. );
  388. NTSYSCALLAPI
  389. NTSTATUS
  390. NTAPI
  391. NtQueryValueKey(
  392. IN HANDLE KeyHandle,
  393. IN PUNICODE_STRING ValueName,
  394. IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
  395. OUT PVOID KeyValueInformation,
  396. IN ULONG Length,
  397. OUT PULONG ResultLength
  398. );
  399. NTSYSCALLAPI
  400. NTSTATUS
  401. NTAPI
  402. NtQueryMultipleValueKey(
  403. IN HANDLE KeyHandle,
  404. IN OUT PKEY_VALUE_ENTRY ValueEntries,
  405. IN ULONG EntryCount,
  406. OUT PVOID ValueBuffer,
  407. IN OUT PULONG BufferLength,
  408. OUT OPTIONAL PULONG RequiredBufferLength
  409. );
  410. NTSYSCALLAPI
  411. NTSTATUS
  412. NTAPI
  413. NtReplaceKey(
  414. IN POBJECT_ATTRIBUTES NewFile,
  415. IN HANDLE TargetHandle,
  416. IN POBJECT_ATTRIBUTES OldFile
  417. );
  418. NTSYSCALLAPI
  419. NTSTATUS
  420. NTAPI
  421. NtRenameKey(
  422. IN HANDLE KeyHandle,
  423. IN PUNICODE_STRING NewName
  424. );
  425. NTSYSCALLAPI
  426. NTSTATUS
  427. NTAPI
  428. NtCompactKeys(
  429. IN ULONG Count,
  430. IN HANDLE KeyArray[]
  431. );
  432. NTSYSCALLAPI
  433. NTSTATUS
  434. NTAPI
  435. NtCompressKey(
  436. IN HANDLE Key
  437. );
  438. NTSYSCALLAPI
  439. NTSTATUS
  440. NTAPI
  441. NtRestoreKey(
  442. IN HANDLE KeyHandle,
  443. IN HANDLE FileHandle,
  444. IN ULONG Flags
  445. );
  446. NTSYSCALLAPI
  447. NTSTATUS
  448. NTAPI
  449. NtSaveKey(
  450. IN HANDLE KeyHandle,
  451. IN HANDLE FileHandle
  452. );
  453. NTSYSCALLAPI
  454. NTSTATUS
  455. NTAPI
  456. NtSaveKeyEx(
  457. IN HANDLE KeyHandle,
  458. IN HANDLE FileHandle,
  459. IN ULONG Format
  460. );
  461. NTSYSCALLAPI
  462. NTSTATUS
  463. NTAPI
  464. NtSaveMergedKeys(
  465. IN HANDLE HighPrecedenceKeyHandle,
  466. IN HANDLE LowPrecedenceKeyHandle,
  467. IN HANDLE FileHandle
  468. );
  469. NTSYSCALLAPI
  470. NTSTATUS
  471. NTAPI
  472. NtSetValueKey(
  473. IN HANDLE KeyHandle,
  474. IN PUNICODE_STRING ValueName,
  475. IN ULONG TitleIndex OPTIONAL,
  476. IN ULONG Type,
  477. IN PVOID Data,
  478. IN ULONG DataSize
  479. );
  480. NTSYSCALLAPI
  481. NTSTATUS
  482. NTAPI
  483. NtUnloadKey(
  484. IN POBJECT_ATTRIBUTES TargetKey
  485. );
  486. NTSYSCALLAPI
  487. NTSTATUS
  488. NTAPI
  489. NtUnloadKeyEx(
  490. IN POBJECT_ATTRIBUTES TargetKey,
  491. IN HANDLE Event OPTIONAL
  492. );
  493. NTSYSCALLAPI
  494. NTSTATUS
  495. NTAPI
  496. NtSetInformationKey(
  497. IN HANDLE KeyHandle,
  498. IN KEY_SET_INFORMATION_CLASS KeySetInformationClass,
  499. IN PVOID KeySetInformation,
  500. IN ULONG KeySetInformationLength
  501. );
  502. NTSYSCALLAPI
  503. NTSTATUS
  504. NTAPI
  505. NtQueryOpenSubKeys(
  506. IN POBJECT_ATTRIBUTES TargetKey,
  507. OUT PULONG HandleCount
  508. );
  509. NTSYSCALLAPI
  510. NTSTATUS
  511. NTAPI
  512. NtLockRegistryKey(
  513. IN HANDLE KeyHandle
  514. );
  515. NTSYSCALLAPI
  516. NTSTATUS
  517. NTAPI
  518. NtLockProductActivationKeys(
  519. ULONG *pPrivateVer,
  520. ULONG *pIsSafeMode
  521. );
  522. #ifdef __cplusplus
  523. }
  524. #endif
  525. #endif // _NTREGAPI_