Freeloader: Check return code of RegOpenKey() in FrLdrLoadBootDrivers() for failure
authorNathan Woods <npwoods@mess.org>
Sat, 14 Jan 2006 21:57:07 +0000 (21:57 +0000)
committerNathan Woods <npwoods@mess.org>
Sat, 14 Jan 2006 21:57:07 +0000 (21:57 +0000)
svn path=/trunk/; revision=20866

reactos/boot/freeldr/freeldr/reactos/reactos.c

index 6e18711..30e06bb 100644 (file)
@@ -428,55 +428,57 @@ FrLdrLoadBootDrivers(PCHAR szSystemRoot,
 
                 /* open driver Key */
                 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 Tag */
+                    ValueSize = sizeof(ULONG);
+                    rc = RegQueryValue(hDriverKey, L"Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
+                    if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
+                    DbgPrint((DPRINT_REACTOS, "  Tag:   %x  \n", (int)TagValue));
+
+                    /* Read the driver's group */
+                    DriverGroupSize = sizeof(DriverGroup);
+                    rc = RegQueryValue(hDriverKey, L"Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
+                    DbgPrint((DPRINT_REACTOS, "  Group: '%S'  \n", DriverGroup));
+
+                    /* Make sure it should be started */
+                    if ((StartValue == 0) &&
+                        (TagValue == OrderList[TagIndex]) &&
+                        (_wcsicmp(DriverGroup, GroupName) == 0)) {
+
+                        /* Get the Driver's Location */
+                        ValueSize = sizeof(TempImagePath);
+                        rc = RegQueryValue(hDriverKey, L"ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
+
+                        /* 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 {
+                            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);
 
-                /* 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 Tag */
-                ValueSize = sizeof(ULONG);
-                rc = RegQueryValue(hDriverKey, L"Tag", &ValueType, (PUCHAR)&TagValue, &ValueSize);
-                if (rc != ERROR_SUCCESS) TagValue = (ULONG)-1;
-                DbgPrint((DPRINT_REACTOS, "  Tag:   %x  \n", (int)TagValue));
-
-                /* Read the driver's group */
-                DriverGroupSize = sizeof(DriverGroup);
-                rc = RegQueryValue(hDriverKey, L"Group", NULL, (PUCHAR)DriverGroup, &DriverGroupSize);
-                DbgPrint((DPRINT_REACTOS, "  Group: '%S'  \n", DriverGroup));
-
-                /* Make sure it should be started */
-                if ((StartValue == 0) &&
-                    (TagValue == OrderList[TagIndex]) &&
-                    (_wcsicmp(DriverGroup, GroupName) == 0)) {
-
-                    /* Get the Driver's Location */
-                    ValueSize = sizeof(TempImagePath);
-                    rc = RegQueryValue(hDriverKey, L"ImagePath", NULL, (PUCHAR)TempImagePath, &ValueSize);
-
-                    /* 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 {
-                        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);
-
-                } 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));
+                        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++;