Index: base/setup/usetup/bootsup.c =================================================================== --- base/setup/usetup/bootsup.c (revision 74470) +++ base/setup/usetup/bootsup.c (working copy) @@ -644,6 +644,7 @@ LARGE_INTEGER FileOffset; PUCHAR BootSector; ULONG Instruction; + WORD BootSectorSignature; /* Allocate buffer for bootsector */ BootSector = RtlAllocateHeap(ProcessHeap, 0, SECTORSIZE); @@ -685,6 +686,8 @@ Instruction = *(PULONG)BootSector; + BootSectorSignature = *(PWORD)(BootSector + 0x1fe); + /* Free the boot sector */ RtlFreeHeap(ProcessHeap, 0, BootSector); @@ -691,7 +694,7 @@ if (!NT_SUCCESS(Status)) return FALSE; // Status; - return (Instruction != 0x00000000); + return (Instruction != 0x00000000 && BootSectorSignature == 0xaa55); } NTSTATUS @@ -2250,6 +2253,7 @@ #ifdef __REACTOS__ NTSTATUS Status; BOOLEAN DoesFreeLdrExist; + WCHAR OriginalSystemRootPath[MAX_PATH]; WCHAR SrcPath[MAX_PATH]; WCHAR DstPath[MAX_PATH]; @@ -2369,11 +2373,17 @@ PWCHAR Section; PWCHAR Description; - PWCHAR BootDrive; - PWCHAR BootPartition; + WCHAR BootDrive[4]; + WCHAR BootPartition[2]; PWCHAR BootSector; PWCHAR BootSectorFileName; + swprintf(BootDrive, + L"hd%d", + PartitionList->OriginalSystemDisk->DiskNumber); + swprintf(BootPartition, + L"%d", + PartitionList->OriginalSystemPartition->PartitionNumber); if (DoesFileExist(SystemRootPath->Buffer, L"io.sys") == TRUE || DoesFileExist(SystemRootPath->Buffer, L"msdos.sys") == TRUE) { @@ -2382,8 +2392,6 @@ Section = L"DOS"; Description = L"\"DOS/Windows\""; - BootDrive = L"hd0"; - BootPartition = L"1"; BootSector = L"BOOTSECT.DOS"; BootSectorFileName = L"\\bootsect.dos"; @@ -2396,8 +2404,6 @@ Section = L"DOS"; Description = L"\"FreeDOS\""; - BootDrive = L"hd0"; - BootPartition = L"1"; BootSector = L"BOOTSECT.DOS"; BootSectorFileName = L"\\bootsect.dos"; @@ -2409,8 +2415,6 @@ Section = L"Unknown"; Description = L"\"Unknown Operating System\""; - BootDrive = L"hd0"; - BootPartition = L"1"; BootSector = L"BOOTSECT.OLD"; BootSectorFileName = L"\\bootsect.old"; @@ -2440,8 +2444,14 @@ wcscpy(DstPath, SystemRootPath->Buffer); wcscat(DstPath, BootSectorFileName); - DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath); - Status = SaveBootSector(SystemRootPath->Buffer, DstPath, SECTORSIZE); + /* Create original system partition bootsector path */ + swprintf(OriginalSystemRootPath, + L"\\Device\\Harddisk%d\\Partition%d", + PartitionList->OriginalSystemDisk->DiskNumber, + PartitionList->OriginalSystemPartition->PartitionNumber); + + DPRINT1("Save bootsector: %S ==> %S\n", OriginalSystemRootPath, DstPath); + Status = SaveBootSector(OriginalSystemRootPath, DstPath, SECTORSIZE); if (!NT_SUCCESS(Status)) { DPRINT1("SaveBootSector() failed (Status %lx)\n", Status); @@ -2508,6 +2518,7 @@ #ifdef __REACTOS__ NTSTATUS Status; BOOLEAN DoesFreeLdrExist; + WCHAR OriginalSystemRootPath[MAX_PATH]; WCHAR SrcPath[MAX_PATH]; WCHAR DstPath[MAX_PATH]; @@ -2575,8 +2586,14 @@ wcscpy(DstPath, SystemRootPath->Buffer); wcscat(DstPath, L"\\bootsect.old"); - DPRINT1("Save bootsector: %S ==> %S\n", SystemRootPath->Buffer, DstPath); - Status = SaveBootSector(SystemRootPath->Buffer, DstPath, sizeof(EXT2_BOOTSECTOR)); + /* Create original system partition bootsector path */ + swprintf(OriginalSystemRootPath, + L"\\Device\\Harddisk%d\\Partition%d", + PartitionList->OriginalSystemDisk->DiskNumber, + PartitionList->OriginalSystemPartition->PartitionNumber); + + DPRINT1("Save bootsector: %S ==> %S\n", OriginalSystemRootPath, DstPath); + Status = SaveBootSector(OriginalSystemRootPath, DstPath, sizeof(EXT2_BOOTSECTOR)); if (!NT_SUCCESS(Status)) { DPRINT1("SaveBootSector() failed (Status %lx)\n", Status);