2 * FreeLoader - registry.h
4 * Copyright (C) 2001 Eric Kohl
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.
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.
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.
25 #define INVALID_HANDLE_VALUE NULL
27 typedef struct _LIST_ENTRY
29 struct _LIST_ENTRY
*Flink
;
30 struct _LIST_ENTRY
*Blink
;
31 } LIST_ENTRY
, *PLIST_ENTRY
;
34 typedef struct _REG_KEY
37 LIST_ENTRY SubKeyList
;
50 } KEY
, *HKEY
, **PHKEY
;
53 typedef struct _REG_VALUE
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
80 * InitializeListHead (
81 * PLIST_ENTRY ListHead
84 * FUNCTION: Initializes a double linked list
86 * ListHead = Caller supplied storage for the head of the list
88 #define InitializeListHead(ListHead) \
90 (ListHead)->Flink = (ListHead); \
91 (ListHead)->Blink = (ListHead); \
98 * PLIST_ENTRY ListHead,
102 * FUNCTION: Inserts an entry in a double linked list
104 * ListHead = Head of the list
105 * Entry = Entry to insert
107 #define InsertHeadList(ListHead, ListEntry) \
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)); \
126 * PLIST_ENTRY ListHead,
131 * Inserts an entry in a double linked list
134 * ListHead = Head of the list
135 * Entry = Entry to insert
137 #define InsertTailList(ListHead, ListEntry) \
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)); \
155 * PLIST_ENTRY ListHead
159 * Checks if a double linked list is empty
162 * ListHead = Head of the list
164 #define IsListEmpty(ListHead) \
165 ((ListHead)->Flink == (ListHead))
175 * Removes an entry from a double linked list
178 * ListEntry = Entry to remove
180 #define RemoveEntryList(ListEntry) \
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; \
198 * PURPOSE: Returns the byte offset of a field within a structure
200 #define FIELD_OFFSET(Type,Field) (S32)(&(((Type *)(0))->Field))
203 * PURPOSE: Returns the base address structure if the caller knows the
204 * address of a field within the structure
206 * Address = address of the field
207 * Type = Type of the whole structure
208 * Field = Name of the field whose address is none
210 #define CONTAINING_RECORD(Address,Type,Field) \
211 (Type *)(((S32)Address) - FIELD_OFFSET(Type,Field))
216 #define REG_EXPAND_SZ 2
219 #define REG_DWORD_BIG_ENDIAN 5
220 #define REG_DWORD_LITTLE_ENDIAN 4
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
230 RegInitializeRegistry(VOID
);
233 RegInitCurrentControlSet(BOOL LastKnownGood
);
237 RegCreateKey(HKEY ParentKey
,
242 RegDeleteKey(HKEY Key
,
252 RegOpenKey(HKEY ParentKey
,
258 RegSetValue(HKEY Key
,
265 RegQueryValue(HKEY Key
,
272 RegDeleteValue(HKEY Key
,
276 RegEnumValue(HKEY Key
,
285 RegGetSubKeyCount (HKEY Key
);
288 RegGetValueCount (HKEY Key
);
292 RegImportBinaryHive (PCHAR ChunkBase
,
296 RegExportBinaryHive (PCHAR KeyName
,
301 #endif /* __REGISTRY_H */