Here is a patch which I believe should detect a modern MBR format
and refuse to overwrite it, and hence avoid breaking windows vista+,
although of course with an option to use --force to do it anyhow.

I did not test it yet since I don't have a system handy that I could
test it on.

Fixing install-mbr to actually support modern MBR format would change
the format and make it incompatible with older versions and is a lot
more work, but at least preventing the breaking of the existing OSs is
pretty simple.

-- 
Len Sorensen
--- mbr-1.1.11.orig/install-mbr.c	2015-03-05 10:47:13.000000000 -0500
+++ mbr-1.1.11/install-mbr.c	2015-03-05 10:45:54.639111226 -0500
@@ -829,6 +829,26 @@
     exit(1);
   }
 
+  /* Check for modern MBR format (which install-mbr does NOT currently support)
+     If bytes 445 and 446 are either 0x0000 or 0x5A5A and bytes 440-443
+     are non zero, then it is very likely to be a modern MBR and we should
+     NOT overwrite it since that would break Windows Vista and higher. */
+  if ((dp->flags & DFLAG_FORCE) == 0 &&
+      (mbr_in[CODE_SIZE-6] != 0x00 ||
+       mbr_in[CODE_SIZE-5] != 0x00 ||
+       mbr_in[CODE_SIZE-4] != 0x00 ||
+       mbr_in[CODE_SIZE-3] != 0x00) &&
+     ((mbr_in[CODE_SIZE-2] == 0x00 && mbr_in[CODE_SIZE-1] == 0x00) ||
+      (mbr_in[CODE_SIZE-2] == 0x5A && mbr_in[CODE_SIZE-1] == 0x5A)))
+  {
+    fprintf(stderr, "%s:%s: Probable detection of modern MBR format which is "
+            "currently incompatible with install-mbr.  Installing will probably "
+            "break Windows installations on this system.  "
+	    "Use --force to override.\n", prog_name,
+	    dp->target.path);
+    exit(1);
+  }
+
   /* Try to extract the parameters unless we're resetting them.  If we
      are resetting, or the extraction fails, reset them anyway. */
   if ((dp->flags & DFLAG_RESET) != 0 ||

Reply via email to