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
13 #define HINIT_CREATE 0
14 #define HINIT_MEMORY 1
16 #define HINIT_MEMORY_INPLACE 3
18 #define HINIT_MAPFILE 5
23 #define HIVE_VOLATILE 1
24 #define HIVE_NOLAZYFLUSH 2
25 #define HIVE_HAS_BEEN_REPLACED 4
26 #define HIVE_HAS_BEEN_FREED 8
27 #define HIVE_UNKNOWN 0x10
28 #define HIVE_IS_UNLOADING 0x20
33 #define HFILE_TYPE_PRIMARY 0
34 #define HFILE_TYPE_LOG 1
35 #define HFILE_TYPE_EXTERNAL 2
36 #define HFILE_TYPE_MAX 3
41 #define HBLOCK_SIZE 0x1000
42 #define HSECTOR_SIZE 0x200
43 #define HSECTOR_COUNT 8
45 #define HV_BLOCK_SIZE 4096
46 #define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
47 #define HV_SIGNATURE 0x66676572
48 #define HV_BIN_SIGNATURE 0x6e696268
55 #define HSYS_WHISTLER_BETA1 4
56 #define HSYS_WHISTLER 5
57 #define HSYS_MINOR_SUPPORTED HSYS_WHISTLER
62 #define HBASE_FORMAT_MEMORY 1
72 * A handle to cell index. The highest bit specifies the cell storage and
73 * the other bits specify index into the hive file. The value HCELL_NULL
74 * (-1) is reserved for marking invalid cells.
76 typedef ULONG HCELL_INDEX
, *PHCELL_INDEX
;
81 #define HCELL_NIL MAXULONG
82 #define HCELL_CACHED 1
84 #define HCELL_TYPE_MASK 0x80000000
85 #define HCELL_BLOCK_MASK 0x7ffff000
86 #define HCELL_OFFSET_MASK 0x00000fff
87 #define HCELL_TYPE_SHIFT 31
88 #define HCELL_BLOCK_SHIFT 12
89 #define HCELL_OFFSET_SHIFT 0
91 #define HvGetCellType(Cell) \
92 ((ULONG)((Cell & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
93 #define HvGetCellBlock(Cell) \
94 ((ULONG)((Cell & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
102 #include <pshpack1.h>
107 * On-disk header for registry hive file.
110 typedef struct _HBASE_BLOCK
112 /* Hive identifier "regf" (0x66676572) */
121 /* When this hive file was last modified */
122 LARGE_INTEGER TimeStamp
;
124 /* Registry format major version (1) */
127 /* Registry format minor version (3)
128 Version 3 added fast indexes, version 5 has large value optimizations */
131 /* Registry file type (0 - Primary, 1 - Log) */
134 /* Registry format (1 is the only defined value so far) */
137 /* Offset into file from the byte after the end of the base block.
138 If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
139 HCELL_INDEX RootCell
;
141 /* Size of each hive block ? */
147 /* Name of hive file */
152 /* Checksum of first 0x200 bytes */
155 ULONG Reserved2
[0x37E];
158 } HBASE_BLOCK
, *PHBASE_BLOCK
;
162 /* Bin identifier "hbin" (0x6E696268) */
165 /* Block offset of this bin */
166 HCELL_INDEX FileOffset
;
168 /* Size in bytes, multiple of the block size (4KB) */
173 /* When this bin was last modified */
174 LARGE_INTEGER TimeStamp
;
176 /* ? (In-memory only) */
180 typedef struct _HCELL
182 /* <0 if used, >0 if free */
190 typedef struct _CELL_DATA
* (CMAPI
*PGET_CELL_ROUTINE
)(
194 typedef VOID (CMAPI
*PRELEASE_CELL_ROUTINE
)(
198 typedef PVOID (CMAPI
*PALLOCATE_ROUTINE
)(
203 typedef VOID (CMAPI
*PFREE_ROUTINE
)(
207 typedef BOOLEAN (CMAPI
*PFILE_READ_ROUTINE
)(
208 struct _HHIVE
*RegistryHive
,
212 SIZE_T BufferLength
);
214 typedef BOOLEAN (CMAPI
*PFILE_WRITE_ROUTINE
)(
215 struct _HHIVE
*RegistryHive
,
219 SIZE_T BufferLength
);
221 typedef BOOLEAN (CMAPI
*PFILE_SET_SIZE_ROUTINE
)(
222 struct _HHIVE
*RegistryHive
,
227 typedef BOOLEAN (CMAPI
*PFILE_FLUSH_ROUTINE
)(
228 struct _HHIVE
*RegistryHive
,
230 PLARGE_INTEGER FileOffset
,
234 typedef struct _HMAP_ENTRY
236 ULONG_PTR BlockAddress
;
237 ULONG_PTR BinAddress
;
238 struct _CM_VIEW_OF_FILE
*CmView
;
240 } HMAP_ENTRY
, *PHMAP_ENTRY
;
242 typedef struct _HMAP_TABLE
244 HMAP_ENTRY Table
[512];
245 } HMAP_TABLE
, *PHMAP_TABLE
;
247 typedef struct _HMAP_DIRECTORY
249 PHMAP_TABLE Directory
[2048];
250 } HMAP_DIRECTORY
, *PHMAP_DIRECTORY
;
256 PHMAP_ENTRY BlockList
; // PHMAP_TABLE SmallDir;
258 HCELL_INDEX FreeDisplay
[24]; //FREE_DISPLAY FreeDisplay[24];
263 typedef struct _HHIVE
266 PGET_CELL_ROUTINE GetCellRoutine
;
267 PRELEASE_CELL_ROUTINE ReleaseCellRoutine
;
268 PALLOCATE_ROUTINE Allocate
;
270 PFILE_READ_ROUTINE FileRead
;
271 PFILE_WRITE_ROUTINE FileWrite
;
272 PFILE_SET_SIZE_ROUTINE FileSetSize
;
273 PFILE_FLUSH_ROUTINE FileFlush
;
274 PHBASE_BLOCK BaseBlock
;
275 RTL_BITMAP DirtyVector
;
278 ULONG BaseBlockAlloc
;
284 ULONG HvBinHeadersUse
;
285 ULONG HvFreeCellsUse
;
286 ULONG HvUsedcellsUse
;
287 ULONG CmUsedCellsUse
;
291 ULONG StorageTypeCount
;
293 DUAL Storage
[HTYPE_COUNT
];
296 #define IsFreeCell(Cell)(Cell->Size >= 0)
297 #define IsUsedCell(Cell)(Cell->Size < 0)