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
9 // Debug support switch
11 #define _CMLIB_DEBUG_ 1
18 // Definitions copied from <ntstatus.h>
19 // We only want to include host headers, so we define them manually
20 #define STATUS_SUCCESS ((NTSTATUS)0x00000000)
21 #define STATUS_NOT_IMPLEMENTED ((NTSTATUS)0xC0000002)
22 #define STATUS_NO_MEMORY ((NTSTATUS)0xC0000017)
23 #define STATUS_INSUFFICIENT_RESOURCES ((NTSTATUS)0xC000009A)
24 #define STATUS_REGISTRY_CORRUPT ((NTSTATUS)0xC000014C)
25 #define STATUS_NOT_REGISTRY_FILE ((NTSTATUS)0xC000015C)
26 #define STATUS_REGISTRY_RECOVERED ((NTSTATUS)0x40000009)
28 #define REG_OPTION_VOLATILE 1
29 #define OBJ_CASE_INSENSITIVE 0x00000040L
30 #define USHORT_MAX USHRT_MAX
34 OUT PLARGE_INTEGER CurrentTime
);
38 IN PRTL_BITMAP BitMapHeader
,
39 IN PULONG BitMapBuffer
,
40 IN ULONG SizeOfBitMap
);
44 IN PRTL_BITMAP BitMapHeader
,
45 IN ULONG NumberToFind
,
50 IN PRTL_BITMAP BitMapHeader
,
51 IN ULONG StartingIndex
,
52 IN ULONG NumberToSet
);
56 IN PRTL_BITMAP BitMapHeader
);
58 #define RtlCheckBit(BMH,BP) (((((PLONG)(BMH)->Buffer)[(BP) / 32]) >> ((BP) % 32)) & 0x1)
59 #define UNREFERENCED_PARAMETER(P) {(P)=(P);}
61 #define PKTHREAD PVOID
62 #define PKGUARDED_MUTEX PVOID
63 #define PERESOURCE PVOID
64 #define PFILE_OBJECT PVOID
66 #define PWORK_QUEUE_ITEM PVOID
67 #define EX_PUSH_LOCK PULONG_PTR
69 #define CMLTRACE(x, ...)
72 // Debug/Tracing support
75 #ifdef NEW_DEBUG_SYSTEM_IMPLEMENTED // enable when Debug Filters are implemented
76 #define CMLTRACE DbgPrintEx
78 #define CMLTRACE(x, ...) \
79 if (x & CmlibTraceLevel) DbgPrint(__VA_ARGS__)
82 #define CMLTRACE(x, ...) DPRINT(__VA_ARGS__)
88 /* Prevent inclusion of Windows headers through <wine/unicode.h> */
96 // These define the Debug Masks Supported
98 #define CMLIB_HCELL_DEBUG 0x01
101 #define ROUND_UP(a,b) ((((a)+(b)-1)/(b))*(b))
102 #define ROUND_DOWN(a,b) (((a)/(b))*(b))
106 // PAGE_SIZE definition
109 #if defined(TARGET_i386) || defined(TARGET_amd64) || defined(TARGET_arm)
110 #define PAGE_SIZE 0x1000
112 #error Local PAGE_SIZE definition required when built as host
116 #define TAG_CM 0x68742020
120 #include <wine/unicode.h>
122 #include "hivedata.h"
125 #if defined(_TYPEDEFS_HOST_H) || defined(__FREELDR_H)
127 #define PCM_KEY_SECURITY_CACHE_ENTRY PVOID
128 #define PCM_KEY_CONTROL_BLOCK PVOID
129 #define CMP_SECURITY_HASH_LISTS 64
130 #define PCM_CELL_REMAP_BLOCK PVOID
133 // Use Count Log and Entry
135 typedef struct _CM_USE_COUNT_LOG_ENTRY
139 } CM_USE_COUNT_LOG_ENTRY
, *PCM_USE_COUNT_LOG_ENTRY
;
141 typedef struct _CM_USE_COUNT_LOG
145 CM_USE_COUNT_LOG_ENTRY Log
[32];
146 } CM_USE_COUNT_LOG
, *PCM_USE_COUNT_LOG
;
149 // Configuration Manager Hive Structure
151 typedef struct _CMHIVE
154 HANDLE FileHandles
[3];
155 LIST_ENTRY NotifyList
;
157 EX_PUSH_LOCK HiveLock
;
158 PKTHREAD HiveLockOwner
;
159 PKGUARDED_MUTEX ViewLock
;
160 PKTHREAD ViewLockOwner
;
161 EX_PUSH_LOCK WriterLock
;
162 PKTHREAD WriterLockOwner
;
163 PERESOURCE FlusherLock
;
164 EX_PUSH_LOCK SecurityLock
;
165 PKTHREAD HiveSecurityLockOwner
;
166 LIST_ENTRY LRUViewListHead
;
167 LIST_ENTRY PinViewListHead
;
168 PFILE_OBJECT FileObject
;
169 UNICODE_STRING FileFullPath
;
170 UNICODE_STRING FileUserName
;
175 ULONG SecurityCacheSize
;
176 LONG SecurityHitHint
;
177 PCM_KEY_SECURITY_CACHE_ENTRY SecurityCache
;
178 LIST_ENTRY SecurityHash
[CMP_SECURITY_HASH_LISTS
];
180 PCM_KEY_CONTROL_BLOCK RootKcb
;
182 PWORK_QUEUE_ITEM UnloadWorkItem
;
183 BOOLEAN GrowOnlyMode
;
185 LIST_ENTRY KcbConvertListHead
;
186 LIST_ENTRY KnodeConvertListHead
;
187 PCM_CELL_REMAP_BLOCK CellRemapArray
;
188 CM_USE_COUNT_LOG UseCountLog
;
189 CM_USE_COUNT_LOG LockHiveLog
;
191 LIST_ENTRY TrustClassEntry
;
193 BOOLEAN HiveIsLoading
;
194 PKTHREAD CreatorOwner
;
199 typedef struct _HV_HIVE_CELL_PAIR
203 } HV_HIVE_CELL_PAIR
, *PHV_HIVE_CELL_PAIR
;
205 #define STATIC_CELL_PAIR_COUNT 4
206 typedef struct _HV_TRACK_CELL_REF
210 PHV_HIVE_CELL_PAIR CellArray
;
211 HV_HIVE_CELL_PAIR StaticArray
[STATIC_CELL_PAIR_COUNT
];
213 } HV_TRACK_CELL_REF
, *PHV_TRACK_CELL_REF
;
215 extern ULONG CmlibTraceLevel
;
226 PVOID HiveData OPTIONAL
,
227 PALLOCATE_ROUTINE Allocate
,
229 PFILE_SET_SIZE_ROUTINE FileSetSize
,
230 PFILE_WRITE_ROUTINE FileWrite
,
231 PFILE_READ_ROUTINE FileRead
,
232 PFILE_FLUSH_ROUTINE FileFlush
,
233 ULONG Cluster OPTIONAL
,
234 PUNICODE_STRING FileName
);
238 PHHIVE RegistryHive
);
243 HCELL_INDEX CellOffset
);
245 #define HvReleaseCell(h, c) \
246 if (h->ReleaseCellRoutine) h->ReleaseCellRoutine(h, c)
257 HSTORAGE_TYPE Storage
,
258 IN HCELL_INDEX Vicinity
);
262 IN PHHIVE RegistryHive
,
263 IN HCELL_INDEX CellIndex
269 HCELL_INDEX CellOffset
,
275 HCELL_INDEX CellOffset
);
280 HCELL_INDEX CellOffset
,
281 BOOLEAN HoldingLock
);
292 IN PHHIVE RegistryHive
297 PHHIVE RegistryHive
);
301 PHHIVE RegistryHive
);
310 PHHIVE RegistryHive
);
316 PHV_TRACK_CELL_REF CellRef
,
323 HvReleaseFreeCellRefArray(
324 PHV_TRACK_CELL_REF CellRef
335 HSTORAGE_TYPE Storage
);
338 HvpCreateHiveFreeCellList(
342 HvpHiveHeaderChecksum(
343 PHBASE_BLOCK HiveHeader
);