mirror of
https://github.com/reactos/reactos.git
synced 2025-03-10 18:24:02 +00:00
Sort the key indexes in CM.
svn path=/trunk/; revision=24478
This commit is contained in:
parent
ca6e7110f5
commit
7bbb81a0d4
2 changed files with 29 additions and 9 deletions
|
@ -216,6 +216,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
|
|||
int subkeyLength;
|
||||
int stringLength;
|
||||
ULONG NameSize;
|
||||
int CmpResult;
|
||||
|
||||
DbgPrint((DPRINT_REGISTRY, "KeyName '%S'\n", KeyName));
|
||||
|
||||
|
@ -261,6 +262,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
|
|||
NameSize = (subkeyLength + 1) * sizeof(WCHAR);
|
||||
|
||||
Ptr = CurrentKey->SubKeyList.Flink;
|
||||
CmpResult = 1;
|
||||
while (Ptr != &CurrentKey->SubKeyList)
|
||||
{
|
||||
DbgPrint((DPRINT_REGISTRY, "Ptr 0x%x\n", Ptr));
|
||||
|
@ -270,14 +272,16 @@ RegCreateKey(FRLDRHKEY ParentKey,
|
|||
KeyList);
|
||||
DbgPrint((DPRINT_REGISTRY, "SearchKey 0x%x\n", SearchKey));
|
||||
DbgPrint((DPRINT_REGISTRY, "Searching '%S'\n", SearchKey->Name));
|
||||
if (SearchKey->NameSize == NameSize &&
|
||||
_wcsnicmp(SearchKey->Name, name, subkeyLength) == 0)
|
||||
CmpResult = _wcsnicmp(SearchKey->Name, name, subkeyLength);
|
||||
if (CmpResult == 0 && SearchKey->NameSize == NameSize)
|
||||
break;
|
||||
else if (CmpResult == 1)
|
||||
break;
|
||||
|
||||
Ptr = Ptr->Flink;
|
||||
}
|
||||
|
||||
if (Ptr == &CurrentKey->SubKeyList)
|
||||
if (CmpResult != 0)
|
||||
{
|
||||
/* no key found -> create new subkey */
|
||||
NewKey = (FRLDRHKEY)MmAllocateMemory(sizeof(KEY));
|
||||
|
@ -294,7 +298,7 @@ RegCreateKey(FRLDRHKEY ParentKey,
|
|||
NewKey->DataSize = 0;
|
||||
NewKey->Data = NULL;
|
||||
|
||||
InsertTailList(&CurrentKey->SubKeyList, &NewKey->KeyList);
|
||||
InsertTailList(Ptr, &NewKey->KeyList);
|
||||
CurrentKey->SubKeyCount++;
|
||||
|
||||
NewKey->NameSize = NameSize;
|
||||
|
|
|
@ -145,16 +145,32 @@ CmiAddKeyToHashTable(
|
|||
IN HCELL_INDEX NKBOffset)
|
||||
{
|
||||
ULONG i = KeyCell->SubKeyCounts[StorageType];
|
||||
ULONG HashValue;
|
||||
|
||||
HashCell->Table[i].KeyOffset = NKBOffset;
|
||||
HashCell->Table[i].HashValue = 0;
|
||||
if (NewKeyCell->Flags & REG_KEY_NAME_PACKED)
|
||||
{
|
||||
RtlCopyMemory(
|
||||
&HashCell->Table[i].HashValue,
|
||||
&HashValue,
|
||||
NewKeyCell->Name,
|
||||
min(NewKeyCell->NameSize, sizeof(ULONG)));
|
||||
}
|
||||
|
||||
for (i = 0; i < KeyCell->SubKeyCounts[StorageType]; i++)
|
||||
{
|
||||
if (HashCell->Table[i].HashValue > HashValue)
|
||||
break;
|
||||
}
|
||||
|
||||
if (i < KeyCell->SubKeyCounts[StorageType])
|
||||
{
|
||||
RtlMoveMemory(HashCell->Table + i + 1,
|
||||
HashCell->Table + i,
|
||||
(HashCell->HashTableSize - 1 - i) *
|
||||
sizeof(HashCell->Table[0]));
|
||||
}
|
||||
|
||||
HashCell->Table[i].KeyOffset = NKBOffset;
|
||||
HashCell->Table[i].HashValue = HashValue;
|
||||
HvMarkCellDirty(&RegistryHive->Hive, KeyCell->SubKeyLists[StorageType]);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
@ -604,7 +620,7 @@ CmiAllocateValueCell(
|
|||
if (*VBOffset == HCELL_NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ASSERT(NameSize <= USHORT_MAX);
|
||||
|
@ -645,7 +661,7 @@ CmiAddValueKey(
|
|||
OUT PCM_KEY_VALUE *pValueCell,
|
||||
OUT HCELL_INDEX *pValueCellOffset)
|
||||
{
|
||||
PVALUE_LIST_CELL ValueListCell;
|
||||
PVALUE_LIST_CELL ValueListCell;
|
||||
PCM_KEY_VALUE NewValueCell;
|
||||
HCELL_INDEX ValueListCellOffset;
|
||||
HCELL_INDEX NewValueCellOffset;
|
||||
|
|
Loading…
Reference in a new issue