From 3ba0c60504defe88e78e2f2b252005b5b671a548 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Sat, 28 Nov 2009 14:54:34 +0000 Subject: [PATCH] [ntoskrnl/config] - CmpFindSubKeyInName: CmpFindSubKeyInRoot is useless in finding the correct leaf with the key name that is being searched for when keys are not sorted. Loop and search each leaf of the root index for the key name. See bug #4895 for more info. svn path=/trunk/; revision=44303 --- reactos/ntoskrnl/config/cmindex.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/reactos/ntoskrnl/config/cmindex.c b/reactos/ntoskrnl/config/cmindex.c index 162263d7590..0948bd31dd4 100644 --- a/reactos/ntoskrnl/config/cmindex.c +++ b/reactos/ntoskrnl/config/cmindex.c @@ -733,6 +733,33 @@ CmpFindSubKeyByName(IN PHHIVE Hive, /* Check if this is another index root */ if (IndexRoot->Signature == CM_KEY_INDEX_ROOT) { + +#ifndef SOMEONE_WAS_NICE_ENOUGH_TO_MAKE_OUR_CELLS_LEXICALLY_SORTED + /* CmpFindSubKeyInRoot is useless for actually finding the correct leaf when keys are not sorted */ + LONG ii; + PCM_KEY_INDEX Leaf; + /* Loop through each leaf in the index root */ + for (ii=0; iiCount; ii++) + { + Leaf = HvGetCell(Hive, IndexRoot->List[ii]); + if (Leaf) + { + Found = CmpFindSubKeyInLeaf(Hive, Leaf, SearchName, &SubKey); + HvReleaseCell(Hive, IndexRoot->List[ii]); + if (Found & 0x80000000) + { + HvReleaseCell(Hive, CellToRelease); + return HCELL_NIL; + } + + if ((Found) && (SubKey != HCELL_NIL)) + { + HvReleaseCell(Hive, CellToRelease); + return SubKey; + } + } + } +#endif /* Lookup the name in the root */ Found = CmpFindSubKeyInRoot(Hive, IndexRoot,