2 * PROJECT: registry manipulation library
3 * LICENSE: GPL - See COPYING in the top level directory
4 * COPYRIGHT: Copyright 2005 Filip Navara <navaraf@reactos.org>
5 * Copyright 2001 - 2005 Eric Kohl
11 // Debug support switch
13 #define _CMLIB_DEBUG_ 1
16 #include <wine/unicode.h>
17 #include <host/typedefs.h>
21 // Definitions copied from <ntstatus.h>
22 // We only want to include host headers, so we define them manually
23 #define STATUS_SUCCESS ((NTSTATUS)0x00000000)
24 #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002)
25 #define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)
26 #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A)
27 #define STATUS_REGISTRY_CORRUPT ((NTSTATUS)0xC000014C)
28 #define STATUS_NOT_REGISTRY_FILE ((NTSTATUS)0xC000015C)
29 #define STATUS_REGISTRY_RECOVERED ((NTSTATUS)0x40000009)
31 #define REG_OPTION_VOLATILE 1
32 #define OBJ_CASE_INSENSITIVE 0x00000040L
33 #define USHORT_MAX USHRT_MAX
37 OUT PLARGE_INTEGER CurrentTime
);
41 IN PRTL_BITMAP BitMapHeader
,
42 IN PULONG BitMapBuffer
,
43 IN ULONG SizeOfBitMap
);
47 IN PRTL_BITMAP BitMapHeader
,
48 IN ULONG NumberToFind
,
53 IN PRTL_BITMAP BitMapHeader
,
54 IN ULONG StartingIndex
,
55 IN ULONG NumberToSet
);
59 IN PRTL_BITMAP BitMapHeader
);
61 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1)
62 #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
64 #define PKTHREAD PVOID
65 #define PKGUARDED_MUTEX PVOID
66 #define PERESOURCE PVOID
67 #define PFILE_OBJECT PVOID
69 #define PWORK_QUEUE_ITEM PVOID
70 #define EX_PUSH_LOCK PULONG_PTR
72 /* For <host/wcsfuncs.h> */
73 #define USE_HOST_WCSFUNCS
75 #define CMLTRACE(x, ...)
78 // Debug/Tracing support
81 #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
82 #define CMLTRACE DbgPrintEx
84 #define CMLTRACE(x, ...) \
85 if (x & CmlibTraceLevel) DbgPrint(__VA_ARGS__)
88 #define CMLTRACE(x, ...) DPRINT(__VA_ARGS__)
92 #undef DECLSPEC_IMPORT
93 #define DECLSPEC_IMPORT
97 #include <host/wcsfuncs.h>
100 // These define the Debug Masks Supported
102 #define CMLIB_HCELL_DEBUG 0x01
105 #define ROUND_UP(a,b) ((((a)+(b)-1)/(b))*(b))
106 #define ROUND_DOWN(a,b) (((a)/(b))*(b))
110 // PAGE_SIZE definition
113 #if defined(TARGET_i386) || defined(TARGET_amd64) || defined(TARGET_arm)
114 #define PAGE_SIZE 0x1000
116 #error Local PAGE_SIZE definition required when built as host
120 #define TAG_CM 0x68742020
125 #include "hivedata.h"
128 #if defined(_TYPEDEFS_HOST_H) || defined(__FREELDR_H)
130 #define PCM_KEY_SECURITY_CACHE_ENTRY PVOID
131 #define PCM_KEY_CONTROL_BLOCK PVOID
132 #define CMP_SECURITY_HASH_LISTS 64
133 #define PCM_CELL_REMAP_BLOCK PVOID
136 // Use Count Log and Entry
138 typedef struct _CM_USE_COUNT_LOG_ENTRY
142 } CM_USE_COUNT_LOG_ENTRY
, *PCM_USE_COUNT_LOG_ENTRY
;
144 typedef struct _CM_USE_COUNT_LOG
148 CM_USE_COUNT_LOG_ENTRY Log
[32];
149 } CM_USE_COUNT_LOG
, *PCM_USE_COUNT_LOG
;
152 // Configuration Manager Hive Structure
154 typedef struct _CMHIVE
157 HANDLE FileHandles
[3];
158 LIST_ENTRY NotifyList
;
160 EX_PUSH_LOCK HiveLock
;
161 PKTHREAD HiveLockOwner
;
162 PKGUARDED_MUTEX ViewLock
;
163 PKTHREAD ViewLockOwner
;
164 EX_PUSH_LOCK WriterLock
;
165 PKTHREAD WriterLockOwner
;
166 PERESOURCE FlusherLock
;
167 EX_PUSH_LOCK SecurityLock
;
168 PKTHREAD HiveSecurityLockOwner
;
169 LIST_ENTRY LRUViewListHead
;
170 LIST_ENTRY PinViewListHead
;
171 PFILE_OBJECT FileObject
;
172 UNICODE_STRING FileFullPath
;
173 UNICODE_STRING FileUserName
;
178 ULONG SecurityCacheSize
;
179 LONG SecurityHitHint
;
180 PCM_KEY_SECURITY_CACHE_ENTRY SecurityCache
;
181 LIST_ENTRY SecurityHash
[CMP_SECURITY_HASH_LISTS
];
183 PCM_KEY_CONTROL_BLOCK RootKcb
;
185 PWORK_QUEUE_ITEM UnloadWorkItem
;
186 BOOLEAN GrowOnlyMode
;
188 LIST_ENTRY KcbConvertListHead
;
189 LIST_ENTRY KnodeConvertListHead
;
190 PCM_CELL_REMAP_BLOCK CellRemapArray
;
191 CM_USE_COUNT_LOG UseCountLog
;
192 CM_USE_COUNT_LOG LockHiveLog
;
194 LIST_ENTRY TrustClassEntry
;
196 BOOLEAN HiveIsLoading
;
197 PKTHREAD CreatorOwner
;
202 typedef struct _HV_HIVE_CELL_PAIR
206 } HV_HIVE_CELL_PAIR
, *PHV_HIVE_CELL_PAIR
;
208 #define STATIC_CELL_PAIR_COUNT 4
209 typedef struct _HV_TRACK_CELL_REF
213 PHV_HIVE_CELL_PAIR CellArray
;
214 HV_HIVE_CELL_PAIR StaticArray
[STATIC_CELL_PAIR_COUNT
];
216 } HV_TRACK_CELL_REF
, *PHV_TRACK_CELL_REF
;
218 extern ULONG CmlibTraceLevel
;
229 PVOID HiveData OPTIONAL
,
230 PALLOCATE_ROUTINE Allocate
,
232 PFILE_SET_SIZE_ROUTINE FileSetSize
,
233 PFILE_WRITE_ROUTINE FileWrite
,
234 PFILE_READ_ROUTINE FileRead
,
235 PFILE_FLUSH_ROUTINE FileFlush
,
236 ULONG Cluster OPTIONAL
,
237 PUNICODE_STRING FileName
);
241 PHHIVE RegistryHive
);
246 HCELL_INDEX CellOffset
);
248 #define HvReleaseCell(h, c) \
249 if (h->ReleaseCellRoutine) h->ReleaseCellRoutine(h, c)
260 HSTORAGE_TYPE Storage
,
261 IN HCELL_INDEX Vicinity
);
265 IN PHHIVE RegistryHive
,
266 IN HCELL_INDEX CellIndex
272 HCELL_INDEX CellOffset
,
278 HCELL_INDEX CellOffset
);
283 HCELL_INDEX CellOffset
,
284 BOOLEAN HoldingLock
);
295 IN PHHIVE RegistryHive
300 PHHIVE RegistryHive
);
304 PHHIVE RegistryHive
);
313 PHHIVE RegistryHive
);
319 PHV_TRACK_CELL_REF CellRef
,
326 HvReleaseFreeCellRefArray(
327 PHV_TRACK_CELL_REF CellRef
338 HSTORAGE_TYPE Storage
);
341 HvpCreateHiveFreeCellList(
345 HvpHiveHeaderChecksum(
346 PHBASE_BLOCK HiveHeader
);