Pay back the US National Debt.
... well not entirely, but at least remove the "hack similar in magnitude to the US's National Debt"! As a nice side effect we can now load Windows 2003 hive files.

svn path=/trunk/; revision=61621
This commit is contained in:
Timo Kreuzer 2014-01-13 21:18:03 +00:00
parent e9741e1328
commit 2a380017c9
4 changed files with 15 additions and 23 deletions

View file

@ -98,6 +98,9 @@ HvpAddBin(
RtlSetBits(&RegistryHive->DirtyVector,
Bin->FileOffset / HV_BLOCK_SIZE,
BlockCount);
/* Update size in the base block */
RegistryHive->BaseBlock->Length += BinSize;
}
return Bin;

View file

@ -149,7 +149,7 @@ HvpComputeFreeListIndex(
ULONG Size)
{
ULONG Index;
static CCHAR FindFirstSet[256] = {
static CCHAR FindFirstSet[128] = {
0, 0, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
@ -157,23 +157,16 @@ HvpComputeFreeListIndex(
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7};
6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6};
ASSERT(Size >= (1 << 3));
Index = (Size >> 3) - 1;
if (Index >= 16)
{
if (Index > 255)
if (Index > 127)
Index = 23;
else
Index = FindFirstSet[Index] + 7;
Index = FindFirstSet[Index] + 16;
}
return Index;
@ -301,7 +294,7 @@ HvpCreateHiveFreeCellList(
Hive->Storage[Stable].FreeDisplay[Index] = HCELL_NIL;
Hive->Storage[Volatile].FreeDisplay[Index] = HCELL_NIL;
}
//__debugbreak();
BlockOffset = 0;
BlockIndex = 0;
while (BlockIndex < Hive->Storage[Stable].Length)

View file

@ -107,7 +107,7 @@ HvpCreateHive(
BaseBlock->Format = HBASE_FORMAT_MEMORY;
BaseBlock->Cluster = 1;
BaseBlock->RootCell = HCELL_NIL;
BaseBlock->Length = HV_BLOCK_SIZE;
BaseBlock->Length = 0;
BaseBlock->Sequence1 = 1;
BaseBlock->Sequence2 = 1;
/* FIXME: Fill in the file name */
@ -145,11 +145,7 @@ HvpInitializeMemoryHive(
PULONG BitmapBuffer;
SIZE_T ChunkSize;
//
// This hack is similar in magnitude to the US's National Debt
//
ChunkSize = ((PHBASE_BLOCK)ChunkBase)->Length;
((PHBASE_BLOCK)ChunkBase)->Length = HV_BLOCK_SIZE;
DPRINT("ChunkSize: %lx\n", ChunkSize);
if (ChunkSize < sizeof(HBASE_BLOCK) ||
@ -172,7 +168,7 @@ HvpInitializeMemoryHive(
* we go.
*/
Hive->Storage[Stable].Length = (ULONG)(ChunkSize / HV_BLOCK_SIZE) - 1;
Hive->Storage[Stable].Length = (ULONG)(ChunkSize / HV_BLOCK_SIZE);
Hive->Storage[Stable].BlockList =
Hive->Allocate(Hive->Storage[Stable].Length *
sizeof(HMAP_ENTRY), FALSE, TAG_CM);
@ -305,8 +301,6 @@ HvpGetHiveHeader(IN PHHIVE Hive,
Hive->Free(BaseBlock, 0);
BaseBlock = Hive->Allocate(PAGE_SIZE, TRUE, TAG_CM);
if (!BaseBlock) return NoMemory;
//BaseBlock->Length = PAGE_SIZE; ??
}
/* Clear it */
@ -384,8 +378,6 @@ HvLoadHive(IN PHHIVE Hive,
FileSize);
if (!Result) return STATUS_NOT_REGISTRY_FILE;
/* Apply "US National Debt" hack */
((PHBASE_BLOCK)HiveData)->Length = FileSize;
/* Free our base block... it's usless in this implementation */
Hive->Free(BaseBlock, 0);

View file

@ -27,6 +27,8 @@ HvpWriteLog(
return TRUE;
ASSERT(RegistryHive->ReadOnly == FALSE);
ASSERT(RegistryHive->BaseBlock->Length ==
RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
DPRINT("HvpWriteLog called\n");
@ -150,6 +152,8 @@ HvpWriteHive(
BOOLEAN Success;
ASSERT(RegistryHive->ReadOnly == FALSE);
ASSERT(RegistryHive->BaseBlock->Length ==
RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
DPRINT("HvpWriteHive called\n");