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.

672 lines
17 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. //
  99. // Unload Flags
  100. //
  101. #define REG_FORCE_UNLOAD 1
  102. // end_ntddk end_wdm end_nthal
  103. //
  104. // Notify filter values
  105. //
  106. #define REG_NOTIFY_CHANGE_NAME (0x00000001L) // Create or delete (child)
  107. #define REG_NOTIFY_CHANGE_ATTRIBUTES (0x00000002L)
  108. #define REG_NOTIFY_CHANGE_LAST_SET (0x00000004L) // time stamp
  109. #define REG_NOTIFY_CHANGE_SECURITY (0x00000008L)
  110. #define REG_LEGAL_CHANGE_FILTER \
  111. (REG_NOTIFY_CHANGE_NAME |\
  112. REG_NOTIFY_CHANGE_ATTRIBUTES |\
  113. REG_NOTIFY_CHANGE_LAST_SET |\
  114. REG_NOTIFY_CHANGE_SECURITY)
  115. //
  116. // end_winnt
  117. //
  118. // Boot condition flags (for NtInitializeRegistry)
  119. #define REG_INIT_BOOT_SM (0x0000) // Init called from SM after Autocheck, etc.
  120. #define REG_INIT_BOOT_SETUP (0x0001) // Init called from text-mode setup
  121. //
  122. // Values to indicate that a standard Boot has been accepted by the Service Controller.
  123. // The Boot information will be saved by NtInitializeRegistry to a registry ControlSet with an
  124. //
  125. // ID = [Given Boot Condition Value] - REG_INIT_BOOT_ACCEPTED_BASE
  126. //
  127. #define REG_INIT_BOOT_ACCEPTED_BASE (0x0002)
  128. #define REG_INIT_BOOT_ACCEPTED_MAX REG_INIT_BOOT_ACCEPTED_BASE + 999
  129. #define REG_INIT_MAX_VALID_CONDITION REG_INIT_BOOT_ACCEPTED_MAX
  130. //
  131. // registry limits for value name and key name
  132. //
  133. #define REG_MAX_KEY_VALUE_NAME_LENGTH 32767 // 32k - sanity limit for value name
  134. #define REG_MAX_KEY_NAME_LENGTH 512 // allow for 256 unicode, as promise
  135. // begin_ntddk begin_wdm begin_nthal
  136. //
  137. // Key query structures
  138. //
  139. typedef struct _KEY_BASIC_INFORMATION {
  140. LARGE_INTEGER LastWriteTime;
  141. ULONG TitleIndex;
  142. ULONG NameLength;
  143. WCHAR Name[1]; // Variable length string
  144. } KEY_BASIC_INFORMATION, *PKEY_BASIC_INFORMATION;
  145. typedef struct _KEY_NODE_INFORMATION {
  146. LARGE_INTEGER LastWriteTime;
  147. ULONG TitleIndex;
  148. ULONG ClassOffset;
  149. ULONG ClassLength;
  150. ULONG NameLength;
  151. WCHAR Name[1]; // Variable length string
  152. // Class[1]; // Variable length string not declared
  153. } KEY_NODE_INFORMATION, *PKEY_NODE_INFORMATION;
  154. typedef struct _KEY_FULL_INFORMATION {
  155. LARGE_INTEGER LastWriteTime;
  156. ULONG TitleIndex;
  157. ULONG ClassOffset;
  158. ULONG ClassLength;
  159. ULONG SubKeys;
  160. ULONG MaxNameLen;
  161. ULONG MaxClassLen;
  162. ULONG Values;
  163. ULONG MaxValueNameLen;
  164. ULONG MaxValueDataLen;
  165. WCHAR Class[1]; // Variable length
  166. } KEY_FULL_INFORMATION, *PKEY_FULL_INFORMATION;
  167. // end_wdm
  168. typedef struct _KEY_NAME_INFORMATION {
  169. ULONG NameLength;
  170. WCHAR Name[1]; // Variable length string
  171. } KEY_NAME_INFORMATION, *PKEY_NAME_INFORMATION;
  172. typedef struct _KEY_CACHED_INFORMATION {
  173. LARGE_INTEGER LastWriteTime;
  174. ULONG TitleIndex;
  175. ULONG SubKeys;
  176. ULONG MaxNameLen;
  177. ULONG Values;
  178. ULONG MaxValueNameLen;
  179. ULONG MaxValueDataLen;
  180. ULONG NameLength;
  181. WCHAR Name[1]; // Variable length string
  182. } KEY_CACHED_INFORMATION, *PKEY_CACHED_INFORMATION;
  183. typedef struct _KEY_FLAGS_INFORMATION {
  184. ULONG UserFlags;
  185. } KEY_FLAGS_INFORMATION, *PKEY_FLAGS_INFORMATION;
  186. // begin_wdm
  187. typedef enum _KEY_INFORMATION_CLASS {
  188. KeyBasicInformation,
  189. KeyNodeInformation,
  190. KeyFullInformation
  191. // end_wdm
  192. ,
  193. KeyNameInformation,
  194. KeyCachedInformation,
  195. KeyFlagsInformation,
  196. MaxKeyInfoClass // MaxKeyInfoClass should always be the last enum
  197. // begin_wdm
  198. } KEY_INFORMATION_CLASS;
  199. typedef struct _KEY_WRITE_TIME_INFORMATION {
  200. LARGE_INTEGER LastWriteTime;
  201. } KEY_WRITE_TIME_INFORMATION, *PKEY_WRITE_TIME_INFORMATION;
  202. typedef struct _KEY_USER_FLAGS_INFORMATION {
  203. ULONG UserFlags;
  204. } KEY_USER_FLAGS_INFORMATION, *PKEY_USER_FLAGS_INFORMATION;
  205. typedef enum _KEY_SET_INFORMATION_CLASS {
  206. KeyWriteTimeInformation,
  207. KeyUserFlagsInformation,
  208. MaxKeySetInfoClass // MaxKeySetInfoClass should always be the last enum
  209. } KEY_SET_INFORMATION_CLASS;
  210. //
  211. // Value entry query structures
  212. //
  213. typedef struct _KEY_VALUE_BASIC_INFORMATION {
  214. ULONG TitleIndex;
  215. ULONG Type;
  216. ULONG NameLength;
  217. WCHAR Name[1]; // Variable size
  218. } KEY_VALUE_BASIC_INFORMATION, *PKEY_VALUE_BASIC_INFORMATION;
  219. typedef struct _KEY_VALUE_FULL_INFORMATION {
  220. ULONG TitleIndex;
  221. ULONG Type;
  222. ULONG DataOffset;
  223. ULONG DataLength;
  224. ULONG NameLength;
  225. WCHAR Name[1]; // Variable size
  226. // Data[1]; // Variable size data not declared
  227. } KEY_VALUE_FULL_INFORMATION, *PKEY_VALUE_FULL_INFORMATION;
  228. typedef struct _KEY_VALUE_PARTIAL_INFORMATION {
  229. ULONG TitleIndex;
  230. ULONG Type;
  231. ULONG DataLength;
  232. UCHAR Data[1]; // Variable size
  233. } KEY_VALUE_PARTIAL_INFORMATION, *PKEY_VALUE_PARTIAL_INFORMATION;
  234. typedef struct _KEY_VALUE_PARTIAL_INFORMATION_ALIGN64 {
  235. ULONG Type;
  236. ULONG DataLength;
  237. UCHAR Data[1]; // Variable size
  238. } KEY_VALUE_PARTIAL_INFORMATION_ALIGN64, *PKEY_VALUE_PARTIAL_INFORMATION_ALIGN64;
  239. typedef struct _KEY_VALUE_ENTRY {
  240. PUNICODE_STRING ValueName;
  241. ULONG DataLength;
  242. ULONG DataOffset;
  243. ULONG Type;
  244. } KEY_VALUE_ENTRY, *PKEY_VALUE_ENTRY;
  245. typedef enum _KEY_VALUE_INFORMATION_CLASS {
  246. KeyValueBasicInformation,
  247. KeyValueFullInformation,
  248. KeyValuePartialInformation,
  249. KeyValueFullInformationAlign64,
  250. KeyValuePartialInformationAlign64,
  251. MaxKeyValueInfoClass // MaxKeyValueInfoClass should always be the last enum
  252. } KEY_VALUE_INFORMATION_CLASS;
  253. // end_ntddk end_wdm end_nthal
  254. //
  255. // Notify return structures
  256. //
  257. typedef enum _REG_ACTION {
  258. KeyAdded,
  259. KeyRemoved,
  260. KeyModified
  261. } REG_ACTION;
  262. typedef struct _REG_NOTIFY_INFORMATION {
  263. ULONG NextEntryOffset;
  264. REG_ACTION Action;
  265. ULONG KeyLength;
  266. WCHAR Key[1]; // Variable size
  267. } REG_NOTIFY_INFORMATION, *PREG_NOTIFY_INFORMATION;
  268. typedef struct {
  269. HANDLE PID; // PID of the process at the time of open
  270. UNICODE_STRING KeyName; // Full name of the key
  271. } KEY_PID_ARRAY;
  272. typedef struct _KEY_OPEN_SUBKEYS_INFORMATION {
  273. ULONG Count; // number of elements in the below array
  274. KEY_PID_ARRAY KeyArray[1];// variable size array; element count above
  275. } KEY_OPEN_SUBKEYS_INFORMATION, *PKEY_OPEN_SUBKEYS_INFORMATION;
  276. //
  277. // Nt level registry API calls
  278. //
  279. NTSYSCALLAPI
  280. NTSTATUS
  281. NTAPI
  282. NtCreateKey(
  283. OUT PHANDLE KeyHandle,
  284. IN ACCESS_MASK DesiredAccess,
  285. IN POBJECT_ATTRIBUTES ObjectAttributes,
  286. IN ULONG TitleIndex,
  287. IN PUNICODE_STRING Class OPTIONAL,
  288. IN ULONG CreateOptions,
  289. OUT PULONG Disposition OPTIONAL
  290. );
  291. NTSYSCALLAPI
  292. NTSTATUS
  293. NTAPI
  294. NtDeleteKey(
  295. IN HANDLE KeyHandle
  296. );
  297. NTSYSCALLAPI
  298. NTSTATUS
  299. NTAPI
  300. NtDeleteValueKey(
  301. IN HANDLE KeyHandle,
  302. IN PUNICODE_STRING ValueName
  303. );
  304. NTSYSCALLAPI
  305. NTSTATUS
  306. NTAPI
  307. NtEnumerateKey(
  308. IN HANDLE KeyHandle,
  309. IN ULONG Index,
  310. IN KEY_INFORMATION_CLASS KeyInformationClass,
  311. OUT PVOID KeyInformation,
  312. IN ULONG Length,
  313. OUT PULONG ResultLength
  314. );
  315. NTSYSCALLAPI
  316. NTSTATUS
  317. NTAPI
  318. NtEnumerateValueKey(
  319. IN HANDLE KeyHandle,
  320. IN ULONG Index,
  321. IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
  322. OUT PVOID KeyValueInformation,
  323. IN ULONG Length,
  324. OUT PULONG ResultLength
  325. );
  326. NTSYSCALLAPI
  327. NTSTATUS
  328. NTAPI
  329. NtFlushKey(
  330. IN HANDLE KeyHandle
  331. );
  332. NTSYSCALLAPI
  333. NTSTATUS
  334. NTAPI
  335. NtInitializeRegistry(
  336. IN USHORT BootCondition
  337. );
  338. NTSYSCALLAPI
  339. NTSTATUS
  340. NTAPI
  341. NtNotifyChangeKey(
  342. IN HANDLE KeyHandle,
  343. IN HANDLE Event OPTIONAL,
  344. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  345. IN PVOID ApcContext OPTIONAL,
  346. OUT PIO_STATUS_BLOCK IoStatusBlock,
  347. IN ULONG CompletionFilter,
  348. IN BOOLEAN WatchTree,
  349. OUT PVOID Buffer,
  350. IN ULONG BufferSize,
  351. IN BOOLEAN Asynchronous
  352. );
  353. NTSYSCALLAPI
  354. NTSTATUS
  355. NTAPI
  356. NtNotifyChangeMultipleKeys(
  357. IN HANDLE MasterKeyHandle,
  358. IN ULONG Count,
  359. IN OBJECT_ATTRIBUTES SlaveObjects[],
  360. IN HANDLE Event OPTIONAL,
  361. IN PIO_APC_ROUTINE ApcRoutine OPTIONAL,
  362. IN PVOID ApcContext OPTIONAL,
  363. OUT PIO_STATUS_BLOCK IoStatusBlock,
  364. IN ULONG CompletionFilter,
  365. IN BOOLEAN WatchTree,
  366. OUT PVOID Buffer,
  367. IN ULONG BufferSize,
  368. IN BOOLEAN Asynchronous
  369. );
  370. NTSYSCALLAPI
  371. NTSTATUS
  372. NTAPI
  373. NtLoadKey(
  374. IN POBJECT_ATTRIBUTES TargetKey,
  375. IN POBJECT_ATTRIBUTES SourceFile
  376. );
  377. NTSYSCALLAPI
  378. NTSTATUS
  379. NTAPI
  380. NtLoadKey2(
  381. IN POBJECT_ATTRIBUTES TargetKey,
  382. IN POBJECT_ATTRIBUTES SourceFile,
  383. IN ULONG Flags
  384. );
  385. NTSYSCALLAPI
  386. NTSTATUS
  387. NTAPI
  388. NtLoadKeyEx(
  389. IN POBJECT_ATTRIBUTES TargetKey,
  390. IN POBJECT_ATTRIBUTES SourceFile,
  391. IN ULONG Flags,
  392. IN HANDLE TrustClassKey OPTIONAL
  393. );
  394. NTSYSCALLAPI
  395. NTSTATUS
  396. NTAPI
  397. NtOpenKey(
  398. OUT PHANDLE KeyHandle,
  399. IN ACCESS_MASK DesiredAccess,
  400. IN POBJECT_ATTRIBUTES ObjectAttributes
  401. );
  402. NTSYSCALLAPI
  403. NTSTATUS
  404. NTAPI
  405. NtQueryKey(
  406. IN HANDLE KeyHandle,
  407. IN KEY_INFORMATION_CLASS KeyInformationClass,
  408. OUT PVOID KeyInformation,
  409. IN ULONG Length,
  410. OUT PULONG ResultLength
  411. );
  412. NTSYSCALLAPI
  413. NTSTATUS
  414. NTAPI
  415. NtQueryValueKey(
  416. IN HANDLE KeyHandle,
  417. IN PUNICODE_STRING ValueName,
  418. IN KEY_VALUE_INFORMATION_CLASS KeyValueInformationClass,
  419. OUT PVOID KeyValueInformation,
  420. IN ULONG Length,
  421. OUT PULONG ResultLength
  422. );
  423. NTSYSCALLAPI
  424. NTSTATUS
  425. NTAPI
  426. NtQueryMultipleValueKey(
  427. IN HANDLE KeyHandle,
  428. IN OUT PKEY_VALUE_ENTRY ValueEntries,
  429. IN ULONG EntryCount,
  430. OUT PVOID ValueBuffer,
  431. IN OUT PULONG BufferLength,
  432. OUT OPTIONAL PULONG RequiredBufferLength
  433. );
  434. NTSYSCALLAPI
  435. NTSTATUS
  436. NTAPI
  437. NtReplaceKey(
  438. IN POBJECT_ATTRIBUTES NewFile,
  439. IN HANDLE TargetHandle,
  440. IN POBJECT_ATTRIBUTES OldFile
  441. );
  442. NTSYSCALLAPI
  443. NTSTATUS
  444. NTAPI
  445. NtRenameKey(
  446. IN HANDLE KeyHandle,
  447. IN PUNICODE_STRING NewName
  448. );
  449. NTSYSCALLAPI
  450. NTSTATUS
  451. NTAPI
  452. NtCompactKeys(
  453. IN ULONG Count,
  454. IN HANDLE KeyArray[]
  455. );
  456. NTSYSCALLAPI
  457. NTSTATUS
  458. NTAPI
  459. NtCompressKey(
  460. IN HANDLE Key
  461. );
  462. NTSYSCALLAPI
  463. NTSTATUS
  464. NTAPI
  465. NtRestoreKey(
  466. IN HANDLE KeyHandle,
  467. IN HANDLE FileHandle,
  468. IN ULONG Flags
  469. );
  470. NTSYSCALLAPI
  471. NTSTATUS
  472. NTAPI
  473. NtSaveKey(
  474. IN HANDLE KeyHandle,
  475. IN HANDLE FileHandle
  476. );
  477. NTSYSCALLAPI
  478. NTSTATUS
  479. NTAPI
  480. NtSaveKeyEx(
  481. IN HANDLE KeyHandle,
  482. IN HANDLE FileHandle,
  483. IN ULONG Format
  484. );
  485. NTSYSCALLAPI
  486. NTSTATUS
  487. NTAPI
  488. NtSaveMergedKeys(
  489. IN HANDLE HighPrecedenceKeyHandle,
  490. IN HANDLE LowPrecedenceKeyHandle,
  491. IN HANDLE FileHandle
  492. );
  493. NTSYSCALLAPI
  494. NTSTATUS
  495. NTAPI
  496. NtSetValueKey(
  497. IN HANDLE KeyHandle,
  498. IN PUNICODE_STRING ValueName,
  499. IN ULONG TitleIndex OPTIONAL,
  500. IN ULONG Type,
  501. IN PVOID Data,
  502. IN ULONG DataSize
  503. );
  504. NTSYSCALLAPI
  505. NTSTATUS
  506. NTAPI
  507. NtUnloadKey(
  508. IN POBJECT_ATTRIBUTES TargetKey
  509. );
  510. NTSYSCALLAPI
  511. NTSTATUS
  512. NTAPI
  513. NtUnloadKey2(
  514. IN POBJECT_ATTRIBUTES TargetKey,
  515. IN ULONG Flags
  516. );
  517. NTSYSCALLAPI
  518. NTSTATUS
  519. NTAPI
  520. NtUnloadKeyEx(
  521. IN POBJECT_ATTRIBUTES TargetKey,
  522. IN HANDLE Event OPTIONAL
  523. );
  524. NTSYSCALLAPI
  525. NTSTATUS
  526. NTAPI
  527. NtSetInformationKey(
  528. IN HANDLE KeyHandle,
  529. IN KEY_SET_INFORMATION_CLASS KeySetInformationClass,
  530. IN PVOID KeySetInformation,
  531. IN ULONG KeySetInformationLength
  532. );
  533. NTSYSCALLAPI
  534. NTSTATUS
  535. NTAPI
  536. NtQueryOpenSubKeys(
  537. IN POBJECT_ATTRIBUTES TargetKey,
  538. OUT PULONG HandleCount
  539. );
  540. NTSYSCALLAPI
  541. NTSTATUS
  542. NTAPI
  543. NtQueryOpenSubKeysEx(
  544. IN POBJECT_ATTRIBUTES TargetKey,
  545. IN ULONG BufferLength,
  546. OUT PVOID Buffer,
  547. OUT PULONG RequiredSize
  548. );
  549. NTSYSCALLAPI
  550. NTSTATUS
  551. NTAPI
  552. NtLockRegistryKey(
  553. IN HANDLE KeyHandle
  554. );
  555. NTSYSCALLAPI
  556. NTSTATUS
  557. NTAPI
  558. NtLockProductActivationKeys(
  559. ULONG *pPrivateVer,
  560. ULONG *pIsSafeMode
  561. );
  562. #ifdef __cplusplus
  563. }
  564. #endif
  565. #endif // _NTREGAPI_