Header->UpdateCounter2 = 0;
Header->DateModified.u.LowPart = 0;
Header->DateModified.u.HighPart = 0;
- Header->Unused3 = 1;
- Header->Unused4 = 3;
- Header->Unused5 = 0;
- Header->Unused6 = 1;
+ Header->MajorVersion = 1;
+ Header->MinorVersion = 3;
+ Header->Type = 0;
+ Header->Format = 1;
Header->Unused7 = 1;
Header->RootKeyOffset = (BLOCK_OFFSET)-1;
Header->BlockSize = REG_BLOCK_SIZE;
- Header->Unused6 = 1;
Header->Checksum = 0;
}
ASSERT(Header->BlockId == REG_HIVE_ID);
}
- if (Header->Unused3 != 1)
+ if (Header->MajorVersion != 1)
{
- DbgPrint("Unused3 is %.08x (must be 1)\n",
- Header->Unused3);
- ASSERT(Header->Unused3 == 1);
+ DbgPrint("MajorVersion is %.08x (must be 1)\n",
+ Header->MajorVersion);
+ ASSERT(Header->MajorVersion == 1);
}
- if (Header->Unused4 != 3)
+ if (Header->MinorVersion != 3)
{
- DbgPrint("Unused4 is %.08x (must be 3)\n",
- Header->Unused4);
- ASSERT(Header->Unused4 == 3);
+ DbgPrint("MinorVersion is %.08x (must be 3)\n",
+ Header->MajorVersion);
+ ASSERT(Header->MajorVersion == 3);
}
- if (Header->Unused5 != 0)
+ if (Header->Type != 0)
{
- DbgPrint("Unused5 is %.08x (must be 0)\n",
- Header->Unused5);
- ASSERT(Header->Unused5 == 0);
+ DbgPrint("Type is %.08x (must be 0)\n",
+ Header->Type);
+ ASSERT(Header->Type == 0);
}
- if (Header->Unused6 != 1)
+ if (Header->Format != 1)
{
- DbgPrint("Unused6 is %.08x (must be 1)\n",
- Header->Unused6);
- ASSERT(Header->Unused6 == 1);
+ DbgPrint("Format is %.08x (must be 1)\n",
+ Header->Format);
+ ASSERT(Header->Format == 1);
}
if (Header->Unused7 != 1)
RegistryHive, Filename);
/* Duplicate Filename */
- Status = RtlpCreateUnicodeString(&RegistryHive->HiveFileName,
- Filename, NonPagedPool);
+ Status = RtlCreateUnicodeString(&RegistryHive->HiveFileName,
+ Filename);
if (!NT_SUCCESS(Status))
{
- DPRINT("RtlpCreateUnicodeString() failed (Status %lx)\n", Status);
+ DPRINT("RtlCreateUnicodeString() failed (Status %lx)\n", Status);
return(Status);
}
/* Create log file name */
RegistryHive->LogFileName.Length = (wcslen(Filename) + 4) * sizeof(WCHAR);
RegistryHive->LogFileName.MaximumLength = RegistryHive->LogFileName.Length + sizeof(WCHAR);
- RegistryHive->LogFileName.Buffer = ExAllocatePool(NonPagedPool,
- RegistryHive->LogFileName.MaximumLength);
+ RegistryHive->LogFileName.Buffer = ExAllocatePoolWithTag(PagedPool,
+ RegistryHive->LogFileName.MaximumLength,
+ TAG('U', 'S', 'T', 'R'));
if (RegistryHive->LogFileName.Buffer == NULL)
{
RtlFreeUnicodeString(&RegistryHive->HiveFileName);
RtlZeroMemory (Hive,
sizeof(REGISTRY_HIVE));
- DPRINT("Hive %x\n", Hive);
+ DPRINT("Hive 0x%p\n", Hive);
Hive->HiveHeader = (PHIVE_HEADER)ExAllocatePool (NonPagedPool,
sizeof(HIVE_HEADER));
RtlZeroMemory (Hive,
sizeof(REGISTRY_HIVE));
- DPRINT ("Hive %x\n", Hive);
+ DPRINT ("Hive 0x%p\n", Hive);
Hive->HiveHeader = (PHIVE_HEADER)ExAllocatePool (NonPagedPool,
REG_BLOCK_SIZE);
RtlZeroMemory (Hive->HiveHeader,
REG_BLOCK_SIZE);
- DPRINT ("HiveHeader %x\n", Hive->HiveHeader);
+ DPRINT ("HiveHeader 0x%p\n", Hive->HiveHeader);
Hive->Flags = HIVE_NO_FILE;
RtlZeroMemory (Hive,
sizeof(REGISTRY_HIVE));
- DPRINT ("Hive %x\n", Hive);
+ DPRINT ("Hive 0x%p\n", Hive);
Hive->Flags = (Flags & REG_NO_LAZY_FLUSH) ? HIVE_NO_SYNCH : 0;
Hive->HiveHeader = (PHIVE_HEADER)ExAllocatePool(NonPagedPool,
PHBIN tmpBin;
ULONG BinSize;
ULONG i;
+ ULONG BitmapSize;
DPRINT ("CmiAddBin (BlockCount %lu)\n", BlockCount);
tmpBin->BinOffset = RegistryHive->FileSize - REG_BLOCK_SIZE;
RegistryHive->FileSize += BinSize;
tmpBin->BinSize = BinSize;
- tmpBin->Unused1 = 0;
KeQuerySystemTime(&tmpBin->DateModified);
- tmpBin->Unused2 = 0;
+ tmpBin->MemAlloc = 0;
DPRINT (" BinOffset %lx BinSize %lx\n", tmpBin->BinOffset,tmpBin->BinSize);
tmpBlock = (PCELL_HEADER)((ULONG_PTR) tmpBin + REG_HBIN_DATA_OFFSET);
tmpBlock->CellSize = (BinSize - REG_HBIN_DATA_OFFSET);
+ /* Calculate bitmap size in bytes (always a multiple of 32 bits) */
+ BitmapSize = ROUND_UP(RegistryHive->BlockListSize, sizeof(ULONG) * 8) / 8;
+
/* Grow bitmap if necessary */
- if (IsNoFileHive(RegistryHive) &&
- (RegistryHive->BlockListSize % (sizeof(ULONG) * 8) == 0))
+ if (!IsNoFileHive(RegistryHive) &&
+ BitmapSize > RegistryHive->DirtyBitMap.SizeOfBitMap / 8)
{
PULONG BitmapBuffer;
- ULONG BitmapSize;
DPRINT("Grow hive bitmap\n");
- /* Calculate bitmap size in bytes (always a multiple of 32 bits) */
- BitmapSize = ROUND_UP(RegistryHive->BlockListSize, sizeof(ULONG) * 8) / 8;
DPRINT("RegistryHive->BlockListSize: %lu\n", RegistryHive->BlockListSize);
DPRINT("BitmapSize: %lu Bytes %lu Bits\n", BitmapSize, BitmapSize * 8);
BitmapBuffer = (PULONG)ExAllocatePool(PagedPool,
RtlZeroMemory(BitmapBuffer, BitmapSize);
RtlCopyMemory(BitmapBuffer,
RegistryHive->DirtyBitMap.Buffer,
- RegistryHive->DirtyBitMap.SizeOfBitMap);
+ RegistryHive->DirtyBitMap.SizeOfBitMap / 8);
ExFreePool(RegistryHive->BitmapBuffer);
RegistryHive->BitmapBuffer = BitmapBuffer;
RtlInitializeBitMap(&RegistryHive->DirtyBitMap,
}
NewKeyCell->HashTableOffset = NewHashTableOffset;
}
+ else
+ {
+ NewHashTableCell = NULL;
+ }
/* Allocate and copy value list and values */
if (SrcKeyCell->NumberOfValues != 0)