[ros-diffs] [fireball] 40437: - Add a new property to the disk entry: NoMbr flag. It's set, if MBR's first two bytes are zero (same algorithm is used by our cdrom bootsector). - If this flag is set for a boot disk, ReactOS MBR code will be installed on it. See issue #4355 for more details.

fireball at svn.reactos.org fireball at svn.reactos.org
Fri Apr 10 12:37:09 CEST 2009


Author: fireball
Date: Fri Apr 10 14:37:08 2009
New Revision: 40437

URL: http://svn.reactos.org/svn/reactos?rev=40437&view=rev
Log:
- Add a new property to the disk entry: NoMbr flag. It's set, if MBR's first two bytes are zero (same algorithm is used by our cdrom bootsector).
- If this flag is set for a boot disk, ReactOS MBR code will be installed on it.
See issue #4355 for more details.

Modified:
    trunk/reactos/base/setup/usetup/interface/usetup.c
    trunk/reactos/base/setup/usetup/partlist.c
    trunk/reactos/base/setup/usetup/partlist.h

Modified: trunk/reactos/base/setup/usetup/interface/usetup.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/interface/usetup.c?rev=40437&r1=40436&r2=40437&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/interface/usetup.c [iso-8859-1] Fri Apr 10 14:37:08 2009
@@ -2380,6 +2380,28 @@
                 CheckActiveBootPartition(PartitionList);
             }
 
+            /* Install MBR if necessary */
+            if (DiskEntry->NoMbr &&
+                DiskEntry->BiosDiskNumber == 0)
+            {
+                wcscpy(PathBuffer, SourceRootPath.Buffer);
+                wcscat(PathBuffer, L"\\loader\\dosmbr.bin");
+
+                DPRINT("Install MBR bootcode: %S ==> %S\n",
+                    PathBuffer, DestinationRootPath.Buffer);
+
+                /* Install MBR bootcode */
+                Status = InstallMbrBootCodeToDisk(PathBuffer, DestinationRootPath.Buffer);
+                if (!NT_SUCCESS (Status))
+                {
+                    DPRINT1("InstallMbrBootCodeToDisk() failed (Status %lx)\n",
+                        Status);
+                    return FALSE;
+                }
+
+                DiskEntry->NoMbr = FALSE;
+            }
+
             if (wcscmp(FileSystemList->Selected->FileSystem, L"FAT") == 0)
             {
                 /* FIXME: Install boot code. This is a hack! */

Modified: trunk/reactos/base/setup/usetup/partlist.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/partlist.c?rev=40437&r1=40436&r2=40437&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/partlist.c [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/partlist.c [iso-8859-1] Fri Apr 10 14:37:08 2009
@@ -775,10 +775,6 @@
   }
   Checksum = ~Checksum + 1;
 
-  RtlFreeHeap (ProcessHeap,
-               0,
-               Mbr);
-
   swprintf(Identifier, L"%08x-%08x-A", Checksum, Signature);
   DPRINT("Identifier: %S\n", Identifier);
 
@@ -798,6 +794,17 @@
     DiskEntry->Modified = TRUE;
   }
   DiskEntry->BiosFound = FALSE;
+
+  /* Check if this disk has a valid MBR */
+  if (Mbr->BootCode[0] == 0 && Mbr->BootCode[1] == 0)
+    DiskEntry->NoMbr = TRUE;
+  else
+    DiskEntry->NoMbr = FALSE;
+
+  /* Free Mbr sector buffer */
+  RtlFreeHeap (ProcessHeap,
+               0,
+               Mbr);
 
   ListEntry = List->BiosDiskListHead.Flink;
   while(ListEntry != &List->BiosDiskListHead)
@@ -2672,6 +2679,7 @@
         }
 
         DiskEntry1->NewDisk = FALSE;
+        DiskEntry1->NoMbr = FALSE;
       }
     }
 

Modified: trunk/reactos/base/setup/usetup/partlist.h
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/base/setup/usetup/partlist.h?rev=40437&r1=40436&r2=40437&view=diff
==============================================================================
--- trunk/reactos/base/setup/usetup/partlist.h [iso-8859-1] (original)
+++ trunk/reactos/base/setup/usetup/partlist.h [iso-8859-1] Fri Apr 10 14:37:08 2009
@@ -109,6 +109,7 @@
   BOOLEAN Modified;
 
   BOOLEAN NewDisk;
+  BOOLEAN NoMbr; /* MBR is absent */
 
   UNICODE_STRING DriverName;
 



More information about the Ros-diffs mailing list