3 * Copyright (C) 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 * COPYRIGHT: See COPYING in the top level directory
21 * PROJECT: ReactOS hive maker
22 * FILE: tools/mkhive/registry.h
23 * PURPOSE: Registry code
24 * PROGRAMMER: Eric Kohl
27 #ifndef __REGISTRY_H__
28 #define __REGISTRY_H__
31 #define INVALID_HANDLE_VALUE NULL
33 typedef struct _LIST_ENTRY
35 struct _LIST_ENTRY *Flink;
36 struct _LIST_ENTRY *Blink;
37 } LIST_ENTRY, *PLIST_ENTRY;
40 typedef struct _REG_KEY
43 LIST_ENTRY SubKeyList;
56 } KEY, *HKEY, **PHKEY;
59 typedef struct _REG_VALUE
74 #define ERROR_SUCCESS 0L
75 #define ERROR_PATH_NOT_FOUND 2L
76 #define ERROR_OUTOFMEMORY 14L
77 #define ERROR_INVALID_PARAMETER 87L
78 #define ERROR_MORE_DATA 234L
79 #define ERROR_NO_MORE_ITEMS 259L
86 * InitializeListHead (
87 * PLIST_ENTRY ListHead
90 * FUNCTION: Initializes a double linked list
92 * ListHead = Caller supplied storage for the head of the list
94 #define InitializeListHead(ListHead) \
96 (ListHead)->Flink = (ListHead); \
97 (ListHead)->Blink = (ListHead); \
104 * PLIST_ENTRY ListHead,
108 * FUNCTION: Inserts an entry in a double linked list
110 * ListHead = Head of the list
111 * Entry = Entry to insert
113 #define InsertHeadList(ListHead, ListEntry) \
115 PLIST_ENTRY OldFlink; \
116 OldFlink = (ListHead)->Flink; \
117 (ListEntry)->Flink = OldFlink; \
118 (ListEntry)->Blink = (ListHead); \
119 OldFlink->Blink = (ListEntry); \
120 (ListHead)->Flink = (ListEntry); \
121 assert((ListEntry) != NULL); \
122 assert((ListEntry)->Blink!=NULL); \
123 assert((ListEntry)->Blink->Flink == (ListEntry)); \
124 assert((ListEntry)->Flink != NULL); \
125 assert((ListEntry)->Flink->Blink == (ListEntry)); \
132 * PLIST_ENTRY ListHead,
137 * Inserts an entry in a double linked list
140 * ListHead = Head of the list
141 * Entry = Entry to insert
143 #define InsertTailList(ListHead, ListEntry) \
145 PLIST_ENTRY OldBlink; \
146 OldBlink = (ListHead)->Blink; \
147 (ListEntry)->Flink = (ListHead); \
148 (ListEntry)->Blink = OldBlink; \
149 OldBlink->Flink = (ListEntry); \
150 (ListHead)->Blink = (ListEntry); \
151 assert((ListEntry) != NULL); \
152 assert((ListEntry)->Blink != NULL); \
153 assert((ListEntry)->Blink->Flink == (ListEntry)); \
154 assert((ListEntry)->Flink != NULL); \
155 assert((ListEntry)->Flink->Blink == (ListEntry)); \
161 * PLIST_ENTRY ListHead
165 * Checks if a double linked list is empty
168 * ListHead = Head of the list
170 #define IsListEmpty(ListHead) \
171 ((ListHead)->Flink == (ListHead))
181 * Removes an entry from a double linked list
184 * ListEntry = Entry to remove
186 #define RemoveEntryList(ListEntry) \
188 PLIST_ENTRY OldFlink; \
189 PLIST_ENTRY OldBlink; \
190 assert((ListEntry) != NULL); \
191 assert((ListEntry)->Blink!=NULL); \
192 assert((ListEntry)->Blink->Flink == (ListEntry)); \
193 assert((ListEntry)->Flink != NULL); \
194 assert((ListEntry)->Flink->Blink == (ListEntry)); \
195 OldFlink = (ListEntry)->Flink; \
196 OldBlink = (ListEntry)->Blink; \
197 OldFlink->Blink = OldBlink; \
198 OldBlink->Flink = OldFlink; \
199 (ListEntry)->Flink = NULL; \
200 (ListEntry)->Blink = NULL; \
204 * PURPOSE: Returns the byte offset of a field within a structure
206 #define FIELD_OFFSET(Type,Field) (LONG)(&(((Type *)(0))->Field))
209 * PURPOSE: Returns the base address structure if the caller knows the
210 * address of a field within the structure
212 * Address = address of the field
213 * Type = Type of the whole structure
214 * Field = Name of the field whose address is none
216 #define CONTAINING_RECORD(Address,Type,Field) \
217 (Type *)(((LONG)Address) - FIELD_OFFSET(Type,Field))
222 #define REG_EXPAND_SZ 2
225 #define REG_DWORD_BIG_ENDIAN 5
226 #define REG_DWORD_LITTLE_ENDIAN 4
228 #define REG_MULTI_SZ 7
229 #define REG_RESOURCE_LIST 8
230 #define REG_FULL_RESOURCE_DESCRIPTOR 9
231 #define REG_RESOURCE_REQUIREMENTS_LIST 10
236 RegInitializeRegistry(VOID);
239 RegCreateKey(HKEY ParentKey,
244 RegDeleteKey(HKEY Key,
254 RegOpenKey(HKEY ParentKey,
260 RegSetValue(HKEY Key,
267 RegQueryValue(HKEY Key,
274 RegDeleteValue(HKEY Key,
278 RegEnumValue(HKEY Key,
287 RegGetSubKeyCount (HKEY Key);
290 RegGetValueCount (HKEY Key);
295 RegImportTextHive(PCHAR ChunkBase,
299 RegImportBinaryHive(PCHAR ChunkBase,
303 #endif /* __REGISTRY_H__ */