- CELL_HEADER -> HCELL.
[reactos.git] / reactos / lib / cmlib / hivedata.h
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 #ifndef CMLIB_HIVEDATA_H
9 #define CMLIB_HIVEDATA_H
10
11 #define HV_BLOCK_SIZE 4096
12 #define HV_LOG_HEADER_SIZE FIELD_OFFSET(HBASE_BLOCK, Reserved2)
13 #define HV_SIGNATURE 0x66676572
14 #define HV_BIN_SIGNATURE 0x6e696268
15
16 #define HV_MAJOR_VER 1
17 #define HV_MINOR_VER 3
18 #define HV_FORMAT_MEMORY 1
19
20 #define HV_TYPE_PRIMARY 0
21 #define HV_TYPE_ALTERNATE 1
22 #define HV_TYPE_LOG 2
23 #define HV_TYPE_EXTERNAL 3
24 #define HV_TYPE_MAX 4
25
26 /**
27 * @name HCELL_INDEX
28 *
29 * A handle to cell index. The highest bit specifies the cell storage and
30 * the other bits specify index into the hive file. The value HCELL_NULL
31 * (-1) is reserved for marking invalid cells.
32 */
33
34 typedef ULONG HCELL_INDEX, *PHCELL_INDEX;
35
36 #define HCELL_NULL ((HCELL_INDEX)-1)
37 #define HCELL_TYPE_MASK 0x80000000
38 #define HCELL_BLOCK_MASK 0x7ffff000
39 #define HCELL_OFFSET_MASK 0x00000fff
40 #define HCELL_TYPE_SHIFT 31
41 #define HCELL_BLOCK_SHIFT 12
42 #define HCELL_OFFSET_SHIFT 0
43
44 #include <pshpack1.h>
45
46 /**
47 * @name HBASE_BLOCK
48 *
49 * On-disk header for registry hive file.
50 */
51
52 typedef struct _HBASE_BLOCK
53 {
54 /* Hive identifier "regf" (0x66676572) */
55 ULONG Signature;
56
57 /* Update counter */
58 ULONG Sequence1;
59
60 /* Update counter */
61 ULONG Sequence2;
62
63 /* When this hive file was last modified */
64 LARGE_INTEGER TimeStamp;
65
66 /* Registry format major version (1) */
67 ULONG Major;
68
69 /* Registry format minor version (3)
70 Version 3 added fast indexes, version 5 has large value optimizations */
71 ULONG Minor;
72
73 /* Registry file type (0 - Primary, 1 - Log) */
74 ULONG Type;
75
76 /* Registry format (1 is the only defined value so far) */
77 ULONG Format;
78
79 /* Offset into file from the byte after the end of the base block.
80 If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
81 HCELL_INDEX RootCell;
82
83 /* Size of each hive block ? */
84 ULONG Length;
85
86 /* (1?) */
87 ULONG Cluster;
88
89 /* Name of hive file */
90 CHAR FileName[64];
91
92 ULONG Reserved1[99];
93
94 /* Checksum of first 0x200 bytes */
95 ULONG Checksum;
96
97 ULONG Reserved2[0x37E];
98 ULONG BootType;
99 ULONG BootRecover;
100 } HBASE_BLOCK, *PHBASE_BLOCK;
101
102 typedef struct _HBIN
103 {
104 /* Bin identifier "hbin" (0x6E696268) */
105 ULONG Signature;
106
107 /* Block offset of this bin */
108 HCELL_INDEX FileOffset;
109
110 /* Size in bytes, multiple of the block size (4KB) */
111 ULONG Size;
112
113 ULONG Reserved1[2];
114
115 /* When this bin was last modified */
116 LARGE_INTEGER TimeStamp;
117
118 /* ? (In-memory only) */
119 ULONG MemAlloc;
120 } HBIN, *PHBIN;
121
122 typedef struct _HCELL
123 {
124 /* <0 if used, >0 if free */
125 LONG Size;
126 union
127 {
128 struct
129 {
130 ULONG Last;
131 union
132 {
133 ULONG UserData;
134 HCELL_INDEX Next;
135 } u;
136 } OldCell;
137 struct
138 {
139 union
140 {
141 ULONG UserData;
142 HCELL_INDEX Next;
143 } u;
144 } NewCell;
145 } u;
146 } HCELL, *PHCELL;
147
148 #include <poppack.h>
149
150 #define IsFreeCell(Cell)(Cell->Size >= 0)
151 #define IsUsedCell(Cell)(Cell->Size < 0)
152
153 typedef enum _HV_STORAGE_TYPE
154 {
155 HvStable = 0,
156 HvVolatile,
157 HvMaxStorageType
158 } HV_STORAGE_TYPE;
159
160 #endif /* CMLIB_HIVEDATA_H */