[FREELDR]

Improve performance of registry enumeration by returning the enumerated subkey in RegEnumKey, instead of searching it by name again.

svn path=/trunk/; revision=62079
This commit is contained in:
Timo Kreuzer 2014-02-09 18:05:00 +00:00
parent a4a1fab753
commit 5a930877dd
3 changed files with 101 additions and 102 deletions

View file

@ -78,10 +78,12 @@ RegDeleteKey(FRLDRHKEY Key,
PCWSTR Name); PCWSTR Name);
LONG LONG
RegEnumKey(FRLDRHKEY Key, RegEnumKey(
ULONG Index, _In_ FRLDRHKEY Key,
PWCHAR Name, _In_ ULONG Index,
ULONG* NameSize); _Out_ PWCHAR Name,
_Inout_ ULONG* NameSize,
_Out_opt_ FRLDRHKEY *SubKey);
LONG LONG
RegOpenKey(FRLDRHKEY ParentKey, RegOpenKey(FRLDRHKEY ParentKey,

View file

@ -259,13 +259,13 @@ RegpFindSubkeyInIndex(
return NULL; return NULL;
} }
// FIXME: optionally return the subkey node/handle as optimization
LONG LONG
RegEnumKey( RegEnumKey(
_In_ FRLDRHKEY Key, _In_ FRLDRHKEY Key,
_In_ ULONG Index, _In_ ULONG Index,
_Out_ PWCHAR Name, _Out_ PWCHAR Name,
_Inout_ ULONG* NameSize) _Inout_ ULONG* NameSize,
_Out_opt_ FRLDRHKEY *SubKey)
{ {
PHHIVE Hive = &CmHive->Hive; PHHIVE Hive = &CmHive->Hive;
PCM_KEY_NODE KeyNode, SubKeyNode; PCM_KEY_NODE KeyNode, SubKeyNode;
@ -305,6 +305,11 @@ RegEnumKey(
*NameSize = CmCopyKeyName(SubKeyNode, Name, *NameSize); *NameSize = CmCopyKeyName(SubKeyNode, Name, *NameSize);
if (SubKey != NULL)
{
*SubKey = (FRLDRHKEY)SubKeyNode;
}
TRACE("RegEnumKey done -> %u, '%.*s'\n", *NameSize, *NameSize, Name); TRACE("RegEnumKey done -> %u, '%.*s'\n", *NameSize, *NameSize, Name);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }

View file

@ -537,7 +537,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
{ {
/* Get the Driver's Name */ /* Get the Driver's Name */
ValueSize = sizeof(ServiceName); ValueSize = sizeof(ServiceName);
rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize); rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize, &hDriverKey);
TRACE("RegEnumKey(): rc %d\n", (int)rc); TRACE("RegEnumKey(): rc %d\n", (int)rc);
/* Make sure it's valid, and check if we're done */ /* Make sure it's valid, and check if we're done */
@ -550,10 +550,6 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
} }
//TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName); //TRACE_CH(REACTOS, "Service %d: '%S'\n", (int)Index, ServiceName);
/* open driver Key */
rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
if (rc == ERROR_SUCCESS)
{
/* Read the Start Value */ /* Read the Start Value */
ValueSize = sizeof(ULONG); ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize); rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
@ -601,12 +597,12 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
if (!Status) if (!Status)
ERR("Failed to add boot driver\n"); ERR("Failed to add boot driver\n");
} else }
else
{ {
//TRACE(" Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current Tag %d, current group '%S')\n", //TRACE(" Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current Tag %d, current group '%S')\n",
// ServiceName, StartValue, TagValue, DriverGroup, OrderList[TagIndex], GroupName); // ServiceName, StartValue, TagValue, DriverGroup, OrderList[TagIndex], GroupName);
} }
}
Index++; Index++;
} }
@ -617,7 +613,7 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
{ {
/* Get the Driver's Name */ /* Get the Driver's Name */
ValueSize = sizeof(ServiceName); ValueSize = sizeof(ServiceName);
rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize); rc = RegEnumKey(hServiceKey, Index, ServiceName, &ValueSize, &hDriverKey);
//TRACE_CH(REACTOS, "RegEnumKey(): rc %d\n", (int)rc); //TRACE_CH(REACTOS, "RegEnumKey(): rc %d\n", (int)rc);
if (rc == ERROR_NO_MORE_ITEMS) if (rc == ERROR_NO_MORE_ITEMS)
@ -629,10 +625,6 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
} }
TRACE("Service %d: '%S'\n", (int)Index, ServiceName); TRACE("Service %d: '%S'\n", (int)Index, ServiceName);
/* open driver Key */
rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
if (rc == ERROR_SUCCESS)
{
/* Read the Start Value */ /* Read the Start Value */
ValueSize = sizeof(ULONG); ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize); rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
@ -679,12 +671,12 @@ WinLdrScanRegistry(IN OUT PLIST_ENTRY BootDriverListHead,
if (!Status) if (!Status)
ERR(" Failed to add boot driver\n"); ERR(" Failed to add boot driver\n");
} else }
else
{ {
//TRACE(" Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current group '%S')\n", //TRACE(" Skipping driver '%S' with Start %d, Tag %d and Group '%S' (Current group '%S')\n",
// ServiceName, StartValue, TagValue, DriverGroup, GroupName); // ServiceName, StartValue, TagValue, DriverGroup, GroupName);
} }
}
Index++; Index++;
} }