ReactOS 0.4.15-dev-6679-g945ee4b
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_MAX 3
37
38//
39// Hive sizes
40//
41#define HBLOCK_SIZE 0x1000
42#define HSECTOR_SIZE 0x200
43#define HSECTOR_COUNT 8
44
45#define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
46
47//
48// Hive structure identifiers
49//
50#define HV_HHIVE_SIGNATURE 0xbee0bee0
51#define HV_HBLOCK_SIGNATURE 0x66676572 // "regf"
52#define HV_HBIN_SIGNATURE 0x6e696268 // "hbin"
53
54//
55// Hive versions
56//
57#define HSYS_MAJOR 1
58#define HSYS_MINOR 3
59#define HSYS_WHISTLER_BETA1 4
60#define HSYS_WHISTLER 5
61#define HSYS_MINOR_SUPPORTED HSYS_WHISTLER
62
63//
64// Hive formats
65//
66#define HBASE_FORMAT_MEMORY 1
67
68//
69// Hive storage
70//
71#define HTYPE_COUNT 2
72
81
82//
83// Cell Magic Values
84//
85#define HCELL_NIL MAXULONG
86#define HCELL_CACHED 1
87
88#define HCELL_TYPE_MASK 0x80000000
89#define HCELL_BLOCK_MASK 0x7ffff000
90#define HCELL_OFFSET_MASK 0x00000fff
91#define HCELL_TYPE_SHIFT 31
92#define HCELL_BLOCK_SHIFT 12
93#define HCELL_OFFSET_SHIFT 0
94
95#define HvGetCellType(Cell) \
96 ((ULONG)(((Cell) & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT))
97#define HvGetCellBlock(Cell) \
98 ((ULONG)(((Cell) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT))
99
100typedef enum
101{
103 Volatile = 1
105
106#include <pshpack1.h>
107
114#define HIVE_FILENAME_MAXLEN 31
115
116typedef struct _HBASE_BLOCK
117{
118 /* Hive base block identifier "regf" (0x66676572) */
120
121 /* Update counters */
124
125 /* When this hive file was last modified */
127
128 /* Registry format major version (1) */
130
131 /* Registry format minor version (3)
132 Version 3 added fast indexes, version 5 has large value optimizations */
134
135 /* Registry file type (0 - Primary, 1 - Log) */
137
138 /* Registry format (1 is the only defined value so far) */
140
141 /* Offset into file from the byte after the end of the base block.
142 If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
144
145 /* Size in bytes of the full hive, minus the header, multiple of the block size (4KB) */
147
148 /* (1?) */
150
151 /* Last 31 UNICODE characters, plus terminating NULL character,
152 of the full name of the hive file */
154
156
157 /* Checksum of first 0x200 bytes */
159
164
166
167typedef struct _HBIN
168{
169 /* Hive bin identifier "hbin" (0x6E696268) */
171
172 /* Block offset of this bin */
174
175 /* Size in bytes of this bin, multiple of the block size (4KB) */
177
179
180 /* When this bin was last modified */
182
183 /* Unused (In-memory only) */
186
187typedef struct _HCELL
188{
189 /* <0 if used, >0 if free */
192
193#include <poppack.h>
194
195struct _HHIVE;
196
197typedef struct _CELL_DATA*
199 struct _HHIVE *Hive,
200 HCELL_INDEX Cell
201);
202
203typedef VOID
205 struct _HHIVE *Hive,
206 HCELL_INDEX Cell
207);
208
209typedef PVOID
211 SIZE_T Size,
212 BOOLEAN Paged,
213 ULONG Tag
214);
215
216typedef VOID
218 PVOID Ptr,
219 ULONG Quota
220);
221
222typedef BOOLEAN
224 struct _HHIVE *RegistryHive,
229);
230
231typedef BOOLEAN
233 struct _HHIVE *RegistryHive,
238);
239
240typedef BOOLEAN
242 struct _HHIVE *RegistryHive,
245 ULONG OldfileSize
246);
247
248typedef BOOLEAN
250 struct _HHIVE *RegistryHive,
254);
255
256typedef struct _HMAP_ENTRY
257{
263
264typedef struct _HMAP_TABLE
265{
268
269typedef struct _HMAP_DIRECTORY
270{
273
274typedef struct _DUAL
275{
278 PHMAP_ENTRY BlockList; // PHMAP_TABLE SmallDir;
280 HCELL_INDEX FreeDisplay[24]; // FREE_DISPLAY FreeDisplay[24];
284
285typedef struct _HHIVE
286{
287 /* Hive identifier (0xBEE0BEE0) */
289
290 /* Callbacks */
299
300#if (NTDDI_VERSION >= NTDDI_WIN7)
301 PVOID HiveLoadFailure; // PHIVE_LOAD_FAILURE
302#endif
311#if (NTDDI_VERSION < NTDDI_VISTA) // NTDDI_LONGHORN
312 BOOLEAN Log;
313#endif
315#if (NTDDI_VERSION >= NTDDI_VISTA) // NTDDI_LONGHORN
320#endif
322#if (NTDDI_VERSION < NTDDI_VISTA) // NTDDI_LONGHORN
324#else
327#endif
333
334#define IsFreeCell(Cell) ((Cell)->Size >= 0)
335#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:223
VOID(CMAPI * PRELEASE_CELL_ROUTINE)(struct _HHIVE *Hive, HCELL_INDEX Cell)
Definition: hivedata.h:204
struct _HMAP_DIRECTORY * PHMAP_DIRECTORY
ULONG * PHCELL_INDEX
Definition: hivedata.h:80
HSTORAGE_TYPE
Definition: hivedata.h:101
@ Volatile
Definition: hivedata.h:103
@ Stable
Definition: hivedata.h:102
#define HTYPE_COUNT
Definition: hivedata.h:71
#define HBLOCK_SIZE
Definition: hivedata.h:41
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:232
VOID(CMAPI * PFREE_ROUTINE)(PVOID Ptr, ULONG Quota)
Definition: hivedata.h:217
struct _CELL_DATA *CMAPI * PGET_CELL_ROUTINE(struct _HHIVE *Hive, HCELL_INDEX Cell)
Definition: hivedata.h:198
struct _DUAL DUAL
struct _HBASE_BLOCK HBASE_BLOCK
struct _HMAP_TABLE HMAP_TABLE
struct _HBIN * PHBIN
#define HIVE_FILENAME_MAXLEN
Definition: hivedata.h:114
struct _HBIN HBIN
BOOLEAN(CMAPI * PFILE_FLUSH_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PLARGE_INTEGER FileOffset, ULONG Length)
Definition: hivedata.h:249
struct _HMAP_ENTRY * PHMAP_ENTRY
struct _HMAP_TABLE * PHMAP_TABLE
PVOID(CMAPI * PALLOCATE_ROUTINE)(SIZE_T Size, BOOLEAN Paged, ULONG Tag)
Definition: hivedata.h:210
struct _DUAL * PDUAL
ULONG HCELL_INDEX
Definition: hivedata.h:80
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:241
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:281
HCELL_INDEX FreeDisplay[24]
Definition: hivedata.h:280
ULONG Length
Definition: hivedata.h:276
PHMAP_DIRECTORY Map
Definition: hivedata.h:277
LIST_ENTRY FreeBins
Definition: hivedata.h:282
ULONG Guard
Definition: hivedata.h:279
PHMAP_ENTRY BlockList
Definition: hivedata.h:278
ULONG BootType
Definition: hivedata.h:161
ULONG Length
Definition: hivedata.h:146
HCELL_INDEX RootCell
Definition: hivedata.h:143
ULONG Reserved1[99]
Definition: hivedata.h:155
ULONG Reserved2[0x37E]
Definition: hivedata.h:160
ULONG Sequence1
Definition: hivedata.h:122
ULONG Minor
Definition: hivedata.h:133
ULONG Type
Definition: hivedata.h:136
ULONG Major
Definition: hivedata.h:129
LARGE_INTEGER TimeStamp
Definition: hivedata.h:126
ULONG BootRecover
Definition: hivedata.h:162
ULONG Signature
Definition: hivedata.h:119
ULONG Format
Definition: hivedata.h:139
ULONG CheckSum
Definition: hivedata.h:158
ULONG Sequence2
Definition: hivedata.h:123
ULONG Cluster
Definition: hivedata.h:149
ULONG Spare
Definition: hivedata.h:184
HCELL_INDEX FileOffset
Definition: hivedata.h:173
LARGE_INTEGER TimeStamp
Definition: hivedata.h:181
ULONG Reserved1[2]
Definition: hivedata.h:178
ULONG Signature
Definition: hivedata.h:170
ULONG Size
Definition: hivedata.h:176
LONG Size
Definition: hivedata.h:190
ULONG CurrentLog
Definition: hivedata.h:325
RTL_BITMAP DirtyVector
Definition: hivedata.h:304
PFILE_FLUSH_ROUTINE FileFlush
Definition: hivedata.h:298
PFILE_SET_SIZE_ROUTINE FileSetSize
Definition: hivedata.h:295
ULONG Signature
Definition: hivedata.h:288
ULONG HvUsedCellsUse
Definition: hivedata.h:318
ULONG HiveFlags
Definition: hivedata.h:321
PFILE_WRITE_ROUTINE FileWrite
Definition: hivedata.h:296
PALLOCATE_ROUTINE Allocate
Definition: hivedata.h:293
ULONG HvBinHeadersUse
Definition: hivedata.h:316
PVOID HiveLoadFailure
Definition: hivedata.h:301
PFILE_READ_ROUTINE FileRead
Definition: hivedata.h:297
BOOLEAN DirtyFlag
Definition: hivedata.h:314
ULONG Cluster
Definition: hivedata.h:308
ULONG DirtyAlloc
Definition: hivedata.h:306
ULONG BaseBlockAlloc
Definition: hivedata.h:307
ULONG RefreshCount
Definition: hivedata.h:328
ULONG LogSize[2]
Definition: hivedata.h:326
BOOLEAN Flat
Definition: hivedata.h:309
PGET_CELL_ROUTINE GetCellRoutine
Definition: hivedata.h:291
PFREE_ROUTINE Free
Definition: hivedata.h:294
DUAL Storage[HTYPE_COUNT]
Definition: hivedata.h:331
ULONG CmUsedCellsUse
Definition: hivedata.h:319
ULONG DirtyCount
Definition: hivedata.h:305
ULONG Version
Definition: hivedata.h:330
PRELEASE_CELL_ROUTINE ReleaseCellRoutine
Definition: hivedata.h:292
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
ULONG StorageTypeCount
Definition: hivedata.h:329
BOOLEAN ReadOnly
Definition: hivedata.h:310
ULONG HvFreeCellsUse
Definition: hivedata.h:317
Definition: hivedata.h:257
struct _CM_VIEW_OF_FILE * CmView
Definition: hivedata.h:260
ULONG_PTR BlockAddress
Definition: hivedata.h:258
ULONG MemAlloc
Definition: hivedata.h:261
ULONG_PTR BinAddress
Definition: hivedata.h:259
HMAP_ENTRY Table[512]
Definition: hivedata.h:266
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