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.

303 lines
6.5 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. regtool.h
  5. Abstract:
  6. This is the include file for the REGTOOL.DLL registry helper.
  7. Author:
  8. Steve Wood (stevewo) 16-Nov-1995
  9. Revision History:
  10. --*/
  11. //
  12. // Routines for accessing registry. Allows code to access any of the following
  13. // registry locations with the same code:
  14. //
  15. // Windows NT registry on local machine
  16. // Windows NT registry on remote machine
  17. // Windows NT hive files
  18. // Windows 95 registry files (system.dat, user.dat)
  19. //
  20. BOOLEAN
  21. RTInitialize( void );
  22. #define REG_TARGET_DISCONNECTED 0
  23. #define REG_TARGET_LOCAL_REGISTRY 1
  24. #define REG_TARGET_REMOTE_REGISTRY 2
  25. #define REG_TARGET_WIN95_REGISTRY 3
  26. #define REG_TARGET_HIVE_REGISTRY 4
  27. typedef struct _REG_CONTEXT_OPEN_HIVE_KEY {
  28. struct _REG_CONTEXT_OPEN_HIVE_KEY *Next;
  29. HKEY KeyHandle;
  30. ULONG ReferenceCount;
  31. } REG_CONTEXT_OPEN_HIVE_KEY, *PREG_CONTEXT_OPEN_HIVE_KEY;
  32. typedef struct _REG_CONTEXT {
  33. struct _REG_CONTEXT *Next;
  34. ULONG Target;
  35. HKEY MachineRoot;
  36. HKEY UsersRoot;
  37. HKEY CurrentUserRoot;
  38. WCHAR MachinePath[ MAX_PATH ];
  39. WCHAR UsersPath[ MAX_PATH ];
  40. WCHAR CurrentUserPath[ MAX_PATH ];
  41. ULONG MachinePathLength;
  42. ULONG UsersPathLength;
  43. ULONG CurrentUserPathLength;
  44. HKEY HiveRootHandle;
  45. OBJECT_ATTRIBUTES HiveRootKey;
  46. PREG_CONTEXT_OPEN_HIVE_KEY OpenHiveKeys;
  47. } REG_CONTEXT, *PREG_CONTEXT;
  48. BOOLEAN
  49. RTEnableBackupRestorePrivilege( void );
  50. void
  51. RTDisableBackupRestorePrivilege( void );
  52. LONG
  53. RTConnectToRegistry(
  54. IN PWSTR MachineName,
  55. IN PWSTR HiveFileName,
  56. IN PWSTR HiveRootName,
  57. IN PWSTR Win95Path,
  58. IN PWSTR Win95UserName,
  59. OUT PWSTR *DefaultRootKeyName,
  60. OUT PREG_CONTEXT RegistryContext
  61. );
  62. LONG
  63. RTDisconnectFromRegistry(
  64. IN PREG_CONTEXT RegistryContext
  65. );
  66. LONG
  67. RTCreateKey(
  68. IN PREG_CONTEXT RegistryContext,
  69. IN HKEY RootKeyHandle,
  70. IN PCWSTR SubKeyName,
  71. IN ACCESS_MASK DesiredAccess,
  72. IN ULONG CreateOptions,
  73. IN PVOID SecurityDescriptor,
  74. OUT PHKEY ReturnedKeyHandle,
  75. OUT PULONG Disposition
  76. );
  77. LONG
  78. RTOpenKey(
  79. IN PREG_CONTEXT RegistryContext,
  80. IN HKEY RootKeyHandle,
  81. IN PCWSTR SubKeyName,
  82. IN ACCESS_MASK DesiredAccess,
  83. IN ULONG OpenOptions,
  84. OUT PHKEY ReturnedKeyHandle
  85. );
  86. #define HKEY_REGISTRY_ROOT (( HKEY ) (ULONG_PTR)((LONG)0x8000000A) )
  87. LONG
  88. RTCloseKey(
  89. IN PREG_CONTEXT RegistryContext,
  90. IN HKEY KeyHandle
  91. );
  92. LONG
  93. RTFlushKey(
  94. IN PREG_CONTEXT RegistryContext,
  95. IN HKEY KeyHandle
  96. );
  97. LONG
  98. RTEnumerateKey(
  99. IN PREG_CONTEXT RegistryContext,
  100. IN HKEY KeyHandle,
  101. IN ULONG Index,
  102. OUT PFILETIME LastWriteTime,
  103. IN OUT PULONG KeyNameLength,
  104. OUT PWSTR KeyName
  105. );
  106. LONG
  107. RTEnumerateValueKey(
  108. IN PREG_CONTEXT RegistryContext,
  109. IN HKEY KeyHandle,
  110. IN ULONG Index,
  111. OUT PULONG ValueType,
  112. IN OUT PULONG ValueNameLength,
  113. OUT PWSTR ValueName,
  114. IN OUT PULONG ValueDataLength,
  115. OUT PVOID ValueData
  116. );
  117. LONG
  118. RTQueryKey(
  119. IN PREG_CONTEXT RegistryContext,
  120. IN HKEY KeyHandle,
  121. OUT PFILETIME LastWriteTime,
  122. OUT PULONG NumberOfSubkeys,
  123. OUT PULONG NumberOfValues
  124. );
  125. LONG
  126. RTQueryValueKey(
  127. IN PREG_CONTEXT RegistryContext,
  128. IN HKEY KeyHandle,
  129. IN PWSTR ValueName,
  130. OUT PULONG ValueType,
  131. IN OUT PULONG ValueDataLength,
  132. OUT PVOID ValueData
  133. );
  134. LONG
  135. RTSetValueKey(
  136. IN PREG_CONTEXT RegistryContext,
  137. IN HKEY KeyHandle,
  138. IN PWSTR ValueName,
  139. IN ULONG ValueType,
  140. IN ULONG ValueDataLength,
  141. IN PVOID ValueData
  142. );
  143. LONG
  144. RTDeleteKey(
  145. IN PREG_CONTEXT RegistryContext,
  146. IN HKEY KeyHandle,
  147. IN PCWSTR SubKeyName
  148. );
  149. LONG
  150. RTDeleteValueKey(
  151. IN PREG_CONTEXT RegistryContext,
  152. IN HKEY KeyHandle,
  153. IN PWSTR ValueName
  154. );
  155. typedef struct _REG_UNICODE_FILE {
  156. PWSTR FileName;
  157. FILETIME LastWriteTime;
  158. PWSTR FileContents;
  159. PWSTR EndOfFile;
  160. PWSTR NextLine;
  161. ULONG NextLineNumber;
  162. BOOLEAN BackwardsCompatibleInput;
  163. } REG_UNICODE_FILE, *PREG_UNICODE_FILE;
  164. LONG
  165. RTLoadAsciiFileAsUnicode(
  166. IN PWSTR Path,
  167. OUT PREG_UNICODE_FILE UnicodeFile
  168. );
  169. void
  170. RTUnloadUnicodeFile(
  171. IN OUT PREG_UNICODE_FILE UnicodeFile
  172. );
  173. typedef enum _REG_UNICODE_PARSE_FAILURE_REASON {
  174. ParseFailNoFailure = 0,
  175. ParseFailValueTooLarge,
  176. ParseFailUnableToAccessFile,
  177. ParseFailDateTimeFormatInvalid,
  178. ParseFailInvalidLineContinuation,
  179. ParseFailInvalidQuoteCharacter,
  180. ParseFailBinaryDataLengthMissing,
  181. ParseFailBinaryDataOmitted,
  182. ParseFailBinaryDataNotEnough,
  183. ParseFailInvalidRegistryType
  184. } REG_UNICODE_PARSE_FAILURE_REASON;
  185. typedef struct _REG_UNICODE_PARSE {
  186. ULONG LineNumber;
  187. ULONG IndentAmount;
  188. PWSTR BeginLine;
  189. BOOLEAN AtEndOfFile;
  190. BOOLEAN IsKeyName;
  191. REG_UNICODE_PARSE_FAILURE_REASON ParseFailureReason;
  192. union {
  193. struct {
  194. PWSTR KeyName;
  195. PWSTR AclString;
  196. PVOID SecurityDescriptor;
  197. BOOLEAN DeleteKey;
  198. SECURITY_DESCRIPTOR SecurityDescriptorBuffer;
  199. };
  200. struct {
  201. PWSTR ValueName;
  202. PWSTR ValueString;
  203. ULONG ValueType;
  204. ULONG ValueLength;
  205. PVOID ValueData;
  206. BOOLEAN DeleteValue;
  207. };
  208. };
  209. } REG_UNICODE_PARSE, *PREG_UNICODE_PARSE;
  210. BOOLEAN
  211. RTParseNextLine(
  212. IN OUT PREG_UNICODE_FILE UnicodeFile,
  213. OUT PREG_UNICODE_PARSE ParsedLine
  214. );
  215. BOOLEAN
  216. RTParseValueData(
  217. IN OUT PREG_UNICODE_FILE UnicodeFile,
  218. IN OUT PREG_UNICODE_PARSE ParsedLine,
  219. IN PVOID ValueBuffer,
  220. IN ULONG ValueBufferSize,
  221. OUT PULONG ValueType,
  222. OUT PVOID *ValueData,
  223. OUT PULONG ValueLength
  224. );
  225. typedef
  226. int
  227. (_cdecl *PREG_OUTPUT_ROUTINE)(
  228. PVOID pParameter,
  229. LPSTR FormatString,
  230. ...
  231. );
  232. void
  233. RTFormatKeyName(
  234. PREG_OUTPUT_ROUTINE OutputRoutine,
  235. PVOID OutputRoutineParameter,
  236. ULONG IndentLevel,
  237. PWSTR KeyName
  238. );
  239. void
  240. RTFormatKeySecurity(
  241. PREG_OUTPUT_ROUTINE OutputRoutine,
  242. PVOID OutputRoutineParameter,
  243. HKEY KeyHandle,
  244. PSECURITY_DESCRIPTOR SecurityDescriptor
  245. );
  246. void
  247. RTFormatKeyValue(
  248. ULONG OutputWidth,
  249. PREG_OUTPUT_ROUTINE OutputRoutine,
  250. PVOID OutputRoutineParameter,
  251. BOOLEAN SummaryOutput,
  252. ULONG IndentLevel,
  253. PWSTR ValueName,
  254. ULONG ValueLength,
  255. ULONG ValueType,
  256. PWSTR ValueData
  257. );