Author: navaraf
Date: Tue Oct 10 03:43:06 2006
New Revision: 24478
URL:
http://svn.reactos.org/svn/reactos?rev=24478&view=rev
Log:
Sort the key indexes in CM.
Modified:
trunk/reactos/boot/freeldr/freeldr/reactos/registry.c
trunk/reactos/tools/mkhive/cmi.c
Modified: trunk/reactos/boot/freeldr/freeldr/reactos/registry.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/freeldr/freeldr/react…
==============================================================================
--- trunk/reactos/boot/freeldr/freeldr/reactos/registry.c (original)
+++ trunk/reactos/boot/freeldr/freeldr/reactos/registry.c Tue Oct 10 03:43:06 2006
@@ -216,6 +216,7 @@
int subkeyLength;
int stringLength;
ULONG NameSize;
+ int CmpResult;
DbgPrint((DPRINT_REGISTRY, "KeyName '%S'\n", KeyName));
@@ -261,6 +262,7 @@
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 @@
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 @@
NewKey->DataSize = 0;
NewKey->Data = NULL;
- InsertTailList(&CurrentKey->SubKeyList, &NewKey->KeyList);
+ InsertTailList(Ptr, &NewKey->KeyList);
CurrentKey->SubKeyCount++;
NewKey->NameSize = NameSize;
Modified: trunk/reactos/tools/mkhive/cmi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/tools/mkhive/cmi.c?rev=244…
==============================================================================
--- trunk/reactos/tools/mkhive/cmi.c (original)
+++ trunk/reactos/tools/mkhive/cmi.c Tue Oct 10 03:43:06 2006
@@ -145,16 +145,32 @@
IN HCELL_INDEX NKBOffset)
{
ULONG i = KeyCell->SubKeyCounts[StorageType];
-
- HashCell->Table[i].KeyOffset = NKBOffset;
- HashCell->Table[i].HashValue = 0;
+ ULONG HashValue;
+
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 @@
if (*VBOffset == HCELL_NULL)
{
Status = STATUS_INSUFFICIENT_RESOURCES;
- }
+ }
else
{
ASSERT(NameSize <= USHORT_MAX);
@@ -645,7 +661,7 @@
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;