Do not overwrite the disk signature, if we install the boot code into the mbr.
[reactos.git] / reactos / subsys / system / usetup / bootsup.c
index b1216d0..22ce216 100644 (file)
  * PROGRAMMER:      Eric Kohl
  */
 
-#include "precomp.h"
-#include <ntdll/rtl.h>
-
-#include "usetup.h"
-#include "inicache.h"
-#include "filesup.h"
-#include "bootsup.h"
+#include <usetup.h>
 
 #define NDEBUG
 #include <debug.h>
@@ -56,14 +50,12 @@ CreateCommonFreeLoaderSections(PINICACHE IniCache)
                    L"DefaultOS",
                    L"ReactOS");
 
-#if 0
   /* Timeout=10 */
   IniCacheInsertKey(IniSection,
                    NULL,
                    INSERT_LAST,
                    L"TimeOut",
                    L"10");
-#endif
 
   /* Create "Display" section */
   IniSection = IniCacheAppendSection(IniCache,
@@ -173,13 +165,6 @@ CreateCommonFreeLoaderSections(PINICACHE IniCache)
                    INSERT_LAST,
                    L"SelectedColor",
                    L"Gray");
-
-  /* TimeOut=5 */
-  IniCacheInsertKey(IniSection,
-                   NULL,
-                   INSERT_LAST,
-                   L"TimeOut",
-                   L"5");
 }
 
 
@@ -1017,13 +1002,13 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath,
   UNICODE_STRING Name;
   HANDLE FileHandle;
   NTSTATUS Status;
-  PUCHAR OrigBootSector;
-  PUCHAR NewBootSector;
+  PPARTITION_SECTOR OrigBootSector;
+  PPARTITION_SECTOR NewBootSector;
 
   /* Allocate buffer for original bootsector */
-  OrigBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
-                                          0,
-                                          SECTORSIZE);
+  OrigBootSector = (PPARTITION_SECTOR)RtlAllocateHeap(ProcessHeap,
+                                                     0,
+                                                      sizeof(PARTITION_SECTOR));
   if (OrigBootSector == NULL)
     return(STATUS_INSUFFICIENT_RESOURCES);
 
@@ -1067,9 +1052,9 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath,
 
 
   /* Allocate buffer for new bootsector */
-  NewBootSector = (PUCHAR)RtlAllocateHeap(ProcessHeap,
-                                         0,
-                                         SECTORSIZE);
+  NewBootSector = (PPARTITION_SECTOR)RtlAllocateHeap(ProcessHeap,
+                                                    0,
+                                                     sizeof(PARTITION_SECTOR));
   if (NewBootSector == NULL)
   {
     RtlFreeHeap(ProcessHeap, 0, OrigBootSector);
@@ -1105,7 +1090,7 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath,
                      NULL,
                      &IoStatusBlock,
                      NewBootSector,
-                     SECTORSIZE,
+                     sizeof(PARTITION_SECTOR),
                      NULL,
                      NULL);
   NtClose(FileHandle);
@@ -1117,9 +1102,9 @@ InstallMbrBootCodeToDisk (PWSTR SrcPath,
   }
 
   /* Copy partition table from old MBR to new */
-  RtlCopyMemory ((NewBootSector + 446),
-                (OrigBootSector + 446),
-                4*16 /* Length of partition table */);
+  RtlCopyMemory (&NewBootSector->Signature,
+                &OrigBootSector->Signature,
+                sizeof(PARTITION_SECTOR) - offsetof(PARTITION_SECTOR, Signature) /* Length of partition table */);
 
   /* Free the original boot sector */
   RtlFreeHeap(ProcessHeap, 0, OrigBootSector);