ReactOS  0.4.14-dev-614-gbfd8a84
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 
100 typedef enum
101 {
102  Stable = 0,
104 } HSTORAGE_TYPE;
105 
106 #include <pshpack1.h>
107 
114 #define HIVE_FILENAME_MAXLEN 31
115 
116 typedef 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 
160  ULONG Reserved2[0x37E];
164 
165 C_ASSERT(sizeof(HBASE_BLOCK) == HBLOCK_SIZE);
166 
167 typedef 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) */
185 } HBIN, *PHBIN;
186 
187 typedef struct _HCELL
188 {
189  /* <0 if used, >0 if free */
191 } HCELL, *PHCELL;
192 
193 #include <poppack.h>
194 
195 struct _HHIVE;
196 
197 typedef struct _CELL_DATA*
199  struct _HHIVE *Hive,
200  HCELL_INDEX Cell
201 );
202 
203 typedef VOID
205  struct _HHIVE *Hive,
206  HCELL_INDEX Cell
207 );
208 
209 typedef PVOID
211  SIZE_T Size,
212  BOOLEAN Paged,
213  ULONG Tag
214 );
215 
216 typedef VOID
218  PVOID Ptr,
219  ULONG Quota
220 );
221 
222 typedef BOOLEAN
224  struct _HHIVE *RegistryHive,
225  ULONG FileType,
227  PVOID Buffer,
229 );
230 
231 typedef BOOLEAN
233  struct _HHIVE *RegistryHive,
234  ULONG FileType,
236  PVOID Buffer,
238 );
239 
240 typedef BOOLEAN
242  struct _HHIVE *RegistryHive,
243  ULONG FileType,
244  ULONG FileSize,
245  ULONG OldfileSize
246 );
247 
248 typedef BOOLEAN
250  struct _HHIVE *RegistryHive,
251  ULONG FileType,
253  ULONG Length
254 );
255 
256 typedef struct _HMAP_ENTRY
257 {
263 
264 typedef struct _HMAP_TABLE
265 {
268 
269 typedef struct _HMAP_DIRECTORY
270 {
273 
274 typedef struct _DUAL
275 {
278  PHMAP_ENTRY BlockList; // PHMAP_TABLE SmallDir;
280  HCELL_INDEX FreeDisplay[24]; // FREE_DISPLAY FreeDisplay[24];
283 } DUAL, *PDUAL;
284 
285 typedef 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
323  ULONG LogSize;
324 #else
327 #endif
332 } HHIVE, *PHHIVE;
333 
334 #define IsFreeCell(Cell) ((Cell)->Size >= 0)
335 #define IsUsedCell(Cell) ((Cell)->Size < 0)
ULONG Size
Definition: hivedata.h:176
struct _HMAP_DIRECTORY HMAP_DIRECTORY
ULONG Sequence2
Definition: hivedata.h:123
ULONG Cluster
Definition: hivedata.h:149
#define HBLOCK_SIZE
Definition: hivedata.h:41
BOOLEAN(CMAPI * PFILE_SET_SIZE_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, ULONG FileSize, ULONG OldfileSize)
Definition: hivedata.h:241
RTL_BITMAP DirtyVector
Definition: hivedata.h:304
ULONG BootType
Definition: hivedata.h:161
Definition: hivedata.h:256
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
ULONG Signature
Definition: hivedata.h:119
BOOLEAN ReadOnly
Definition: hivedata.h:310
ULONG_PTR BlockAddress
Definition: hivedata.h:258
#define HTYPE_COUNT
Definition: hivedata.h:71
struct _HMAP_ENTRY HMAP_ENTRY
struct _HBIN HBIN
PFREE_ROUTINE Free
Definition: hivedata.h:294
struct _HBIN * PHBIN
PGET_CELL_ROUTINE GetCellRoutine
Definition: hivedata.h:291
PALLOCATE_ROUTINE Allocate
Definition: hivedata.h:293
ULONG Signature
Definition: hivedata.h:170
struct _DUAL * PDUAL
ULONG Length
Definition: hivedata.h:146
ULONG DirtyCount
Definition: hivedata.h:305
LARGE_INTEGER TimeStamp
Definition: hivedata.h:126
struct _HHIVE HHIVE
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONG Spare
Definition: hivedata.h:184
ULONG MemAlloc
Definition: hivedata.h:261
struct _CELL_DATA *CMAPI * PGET_CELL_ROUTINE(struct _HHIVE *Hive, HCELL_INDEX Cell)
Definition: hivedata.h:198
struct _HBASE_BLOCK * PHBASE_BLOCK
BOOLEAN(CMAPI * PFILE_READ_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PULONG FileOffset, PVOID Buffer, SIZE_T BufferLength)
Definition: hivedata.h:223
#define CMAPI
Definition: cfgmgr32.h:41
ULONG StorageTypeCount
Definition: hivedata.h:329
ULONG Sequence1
Definition: hivedata.h:122
ULONG Reserved2[0x37E]
Definition: hivedata.h:160
BOOLEAN(CMAPI * PFILE_FLUSH_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PLARGE_INTEGER FileOffset, ULONG Length)
Definition: hivedata.h:249
long LONG
Definition: pedump.c:60
_In_ ULONG BufferLength
Definition: usbdlib.h:225
ULONG Major
Definition: hivedata.h:129
ULONG RefreshCount
Definition: hivedata.h:328
ULONG CheckSum
Definition: hivedata.h:158
ULONG Reserved1[99]
Definition: hivedata.h:155
BOOLEAN DirtyFlag
Definition: hivedata.h:314
PHMAP_DIRECTORY Map
Definition: hivedata.h:277
unsigned char BOOLEAN
ULONG * PHCELL_INDEX
Definition: hivedata.h:80
ULONG FreeSummary
Definition: hivedata.h:281
DUAL Storage[HTYPE_COUNT]
Definition: hivedata.h:331
void * PVOID
Definition: retypes.h:9
ULONG BootRecover
Definition: hivedata.h:162
struct _HMAP_TABLE HMAP_TABLE
LARGE_INTEGER TimeStamp
Definition: hivedata.h:181
PFILE_SET_SIZE_ROUTINE FileSetSize
Definition: hivedata.h:295
ULONG Signature
Definition: hivedata.h:288
ULONG Version
Definition: hivedata.h:330
struct _HCELL HCELL
__wchar_t WCHAR
Definition: xmlstorage.h:180
ULONG HCELL_INDEX
Definition: hivedata.h:80
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 _DUAL DUAL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:101
ULONG Cluster
Definition: hivedata.h:308
ULONG DirtyAlloc
Definition: hivedata.h:306
VOID(CMAPI * PRELEASE_CELL_ROUTINE)(struct _HHIVE *Hive, HCELL_INDEX Cell)
Definition: hivedata.h:204
struct _HMAP_TABLE * PHMAP_TABLE
#define HIVE_FILENAME_MAXLEN
Definition: hivedata.h:114
ULONG LogSize[2]
Definition: hivedata.h:326
PFILE_WRITE_ROUTINE FileWrite
Definition: hivedata.h:296
HCELL_INDEX FreeDisplay[24]
Definition: hivedata.h:280
#define VOID
Definition: acefi.h:82
LIST_ENTRY FreeBins
Definition: hivedata.h:282
PVOID HiveLoadFailure
Definition: hivedata.h:301
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
ULONG Guard
Definition: hivedata.h:279
Definition: typedefs.h:117
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
HCELL_INDEX RootCell
Definition: hivedata.h:143
C_ASSERT(sizeof(HBASE_BLOCK)==HBLOCK_SIZE)
struct _HHIVE * PHHIVE
ULONG HvFreeCellsUse
Definition: hivedata.h:317
ULONG_PTR SIZE_T
Definition: typedefs.h:78
HCELL_INDEX FileOffset
Definition: hivedata.h:173
PHMAP_ENTRY BlockList
Definition: hivedata.h:278
LONG Size
Definition: hivedata.h:190
ULONG CurrentLog
Definition: hivedata.h:325
ULONG HiveFlags
Definition: hivedata.h:321
ULONG HvUsedCellsUse
Definition: hivedata.h:318
ULONG CmUsedCellsUse
Definition: hivedata.h:319
_In_ PFCB _In_ LONGLONG FileOffset
Definition: cdprocs.h:151
HSTORAGE_TYPE
Definition: hivedata.h:100
ULONG_PTR BinAddress
Definition: hivedata.h:259
PFILE_FLUSH_ROUTINE FileFlush
Definition: hivedata.h:298
ULONG BaseBlockAlloc
Definition: hivedata.h:307
unsigned int * PULONG
Definition: retypes.h:1
struct _HMAP_ENTRY * PHMAP_ENTRY
ULONG Length
Definition: hivedata.h:276
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
PVOID(CMAPI * PALLOCATE_ROUTINE)(SIZE_T Size, BOOLEAN Paged, ULONG Tag)
Definition: hivedata.h:210
#define BOOLEAN
Definition: pedump.c:73
struct _HMAP_DIRECTORY * PHMAP_DIRECTORY
unsigned int ULONG
Definition: retypes.h:1
base for all directory entries
Definition: entries.h:138
struct _HBASE_BLOCK HBASE_BLOCK
ULONG Minor
Definition: hivedata.h:133
ULONG Reserved1[2]
Definition: hivedata.h:178
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
BOOLEAN Flat
Definition: hivedata.h:309
struct _HCELL * PHCELL
PRELEASE_CELL_ROUTINE ReleaseCellRoutine
Definition: hivedata.h:292
ULONG Type
Definition: hivedata.h:136
ULONG HvBinHeadersUse
Definition: hivedata.h:316
HMAP_ENTRY Table[512]
Definition: hivedata.h:266
struct _CM_VIEW_OF_FILE * CmView
Definition: hivedata.h:260
PFILE_READ_ROUTINE FileRead
Definition: hivedata.h:297
ULONG Format
Definition: hivedata.h:139