Author: tkreuzer
Date: Mon Jan 13 21:18:03 2014
New Revision: 61621
URL:
http://svn.reactos.org/svn/reactos?rev=61621&view=rev
Log:
[CMLIB]
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.
Modified:
trunk/reactos/lib/cmlib/hivebin.c
trunk/reactos/lib/cmlib/hivecell.c
trunk/reactos/lib/cmlib/hiveinit.c
trunk/reactos/lib/cmlib/hivewrt.c
Modified: trunk/reactos/lib/cmlib/hivebin.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivebin.c?rev=61…
==============================================================================
--- trunk/reactos/lib/cmlib/hivebin.c [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/hivebin.c [iso-8859-1] Mon Jan 13 21:18:03 2014
@@ -98,6 +98,9 @@
RtlSetBits(&RegistryHive->DirtyVector,
Bin->FileOffset / HV_BLOCK_SIZE,
BlockCount);
+
+ /* Update size in the base block */
+ RegistryHive->BaseBlock->Length += BinSize;
}
return Bin;
Modified: trunk/reactos/lib/cmlib/hivecell.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivecell.c?rev=6…
==============================================================================
--- trunk/reactos/lib/cmlib/hivecell.c [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/hivecell.c [iso-8859-1] Mon Jan 13 21:18:03 2014
@@ -149,7 +149,7 @@
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 @@
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 @@
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)
Modified: trunk/reactos/lib/cmlib/hiveinit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hiveinit.c?rev=6…
==============================================================================
--- trunk/reactos/lib/cmlib/hiveinit.c [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/hiveinit.c [iso-8859-1] Mon Jan 13 21:18:03 2014
@@ -107,7 +107,7 @@
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 @@
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 @@
* 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 @@
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 @@
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);
Modified: trunk/reactos/lib/cmlib/hivewrt.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivewrt.c?rev=61…
==============================================================================
--- trunk/reactos/lib/cmlib/hivewrt.c [iso-8859-1] (original)
+++ trunk/reactos/lib/cmlib/hivewrt.c [iso-8859-1] Mon Jan 13 21:18:03 2014
@@ -27,6 +27,8 @@
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 @@
BOOLEAN Success;
ASSERT(RegistryHive->ReadOnly == FALSE);
+ ASSERT(RegistryHive->BaseBlock->Length ==
+ RegistryHive->Storage[Stable].Length * HV_BLOCK_SIZE);
DPRINT("HvpWriteHive called\n");