/* $Id$
- *
+ *
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/cm/regfile.c
/* LOCAL MACROS *************************************************************/
-#define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
-
#define ABS_VALUE(V) (((V) < 0) ? -(V) : (V))
BOOLEAN CmiDoVerify = FALSE;
//BinHeader->DateModified.dwHighDateTime
-
+
if (BinHeader->BinSize != REG_BLOCK_SIZE)
{
DbgPrint("BinSize is %.08x (should be a multiple of %.08x)\n",
ExFreePool(Buffer);
- ASSERTMSG(NT_SUCCESS(Status), ("Status: 0x%X\n", Status));
-
if (!NT_SUCCESS(Status))
{
return(Status);
return STATUS_REGISTRY_CORRUPT;
}
- ASSERTMSG((Bin->BinSize % REG_BLOCK_SIZE) == 0,
- ("Bin size (0x%.08x) must be multiple of 4K\n",
- Bin->BinSize));
+ ASSERTMSG("Bin size must be multiple of 4K\n",
+ (Bin->BinSize % REG_BLOCK_SIZE) == 0);
/* Allocate the hive block */
Hive->BlockList[BlockIndex].Bin = ExAllocatePool (PagedPool,
/* Duplicate Filename */
Status = RtlCreateUnicodeString(&RegistryHive->HiveFileName,
- Filename);
+ Filename);
if (!NT_SUCCESS(Status))
{
- DPRINT("RtlCreateUnicodeString() failed (Status %lx)\n", Status);
+ DPRINT("RtlpCreateUnicodeString() 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,
CmiMarkBlockDirty(RegistryHive, KeyCellOffset);
CmiMarkBlockDirty(RegistryHive, ValueListCellOffset);
}
- else if (KeyCell->NumberOfValues >=
+ else if (KeyCell->NumberOfValues >=
(((ULONG)ABS_VALUE(ValueListCell->CellSize) - sizeof(VALUE_LIST_CELL)) / sizeof(BLOCK_OFFSET)))
{
#if 0
Status = STATUS_SUCCESS;
*HashBlock = NULL;
- NewHashSize = sizeof(HASH_TABLE_CELL) +
+ NewHashSize = sizeof(HASH_TABLE_CELL) +
(SubKeyCount * sizeof(HASH_RECORD));
Status = CmiAllocateCell (RegistryHive,
NewHashSize,
else
{
PCELL_HEADER pFree = Cell;
+ PHASH_TABLE_CELL pHash = Cell;
+ LONG CellSize;
- if (pFree->CellSize < 0)
- pFree->CellSize = -pFree->CellSize;
-
- /* Clear block (except the block size) */
- RtlZeroMemory(((char*)pFree) + sizeof(ULONG),
- pFree->CellSize - sizeof(ULONG));
-
+ if (pHash->Id == REG_HASH_TABLE_CELL_ID)
+ CellSize = sizeof(HASH_TABLE_CELL) + pHash->HashTableSize * sizeof(HASH_RECORD);
+ else
+ CellSize = abs(pFree->CellSize);
+
+ /* Clear block */
+ RtlZeroMemory(pFree, CellSize);
+
+ /* restore CellSize */
+ pFree->CellSize = CellSize;
+
/* Add block to the list of free blocks */
CmiAddFree(RegistryHive, Cell, CellOffset, TRUE);
}
NewKeyCell->HashTableOffset = NewHashTableOffset;
}
+ else
+ {
+ NewHashTableCell = NULL;
+ }
/* Allocate and copy value list and values */
if (SrcKeyCell->NumberOfValues != 0)