xref: /reactos/sdk/lib/cmlib/cmdata.h (revision c2c66aff)
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 // Key Types
12 //
13 #define CM_KEY_INDEX_ROOT               0x6972  // "ri"
14 #define CM_KEY_INDEX_LEAF               0x696C  // "li"
15 #define CM_KEY_FAST_LEAF                0x666C  // "lf"
16 #define CM_KEY_HASH_LEAF                0x686C  // "lh"
17 
18 //
19 // Key Signatures
20 //
21 #define CM_KEY_NODE_SIGNATURE           0x6B6E  // "nk"
22 #define CM_LINK_NODE_SIGNATURE          0x6B6C  // "lk"
23 #define CM_KEY_SECURITY_SIGNATURE       0x6B73  // "sk"
24 #define CM_KEY_VALUE_SIGNATURE          0x6B76  // "vk"
25 #define CM_BIG_DATA_SIGNATURE           0x6264  // "db"
26 
27 //
28 // CM_KEY_NODE Flags
29 //
30 #define KEY_IS_VOLATILE                 0x0001
31 #define KEY_HIVE_EXIT                   0x0002
32 #define KEY_HIVE_ENTRY                  0x0004
33 #define KEY_NO_DELETE                   0x0008
34 #define KEY_SYM_LINK                    0x0010
35 #define KEY_COMP_NAME                   0x0020
36 #define KEY_PREDEF_HANDLE               0x0040
37 #define KEY_VIRT_MIRRORED               0x0080
38 #define KEY_VIRT_TARGET                 0x0100
39 #define KEY_VIRTUAL_STORE               0x0200
40 
41 //
42 // CM_KEY_VALUE Flags
43 //
44 #define VALUE_COMP_NAME                 0x0001
45 
46 //
47 // CM_KEY_VALUE Types
48 //
49 #define CM_KEY_VALUE_SMALL              0x4
50 #define CM_KEY_VALUE_BIG                0x3FD8
51 #define CM_KEY_VALUE_SPECIAL_SIZE       0x80000000
52 
53 #include <pshpack1.h>
54 
55 //
56 // For memory-mapped Hives
57 //
58 typedef struct _CM_VIEW_OF_FILE
59 {
60     LIST_ENTRY LRUViewList;
61     LIST_ENTRY PinViewList;
62     ULONG FileOffset;
63     ULONG Size;
64     PULONG_PTR ViewAddress;
65     PVOID Bcb;
66     ULONG UseCount;
67 } CM_VIEW_OF_FILE, *PCM_VIEW_OF_FILE;
68 
69 //
70 // Children of Key Nodes
71 //
72 typedef struct _CHILD_LIST
73 {
74     ULONG Count;
75     HCELL_INDEX List;
76 } CHILD_LIST, *PCHILD_LIST;
77 
78 //
79 // Node Key Reference to Parents
80 //
81 typedef struct  _CM_KEY_REFERENCE
82 {
83     HCELL_INDEX KeyCell;
84     PHHIVE KeyHive;
85 } CM_KEY_REFERENCE, *PCM_KEY_REFERENCE;
86 
87 //
88 // Node Key
89 //
90 typedef struct _CM_KEY_NODE
91 {
92     USHORT Signature;
93     USHORT Flags;
94     LARGE_INTEGER LastWriteTime;
95     ULONG Spare;
96     HCELL_INDEX Parent;
97     ULONG SubKeyCounts[HTYPE_COUNT];
98     union
99     {
100         struct
101         {
102             HCELL_INDEX SubKeyLists[HTYPE_COUNT];
103             CHILD_LIST ValueList;
104         };
105         CM_KEY_REFERENCE ChildHiveReference;
106     };
107     HCELL_INDEX Security;
108     HCELL_INDEX Class;
109     ULONG MaxNameLen;
110     ULONG MaxClassLen;
111     ULONG MaxValueNameLen;
112     ULONG MaxValueDataLen;
113     ULONG WorkVar;
114     USHORT NameLength;
115     USHORT ClassLength;
116     WCHAR Name[ANYSIZE_ARRAY];
117 } CM_KEY_NODE, *PCM_KEY_NODE;
118 
119 //
120 // Value Key
121 //
122 typedef struct _CM_KEY_VALUE
123 {
124     USHORT Signature;
125     USHORT NameLength;
126     ULONG DataLength;
127     HCELL_INDEX Data;
128     ULONG Type;
129     USHORT Flags;
130     USHORT Spare;
131     WCHAR Name[ANYSIZE_ARRAY];
132 } CM_KEY_VALUE, *PCM_KEY_VALUE;
133 
134 //
135 // Security Key
136 //
137 typedef struct _CM_KEY_SECURITY
138 {
139     USHORT Signature;
140     USHORT Reserved;
141     HCELL_INDEX Flink;
142     HCELL_INDEX Blink;
143     ULONG ReferenceCount;
144     ULONG DescriptorLength;
145     SECURITY_DESCRIPTOR_RELATIVE Descriptor;
146 } CM_KEY_SECURITY, *PCM_KEY_SECURITY;
147 
148 //
149 // Big Value Key
150 //
151 typedef struct _CM_BIG_DATA
152 {
153     USHORT Signature;
154     USHORT Count;
155     HCELL_INDEX List;
156 } CM_BIG_DATA, *PCM_BIG_DATA;
157 
158 #include <poppack.h>
159 
160 //
161 // Generic Index Entry
162 //
163 typedef struct _CM_INDEX
164 {
165     HCELL_INDEX Cell;
166     union
167     {
168         UCHAR NameHint[4];
169         ULONG HashKey;
170     };
171 } CM_INDEX, *PCM_INDEX;
172 
173 //
174 // Key Index
175 //
176 typedef struct _CM_KEY_INDEX
177 {
178     USHORT Signature;
179     USHORT Count;
180     HCELL_INDEX List[ANYSIZE_ARRAY];
181 } CM_KEY_INDEX, *PCM_KEY_INDEX;
182 
183 //
184 // Fast/Hash Key Index
185 //
186 typedef struct _CM_KEY_FAST_INDEX
187 {
188     USHORT Signature;
189     USHORT Count;
190     CM_INDEX List[ANYSIZE_ARRAY];
191 } CM_KEY_FAST_INDEX, *PCM_KEY_FAST_INDEX;
192 
193 //
194 // Cell Data
195 //
196 typedef struct _CELL_DATA
197 {
198     union
199     {
200         CM_KEY_NODE KeyNode;
201         CM_KEY_VALUE KeyValue;
202         CM_KEY_SECURITY KeySecurity;
203         CM_KEY_INDEX KeyIndex;
204         CM_BIG_DATA ValueData;
205         HCELL_INDEX KeyList[ANYSIZE_ARRAY];
206         WCHAR KeyString[ANYSIZE_ARRAY];
207     } u;
208 } CELL_DATA, *PCELL_DATA;
209