17#if !defined(CMLIB_HOST) && !defined(_BLDR_)
53 BaseBlock = RegistryHive->BaseBlock;
100 ASSERT(!RegistryHive->ReadOnly);
101 ASSERT(RegistryHive->BaseBlock->Length ==
114 if (RegistryHive->BaseBlock->Sequence1 !=
115 RegistryHive->BaseBlock->Sequence2)
117 DPRINT1(
"The sequences DO NOT MATCH (Sequence1 == 0x%x, Sequence2 == 0x%x)\n",
118 RegistryHive->BaseBlock->Sequence1, RegistryHive->BaseBlock->Sequence2);
140 DPRINT1(
"Couldn't allocate buffer for base header block\n");
153 RegistryHive->BaseBlock->Sequence1++;
178 LastIndex = BlockIndex;
179 BlockIndex =
RtlFindSetBits(&RegistryHive->DirtyVector, 1, BlockIndex);
200 RegistryHive->Free(HeaderBuffer, 0);
203 DPRINT1(
"Failed to write the hive header block to log (primary sequence)\n");
213 LastIndex = BlockIndex;
214 BlockIndex =
RtlFindSetBits(&RegistryHive->DirtyVector, 1, BlockIndex);
221 Block = (
PVOID)RegistryHive->Storage[
Stable].BlockList[BlockIndex].BlockAddress;
228 DPRINT1(
"Failed to write dirty block to log (block 0x%p, block index 0x%x)\n", Block, BlockIndex);
244 DPRINT1(
"Failed to flush the log\n");
255 RegistryHive->BaseBlock->Sequence2++;
265 DPRINT1(
"Failed to write the log file (secondary sequence)\n");
273 DPRINT1(
"Failed to flush the log\n");
322 ASSERT(!RegistryHive->ReadOnly);
323 ASSERT(RegistryHive->BaseBlock->Length ==
337 if (RegistryHive->BaseBlock->Sequence1 !=
338 RegistryHive->BaseBlock->Sequence2)
340 DPRINT1(
"The sequences DO NOT MATCH (Sequence1 == 0x%x, Sequence2 == 0x%x)\n",
341 RegistryHive->BaseBlock->Sequence1, RegistryHive->BaseBlock->Sequence2);
350 RegistryHive->BaseBlock->Sequence1++;
360 DPRINT1(
"Failed to write the base block header to primary hive (primary sequence)\n");
378 LastIndex = BlockIndex;
379 BlockIndex =
RtlFindSetBits(&RegistryHive->DirtyVector, 1, BlockIndex);
387 Block = (
PVOID)RegistryHive->Storage[
Stable].BlockList[BlockIndex].BlockAddress;
395 DPRINT1(
"Failed to write hive block to primary hive file (block 0x%p, block index 0x%x)\n",
411 DPRINT1(
"Failed to flush the primary hive\n");
422 RegistryHive->BaseBlock->Sequence2++;
432 DPRINT1(
"Failed to write the base block header to primary hive (secondary sequence)\n");
440 DPRINT1(
"Failed to flush the primary hive\n");
469#if !defined(CMLIB_HOST) && !defined(_BLDR_)
473 ASSERT(!RegistryHive->ReadOnly);
479 DPRINT(
"Hive 0x%p is volatile\n", RegistryHive);
492 DPRINT(
"The dirty vector has clean data, nothing to do\n");
496#if !defined(CMLIB_HOST) && !defined(_BLDR_)
507 if (RegistryHive->Log)
511 DPRINT1(
"Failed to write a log whilst syncing the hive\n");
512#if !defined(CMLIB_HOST) && !defined(_BLDR_)
522 DPRINT1(
"Failed to write the primary hive\n");
523#if !defined(CMLIB_HOST) && !defined(_BLDR_)
530 if (RegistryHive->Alternate)
534 DPRINT1(
"Failed to write the alternate hive\n");
535#if !defined(CMLIB_HOST) && !defined(_BLDR_)
544 RegistryHive->DirtyCount = 0;
546#if !defined(CMLIB_HOST) && !defined(_BLDR_)
599 ASSERT(!RegistryHive->ReadOnly);
610 DPRINT1(
"Failed to write the hive\n");
637 ASSERT(!RegistryHive->ReadOnly);
639 ASSERT(RegistryHive->Alternate);
649 DPRINT1(
"Failed to write the alternate hive\n");
675 ASSERT(!RegistryHive->ReadOnly);
_In_ PFCB _In_ LONGLONG FileOffset
ULONG CMAPI HvpHiveHeaderChecksum(PHBASE_BLOCK HiveHeader)
#define KeQuerySystemTime(t)
#define ROUND_UP(n, align)
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
#define HV_HHIVE_SIGNATURE
#define HV_LOG_HEADER_SIZE
#define HFILE_TYPE_ALTERNATE
#define HV_HBLOCK_SIGNATURE
#define HFILE_TYPE_PRIMARY
#define HV_LOG_DIRTY_BLOCK
#define HBASE_FORMAT_MEMORY
#define HV_LOG_DIRTY_SIGNATURE
BOOLEAN CMAPI HvSyncHive(_In_ PHHIVE RegistryHive)
Synchronizes a registry hive with latest updates from dirty data present in volatile memory,...
static BOOLEAN CMAPI HvpWriteHive(_In_ PHHIVE RegistryHive, _In_ BOOLEAN OnlyDirty, _In_ ULONG FileType)
Writes data (dirty or non) to a primary hive during syncing operation. Hive writing is also performed...
BOOLEAN CMAPI HvSyncHiveFromRecover(_In_ PHHIVE RegistryHive)
Synchronizes a hive with recovered data during a healing/resuscitation operation of the registry.
BOOLEAN CMAPI HvWriteHive(_In_ PHHIVE RegistryHive)
Writes data to a registry hive. Unlike HvSyncHive, this function just writes the wholy registry data ...
BOOLEAN CMAPI HvHiveWillShrink(_In_ PHHIVE RegistryHive)
Determines whether a registry hive needs to be shrinked or not based on its overall size of the hive ...
BOOLEAN NTAPI IoSetThreadHardErrorMode(_In_ BOOLEAN HardErrorEnabled)
static BOOLEAN CMAPI HvpWriteLog(_In_ PHHIVE RegistryHive)
Writes dirty data in a transacted way to a hive log file during hive syncing operation....
BOOLEAN CMAPI HvWriteAlternateHive(_In_ PHHIVE RegistryHive)
Writes data to an alternate registry hive. An alternate hive is usually backed up by a primary hive....
static VOID HvpValidateBaseHeader(_In_ PHHIVE RegistryHive)
Validates the base block header of a primary hive for consistency.
_In_ ULONG _In_ ULONG _In_ ULONG Length
#define UNIMPLEMENTED_ONCE
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
_In_ WDFDEVICE _In_ WDF_SPECIAL_FILE_TYPE FileType
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize