- most of the churn here is from code and headers imported from trunk.
[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 typedef ULONG HCELL_INDEX, *PHCELL_INDEX;
34
35 #define HCELL_NULL ((HCELL_INDEX)-1)
36 #define HCELL_TYPE_MASK 0x80000000
37 #define HCELL_BLOCK_MASK 0x7ffff000
38 #define HCELL_OFFSET_MASK 0x00000fff
39 #define HCELL_TYPE_SHIFT 31
40 #define HCELL_BLOCK_SHIFT 12
41 #define HCELL_OFFSET_SHIFT 0
42
43 #include <pshpack1.h>
44
45 /**
46 * @name HBASE_BLOCK
47 *
48 * On-disk header for registry hive file.
49 */
50
51 typedef struct _HBASE_BLOCK
52 {
53 /* Hive identifier "regf" (0x66676572) */
54 ULONG Signature;
55
56 /* Update counter */
57 ULONG Sequence1;
58
59 /* Update counter */
60 ULONG Sequence2;
61
62 /* When this hive file was last modified */
63 LARGE_INTEGER TimeStamp;
64
65 /* Registry format major version (1) */
66 ULONG Major;
67
68 /* Registry format minor version (3)
69 Version 3 added fast indexes, version 5 has large value optimizations */
70 ULONG Minor;
71
72 /* Registry file type (0 - Primary, 1 - Log) */
73 ULONG Type;
74
75 /* Registry format (1 is the only defined value so far) */
76 ULONG Format;
77
78 /* Offset into file from the byte after the end of the base block.
79 If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
80 HCELL_INDEX RootCell;
81
82 /* Size of each hive block ? */
83 ULONG Length;
84
85 /* (1?) */
86 ULONG Cluster;
87
88 /* Name of hive file */
89 CHAR FileName[64];
90
91 ULONG Reserved1[99];
92
93 /* Checksum of first 0x200 bytes */
94 ULONG Checksum;
95
96 ULONG Reserved2[0x37E];
97 ULONG BootType;
98 ULONG BootRecover;
99 } HBASE_BLOCK, *PHBASE_BLOCK;
100
101 typedef struct _HBIN
102 {
103 /* Bin identifier "hbin" (0x6E696268) */
104 ULONG Signature;
105
106 /* Block offset of this bin */
107 HCELL_INDEX FileOffset;
108
109 /* Size in bytes, multiple of the block size (4KB) */
110 ULONG Size;
111
112 ULONG Reserved1[2];
113
114 /* When this bin was last modified */
115 LARGE_INTEGER TimeStamp;
116
117 /* ? (In-memory only) */
118 ULONG MemAlloc;
119 } HBIN, *PHBIN;
120
121 typedef struct _HCELL
122 {
123 /* <0 if used, >0 if free */
124 LONG Size;
125 } HCELL, *PHCELL;
126
127 #include <poppack.h>
128
129 #define IsFreeCell(Cell)(Cell->Size >= 0)
130 #define IsUsedCell(Cell)(Cell->Size < 0)
131
132 typedef enum _HV_STORAGE_TYPE
133 {
134 HvStable = 0,
135 HvVolatile,
136 HvMaxStorageType
137 } HV_STORAGE_TYPE;
138
139 #endif /* CMLIB_HIVEDATA_H */