Fix some Rtl Prototype inconsistencies, more are in ntifs/winddk but i have fixed...
[reactos.git] / freeldr / freeldr / reactos / registry.h
1 /*
2 * FreeLoader - registry.h
3 *
4 * Copyright (C) 2001 Eric Kohl
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #ifndef __REGISTRY_H
22 #define __REGISTRY_H
23
24
25 #define INVALID_HANDLE_VALUE NULL
26
27 typedef struct _LIST_ENTRY
28 {
29 struct _LIST_ENTRY *Flink;
30 struct _LIST_ENTRY *Blink;
31 } LIST_ENTRY, *PLIST_ENTRY;
32
33
34 typedef struct _REG_KEY
35 {
36 LIST_ENTRY KeyList;
37 LIST_ENTRY SubKeyList;
38 LIST_ENTRY ValueList;
39
40 U32 SubKeyCount;
41 U32 ValueCount;
42
43 U32 NameSize;
44 PUCHAR Name;
45
46 /* default data */
47 U32 DataType;
48 U32 DataSize;
49 PUCHAR Data;
50 } KEY, *HKEY, **PHKEY;
51
52
53 typedef struct _REG_VALUE
54 {
55 LIST_ENTRY ValueList;
56
57 /* value name */
58 U32 NameSize;
59 PUCHAR Name;
60
61 /* value data */
62 U32 DataType;
63 U32 DataSize;
64 PUCHAR Data;
65 } VALUE, *PVALUE;
66
67
68 #define ERROR_SUCCESS 0L
69 #define ERROR_PATH_NOT_FOUND 2L
70 #define ERROR_OUTOFMEMORY 14L
71 #define ERROR_INVALID_PARAMETER 87L
72 #define ERROR_MORE_DATA 234L
73 #define ERROR_NO_MORE_ITEMS 259L
74
75
76 #define assert(x)
77
78 /*
79 * VOID
80 * InitializeListHead (
81 * PLIST_ENTRY ListHead
82 * );
83 *
84 * FUNCTION: Initializes a double linked list
85 * ARGUMENTS:
86 * ListHead = Caller supplied storage for the head of the list
87 */
88 #define InitializeListHead(ListHead) \
89 { \
90 (ListHead)->Flink = (ListHead); \
91 (ListHead)->Blink = (ListHead); \
92 }
93
94
95 /*
96 * VOID
97 * InsertHeadList (
98 * PLIST_ENTRY ListHead,
99 * PLIST_ENTRY Entry
100 * );
101 *
102 * FUNCTION: Inserts an entry in a double linked list
103 * ARGUMENTS:
104 * ListHead = Head of the list
105 * Entry = Entry to insert
106 */
107 #define InsertHeadList(ListHead, ListEntry) \
108 { \
109 PLIST_ENTRY OldFlink; \
110 OldFlink = (ListHead)->Flink; \
111 (ListEntry)->Flink = OldFlink; \
112 (ListEntry)->Blink = (ListHead); \
113 OldFlink->Blink = (ListEntry); \
114 (ListHead)->Flink = (ListEntry); \
115 assert((ListEntry) != NULL); \
116 assert((ListEntry)->Blink!=NULL); \
117 assert((ListEntry)->Blink->Flink == (ListEntry)); \
118 assert((ListEntry)->Flink != NULL); \
119 assert((ListEntry)->Flink->Blink == (ListEntry)); \
120 }
121
122
123 /*
124 * VOID
125 * InsertTailList (
126 * PLIST_ENTRY ListHead,
127 * PLIST_ENTRY Entry
128 * );
129 *
130 * FUNCTION:
131 * Inserts an entry in a double linked list
132 *
133 * ARGUMENTS:
134 * ListHead = Head of the list
135 * Entry = Entry to insert
136 */
137 #define InsertTailList(ListHead, ListEntry) \
138 { \
139 PLIST_ENTRY OldBlink; \
140 OldBlink = (ListHead)->Blink; \
141 (ListEntry)->Flink = (ListHead); \
142 (ListEntry)->Blink = OldBlink; \
143 OldBlink->Flink = (ListEntry); \
144 (ListHead)->Blink = (ListEntry); \
145 assert((ListEntry) != NULL); \
146 assert((ListEntry)->Blink != NULL); \
147 assert((ListEntry)->Blink->Flink == (ListEntry)); \
148 assert((ListEntry)->Flink != NULL); \
149 assert((ListEntry)->Flink->Blink == (ListEntry)); \
150 }
151
152 /*
153 * BOOLEAN
154 * IsListEmpty (
155 * PLIST_ENTRY ListHead
156 * );
157 *
158 * FUNCTION:
159 * Checks if a double linked list is empty
160 *
161 * ARGUMENTS:
162 * ListHead = Head of the list
163 */
164 #define IsListEmpty(ListHead) \
165 ((ListHead)->Flink == (ListHead))
166
167
168 /*
169 *VOID
170 *RemoveEntryList (
171 * PLIST_ENTRY Entry
172 * );
173 *
174 * FUNCTION:
175 * Removes an entry from a double linked list
176 *
177 * ARGUMENTS:
178 * ListEntry = Entry to remove
179 */
180 #define RemoveEntryList(ListEntry) \
181 { \
182 PLIST_ENTRY OldFlink; \
183 PLIST_ENTRY OldBlink; \
184 assert((ListEntry) != NULL); \
185 assert((ListEntry)->Blink!=NULL); \
186 assert((ListEntry)->Blink->Flink == (ListEntry)); \
187 assert((ListEntry)->Flink != NULL); \
188 assert((ListEntry)->Flink->Blink == (ListEntry)); \
189 OldFlink = (ListEntry)->Flink; \
190 OldBlink = (ListEntry)->Blink; \
191 OldFlink->Blink = OldBlink; \
192 OldBlink->Flink = OldFlink; \
193 (ListEntry)->Flink = NULL; \
194 (ListEntry)->Blink = NULL; \
195 }
196
197 /*
198 * PURPOSE: Returns the byte offset of a field within a structure
199 */
200 #define FIELD_OFFSET(Type,Field) (S32)(&(((Type *)(0))->Field))
201
202 /*
203 * PURPOSE: Returns the base address structure if the caller knows the
204 * address of a field within the structure
205 * ARGUMENTS:
206 * Address = address of the field
207 * Type = Type of the whole structure
208 * Field = Name of the field whose address is none
209 */
210 #define CONTAINING_RECORD(Address,Type,Field) \
211 (Type *)(((S32)Address) - FIELD_OFFSET(Type,Field))
212
213
214 #define REG_NONE 0
215 #define REG_SZ 1
216 #define REG_EXPAND_SZ 2
217 #define REG_BINARY 3
218 #define REG_DWORD 4
219 #define REG_DWORD_BIG_ENDIAN 5
220 #define REG_DWORD_LITTLE_ENDIAN 4
221 #define REG_LINK 6
222 #define REG_MULTI_SZ 7
223 #define REG_RESOURCE_LIST 8
224 #define REG_FULL_RESOURCE_DESCRIPTOR 9
225 #define REG_RESOURCE_REQUIREMENTS_LIST 10
226
227
228
229 VOID
230 RegInitializeRegistry(VOID);
231
232 S32
233 RegInitCurrentControlSet(BOOL LastKnownGood);
234
235
236 S32
237 RegCreateKey(HKEY ParentKey,
238 PCHAR KeyName,
239 PHKEY Key);
240
241 S32
242 RegDeleteKey(HKEY Key,
243 PCHAR Name);
244
245 S32
246 RegEnumKey(HKEY Key,
247 U32 Index,
248 PCHAR Name,
249 U32* NameSize);
250
251 S32
252 RegOpenKey(HKEY ParentKey,
253 PCHAR KeyName,
254 PHKEY Key);
255
256
257 S32
258 RegSetValue(HKEY Key,
259 PCHAR ValueName,
260 U32 Type,
261 PUCHAR Data,
262 U32 DataSize);
263
264 S32
265 RegQueryValue(HKEY Key,
266 PCHAR ValueName,
267 U32* Type,
268 PUCHAR Data,
269 U32* DataSize);
270
271 S32
272 RegDeleteValue(HKEY Key,
273 PCHAR ValueName);
274
275 S32
276 RegEnumValue(HKEY Key,
277 U32 Index,
278 PCHAR ValueName,
279 U32* NameSize,
280 U32* Type,
281 PUCHAR Data,
282 U32* DataSize);
283
284 U32
285 RegGetSubKeyCount (HKEY Key);
286
287 U32
288 RegGetValueCount (HKEY Key);
289
290
291 BOOL
292 RegImportBinaryHive (PCHAR ChunkBase,
293 U32 ChunkSize);
294
295 BOOL
296 RegExportBinaryHive (PCHAR KeyName,
297 PCHAR ChunkBase,
298 U32* ChunkSize);
299
300
301 #endif /* __REGISTRY_H */
302
303 /* EOF */
304