Added a keep-alive reference to each key object.
[reactos.git] / reactos / ntoskrnl / cm / cm.h
1 #ifndef __INCLUDE_CM_H
2 #define __INCLUDE_CM_H
3
4 #ifdef DBG
5 #define CHECKED 1
6 #else
7 #define CHECKED 0
8 #endif
9
10 #define REG_ROOT_KEY_NAME L"\\Registry"
11 #define REG_MACHINE_KEY_NAME L"\\Registry\\Machine"
12 #define REG_HARDWARE_KEY_NAME L"\\Registry\\Machine\\HARDWARE"
13 #define REG_DESCRIPTION_KEY_NAME L"\\Registry\\Machine\\HARDWARE\\DESCRIPTION"
14 #define REG_DEVICEMAP_KEY_NAME L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP"
15 #define REG_RESOURCEMAP_KEY_NAME L"\\Registry\\Machine\\HARDWARE\\RESOURCEMAP"
16 #define REG_CLASSES_KEY_NAME L"\\Registry\\Machine\\Software\\Classes"
17 #define REG_SYSTEM_KEY_NAME L"\\Registry\\Machine\\SYSTEM"
18 #define REG_SOFTWARE_KEY_NAME L"\\Registry\\Machine\\SOFTWARE"
19 #define REG_SAM_KEY_NAME L"\\Registry\\Machine\\SAM"
20 #define REG_SEC_KEY_NAME L"\\Registry\\Machine\\SECURITY"
21 #define REG_USER_KEY_NAME L"\\Registry\\User"
22 #define REG_DEFAULT_USER_KEY_NAME L"\\Registry\\User\\.Default"
23 #define REG_CURRENT_USER_KEY_NAME L"\\Registry\\User\\CurrentUser"
24
25 #define SYSTEM_REG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM"
26 #define SYSTEM_LOG_FILE L"\\SystemRoot\\System32\\Config\\SYSTEM.log"
27 #define SOFTWARE_REG_FILE L"\\SystemRoot\\System32\\Config\\SOFTWARE"
28 #define DEFAULT_USER_REG_FILE L"\\SystemRoot\\System32\\Config\\DEFAULT"
29 #define SAM_REG_FILE L"\\SystemRoot\\System32\\Config\\SAM"
30 #define SEC_REG_FILE L"\\SystemRoot\\System32\\Config\\SECURITY"
31
32 #define REG_SYSTEM_FILE_NAME L"\\system"
33 #define REG_SOFTWARE_FILE_NAME L"\\software"
34 #define REG_DEFAULT_USER_FILE_NAME L"\\default"
35 #define REG_SAM_FILE_NAME L"\\sam"
36 #define REG_SEC_FILE_NAME L"\\security"
37
38 #define REG_BLOCK_SIZE 4096
39 #define REG_HBIN_DATA_OFFSET 32
40 #define REG_INIT_BLOCK_LIST_SIZE 32
41 #define REG_INIT_HASH_TABLE_SIZE 3
42 #define REG_EXTEND_HASH_TABLE_SIZE 4
43 #define REG_VALUE_LIST_CELL_MULTIPLE 4
44
45 #define REG_HIVE_ID 0x66676572
46 #define REG_BIN_ID 0x6e696268
47 #define REG_KEY_CELL_ID 0x6b6e
48 #define REG_HASH_TABLE_CELL_ID 0x666c
49 #define REG_VALUE_CELL_ID 0x6b76
50 #define REG_SECURITY_CELL_ID 0x6b73
51
52
53 // BLOCK_OFFSET = offset in file after header block
54 typedef ULONG BLOCK_OFFSET, *PBLOCK_OFFSET;
55
56 #include <pshpack1.h>
57
58 /* header for registry hive file : */
59 typedef struct _HIVE_HEADER
60 {
61 /* Hive identifier "regf" (0x66676572) */
62 ULONG BlockId;
63
64 /* Update counter */
65 ULONG UpdateCounter1;
66
67 /* Update counter */
68 ULONG UpdateCounter2;
69
70 /* When this hive file was last modified */
71 LARGE_INTEGER DateModified;
72
73 /* Registry format version ? (1?) */
74 ULONG Unused3;
75
76 /* Registry format version ? (3?) */
77 ULONG Unused4;
78
79 /* Registry format version ? (0?) */
80 ULONG Unused5;
81
82 /* Registry format version ? (1?) */
83 ULONG Unused6;
84
85 /* Offset into file from the byte after the end of the base block.
86 If the hive is volatile, this is the actual pointer to the KEY_CELL */
87 BLOCK_OFFSET RootKeyOffset;
88
89 /* Size of each hive block ? */
90 ULONG BlockSize;
91
92 /* (1?) */
93 ULONG Unused7;
94
95 /* Name of hive file */
96 WCHAR FileName[64];
97
98 /* ? */
99 ULONG Unused8[83];
100
101 /* Checksum of first 0x200 bytes */
102 ULONG Checksum;
103 } HIVE_HEADER, *PHIVE_HEADER;
104
105 typedef struct _BIN_HEADER
106 {
107 /* Bin identifier "hbin" (0x6E696268) */
108 ULONG HeaderId;
109
110 /* Block offset of this bin */
111 BLOCK_OFFSET BinOffset;
112
113 /* Size in bytes, multiple of the block size (4KB) */
114 ULONG BinSize;
115
116 /* ? */
117 ULONG Unused1;
118
119 /* When this bin was last modified */
120 LARGE_INTEGER DateModified;
121
122 /* ? */
123 ULONG Unused2;
124 } HBIN, *PHBIN;
125
126 typedef struct _CELL_HEADER
127 {
128 /* <0 if used, >0 if free */
129 LONG CellSize;
130 } CELL_HEADER, *PCELL_HEADER;
131
132 typedef struct _KEY_CELL
133 {
134 /* Size of this cell */
135 LONG CellSize;
136
137 /* Key cell identifier "kn" (0x6b6e) */
138 USHORT Id;
139
140 /* Flags */
141 USHORT Flags;
142
143 /* Time of last flush */
144 LARGE_INTEGER LastWriteTime;
145
146 /* ? */
147 ULONG UnUsed1;
148
149 /* Block offset of parent key cell */
150 BLOCK_OFFSET ParentKeyOffset;
151
152 /* Count of sub keys for the key in this key cell */
153 ULONG NumberOfSubKeys;
154
155 /* ? */
156 ULONG UnUsed2;
157
158 /* Block offset of has table for FIXME: subkeys/values? */
159 BLOCK_OFFSET HashTableOffset;
160
161 /* ? */
162 ULONG UnUsed3;
163
164 /* Count of values contained in this key cell */
165 ULONG NumberOfValues;
166
167 /* Block offset of VALUE_LIST_CELL */
168 BLOCK_OFFSET ValueListOffset;
169
170 /* Block offset of security cell */
171 BLOCK_OFFSET SecurityKeyOffset;
172
173 /* Block offset of registry key class */
174 BLOCK_OFFSET ClassNameOffset;
175
176 /* ? */
177 ULONG Unused4[5];
178
179 /* Size in bytes of key name */
180 USHORT NameSize;
181
182 /* Size of class name in bytes */
183 USHORT ClassSize;
184
185 /* Name of key (not zero terminated) */
186 UCHAR Name[0];
187 } KEY_CELL, *PKEY_CELL;
188
189 /* KEY_CELL.Flags constants */
190 #define REG_KEY_ROOT_CELL 0x0C
191 #define REG_KEY_LINK_CELL 0x10
192 #define REG_KEY_NAME_PACKED 0x20
193
194 /*
195 * Hash record
196 *
197 * HashValue:
198 * packed name: four letters of value's name
199 * otherwise: Zero!
200 */
201 typedef struct _HASH_RECORD
202 {
203 BLOCK_OFFSET KeyOffset;
204 ULONG HashValue;
205 } HASH_RECORD, *PHASH_RECORD;
206
207 typedef struct _HASH_TABLE_CELL
208 {
209 LONG CellSize;
210 USHORT Id;
211 USHORT HashTableSize;
212 HASH_RECORD Table[0];
213 } HASH_TABLE_CELL, *PHASH_TABLE_CELL;
214
215
216 typedef struct _VALUE_LIST_CELL
217 {
218 LONG CellSize;
219 BLOCK_OFFSET ValueOffset[0];
220 } VALUE_LIST_CELL, *PVALUE_LIST_CELL;
221
222 typedef struct _VALUE_CELL
223 {
224 LONG CellSize;
225 USHORT Id; // "kv"
226 USHORT NameSize; // length of Name
227 ULONG DataSize; // length of datas in the cell pointed by DataOffset
228 BLOCK_OFFSET DataOffset;// datas are here if high bit of DataSize is set
229 ULONG DataType;
230 USHORT Flags;
231 USHORT Unused1;
232 UCHAR Name[0]; /* warning : not zero terminated */
233 } VALUE_CELL, *PVALUE_CELL;
234
235 /* VALUE_CELL.Flags constants */
236 #define REG_VALUE_NAME_PACKED 0x0001
237
238 /* VALUE_CELL.DataSize mask constants */
239 #define REG_DATA_SIZE_MASK 0x7FFFFFFF
240 #define REG_DATA_IN_OFFSET 0x80000000
241
242
243 typedef struct _SECURITY_CELL
244 {
245 LONG CellSize;
246 USHORT Id; // "sk"
247 USHORT Reserved;
248 BLOCK_OFFSET PrevSecurityCell;
249 BLOCK_OFFSET NextSecurityCell;
250 ULONG RefCount;
251 ULONG SdSize;
252 UCHAR Data[0];
253 } SECURITY_CELL, *PSECURITY_CELL;
254
255
256 typedef struct _DATA_CELL
257 {
258 LONG CellSize;
259 UCHAR Data[0];
260 } DATA_CELL, *PDATA_CELL;
261
262 #include <poppack.h>
263
264
265 typedef struct _BLOCK_LIST_ENTRY
266 {
267 PHBIN Bin;
268 PVOID Block;
269 } BLOCK_LIST_ENTRY, *PBLOCK_LIST_ENTRY;
270
271
272 typedef struct _REGISTRY_HIVE
273 {
274 LIST_ENTRY HiveList;
275 ULONG Flags;
276 UNICODE_STRING HiveFileName;
277 UNICODE_STRING LogFileName;
278 ULONG FileSize;
279 PHIVE_HEADER HiveHeader;
280 ULONG UpdateCounter;
281 ULONG BlockListSize;
282 PBLOCK_LIST_ENTRY BlockList;
283 ULONG FreeListSize;
284 ULONG FreeListMax;
285 PCELL_HEADER *FreeList;
286 BLOCK_OFFSET *FreeListOffset;
287
288 PSECURITY_CELL RootSecurityCell;
289
290 PULONG BitmapBuffer;
291 RTL_BITMAP DirtyBitMap;
292 BOOLEAN HiveDirty;
293 } REGISTRY_HIVE, *PREGISTRY_HIVE;
294
295 /* REGISTRY_HIVE.Flags constants */
296 /* When set, the hive uses pointers instead of offsets. */
297 #define HIVE_POINTER 0x00000001
298
299 /* When set, the hive is not backed by a file.
300 Therefore, it can not be flushed to disk. */
301 #define HIVE_NO_FILE 0x00000002
302
303 /* When set, a modified (dirty) hive is not synchronized automatically.
304 Explicit synchronization (save/flush) works. */
305 #define HIVE_NO_SYNCH 0x00000004
306
307 #define IsPointerHive(Hive) ((Hive)->Flags & HIVE_POINTER)
308 #define IsNoFileHive(Hive) ((Hive)->Flags & HIVE_NO_FILE)
309 #define IsNoSynchHive(Hive) ((Hive)->Flags & HIVE_NO_SYNCH)
310
311
312 #define IsFreeCell(Cell)(Cell->CellSize >= 0)
313 #define IsUsedCell(Cell)(Cell->CellSize < 0)
314
315
316 /* KEY_OBJECT.Flags */
317
318 /* When set, the key is scheduled for deletion, and all
319 attempts to access the key must not succeed */
320 #define KO_MARKED_FOR_DELETE 0x00000001
321
322
323 /* Type defining the Object Manager Key Object */
324 typedef struct _KEY_OBJECT
325 {
326 /* Fields used by the Object Manager */
327 CSHORT Type;
328 CSHORT Size;
329
330 /* Key flags */
331 ULONG Flags;
332
333 /* Key name */
334 UNICODE_STRING Name;
335
336 /* Registry hive the key belongs to */
337 PREGISTRY_HIVE RegistryHive;
338
339 /* Block offset of the key cell this key belongs in */
340 BLOCK_OFFSET KeyCellOffset;
341
342 /* KEY_CELL this key belong in */
343 PKEY_CELL KeyCell;
344
345 /* Link to the parent KEY_OBJECT for this key */
346 struct _KEY_OBJECT *ParentKey;
347
348 /* Subkeys loaded in SubKeys */
349 ULONG NumberOfSubKeys;
350
351 /* Space allocated in SubKeys */
352 ULONG SizeOfSubKeys;
353
354 /* List of subkeys loaded */
355 struct _KEY_OBJECT **SubKeys;
356
357 /* List entry into the global key object list */
358 LIST_ENTRY ListEntry;
359
360 /* Time stamp for the last access by the parse routine */
361 ULONG TimeStamp;
362 } KEY_OBJECT, *PKEY_OBJECT;
363
364 /* Bits 31-22 (top 10 bits) of the cell index is the directory index */
365 #define CmiDirectoryIndex(CellIndex)(CellIndex & 0xffc000000)
366 /* Bits 21-12 (middle 10 bits) of the cell index is the table index */
367 #define CmiTableIndex(Cellndex)(CellIndex & 0x003ff000)
368 /* Bits 11-0 (bottom 12 bits) of the cell index is the byte offset */
369 #define CmiByteOffset(Cellndex)(CellIndex & 0x00000fff)
370
371
372 extern BOOLEAN CmiDoVerify;
373 extern PREGISTRY_HIVE CmiVolatileHive;
374 extern POBJECT_TYPE CmiKeyType;
375 extern KSPIN_LOCK CmiKeyListLock;
376
377 extern LIST_ENTRY CmiHiveListHead;
378
379 extern ERESOURCE CmiRegistryLock;
380
381 typedef enum _REG_NOTIFY_CLASS
382 {
383 RegNtDeleteKey,
384 RegNtPreDeleteKey = RegNtDeleteKey,
385 RegNtSetValueKey,
386 RegNtPreSetValueKey = RegNtSetValueKey,
387 RegNtDeleteValueKey,
388 RegNtPreDeleteValueKey = RegNtDeleteValueKey,
389 RegNtSetInformationKey,
390 RegNtPreSetInformationKey = RegNtSetInformationKey,
391 RegNtRenameKey,
392 RegNtPreRenameKey = RegNtRenameKey,
393 RegNtEnumerateKey,
394 RegNtPreEnumerateKey = RegNtEnumerateKey,
395 RegNtEnumerateValueKey,
396 RegNtPreEnumerateValueKey = RegNtEnumerateValueKey,
397 RegNtQueryKey,
398 RegNtPreQueryKey = RegNtQueryKey,
399 RegNtQueryValueKey,
400 RegNtPreQueryValueKey = RegNtQueryValueKey,
401 RegNtQueryMultipleValueKey,
402 RegNtPreQueryMultipleValueKey = RegNtQueryMultipleValueKey,
403 RegNtPreCreateKey,
404 RegNtPostCreateKey,
405 RegNtPreOpenKey,
406 RegNtPostOpenKey,
407 RegNtKeyHandleClose,
408 RegNtPreKeyHandleClose = RegNtKeyHandleClose,
409 RegNtPostDeleteKey,
410 RegNtPostSetValueKey,
411 RegNtPostDeleteValueKey,
412 RegNtPostSetInformationKey,
413 RegNtPostRenameKey,
414 RegNtPostEnumerateKey,
415 RegNtPostEnumerateValueKey,
416 RegNtPostQueryKey,
417 RegNtPostQueryValueKey,
418 RegNtPostQueryMultipleValueKey,
419 RegNtPostKeyHandleClose,
420 RegNtPreCreateKeyEx,
421 RegNtPostCreateKeyEx,
422 RegNtPreOpenKeyEx,
423 RegNtPostOpenKeyEx
424 } REG_NOTIFY_CLASS, *PREG_NOTIFY_CLASS;
425
426 /* Registry Callback Function */
427 typedef NTSTATUS (*PEX_CALLBACK_FUNCTION ) (
428 IN PVOID CallbackContext,
429 IN REG_NOTIFY_CLASS Argument1,
430 IN PVOID Argument2
431 );
432
433 typedef struct _REGISTRY_CALLBACK
434 {
435 LIST_ENTRY ListEntry;
436 EX_RUNDOWN_REF RundownRef;
437 PEX_CALLBACK_FUNCTION Function;
438 PVOID Context;
439 LARGE_INTEGER Cookie;
440 BOOLEAN PendingDelete;
441 } REGISTRY_CALLBACK, *PREGISTRY_CALLBACK;
442
443 NTSTATUS
444 CmiCallRegisteredCallbacks(IN REG_NOTIFY_CLASS Argument1,
445 IN PVOID Argument2);
446
447 VOID
448 CmiVerifyBinHeader(PHBIN BinHeader);
449 VOID
450 CmiVerifyKeyCell(PKEY_CELL KeyCell);
451 VOID
452 CmiVerifyRootKeyCell(PKEY_CELL RootKeyCell);
453 VOID
454 CmiVerifyKeyObject(PKEY_OBJECT KeyObject);
455 VOID
456 CmiVerifyRegistryHive(PREGISTRY_HIVE RegistryHive);
457
458 #ifdef DBG
459 #define VERIFY_BIN_HEADER CmiVerifyBinHeader
460 #define VERIFY_KEY_CELL CmiVerifyKeyCell
461 #define VERIFY_ROOT_KEY_CELL CmiVerifyRootKeyCell
462 #define VERIFY_VALUE_CELL CmiVerifyValueCell
463 #define VERIFY_VALUE_LIST_CELL CmiVerifyValueListCell
464 #define VERIFY_KEY_OBJECT CmiVerifyKeyObject
465 #define VERIFY_REGISTRY_HIVE CmiVerifyRegistryHive
466 #else
467 #define VERIFY_BIN_HEADER(x)
468 #define VERIFY_KEY_CELL(x)
469 #define VERIFY_ROOT_KEY_CELL(x)
470 #define VERIFY_VALUE_CELL(x)
471 #define VERIFY_VALUE_LIST_CELL(x)
472 #define VERIFY_KEY_OBJECT(x)
473 #define VERIFY_REGISTRY_HIVE(x)
474 #endif
475
476 NTSTATUS STDCALL
477 CmRegisterCallback(IN PEX_CALLBACK_FUNCTION Function,
478 IN PVOID Context,
479 IN OUT PLARGE_INTEGER Cookie
480 );
481
482 NTSTATUS STDCALL
483 CmUnRegisterCallback(IN LARGE_INTEGER Cookie);
484
485 NTSTATUS STDCALL
486 CmiObjectParse(IN PVOID ParsedObject,
487 OUT PVOID *NextObject,
488 IN PUNICODE_STRING FullPath,
489 IN OUT PWSTR *Path,
490 IN ULONG Attribute);
491
492 NTSTATUS STDCALL
493 CmiObjectCreate(PVOID ObjectBody,
494 PVOID Parent,
495 PWSTR RemainingPath,
496 POBJECT_ATTRIBUTES ObjectAttributes);
497
498 VOID STDCALL
499 CmiObjectDelete(PVOID DeletedObject);
500
501 NTSTATUS STDCALL
502 CmiObjectSecurity(PVOID ObjectBody,
503 SECURITY_OPERATION_CODE OperationCode,
504 SECURITY_INFORMATION SecurityInformation,
505 PSECURITY_DESCRIPTOR SecurityDescriptor,
506 PULONG BufferLength);
507
508 NTSTATUS STDCALL
509 CmiObjectQueryName (PVOID ObjectBody,
510 POBJECT_NAME_INFORMATION ObjectNameInfo,
511 ULONG Length,
512 PULONG ReturnLength);
513
514 NTSTATUS
515 CmiImportHiveBins(PREGISTRY_HIVE Hive,
516 PUCHAR ChunkPtr);
517
518 VOID
519 CmiFreeHiveBins(PREGISTRY_HIVE Hive);
520
521 NTSTATUS
522 CmiCreateHiveFreeCellList(PREGISTRY_HIVE Hive);
523
524 VOID
525 CmiFreeHiveFreeCellList(PREGISTRY_HIVE Hive);
526
527 NTSTATUS
528 CmiCreateHiveBitmap(PREGISTRY_HIVE Hive);
529
530
531 VOID
532 CmiAddKeyToList(IN PKEY_OBJECT ParentKey,
533 IN PKEY_OBJECT NewKey);
534
535 NTSTATUS
536 CmiRemoveKeyFromList(IN PKEY_OBJECT NewKey);
537
538 NTSTATUS
539 CmiScanKeyList(IN PKEY_OBJECT Parent,
540 IN PUNICODE_STRING KeyName,
541 IN ULONG Attributes,
542 PKEY_OBJECT* ReturnedObject);
543
544 NTSTATUS
545 CmiCreateVolatileHive(PREGISTRY_HIVE *RegistryHive);
546
547 NTSTATUS
548 CmiLoadHive(POBJECT_ATTRIBUTES KeyObjectAttributes,
549 PUNICODE_STRING FileName,
550 ULONG Flags);
551
552 NTSTATUS
553 CmiRemoveRegistryHive(PREGISTRY_HIVE RegistryHive);
554
555 NTSTATUS
556 CmiFlushRegistryHive(PREGISTRY_HIVE RegistryHive);
557
558 ULONG
559 CmiGetNumberOfSubKeys(PKEY_OBJECT KeyObject);
560
561 ULONG
562 CmiGetMaxNameLength(IN PKEY_OBJECT KeyObject);
563
564 ULONG
565 CmiGetMaxClassLength(IN PKEY_OBJECT KeyObject);
566
567 ULONG
568 CmiGetMaxValueNameLength(IN PREGISTRY_HIVE RegistryHive,
569 IN PKEY_CELL KeyCell);
570
571 ULONG
572 CmiGetMaxValueDataLength(IN PREGISTRY_HIVE RegistryHive,
573 IN PKEY_CELL KeyCell);
574
575 NTSTATUS
576 CmiScanForSubKey(IN PREGISTRY_HIVE RegistryHive,
577 IN PKEY_CELL KeyCell,
578 OUT PKEY_CELL *SubKeyCell,
579 OUT BLOCK_OFFSET *BlockOffset,
580 IN PUNICODE_STRING KeyName,
581 IN ACCESS_MASK DesiredAccess,
582 IN ULONG Attributes);
583
584 NTSTATUS
585 CmiAddSubKey(IN PREGISTRY_HIVE RegistryHive,
586 IN PKEY_OBJECT ParentKey,
587 OUT PKEY_OBJECT SubKey,
588 IN PUNICODE_STRING SubKeyName,
589 IN ULONG TitleIndex,
590 IN PUNICODE_STRING Class,
591 IN ULONG CreateOptions);
592
593 NTSTATUS
594 CmiRemoveSubKey(IN PREGISTRY_HIVE RegistryHive,
595 IN PKEY_OBJECT Parent,
596 IN PKEY_OBJECT SubKey);
597
598 NTSTATUS
599 CmiScanKeyForValue(IN PREGISTRY_HIVE RegistryHive,
600 IN PKEY_CELL KeyCell,
601 IN PUNICODE_STRING ValueName,
602 OUT PVALUE_CELL *ValueCell,
603 OUT BLOCK_OFFSET *VBOffset);
604
605 NTSTATUS
606 CmiGetValueFromKeyByIndex(IN PREGISTRY_HIVE RegistryHive,
607 IN PKEY_CELL KeyCell,
608 IN ULONG Index,
609 OUT PVALUE_CELL *ValueCell);
610
611 NTSTATUS
612 CmiAddValueToKey(IN PREGISTRY_HIVE RegistryHive,
613 IN PKEY_CELL KeyCell,
614 IN BLOCK_OFFSET KeyCellOffset,
615 IN PUNICODE_STRING ValueName,
616 OUT PVALUE_CELL *pValueCell,
617 OUT BLOCK_OFFSET *pValueCellOffset);
618
619 NTSTATUS
620 CmiDeleteValueFromKey(IN PREGISTRY_HIVE RegistryHive,
621 IN PKEY_CELL KeyCell,
622 IN BLOCK_OFFSET KeyCellOffset,
623 IN PUNICODE_STRING ValueName);
624
625 NTSTATUS
626 CmiAllocateHashTableCell(IN PREGISTRY_HIVE RegistryHive,
627 OUT PHASH_TABLE_CELL *HashBlock,
628 OUT BLOCK_OFFSET *HBOffset,
629 IN ULONG HashTableSize);
630
631 PKEY_CELL
632 CmiGetKeyFromHashByIndex(PREGISTRY_HIVE RegistryHive,
633 PHASH_TABLE_CELL HashBlock,
634 ULONG Index);
635
636 NTSTATUS
637 CmiAddKeyToHashTable(PREGISTRY_HIVE RegistryHive,
638 PHASH_TABLE_CELL HashCell,
639 BLOCK_OFFSET HashCellOffset,
640 PKEY_CELL NewKeyCell,
641 BLOCK_OFFSET NKBOffset);
642
643 NTSTATUS
644 CmiRemoveKeyFromHashTable(PREGISTRY_HIVE RegistryHive,
645 PHASH_TABLE_CELL HashBlock,
646 BLOCK_OFFSET NKBOffset);
647
648 NTSTATUS
649 CmiAllocateValueCell(IN PREGISTRY_HIVE RegistryHive,
650 OUT PVALUE_CELL *ValueCell,
651 OUT BLOCK_OFFSET *VBOffset,
652 IN PUNICODE_STRING ValueName);
653
654 NTSTATUS
655 CmiDestroyValueCell(PREGISTRY_HIVE RegistryHive,
656 PVALUE_CELL ValueCell,
657 BLOCK_OFFSET VBOffset);
658
659 NTSTATUS
660 CmiAllocateCell(PREGISTRY_HIVE RegistryHive,
661 LONG CellSize,
662 PVOID *Cell,
663 BLOCK_OFFSET *CellOffset);
664
665 NTSTATUS
666 CmiDestroyCell(PREGISTRY_HIVE RegistryHive,
667 PVOID Cell,
668 BLOCK_OFFSET CellOffset);
669
670 PHBIN
671 CmiGetBin (PREGISTRY_HIVE RegistryHive,
672 BLOCK_OFFSET CellOffset);
673
674 PVOID
675 CmiGetCell (PREGISTRY_HIVE RegistryHive,
676 BLOCK_OFFSET CellOffset,
677 OUT PHBIN *Bin);
678
679 VOID
680 CmiMarkBlockDirty(PREGISTRY_HIVE RegistryHive,
681 BLOCK_OFFSET BlockOffset);
682
683 VOID
684 CmiMarkBinDirty(PREGISTRY_HIVE RegistryHive,
685 BLOCK_OFFSET BinOffset);
686
687 NTSTATUS
688 CmiAddFree(PREGISTRY_HIVE RegistryHive,
689 PCELL_HEADER FreeBlock,
690 BLOCK_OFFSET FreeOffset,
691 BOOLEAN MergeFreeBlocks);
692
693 NTSTATUS
694 CmiConnectHive(POBJECT_ATTRIBUTES KeyObjectAttributes,
695 PREGISTRY_HIVE RegistryHive);
696
697 NTSTATUS
698 CmiDisconnectHive (POBJECT_ATTRIBUTES KeyObjectAttributes,
699 PREGISTRY_HIVE *RegistryHive);
700
701 NTSTATUS
702 CmiInitHives(BOOLEAN SetupBoot);
703
704 ULONG
705 CmiGetPackedNameLength(IN PUNICODE_STRING Name,
706 OUT PBOOLEAN Packable);
707
708 BOOLEAN
709 CmiComparePackedNames(IN PUNICODE_STRING Name,
710 IN PUCHAR NameBuffer,
711 IN USHORT NameBufferSize,
712 IN BOOLEAN NamePacked);
713
714 VOID
715 CmiCopyPackedName(PWCHAR NameBuffer,
716 PUCHAR PackedNameBuffer,
717 ULONG PackedNameSize);
718
719 BOOLEAN
720 CmiCompareHash(PUNICODE_STRING KeyName,
721 PCHAR HashString);
722
723 BOOLEAN
724 CmiCompareHashI(PUNICODE_STRING KeyName,
725 PCHAR HashString);
726
727 BOOLEAN
728 CmiCompareKeyNames(PUNICODE_STRING KeyName,
729 PKEY_CELL KeyCell);
730
731 BOOLEAN
732 CmiCompareKeyNamesI(PUNICODE_STRING KeyName,
733 PKEY_CELL KeyCell);
734
735
736 VOID
737 CmiSyncHives(VOID);
738
739
740 NTSTATUS
741 CmiCreateTempHive(PREGISTRY_HIVE *RegistryHive);
742
743 NTSTATUS
744 CmiCopyKey (PREGISTRY_HIVE DstHive,
745 PKEY_CELL DstKeyCell,
746 PREGISTRY_HIVE SrcHive,
747 PKEY_CELL SrcKeyCell);
748
749 NTSTATUS
750 CmiSaveTempHive (PREGISTRY_HIVE Hive,
751 HANDLE FileHandle);
752
753 #endif /*__INCLUDE_CM_H*/