mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
Fix hash table generating.
svn path=/trunk/; revision=32180
This commit is contained in:
parent
ac30a263d8
commit
f5d676df0d
1 changed files with 12 additions and 17 deletions
|
@ -151,13 +151,12 @@ static NTSTATUS
|
||||||
CmiAddKeyToHashTable(
|
CmiAddKeyToHashTable(
|
||||||
IN PCMHIVE RegistryHive,
|
IN PCMHIVE RegistryHive,
|
||||||
IN OUT PCM_KEY_FAST_INDEX HashCell,
|
IN OUT PCM_KEY_FAST_INDEX HashCell,
|
||||||
IN PCM_KEY_NODE KeyCell,
|
IN HCELL_INDEX HashCellIndex,
|
||||||
IN HSTORAGE_TYPE StorageType,
|
|
||||||
IN PCM_KEY_NODE NewKeyCell,
|
IN PCM_KEY_NODE NewKeyCell,
|
||||||
IN HCELL_INDEX NKBOffset)
|
IN HCELL_INDEX NKBOffset)
|
||||||
{
|
{
|
||||||
ULONG i = KeyCell->SubKeyCounts[StorageType];
|
ULONG i;
|
||||||
ULONG HashKey;
|
ULONG HashKey = 0;
|
||||||
|
|
||||||
if (NewKeyCell->Flags & KEY_COMP_NAME)
|
if (NewKeyCell->Flags & KEY_COMP_NAME)
|
||||||
{
|
{
|
||||||
|
@ -167,13 +166,13 @@ CmiAddKeyToHashTable(
|
||||||
min(NewKeyCell->NameLength, sizeof(ULONG)));
|
min(NewKeyCell->NameLength, sizeof(ULONG)));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < KeyCell->SubKeyCounts[StorageType]; i++)
|
for (i = 0; i < HashCell->Count; i++)
|
||||||
{
|
{
|
||||||
if (HashCell->List[i].HashKey > HashKey)
|
if (HashCell->List[i].HashKey > HashKey)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < KeyCell->SubKeyCounts[StorageType])
|
if (i < HashCell->Count)
|
||||||
{
|
{
|
||||||
RtlMoveMemory(HashCell->List + i + 1,
|
RtlMoveMemory(HashCell->List + i + 1,
|
||||||
HashCell->List + i,
|
HashCell->List + i,
|
||||||
|
@ -183,7 +182,8 @@ CmiAddKeyToHashTable(
|
||||||
|
|
||||||
HashCell->List[i].Cell = NKBOffset;
|
HashCell->List[i].Cell = NKBOffset;
|
||||||
HashCell->List[i].HashKey = HashKey;
|
HashCell->List[i].HashKey = HashKey;
|
||||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCell->SubKeyLists[StorageType], FALSE);
|
HashCell->Count++;
|
||||||
|
HvMarkCellDirty(&RegistryHive->Hive, HashCellIndex, FALSE);
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -211,10 +211,9 @@ CmiAllocateHashTableCell (
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(SubKeyCount <= USHORT_MAX);
|
|
||||||
NewHashBlock = (PCM_KEY_FAST_INDEX)HvGetCell (&RegistryHive->Hive, *HBOffset);
|
NewHashBlock = (PCM_KEY_FAST_INDEX)HvGetCell (&RegistryHive->Hive, *HBOffset);
|
||||||
NewHashBlock->Signature = CM_KEY_FAST_LEAF;
|
NewHashBlock->Signature = CM_KEY_FAST_LEAF;
|
||||||
NewHashBlock->Count = SubKeyCount;
|
NewHashBlock->Count = 0;
|
||||||
*HashBlock = NewHashBlock;
|
*HashBlock = NewHashBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +352,8 @@ CmiAddSubKey(
|
||||||
ParentKeyCell->SubKeyLists[Storage]);
|
ParentKeyCell->SubKeyLists[Storage]);
|
||||||
ASSERT(HashBlock->Signature == CM_KEY_FAST_LEAF);
|
ASSERT(HashBlock->Signature == CM_KEY_FAST_LEAF);
|
||||||
|
|
||||||
if (((ParentKeyCell->SubKeyCounts[Storage] + 1) >= HashBlock->Count))
|
if (HashBlock->Count ==
|
||||||
|
((HvGetCellSize(&RegistryHive->Hive, HashBlock) - FIELD_OFFSET(CM_KEY_FAST_INDEX, List)) / sizeof(CM_INDEX)))
|
||||||
{
|
{
|
||||||
PCM_KEY_FAST_INDEX NewHashBlock;
|
PCM_KEY_FAST_INDEX NewHashBlock;
|
||||||
HCELL_INDEX HTOffset;
|
HCELL_INDEX HTOffset;
|
||||||
|
@ -370,14 +370,11 @@ CmiAddSubKey(
|
||||||
{
|
{
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
RtlZeroMemory(
|
|
||||||
&NewHashBlock->List[0],
|
|
||||||
sizeof(NewHashBlock->List[0]) * NewHashBlock->Count);
|
|
||||||
RtlCopyMemory(
|
RtlCopyMemory(
|
||||||
&NewHashBlock->List[0],
|
&NewHashBlock->List[0],
|
||||||
&HashBlock->List[0],
|
&HashBlock->List[0],
|
||||||
sizeof(NewHashBlock->List[0]) * HashBlock->Count);
|
sizeof(NewHashBlock->List[0]) * HashBlock->Count);
|
||||||
|
NewHashBlock->Count = HashBlock->Count;
|
||||||
HvFreeCell (&RegistryHive->Hive, ParentKeyCell->SubKeyLists[Storage]);
|
HvFreeCell (&RegistryHive->Hive, ParentKeyCell->SubKeyLists[Storage]);
|
||||||
ParentKeyCell->SubKeyLists[Storage] = HTOffset;
|
ParentKeyCell->SubKeyLists[Storage] = HTOffset;
|
||||||
HashBlock = NewHashBlock;
|
HashBlock = NewHashBlock;
|
||||||
|
@ -387,8 +384,7 @@ CmiAddSubKey(
|
||||||
Status = CmiAddKeyToHashTable(
|
Status = CmiAddKeyToHashTable(
|
||||||
RegistryHive,
|
RegistryHive,
|
||||||
HashBlock,
|
HashBlock,
|
||||||
ParentKeyCell,
|
ParentKeyCell->SubKeyLists[Storage],
|
||||||
Storage,
|
|
||||||
NewKeyCell,
|
NewKeyCell,
|
||||||
NKBOffset);
|
NKBOffset);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
|
@ -635,7 +631,6 @@ CmiAllocateValueCell(
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
ASSERT(NameLength <= USHORT_MAX);
|
|
||||||
NewValueCell = (PCM_KEY_VALUE)HvGetCell (&RegistryHive->Hive, *VBOffset);
|
NewValueCell = (PCM_KEY_VALUE)HvGetCell (&RegistryHive->Hive, *VBOffset);
|
||||||
NewValueCell->Signature = CM_KEY_VALUE_SIGNATURE;
|
NewValueCell->Signature = CM_KEY_VALUE_SIGNATURE;
|
||||||
NewValueCell->NameLength = (USHORT)NameLength;
|
NewValueCell->NameLength = (USHORT)NameLength;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue