ReactOS 0.4.15-dev-5893-g1bb4167
hiveinit.c
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#include "cmlib.h"
9#define NDEBUG
10#include <debug.h>
11
19 IN PHBASE_BLOCK BaseBlock)
20{
21 if (BaseBlock->Signature != HV_HBLOCK_SIGNATURE ||
22 BaseBlock->Major != HSYS_MAJOR ||
23 BaseBlock->Minor < HSYS_MINOR ||
24 BaseBlock->Type != HFILE_TYPE_PRIMARY ||
25 BaseBlock->Format != HBASE_FORMAT_MEMORY ||
26 BaseBlock->Cluster != 1 ||
27 BaseBlock->Sequence1 != BaseBlock->Sequence2 ||
28 HvpHiveHeaderChecksum(BaseBlock) != BaseBlock->CheckSum)
29 {
30 DPRINT1("Verify Hive Header failed:\n");
31 DPRINT1(" Signature: 0x%x, expected 0x%x; Major: 0x%x, expected 0x%x\n",
32 BaseBlock->Signature, HV_HBLOCK_SIGNATURE, BaseBlock->Major, HSYS_MAJOR);
33 DPRINT1(" Minor: 0x%x expected to be >= 0x%x; Type: 0x%x, expected 0x%x\n",
34 BaseBlock->Minor, HSYS_MINOR, BaseBlock->Type, HFILE_TYPE_PRIMARY);
35 DPRINT1(" Format: 0x%x, expected 0x%x; Cluster: 0x%x, expected 1\n",
36 BaseBlock->Format, HBASE_FORMAT_MEMORY, BaseBlock->Cluster);
37 DPRINT1(" Sequence: 0x%x, expected 0x%x; Checksum: 0x%x, expected 0x%x\n",
38 BaseBlock->Sequence1, BaseBlock->Sequence2,
39 HvpHiveHeaderChecksum(BaseBlock), BaseBlock->CheckSum);
40
41 return FALSE;
42 }
43
44 return TRUE;
45}
46
54 PHHIVE Hive)
55{
56 ULONG i;
57 PHBIN Bin;
59
60 for (Storage = 0; Storage < Hive->StorageTypeCount; Storage++)
61 {
62 Bin = NULL;
63 for (i = 0; i < Hive->Storage[Storage].Length; i++)
64 {
66 continue;
68 {
70 Hive->Free((PHBIN)Hive->Storage[Storage].BlockList[i].BinAddress, 0);
71 }
74 }
75
76 if (Hive->Storage[Storage].Length)
77 Hive->Free(Hive->Storage[Storage].BlockList, 0);
78 }
79}
80
86static __inline PHBASE_BLOCK
88 IN PHHIVE Hive,
89 IN BOOLEAN Paged,
90 IN ULONG Tag)
91{
92 PHBASE_BLOCK BaseBlock;
94
95 ASSERT(sizeof(HBASE_BLOCK) >= (HSECTOR_SIZE * Hive->Cluster));
96
97 /* Allocate the buffer */
98 BaseBlock = Hive->Allocate(Hive->BaseBlockAlloc, Paged, Tag);
99 if (!BaseBlock) return NULL;
100
101 /* Check for, and enforce, alignment */
102 Alignment = Hive->Cluster * HSECTOR_SIZE -1;
103 if ((ULONG_PTR)BaseBlock & Alignment)
104 {
105 /* Free the old header and reallocate a new one, always paged */
106 Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
107 BaseBlock = Hive->Allocate(PAGE_SIZE, TRUE, Tag);
108 if (!BaseBlock) return NULL;
109
110 Hive->BaseBlockAlloc = PAGE_SIZE;
111 }
112
113 return BaseBlock;
114}
115
123static VOID
125 IN OUT PHBASE_BLOCK BaseBlock,
127{
130
131 /* Always NULL-initialize */
132 RtlZeroMemory(BaseBlock->FileName, (HIVE_FILENAME_MAXLEN + 1) * sizeof(WCHAR));
133
134 /* Copy the 31 last characters of the hive file name if any */
135 if (!FileName) return;
136
137 if (FileName->Length / sizeof(WCHAR) <= HIVE_FILENAME_MAXLEN)
138 {
139 Offset = 0;
140 Length = FileName->Length;
141 }
142 else
143 {
144 Offset = FileName->Length / sizeof(WCHAR) - HIVE_FILENAME_MAXLEN;
146 }
147
148 RtlCopyMemory(BaseBlock->FileName, FileName->Buffer + Offset, Length);
149}
150
161 IN OUT PHHIVE RegistryHive,
163{
164 PHBASE_BLOCK BaseBlock;
165 ULONG Index;
166
167 /* Allocate the base block */
168 BaseBlock = HvpAllocBaseBlockAligned(RegistryHive, FALSE, TAG_CM);
169 if (BaseBlock == NULL)
170 return STATUS_NO_MEMORY;
171
172 /* Clear it */
173 RtlZeroMemory(BaseBlock, RegistryHive->BaseBlockAlloc);
174
175 BaseBlock->Signature = HV_HBLOCK_SIGNATURE;
176 BaseBlock->Major = HSYS_MAJOR;
177 BaseBlock->Minor = HSYS_MINOR;
178 BaseBlock->Type = HFILE_TYPE_PRIMARY;
179 BaseBlock->Format = HBASE_FORMAT_MEMORY;
180 BaseBlock->Cluster = 1;
181 BaseBlock->RootCell = HCELL_NIL;
182 BaseBlock->Length = 0;
183 BaseBlock->Sequence1 = 1;
184 BaseBlock->Sequence2 = 1;
185 BaseBlock->TimeStamp.QuadPart = 0ULL;
186
187 /*
188 * No need to compute the checksum since
189 * the hive resides only in memory so far.
190 */
191 BaseBlock->CheckSum = 0;
192
193 /* Set default boot type */
194 BaseBlock->BootType = 0;
195
196 /* Setup hive data */
197 RegistryHive->BaseBlock = BaseBlock;
198 RegistryHive->Version = BaseBlock->Minor; // == HSYS_MINOR
199
200 for (Index = 0; Index < 24; Index++)
201 {
202 RegistryHive->Storage[Stable].FreeDisplay[Index] = HCELL_NIL;
203 RegistryHive->Storage[Volatile].FreeDisplay[Index] = HCELL_NIL;
204 }
205
206 HvpInitFileName(BaseBlock, FileName);
207
208 return STATUS_SUCCESS;
209}
210
222 PHHIVE Hive,
223 PHBASE_BLOCK ChunkBase,
225{
226 SIZE_T BlockIndex;
227 PHBIN Bin, NewBin;
228 ULONG i;
229 ULONG BitmapSize;
232
233 ChunkSize = ChunkBase->Length;
234 DPRINT("ChunkSize: %zx\n", ChunkSize);
235
236 if (ChunkSize < sizeof(HBASE_BLOCK) ||
237 !HvpVerifyHiveHeader(ChunkBase))
238 {
239 DPRINT1("Registry is corrupt: ChunkSize 0x%zx < sizeof(HBASE_BLOCK) 0x%zx, "
240 "or HvpVerifyHiveHeader() failed\n", ChunkSize, sizeof(HBASE_BLOCK));
242 }
243
244 /* Allocate the base block */
246 if (Hive->BaseBlock == NULL)
247 return STATUS_NO_MEMORY;
248
249 RtlCopyMemory(Hive->BaseBlock, ChunkBase, sizeof(HBASE_BLOCK));
250
251 /* Setup hive data */
252 Hive->Version = ChunkBase->Minor;
253
254 /*
255 * Build a block list from the in-memory chunk and copy the data as
256 * we go.
257 */
258
260 Hive->Storage[Stable].BlockList =
261 Hive->Allocate(Hive->Storage[Stable].Length *
262 sizeof(HMAP_ENTRY), FALSE, TAG_CM);
263 if (Hive->Storage[Stable].BlockList == NULL)
264 {
265 DPRINT1("Allocating block list failed\n");
266 Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
267 return STATUS_NO_MEMORY;
268 }
269
270 for (BlockIndex = 0; BlockIndex < Hive->Storage[Stable].Length; )
271 {
272 Bin = (PHBIN)((ULONG_PTR)ChunkBase + (BlockIndex + 1) * HBLOCK_SIZE);
273 if (Bin->Signature != HV_HBIN_SIGNATURE ||
274 (Bin->Size % HBLOCK_SIZE) != 0)
275 {
276 DPRINT1("Invalid bin at BlockIndex %lu, Signature 0x%x, Size 0x%x\n",
277 (unsigned long)BlockIndex, (unsigned)Bin->Signature, (unsigned)Bin->Size);
278 Hive->Free(Hive->Storage[Stable].BlockList, 0);
279 Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
281 }
282
283 NewBin = Hive->Allocate(Bin->Size, TRUE, TAG_CM);
284 if (NewBin == NULL)
285 {
286 Hive->Free(Hive->Storage[Stable].BlockList, 0);
287 Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
288 return STATUS_NO_MEMORY;
289 }
290
291 Hive->Storage[Stable].BlockList[BlockIndex].BinAddress = (ULONG_PTR)NewBin;
292 Hive->Storage[Stable].BlockList[BlockIndex].BlockAddress = (ULONG_PTR)NewBin;
293
294 RtlCopyMemory(NewBin, Bin, Bin->Size);
295
296 if (Bin->Size > HBLOCK_SIZE)
297 {
298 for (i = 1; i < Bin->Size / HBLOCK_SIZE; i++)
299 {
300 Hive->Storage[Stable].BlockList[BlockIndex + i].BinAddress = (ULONG_PTR)NewBin;
301 Hive->Storage[Stable].BlockList[BlockIndex + i].BlockAddress =
302 ((ULONG_PTR)NewBin + (i * HBLOCK_SIZE));
303 }
304 }
305
306 BlockIndex += Bin->Size / HBLOCK_SIZE;
307 }
308
310 {
311 HvpFreeHiveBins(Hive);
312 Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
313 return STATUS_NO_MEMORY;
314 }
315
316 BitmapSize = ROUND_UP(Hive->Storage[Stable].Length,
317 sizeof(ULONG) * 8) / 8;
318 BitmapBuffer = (PULONG)Hive->Allocate(BitmapSize, TRUE, TAG_CM);
319 if (BitmapBuffer == NULL)
320 {
321 HvpFreeHiveBins(Hive);
322 Hive->Free(Hive->BaseBlock, Hive->BaseBlockAlloc);
323 return STATUS_NO_MEMORY;
324 }
325
326 RtlInitializeBitMap(&Hive->DirtyVector, BitmapBuffer, BitmapSize * 8);
328
330
331 return STATUS_SUCCESS;
332}
333
345 PHHIVE Hive,
346 PHBASE_BLOCK ChunkBase)
347{
348 if (!HvpVerifyHiveHeader(ChunkBase))
350
351 /* Setup hive data */
352 Hive->BaseBlock = ChunkBase;
353 Hive->Version = ChunkBase->Minor;
354 Hive->Flat = TRUE;
355 Hive->ReadOnly = TRUE;
356
357 Hive->StorageTypeCount = 1;
358
359 /* Set default boot type */
360 ChunkBase->BootType = 0;
361
362 return STATUS_SUCCESS;
363}
364
365typedef enum _RESULT
366{
375
378 IN PHBASE_BLOCK *HiveBaseBlock,
380{
381 PHBASE_BLOCK BaseBlock;
383 ULONG Offset = 0;
384
385 ASSERT(sizeof(HBASE_BLOCK) >= (HSECTOR_SIZE * Hive->Cluster));
386
387 /* Assume failure and allocate the base block */
388 *HiveBaseBlock = NULL;
389 BaseBlock = HvpAllocBaseBlockAligned(Hive, TRUE, TAG_CM);
390 if (!BaseBlock) return NoMemory;
391
392 /* Clear it */
393 RtlZeroMemory(BaseBlock, sizeof(HBASE_BLOCK));
394
395 /* Now read it from disk */
396 Result = Hive->FileRead(Hive,
398 &Offset,
399 BaseBlock,
400 Hive->Cluster * HSECTOR_SIZE);
401
402 /* Couldn't read: assume it's not a hive */
403 if (!Result) return NotHive;
404
405 /* Do validation */
406 if (!HvpVerifyHiveHeader(BaseBlock)) return NotHive;
407
408 /* Return information */
409 *HiveBaseBlock = BaseBlock;
410 *TimeStamp = BaseBlock->TimeStamp;
411 return HiveSuccess;
412}
413
417{
419 PHBASE_BLOCK BaseBlock = NULL;
422 ULONG Offset = 0;
423 PVOID HiveData;
425
426 /* Get the hive header */
427 Result = HvpGetHiveHeader(Hive, &BaseBlock, &TimeStamp);
428 switch (Result)
429 {
430 /* Out of memory */
431 case NoMemory:
432
433 /* Fail */
435
436 /* Not a hive */
437 case NotHive:
438
439 /* Fail */
441
442 /* Has recovery data */
443 case RecoverData:
444 case RecoverHeader:
445
446 /* Fail */
448 }
449
450 /* Set default boot type */
451 BaseBlock->BootType = 0;
452
453 /* Setup hive data */
454 Hive->BaseBlock = BaseBlock;
455 Hive->Version = BaseBlock->Minor;
456
457 /* Allocate a buffer large enough to hold the hive */
458 FileSize = HBLOCK_SIZE + BaseBlock->Length; // == sizeof(HBASE_BLOCK) + BaseBlock->Length;
459 HiveData = Hive->Allocate(FileSize, TRUE, TAG_CM);
460 if (!HiveData)
461 {
462 Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
464 }
465
466 /* Now read the whole hive */
467 Result = Hive->FileRead(Hive,
469 &Offset,
470 HiveData,
471 FileSize);
472 if (!Result)
473 {
474 Hive->Free(HiveData, FileSize);
475 Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
477 }
478
479 // This is a HACK!
480 /* Free our base block... it's usless in this implementation */
481 Hive->Free(BaseBlock, Hive->BaseBlockAlloc);
482
483 /* Initialize the hive directly from memory */
484 Status = HvpInitializeMemoryHive(Hive, HiveData, FileName);
485 if (!NT_SUCCESS(Status))
486 Hive->Free(HiveData, FileSize);
487
488 return Status;
489}
490
523 PHHIVE RegistryHive,
524 ULONG OperationType,
525 ULONG HiveFlags,
527 PVOID HiveData OPTIONAL,
530 PFILE_SET_SIZE_ROUTINE FileSetSize,
531 PFILE_WRITE_ROUTINE FileWrite,
532 PFILE_READ_ROUTINE FileRead,
533 PFILE_FLUSH_ROUTINE FileFlush,
534 ULONG Cluster OPTIONAL,
536{
538 PHHIVE Hive = RegistryHive;
539
540 /*
541 * Create a new hive structure that will hold all the maintenance data.
542 */
543
544 RtlZeroMemory(Hive, sizeof(HHIVE));
546
547 Hive->Allocate = Allocate;
548 Hive->Free = Free;
549 Hive->FileSetSize = FileSetSize;
550 Hive->FileWrite = FileWrite;
551 Hive->FileRead = FileRead;
552 Hive->FileFlush = FileFlush;
553
554 Hive->RefreshCount = 0;
556 Hive->Cluster = Cluster;
557 Hive->BaseBlockAlloc = sizeof(HBASE_BLOCK); // == HBLOCK_SIZE
558
559 Hive->Version = HSYS_MINOR;
560#if (NTDDI_VERSION < NTDDI_VISTA)
561 Hive->Log = (FileType == HFILE_TYPE_LOG);
562#endif
563 Hive->HiveFlags = HiveFlags & ~HIVE_NOLAZYFLUSH;
564
565 // TODO: The CellRoutines point to different callbacks
566 // depending on the OperationType.
568 Hive->ReleaseCellRoutine = NULL;
569
570 switch (OperationType)
571 {
572 case HINIT_CREATE:
574 break;
575
576 case HINIT_MEMORY:
577 Status = HvpInitializeMemoryHive(Hive, HiveData, FileName);
578 break;
579
580 case HINIT_FLAT:
581 Status = HvpInitializeFlatHive(Hive, HiveData);
582 break;
583
584 case HINIT_FILE:
585 {
586 Status = HvLoadHive(Hive, FileName);
587 if ((Status != STATUS_SUCCESS) &&
589 {
590 /* Unrecoverable failure */
591 return Status;
592 }
593
594 /* Check for previous damage */
596 break;
597 }
598
600 // Status = HvpInitializeMemoryInplaceHive(Hive, HiveData);
601 // break;
602
603 case HINIT_MAPFILE:
604
605 default:
606 /* FIXME: A better return status value is needed */
608 ASSERT(FALSE);
609 }
610
611 if (!NT_SUCCESS(Status)) return Status;
612
613 /* HACK: ROS: Init root key cell and prepare the hive */
614 // r31253
615 // if (OperationType == HINIT_CREATE) CmCreateRootNode(Hive, L"");
616 if (OperationType != HINIT_CREATE) CmPrepareHive(Hive);
617
618 return Status;
619}
620
629 PHHIVE RegistryHive)
630{
631 if (!RegistryHive->ReadOnly)
632 {
633 /* Release hive bitmap */
634 if (RegistryHive->DirtyVector.Buffer)
635 {
636 RegistryHive->Free(RegistryHive->DirtyVector.Buffer, 0);
637 }
638
639 HvpFreeHiveBins(RegistryHive);
640
641 /* Free the BaseBlock */
642 if (RegistryHive->BaseBlock)
643 {
644 RegistryHive->Free(RegistryHive->BaseBlock, RegistryHive->BaseBlockAlloc);
645 RegistryHive->BaseBlock = NULL;
646 }
647 }
648}
649
650/* EOF */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
#define CMAPI
Definition: cfgmgr32.h:41
Definition: bin.h:44
ULONG CMAPI HvpHiveHeaderChecksum(PHBASE_BLOCK HiveHeader)
Definition: hivesum.c:17
PCELL_DATA CMAPI HvpGetCellData(_In_ PHHIVE Hive, _In_ HCELL_INDEX CellIndex)
Definition: hivecell.c:77
NTSTATUS CMAPI HvpCreateHiveFreeCellList(PHHIVE Hive)
Definition: hivecell.c:306
#define TAG_CM
Definition: cmlib.h:205
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ULONG_PTR
Definition: config.h:101
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
_Must_inspect_result_ _Out_ PLARGE_INTEGER FileSize
Definition: fsrtlfuncs.h:108
union Alignment_ Alignment
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static ULONG BitmapBuffer[(XMS_BLOCKS+31)/32]
Definition: himem.c:86
BOOLEAN(CMAPI * PFILE_READ_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PULONG FileOffset, PVOID Buffer, SIZE_T BufferLength)
Definition: hivedata.h:223
#define HV_HBIN_SIGNATURE
Definition: hivedata.h:52
#define HV_HHIVE_SIGNATURE
Definition: hivedata.h:50
#define HINIT_CREATE
Definition: hivedata.h:13
@ Volatile
Definition: hivedata.h:103
@ Stable
Definition: hivedata.h:102
#define HTYPE_COUNT
Definition: hivedata.h:71
#define HBLOCK_SIZE
Definition: hivedata.h:41
#define HINIT_FILE
Definition: hivedata.h:15
#define HINIT_MEMORY
Definition: hivedata.h:14
#define HFILE_TYPE_LOG
Definition: hivedata.h:34
#define HV_HBLOCK_SIGNATURE
Definition: hivedata.h:51
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
#define HINIT_FLAT
Definition: hivedata.h:17
#define HFILE_TYPE_PRIMARY
Definition: hivedata.h:33
struct _HBASE_BLOCK HBASE_BLOCK
#define HINIT_MAPFILE
Definition: hivedata.h:18
struct _HBIN * PHBIN
#define HCELL_NIL
Definition: hivedata.h:85
#define HSYS_MINOR
Definition: hivedata.h:58
#define HSYS_MAJOR
Definition: hivedata.h:57
#define HIVE_FILENAME_MAXLEN
Definition: hivedata.h:114
BOOLEAN(CMAPI * PFILE_FLUSH_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, PLARGE_INTEGER FileOffset, ULONG Length)
Definition: hivedata.h:249
PVOID(CMAPI * PALLOCATE_ROUTINE)(SIZE_T Size, BOOLEAN Paged, ULONG Tag)
Definition: hivedata.h:210
#define HINIT_MEMORY_INPLACE
Definition: hivedata.h:16
#define HBASE_FORMAT_MEMORY
Definition: hivedata.h:66
BOOLEAN(CMAPI * PFILE_SET_SIZE_ROUTINE)(struct _HHIVE *RegistryHive, ULONG FileType, ULONG FileSize, ULONG OldfileSize)
Definition: hivedata.h:241
#define HSECTOR_SIZE
Definition: hivedata.h:42
RESULT CMAPI HvpGetHiveHeader(IN PHHIVE Hive, IN PHBASE_BLOCK *HiveBaseBlock, IN PLARGE_INTEGER TimeStamp)
Definition: hiveinit.c:377
NTSTATUS CMAPI HvpInitializeFlatHive(PHHIVE Hive, PHBASE_BLOCK ChunkBase)
Definition: hiveinit.c:344
static VOID HvpInitFileName(IN OUT PHBASE_BLOCK BaseBlock, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:124
_RESULT
Definition: hiveinit.c:366
@ HiveSuccess
Definition: hiveinit.c:370
@ NotHive
Definition: hiveinit.c:367
@ Fail
Definition: hiveinit.c:368
@ SelfHeal
Definition: hiveinit.c:373
@ RecoverData
Definition: hiveinit.c:372
@ NoMemory
Definition: hiveinit.c:369
@ RecoverHeader
Definition: hiveinit.c:371
BOOLEAN CMAPI HvpVerifyHiveHeader(IN PHBASE_BLOCK BaseBlock)
Definition: hiveinit.c:18
NTSTATUS CMAPI HvLoadHive(IN PHHIVE Hive, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:415
NTSTATUS CMAPI HvInitialize(PHHIVE RegistryHive, ULONG OperationType, ULONG HiveFlags, ULONG FileType, PVOID HiveData OPTIONAL, PALLOCATE_ROUTINE Allocate, PFREE_ROUTINE Free, PFILE_SET_SIZE_ROUTINE FileSetSize, PFILE_WRITE_ROUTINE FileWrite, PFILE_READ_ROUTINE FileRead, PFILE_FLUSH_ROUTINE FileFlush, ULONG Cluster OPTIONAL, PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:522
VOID CMAPI HvpFreeHiveBins(PHHIVE Hive)
Definition: hiveinit.c:53
NTSTATUS CMAPI HvpCreateHive(IN OUT PHHIVE RegistryHive, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:160
NTSTATUS CMAPI HvpInitializeMemoryHive(PHHIVE Hive, PHBASE_BLOCK ChunkBase, IN PCUNICODE_STRING FileName OPTIONAL)
Definition: hiveinit.c:221
enum _RESULT RESULT
static __inline PHBASE_BLOCK HvpAllocBaseBlockAligned(IN PHHIVE Hive, IN BOOLEAN Paged, IN ULONG Tag)
Definition: hiveinit.c:87
VOID CMAPI HvFree(PHHIVE RegistryHive)
Definition: hiveinit.c:628
NTSYSAPI void WINAPI RtlInitializeBitMap(PRTL_BITMAP, PULONG, ULONG)
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
#define ASSERT(a)
Definition: mode.c:44
#define ULL(a, b)
Definition: format_msg.c:27
static IStorage Storage
Definition: ole2.c:3548
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
#define STATUS_REGISTRY_RECOVERED
Definition: ntstatus.h:123
#define STATUS_NOT_REGISTRY_FILE
Definition: ntstatus.h:584
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
#define STATUS_REGISTRY_CORRUPT
Definition: ntstatus.h:568
SECURITY_INTEGER TimeStamp
Definition: sspi.h:78
VOID CMAPI CmPrepareHive(PHHIVE RegistryHive)
Definition: cminit.c:135
#define STATUS_SUCCESS
Definition: shellext.h:65
#define DPRINT
Definition: sndvol32.h:71
PULONG MinorVersion OPTIONAL
Definition: CrossNt.h:68
ULONG Length
Definition: hivedata.h:276
PHMAP_ENTRY BlockList
Definition: hivedata.h:278
ULONG BootType
Definition: hivedata.h:161
ULONG Length
Definition: hivedata.h:146
HCELL_INDEX RootCell
Definition: hivedata.h:143
ULONG Sequence1
Definition: hivedata.h:122
ULONG Minor
Definition: hivedata.h:133
ULONG Type
Definition: hivedata.h:136
ULONG Major
Definition: hivedata.h:129
LARGE_INTEGER TimeStamp
Definition: hivedata.h:126
ULONG Signature
Definition: hivedata.h:119
ULONG Format
Definition: hivedata.h:139
ULONG CheckSum
Definition: hivedata.h:158
ULONG Sequence2
Definition: hivedata.h:123
ULONG Cluster
Definition: hivedata.h:149
RTL_BITMAP DirtyVector
Definition: hivedata.h:304
PFILE_FLUSH_ROUTINE FileFlush
Definition: hivedata.h:298
PFILE_SET_SIZE_ROUTINE FileSetSize
Definition: hivedata.h:295
ULONG Signature
Definition: hivedata.h:288
ULONG HiveFlags
Definition: hivedata.h:321
PFILE_WRITE_ROUTINE FileWrite
Definition: hivedata.h:296
PALLOCATE_ROUTINE Allocate
Definition: hivedata.h:293
PFILE_READ_ROUTINE FileRead
Definition: hivedata.h:297
ULONG Cluster
Definition: hivedata.h:308
ULONG BaseBlockAlloc
Definition: hivedata.h:307
ULONG RefreshCount
Definition: hivedata.h:328
BOOLEAN Flat
Definition: hivedata.h:309
PGET_CELL_ROUTINE GetCellRoutine
Definition: hivedata.h:291
PFREE_ROUTINE Free
Definition: hivedata.h:294
DUAL Storage[HTYPE_COUNT]
Definition: hivedata.h:331
ULONG Version
Definition: hivedata.h:330
PRELEASE_CELL_ROUTINE ReleaseCellRoutine
Definition: hivedata.h:292
PHBASE_BLOCK BaseBlock
Definition: hivedata.h:303
ULONG StorageTypeCount
Definition: hivedata.h:329
BOOLEAN ReadOnly
Definition: hivedata.h:310
Definition: hivedata.h:257
ULONG_PTR BlockAddress
Definition: hivedata.h:258
ULONG_PTR BinAddress
Definition: hivedata.h:259
PULONG Buffer
Definition: typedefs.h:91
uint32_t * PULONG
Definition: typedefs.h:59
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONGLONG QuadPart
Definition: typedefs.h:114
_In_ WDFCOLLECTION _In_ ULONG Index
_Must_inspect_result_ _In_ WDFDEVICE _In_ BOOLEAN _In_opt_ PVOID Tag
Definition: wdfdevice.h:4065
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
Definition: wdfdevice.h:2741
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
_In_opt_ PALLOCATE_FUNCTION Allocate
Definition: exfuncs.h:814
_In_opt_ PALLOCATE_FUNCTION _In_opt_ PFREE_FUNCTION Free
Definition: exfuncs.h:815
_Inout_ PUCHAR _In_ PUCHAR _Out_ PUCHAR _Out_ PULONG ChunkSize
Definition: rtlfuncs.h:2277
__wchar_t WCHAR
Definition: xmlstorage.h:180