[CMLIB][NTOS:CONFIG]

- The BaseBlock->Length member is really the size in bytes of the full hive, minus the header (base) block size.
- Remove the last remnents of the "hack of doom" aka. the one similar in magnitude to the US national debt, addendum to r61621 and r26712. The FileSize can be computed with BaseBlock->Length.

svn path=/trunk/; revision=70565
This commit is contained in:
Hermès Bélusca-Maïto 2016-01-10 02:16:39 +00:00
parent a5ed535978
commit 1dba309628
3 changed files with 8 additions and 26 deletions

View file

@ -113,10 +113,8 @@ typedef struct _HBASE_BLOCK
/* Hive identifier "regf" (0x66676572) */
ULONG Signature;
/* Update counter */
/* Update counters */
ULONG Sequence1;
/* Update counter */
ULONG Sequence2;
/* When this hive file was last modified */
@ -139,7 +137,7 @@ typedef struct _HBASE_BLOCK
If the hive is volatile, this is the actual pointer to the CM_KEY_NODE */
HCELL_INDEX RootCell;
/* Size of each hive block ? */
/* Size in bytes of the full hive, minus the header */
ULONG Length;
/* (1?) */

View file

@ -353,14 +353,14 @@ HvpGetHiveHeader(IN PHHIVE Hive,
}
NTSTATUS CMAPI
HvLoadHive(IN PHHIVE Hive,
IN ULONG FileSize)
HvLoadHive(IN PHHIVE Hive)
{
PHBASE_BLOCK BaseBlock = NULL;
ULONG Result;
LARGE_INTEGER TimeStamp;
ULONG Offset = 0;
PVOID HiveData;
ULONG FileSize;
/* Get the hive header */
Result = HvpGetHiveHeader(Hive, &BaseBlock, &TimeStamp);
@ -394,6 +394,7 @@ HvLoadHive(IN PHHIVE Hive,
Hive->Version = Hive->BaseBlock->Minor;
/* Allocate a buffer large enough to hold the hive */
FileSize = HBLOCK_SIZE + BaseBlock->Length;
HiveData = Hive->Allocate(FileSize, TRUE, TAG_CM);
if (!HiveData) return STATUS_INSUFFICIENT_RESOURCES;
@ -405,7 +406,7 @@ HvLoadHive(IN PHHIVE Hive,
FileSize);
if (!Result) return STATUS_NOT_REGISTRY_FILE;
// This is a HACK!
/* Free our base block... it's usless in this implementation */
Hive->Free(BaseBlock, 0);
@ -480,7 +481,7 @@ HvInitialize(
Hive->StorageTypeCount = HTYPE_COUNT;
Hive->Cluster = 1;
Hive->Version = HSYS_MINOR;
Hive->HiveFlags = HiveFlags &~ HIVE_NOLAZYFLUSH;
Hive->HiveFlags = HiveFlags & ~HIVE_NOLAZYFLUSH;
switch (OperationType)
{
@ -498,8 +499,7 @@ HvInitialize(
case HINIT_FILE:
{
/* HACK of doom: Cluster is actually the file size. */
Status = HvLoadHive(Hive, Cluster);
Status = HvLoadHive(Hive);
if ((Status != STATUS_SUCCESS) &&
(Status != STATUS_REGISTRY_RECOVERED))
{

View file

@ -28,7 +28,6 @@ CmpInitializeHive(OUT PCMHIVE *CmHive,
IN ULONG CheckFlags)
{
PCMHIVE Hive;
FILE_STANDARD_INFORMATION FileInformation;
IO_STATUS_BLOCK IoStatusBlock;
FILE_FS_SIZE_INFORMATION FileSizeInformation;
NTSTATUS Status;
@ -169,21 +168,6 @@ CmpInitializeHive(OUT PCMHIVE *CmHive,
Hive->Flags = 0;
Hive->FlushCount = 0;
/* Set flags */
Hive->Flags = HiveFlags;
/* Check if this is a primary */
if (Primary)
{
/* Check how large the file is */
ZwQueryInformationFile(Primary,
&IoStatusBlock,
&FileInformation,
sizeof(FileInformation),
FileStandardInformation);
Cluster = FileInformation.EndOfFile.LowPart;
}
/* Initialize it */
Status = HvInitialize(&Hive->Hive,
OperationType,