Freeloader: Check return code of RegOpenKey() in FrLdrLoadBootDrivers() for failure

svn path=/trunk/; revision=20866
This commit is contained in:
Nathan Woods 2006-01-14 21:57:07 +00:00
parent 24460a5027
commit df36b0db90

View file

@ -428,55 +428,57 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
/* open driver Key */ /* open driver Key */
rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey); rc = RegOpenKey(hServiceKey, ServiceName, &hDriverKey);
if (rc == ERROR_SUCCESS)
{
/* Read the Start Value */
ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize);
if (rc != ERROR_SUCCESS) StartValue = (ULONG)-1;
DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue));
/* Read the Start Value */ /* Read the Tag */
ValueSize = sizeof(ULONG); ValueSize = sizeof(ULONG);
rc = RegQueryValue(hDriverKey, L"Start", &ValueType, (PUCHAR)&StartValue, &ValueSize); rc = RegQueryValue(hDriverKey, L"Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
if (rc != ERROR_SUCCESS) StartValue = (ULONG)-1; if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
DbgPrint((DPRINT_REACTOS, " Start: %x \n", (int)StartValue)); DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
/* Read the Tag */ /* Read the driver's group */
ValueSize = sizeof(ULONG); DriverGroupSize = sizeof(DriverGroup);
rc = RegQueryValue(hDriverKey, L"Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize); rc = RegQueryValue(hDriverKey, L"Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1; DbgPrint((DPRINT_REACTOS, " Group: '%S' \n", DriverGroup));
DbgPrint((DPRINT_REACTOS, " Tag: %x \n", (int)TagValue));
/* Read the driver's group */ /* Make sure it should be started */
DriverGroupSize = sizeof(DriverGroup); if ((StartValue == 0) &&
rc = RegQueryValue(hDriverKey, L"Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize); (TagValue == OrderList[TagIndex]) &&
DbgPrint((DPRINT_REACTOS, " Group: '%S' \n", DriverGroup)); (_wcsicmp(DriverGroup, GroupName) == 0)) {
/* Make sure it should be started */ /* Get the Driver's Location */
if ((StartValue == 0) && ValueSize = sizeof(TempImagePath);
(TagValue == OrderList[TagIndex]) && rc = RegQueryValue(hDriverKey, L"ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
(_wcsicmp(DriverGroup, GroupName) == 0)) {
/* Get the Driver's Location */ /* Write the whole path if it suceeded, else prepare to fail */
ValueSize = sizeof(TempImagePath); if (rc != ERROR_SUCCESS) {
rc = RegQueryValue(hDriverKey, L"ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize); DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
sprintf(ImagePath, "%s\\system32\\drivers\\%S.sys", szSystemRoot, ServiceName);
} else if (TempImagePath[0] != L'\\') {
sprintf(ImagePath, "%s%S", szSystemRoot, TempImagePath);
} else {
sprintf(ImagePath, "%S", TempImagePath);
DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath));
}
DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
/* Update the position if needed */
if (nPos < 100) nPos += 5;
FrLdrLoadDriver(ImagePath, nPos);
/* Write the whole path if it suceeded, else prepare to fail */
if (rc != ERROR_SUCCESS) {
DbgPrint((DPRINT_REACTOS, " ImagePath: not found\n"));
sprintf(ImagePath, "%s\\system32\\drivers\\%S.sys", szSystemRoot, ServiceName);
} else if (TempImagePath[0] != L'\\') {
sprintf(ImagePath, "%s%S", szSystemRoot, TempImagePath);
} else { } else {
sprintf(ImagePath, "%S", TempImagePath);
DbgPrint((DPRINT_REACTOS, " ImagePath: '%s'\n", ImagePath)); DbgPrint((DPRINT_REACTOS, " 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));
} }
DbgPrint((DPRINT_REACTOS, " Loading driver: '%s'\n", ImagePath));
/* Update the position if needed */
if (nPos < 100) nPos += 5;
FrLdrLoadDriver(ImagePath, nPos);
} else {
DbgPrint((DPRINT_REACTOS, " 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));
} }
Index++; Index++;