17#if !defined(CMLIB_HOST) && !defined(_BLDR_)
26#if !defined(CMLIB_HOST) && !defined(_BLDR_)
57 BaseBlock = RegistryHive->BaseBlock;
105 ASSERT(RegistryHive->BaseBlock->Length ==
119 if (RegistryHive->BaseBlock->Sequence1 !=
120 RegistryHive->BaseBlock->Sequence2)
122 DPRINT1(
"The sequences DO NOT MATCH (Sequence1 == 0x%x, Sequence2 == 0x%x)\n",
123 RegistryHive->BaseBlock->Sequence1, RegistryHive->BaseBlock->Sequence2);
145 DPRINT1(
"Couldn't allocate buffer for base header block\n");
158 RegistryHive->BaseBlock->Sequence1++;
183 LastIndex = BlockIndex;
184 BlockIndex =
RtlFindSetBits(&RegistryHive->DirtyVector, 1, BlockIndex);
205 RegistryHive->Free(HeaderBuffer, 0);
208 DPRINT1(
"Failed to write the hive header block to log (primary sequence)\n");
218 LastIndex = BlockIndex;
219 BlockIndex =
RtlFindSetBits(&RegistryHive->DirtyVector, 1, BlockIndex);
226 Block = (
PVOID)RegistryHive->Storage[
Stable].BlockList[BlockIndex].BlockAddress;
233 DPRINT1(
"Failed to write dirty block to log (block 0x%p, block index 0x%x)\n", Block, BlockIndex);
249 DPRINT1(
"Failed to flush the log\n");
260 RegistryHive->BaseBlock->Sequence2++;
270 DPRINT1(
"Failed to write the log file (secondary sequence)\n");
278 DPRINT1(
"Failed to flush the log\n");
328 ASSERT(RegistryHive->BaseBlock->Length ==
343 if (RegistryHive->BaseBlock->Sequence1 !=
344 RegistryHive->BaseBlock->Sequence2)
346 DPRINT1(
"The sequences DO NOT MATCH (Sequence1 == 0x%x, Sequence2 == 0x%x)\n",
347 RegistryHive->BaseBlock->Sequence1, RegistryHive->BaseBlock->Sequence2);
356 RegistryHive->BaseBlock->Sequence1++;
366 DPRINT1(
"Failed to write the base block header to primary hive (primary sequence)\n");
384 LastIndex = BlockIndex;
385 BlockIndex =
RtlFindSetBits(&RegistryHive->DirtyVector, 1, BlockIndex);
393 Block = (
PVOID)RegistryHive->Storage[
Stable].BlockList[BlockIndex].BlockAddress;
401 DPRINT1(
"Failed to write hive block to primary hive file (block 0x%p, block index 0x%x)\n",
417 DPRINT1(
"Failed to flush the primary hive\n");
428 RegistryHive->BaseBlock->Sequence2++;
438 DPRINT1(
"Failed to write the base block header to primary hive (secondary sequence)\n");
446 DPRINT1(
"Failed to flush the primary hive\n");
475#if !defined(CMLIB_HOST) && !defined(_BLDR_)
491 DPRINT(
"The dirty vector has clean data, nothing to do\n");
500#if !defined(CMLIB_HOST) && !defined(_BLDR_)
503 DPRINT(
"We are sharing hives or in Live CD mode, abort syncing\n");
511 DPRINT(
"The hive is volatile (hive 0x%p)\n", RegistryHive);
515#if !defined(CMLIB_HOST) && !defined(_BLDR_)
526 if (RegistryHive->Log ==
TRUE)
530 DPRINT1(
"Failed to write a log whilst syncing the hive\n");
531#if !defined(CMLIB_HOST) && !defined(_BLDR_)
541 DPRINT1(
"Failed to write the primary hive\n");
542#if !defined(CMLIB_HOST) && !defined(_BLDR_)
549 if (RegistryHive->Alternate ==
TRUE)
553 DPRINT1(
"Failed to write the alternate hive\n");
554#if !defined(CMLIB_HOST) && !defined(_BLDR_)
563 RegistryHive->DirtyCount = 0;
565#if !defined(CMLIB_HOST) && !defined(_BLDR_)
629 DPRINT1(
"Failed to write the hive\n");
668 DPRINT1(
"Failed to write the alternate hive\n");
_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.
NTSYSAPI void WINAPI RtlClearAllBits(PRTL_BITMAP)
NTSYSAPI ULONG WINAPI RtlFindSetBits(PCRTL_BITMAP, ULONG, ULONG)
_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