Author: ion
Date: Mon Oct  5 01:02:56 2015
New Revision: 69450

URL: http://svn.reactos.org/svn/reactos?rev=69450&view=rev
Log:
[BOOTLIB]:
- Fix BCD bugs.

Modified:
    trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
    trunk/reactos/boot/environ/app/bootmgr/efiemu.c
    trunk/reactos/boot/environ/lib/misc/bcd.c

Modified: trunk/reactos/boot/environ/app/bootmgr/bootmgr.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/bootmgr.c?rev=69450&r1=69449&r2=69450&view=diff
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/bootmgr.c    [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/bootmgr.c    [iso-8859-1] Mon Oct  5 
01:02:56 2015
@@ -505,6 +505,7 @@
     PVOID FinalBuffer;
     UNICODE_STRING BcdString;
 
+    /* Initialize variables */
     PathBuffer = NULL;
     BcdDevice = NULL;
     BcdPath = NULL;
@@ -559,6 +560,7 @@
 
     /* Otherwise, compute the hardcoded path of the BCD */
     Status = BmpFwGetFullPath(L"\\BCD", &FullPath);
+    EfiPrintf(L"Status: %lx %s\r\n", Status, FullPath);
     if (!NT_SUCCESS(Status))
     {
         /* User the raw path */

Modified: trunk/reactos/boot/environ/app/bootmgr/efiemu.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/app/bootmgr/efiemu.c?rev=69450&r1=69449&r2=69450&view=diff
==============================================================================
--- trunk/reactos/boot/environ/app/bootmgr/efiemu.c     [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/app/bootmgr/efiemu.c     [iso-8859-1] Mon Oct  5 
01:02:56 2015
@@ -803,7 +803,7 @@
             /* Calculate where the next option should go */
             Option = (PVOID)((ULONG_PTR)Option + Size);
 
-            /* Convert the path oprtion */
+            /* Convert the path option */
             Status = EfiInitpConvertEfiFilePath(OsDevicePath,
                                                 BcdOSLoaderString_SystemRoot,
                                                 Option,

Modified: trunk/reactos/boot/environ/lib/misc/bcd.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/misc/bcd.c?rev=69450&r1=69449&r2=69450&view=diff
==============================================================================
--- trunk/reactos/boot/environ/lib/misc/bcd.c   [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/misc/bcd.c   [iso-8859-1] Mon Oct  5 
01:02:56 2015
@@ -20,7 +20,7 @@
     )
 {
     ULONG_PTR NextOption = 0, ListOption;
-    PBL_BCD_OPTION Option;
+    PBL_BCD_OPTION Option, FoundOption;
 
     /* No options, bail out */
     if (!List)
@@ -29,12 +29,14 @@
     }
 
     /* Loop while we find an option */
-    while (TRUE)
+    FoundOption = NULL;
+    do
     {
         /* Get the next option and see if it matches the type */
         Option = (PBL_BCD_OPTION)((ULONG_PTR)List + NextOption);
         if ((Option->Type == Type) && !(Option->Empty))
         {
+            FoundOption = Option;
             break;
         }
 
@@ -49,20 +51,18 @@
             Option = MiscGetBootOption((PBL_BCD_OPTION)((ULONG_PTR)Option +
                                        ListOption),
                                        Type);
-
-            /* Found one, return it */
             if (Option)
             {
-                return Option;
+                /* Return it */
+                FoundOption = Option;
+                break;
             }
         }
-    }
-
-    /* We found the option, return it */
-    return Option;
-}
-
-
+    } while (NextOption);
+
+    /* Return the option that was found, if any */
+    return FoundOption;
+}
 
 /*++
  * @name BlGetBootOptionListSize
@@ -94,7 +94,7 @@
 
         /* Update the offset */
         NextOffset = NextOption->NextEntryOffset;
-    } while (NextOffset != 0);
+    } while (NextOffset);
 
     /* Return final computed size */
     return Size;
@@ -119,7 +119,7 @@
     ULONG Size, Offset;
 
     /* Check if there's any data */
-    if (BcdOption->DataOffset != 0)
+    if (BcdOption->DataOffset)
     {
         /* Add the size of the data */
         Size = BcdOption->DataOffset + BcdOption->DataSize;
@@ -132,7 +132,7 @@
 
     /* Any associated options? */
     Offset = BcdOption->ListOffset;
-    if (Offset != 0)
+    if (Offset)
     {
         /* Go get those too */
         Size += BlGetBootOptionListSize((PVOID)((ULONG_PTR)BcdOption + 
Offset));
@@ -167,11 +167,13 @@
     {
         /* Extract the string */
         String = (PWCHAR)((ULONG_PTR)Option + Option->DataOffset);
+        Status = STATUS_SUCCESS;
     }
     else
     {
         /* No string is present */
         String = NULL;
+        Status = STATUS_NOT_FOUND;
     }
 
     /* Compute the data size */
@@ -182,9 +184,7 @@
     AppIdentifier = BlGetApplicationIdentifier();
     Status = BlpBootOptionCallbackString(AppIdentifier, Type, String, 
StringLength, &String, &StringLength);
 #else
-    Status = STATUS_SUCCESS;
 #endif
-
     /* Check if we have space for one more character */
     CopyLength = StringLength + 1;
     if (CopyLength < StringLength)
@@ -192,11 +192,6 @@
         /* Nope, we'll overflow */
         CopyLength = -1;
         Status = STATUS_INTEGER_OVERFLOW;
-    }
-    else
-    {
-        /* Go ahead */
-        Status = STATUS_SUCCESS;
     }
 
     /* No overflow? */
@@ -331,7 +326,6 @@
     }
 #else
     /* No secure boot, so the secure descriptors are the standard ones */
-    Status = STATUS_SUCCESS;
     SecureDescriptor = DeviceDescriptor;
     SecureListData = ListCopy;
 #endif
@@ -765,6 +759,7 @@
 
     /* Assume failure */
     LocalHandle = NULL;
+    EfiPrintf(L"Opening BCD store: %wZ\n", FileName);
 
     /* Allocate a path descriptor */
     Length = FileName->Length + sizeof(*FilePath);


Reply via email to