ReactOS 0.4.15-dev-8348-gc1b9bb5
hivedata.h
Go to the documentation of this file.
1/*
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
6 */
7
8#pragma once
9
10//
11// Hive operations
12//
13#define HINIT_CREATE 0
14#define HINIT_MEMORY 1
15#define HINIT_FILE 2
16#define HINIT_MEMORY_INPLACE 3
17#define HINIT_FLAT 4
18#define HINIT_MAPFILE 5
19
20//
21// Hive flags
22//
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
29
30//
31// Hive types
32//
33#define HFILE_TYPE_PRIMARY 0
34#define HFILE_TYPE_LOG 1
35#define HFILE_TYPE_EXTERNAL 2
36#define HFILE_TYPE_ALTERNATE 3 // Technically a HFILE_TYPE_PRIMARY but for mirror backup hives. ONLY USED for the SYSTEM hive!
37#define HFILE_TYPE_MAX 4
38
39//
40// Hive sizes
41//
42#define HBLOCK_SIZE 0x1000
43#define HSECTOR_SIZE 0x200
44#define HSECTOR_COUNT 8
45
46#define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
47
48//
49// Clean Block identifier
50//
51#define HV_CLEAN_BLOCK 0U
52
53//
54// Hive Log identifiers
55//
56#define HV_LOG_DIRTY_BLOCK 0xFF
57#define HV_LOG_DIRTY_SIGNATURE 0x54524944 // "DIRT"
58
59//
60// Hive structure identifiers
61//
62#define HV_HHIVE_SIGNATURE 0xbee0bee0
63#define HV_HBLOCK_SIGNATURE 0x66676572 // "regf"
64#define HV_HBIN_SIGNATURE 0x6e696268 // "hbin"
65
66//
67// Hive versions
68//
69#define HSYS_MAJOR 1
70#define HSYS_MINOR 3
71#define HSYS_WHISTLER_BETA1 4
72#define HSYS_WHISTLER 5
73#define HSYS_MINOR_SUPPORTED HSYS_WHISTLER
74
75//
76// Hive formats
77//
78#define HBASE_FORMAT_MEMORY 1
79
80//
81// Hive storage
82//
83#define HTYPE_COUNT 2
84
85//
86// Hive boot types
87//
88#define HBOOT_TYPE_REGULAR 0
89#define HBOOT_TYPE_SELF_HEAL 4
90
91//
92// Hive boot recover types
93//
94#define HBOOT_NO_BOOT_RECOVER 0
95#define HBOOT_BOOT_RECOVERED_BY_HIVE_LOG 1
96#define HBOOT_BOOT_RECOVERED_BY_ALTERNATE_HIVE 2
97
106
107//
108// Cell Magic Values
109//
110#define HCELL_NIL MAXULONG
111#define HCELL_CACHED 1
112
113#define HCELL_TYPE_MASK 0x80000000
114#define HCELL_BLOCK_MASK 0x7ffff000
115#define HCELL_OFFSET_MASK 0x00000fff
116#define HCELL_TYPE_SHIFT 31
117#define HCELL_BLOCK_SHIFT 12
118#define HCELL_OFFSET_SHIFT 0
119
120#define HvGetCellType(Cell) \
121 ((ULONG)(((Cell) & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
122#define HvGetCellBlock(Cell) \
123 ((ULONG)(((Cell) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
124
125typedef enum
126{
128 Volatile = 1
130
131#include <pshpack1.h>
132
139#define HIVE_FILENAME_MAXLEN 31
140
141typedef struct _HBASE_BLOCK
142{
143 /* Hive base block identifier "regf" (0x66676572) */
145
146 /* Update counters */
149
150 /* When this hive file was last modified */
152
153 /* Registry format major version (1) */
155
156 /* Registry format minor version (3)
157 Version 3 added fast indexes, version 5 has large value optimizations */
159
160 /* Registry file type (0 - Primary, 1 - Log) */
162
163 /* Registry format (1 is the only defined value so far) */
165
166 /* Offset into file from the byte after the end of the base block.
167 If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
169
170 /* Size in bytes of the full hive, minus the header, multiple of the block size (4KB) */
172
173 /* (1?) */
175
176 /* Last 31 UNICODE characters, plus terminating NULL character,
177 of the full name of the hive file */
179
181
182 /* Checksum of first 0x200 bytes */
184
189
191
192typedef struct _HBIN
193{
194 /* Hive bin identifier "hbin" (0x6E696268) */
196
197 /* Block offset of this bin */
199
200 /* Size in bytes of this bin, multiple of the block size (4KB) */
202
204
205 /* When this bin was last modified */
207
208 /* Unused (In-memory only) */
211
212typedef struct _HCELL
213{
214 /* <0 if used, >0 if free */
217
218#include <poppack.h>
219
220struct _HHIVE;
221
222typedef struct _CELL_DATA*
224 struct _HHIVE *Hive,
225 HCELL_INDEX Cell
226);
227
228typedef VOID
230 struct _HHIVE *Hive,
231 HCELL_INDEX Cell
232);
233
234typedef PVOID
236 SIZE_T Size,
237 BOOLEAN Paged,
238 ULONG Tag
239);
240
241typedef VOID
243 PVOID Ptr,
244 ULONG Quota
245);
246
247typedef BOOLEAN
249 struct _HHIVE *RegistryHive,
254);
255
256typedef BOOLEAN
258 struct _HHIVE *RegistryHive,
263);
264
265typedef BOOLEAN
267 struct _HHIVE *RegistryHive,
270 ULONG OldfileSize
271);
272
273typedef BOOLEAN
275 struct _HHIVE *RegistryHive,
279);
280
281typedef struct _HMAP_ENTRY
282{
288
289typedef struct _HMAP_TABLE
290{
293
294typedef struct _HMAP_DIRECTORY
295{
298
299typedef struct _DUAL
300{
303 PHMAP_ENTRY BlockList; // PHMAP_TABLE SmallDir;
305 HCELL_INDEX FreeDisplay[24]; // FREE_DISPLAY FreeDisplay[24];
309
310typedef struct _HHIVE
311{
312 /* Hive identifier (0xBEE0BEE0) */
314
315 /* Callbacks */
324
325#if (NTDDI_VERSION >= NTDDI_WIN7)
326 PVOID HiveLoadFailure; // PHIVE_LOAD_FAILURE
327#endif
336#if (NTDDI_VERSION < NTDDI_VISTA) // NTDDI_LONGHORN
337 BOOLEAN Log;
338 BOOLEAN Alternate;
339#endif
341#if (NTDDI_VERSION >= NTDDI_VISTA) // NTDDI_LONGHORN
346#endif
348#if (NTDDI_VERSION < NTDDI_VISTA) // NTDDI_LONGHORN
350#else
353#endif
359
360#define IsFreeCell(Cell) ((Cell)->Size >= 0)
361#define IsUsedCell(Cell) ((Cell)->Size < 0)
unsigned char BOOLEAN
#define VOID
Definition: acefi.h:82
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:160
#define CMAPI
Definition: cfgmgr32.h:41
Definition: bufpool.h:45
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
BOOLEAN(CMAPI * PFILE_READ_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PULONG FileOffset, PVOID Buffer, SIZE_T BufferLength)
Definition: hivedata.h:248
VOID(CMAPI * PRELEASE_CELL_ROUTINE)(struct _HHIVE *Hive, HCELL_INDEX Cell)
Definition: hivedata.h:229
struct _HMAP_DIRECTORY * PHMAP_DIRECTORY
ULONG * PHCELL_INDEX
Definition: hivedata.h:105
HSTORAGE_TYPE
Definition: hivedata.h:126
@ Volatile
Definition: hivedata.h:128
@ Stable
Definition: hivedata.h:127
#define HTYPE_COUNT
Definition: hivedata.h:83
#define HBLOCK_SIZE
Definition: hivedata.h:42
struct _HCELL * PHCELL
struct _HCELL HCELL
BOOLEAN(CMAPI * PFILE_WRITE_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PULONG FileOffset, PVOID Buffer, SIZE_T BufferLength)
Definition: hivedata.h:257
VOID(CMAPI * PFREE_ROUTINE)(PVOID Ptr, ULONG Quota)
Definition: hivedata.h:242
struct _CELL_DATA *CMAPI * PGET_CELL_ROUTINE(struct _HHIVE *Hive, HCELL_INDEX Cell)
Definition: hivedata.h:223
struct _DUAL DUAL
struct _HBASE_BLOCK HBASE_BLOCK
struct _HMAP_TABLE HMAP_TABLE
struct _HBIN * PHBIN
#define HIVE_FILENAME_MAXLEN
Definition: hivedata.h:139
struct _HBIN HBIN
BOOLEAN(CMAPI * PFILE_FLUSH_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PLARGE_INTEGER FileOffset, ULONG Length)
Definition: hivedata.h:274
struct _HMAP_ENTRY * PHMAP_ENTRY
struct _HMAP_TABLE * PHMAP_TABLE
PVOID(CMAPI * PALLOCATE_ROUTINE)(SIZE_T Size, BOOLEAN Paged, ULONG Tag)
Definition: hivedata.h:235
struct _DUAL * PDUAL
ULONG HCELL_INDEX
Definition: hivedata.h:105
struct _HHIVE HHIVE
struct _HMAP_ENTRY HMAP_ENTRY
struct _HMAP_DIRECTORY HMAP_DIRECTORY
BOOLEAN(CMAPI * PFILE_SET_SIZE_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, ULONG FileSize, ULONG OldfileSize)
Definition: hivedata.h:266
struct _HBASE_BLOCK * PHBASE_BLOCK
struct _HHIVE * PHHIVE
#define C_ASSERT(e)
Definition: intsafe.h:73
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define BOOLEAN
Definition: pedump.c:73
long LONG
Definition: pedump.c:60
base for all directory entries
Definition: entries.h:138
ULONG FreeSummary
Definition: hivedata.h:306
HCELL_INDEX FreeDisplay[24]
Definition: hivedata.h:305
ULONG Length
Definition: hivedata.h:301
PHMAP_DIRECTORY Map
Definition: hivedata.h:302
LIST_ENTRY FreeBins
Definition: hivedata.h:307
ULONG Guard
Definition: hivedata.h:304
PHMAP_ENTRY BlockList
Definition: hivedata.h:303
ULONG BootType
Definition: hivedata.h:186
ULONG Length
Definition: hivedata.h:171
HCELL_INDEX RootCell
Definition: hivedata.h:168
ULONG Reserved1[99]
Definition: hivedata.h:180
ULONG Reserved2[0x37E]
Definition: hivedata.h:185
ULONG Sequence1
Definition: hivedata.h:147
ULONG Minor
Definition: hivedata.h:158
ULONG Type
Definition: hivedata.h:161
ULONG Major
Definition: hivedata.h:154
LARGE_INTEGER TimeStamp
Definition: hivedata.h:151
ULONG BootRecover
Definition: hivedata.h:187
ULONG Signature
Definition: hivedata.h:144
ULONG Format
Definition: hivedata.h:164
ULONG CheckSum
Definition: hivedata.h:183
ULONG Sequence2
Definition: hivedata.h:148
ULONG Cluster
Definition: hivedata.h:174
ULONG Spare
Definition: hivedata.h:209
HCELL_INDEX FileOffset
Definition: hivedata.h:198
LARGE_INTEGER TimeStamp
Definition: hivedata.h:206
ULONG Reserved1[2]
Definition: hivedata.h:203
ULONG Signature
Definition: hivedata.h:195
ULONG Size
Definition: hivedata.h:201
LONG Size
Definition: hivedata.h:215
ULONG CurrentLog
Definition: hivedata.h:351
RTL_BITMAP DirtyVector
Definition: hivedata.h:329
PFILE_FLUSH_ROUTINE FileFlush
Definition: hivedata.h:323
PFILE_SET_SIZE_ROUTINE FileSetSize
Definition: hivedata.h:320
ULONG Signature
Definition: hivedata.h:313
ULONG HvUsedCellsUse
Definition: hivedata.h:344
ULONG HiveFlags
Definition: hivedata.h:347
PFILE_WRITE_ROUTINE FileWrite
Definition: hivedata.h:321
PALLOCATE_ROUTINE Allocate
Definition: hivedata.h:318
ULONG HvBinHeadersUse
Definition: hivedata.h:342
PVOID HiveLoadFailure
Definition: hivedata.h:326
PFILE_READ_ROUTINE FileRead
Definition: hivedata.h:322
BOOLEAN DirtyFlag
Definition: hivedata.h:340
ULONG Cluster
Definition: hivedata.h:333
ULONG DirtyAlloc
Definition: hivedata.h:331
ULONG BaseBlockAlloc
Definition: hivedata.h:332
ULONG RefreshCount
Definition: hivedata.h:354
ULONG LogSize[2]
Definition: hivedata.h:352
BOOLEAN Flat
Definition: hivedata.h:334
PGET_CELL_ROUTINE GetCellRoutine
Definition: hivedata.h:316
PFREE_ROUTINE Free
Definition: hivedata.h:319
DUAL Storage[HTYPE_COUNT]
Definition: hivedata.h:357
ULONG CmUsedCellsUse
Definition: hivedata.h:345
ULONG DirtyCount
Definition: hivedata.h:330
ULONG Version
Definition: hivedata.h:356
PRELEASE_CELL_ROUTINE ReleaseCellRoutine
Definition: hivedata.h:317
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:328
ULONG StorageTypeCount
Definition: hivedata.h:355
BOOLEAN ReadOnly
Definition: hivedata.h:335
ULONG HvFreeCellsUse
Definition: hivedata.h:343
Definition: hivedata.h:282
struct _CM_VIEW_OF_FILE * CmView
Definition: hivedata.h:285
ULONG_PTR BlockAddress
Definition: hivedata.h:283
ULONG MemAlloc
Definition: hivedata.h:286
ULONG_PTR BinAddress
Definition: hivedata.h:284
HMAP_ENTRY Table[512]
Definition: hivedata.h:291
Definition: typedefs.h:120
uint32_t * PULONG
Definition: typedefs.h:59
void * PVOID
Definition: typedefs.h:50
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
Definition: wdfdevice.h:2741
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFDEVICE _In_ DEVICE_REGISTRY_PROPERTY _In_ ULONG BufferLength
Definition: wdfdevice.h:3771
__wchar_t WCHAR
Definition: xmlstorage.h:180