mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[core] fix MBR protective message overwriting the primary GPT
* We distractedly chose to populate the message from our protective MBR for GPT/UEFI-only boot media into the 4KB that directly followed the MBR, which of course is space that is being used by the primary GPT. * This resulted on systems having to fall back to using the secondary GPT, which not all appear to be designed to do. * Alter the code to ensure the protective message is written at LBA 34, after the primary GPT. * Closes #1507
This commit is contained in:
parent
129aa64394
commit
2dd538b7cb
9 changed files with 60 additions and 57 deletions
|
@ -53,9 +53,11 @@ dis: $(TEST_TARGET).out
|
|||
# Run the MBR in a Bochs environment (append msg.txt in subsequent blocks)
|
||||
test: $(TEST_TARGET).bin
|
||||
@test -s $(BOCHS) || { echo "Error: $(BOCHS) was not found on this system"; exit 1; }
|
||||
@cat $(TEST_TARGET).bin msg.txt > disk.img
|
||||
@cp $(TEST_TARGET).bin disk.img
|
||||
@truncate -c -s 17K disk.img
|
||||
@cat msg.txt >> disk.img
|
||||
@truncate -c -s 10M disk.img
|
||||
-@$(BOCHS) -f bochsrc.bxrc -q
|
||||
@-$(BOCHS) -f bochsrc.bxrc -q
|
||||
|
||||
%.out: %.o mbr.ld
|
||||
@echo "[LD] $@"
|
||||
|
|
BIN
res/mbr/mbr.bin
BIN
res/mbr/mbr.bin
Binary file not shown.
|
@ -31,6 +31,7 @@
|
|||
/********************************************************************************/
|
||||
MBR_ADDR = 0x7c00
|
||||
MBR_RESERVED = 0x1b8 # Start of the reserved section (partition table, etc.)
|
||||
MSG_SECTOR = 0x22 # First sector of the message (must be after the GPT)
|
||||
NB_SECTORS = 0x08 # Number of sectors to read
|
||||
PT_MAX = 0x04 # Number of partition entries in the partition table
|
||||
PT_ENTRY_SIZE = 0x10 # Size of a partition entry in the partition table
|
||||
|
@ -109,10 +110,9 @@ read_sectors: # Copy the next sectors into RAM
|
|||
ext: # http://en.wikipedia.org/wiki/INT_13H#INT_13h_AH.3D42h:_Extended_Read_Sectors_From_Drive
|
||||
xor eax, eax
|
||||
push eax # bits 32-63 of sector address
|
||||
inc eax
|
||||
push eax # bits 0-31 of sector address
|
||||
push MSG_SECTOR # bits 0-31 of sector address
|
||||
push es # destination segment
|
||||
push 0x0000 # destination address
|
||||
push eax # destination address (0)
|
||||
push NB_SECTORS # number of sectors to be read
|
||||
push 0x0010 # size of DAP struct
|
||||
mov si, sp # DAP address (= stack)
|
||||
|
@ -125,7 +125,7 @@ ext: # http://en.wikipedia.org/wiki/INT_13H#INT_13h_AH.3D42h:_Extended_Read_Sect
|
|||
|
||||
no_ext: # http://en.wikipedia.org/wiki/INT_13H#INT_13h_AH.3D02h:_Read_Sectors_From_Drive
|
||||
mov ax, 0x0200 + NB_SECTORS
|
||||
mov cx, 0x0002 # Sector address (starts at 1)
|
||||
mov cx, (MSG_SECTOR + 1) # Sector address (starts at 1)
|
||||
mov dx, 0x0080 # Drive ID
|
||||
xor bx, bx # Destination address in ES
|
||||
int 0x13
|
||||
|
|
BIN
res/mbr/msg.bin
BIN
res/mbr/msg.bin
Binary file not shown.
|
@ -10,8 +10,8 @@
|
|||
boot it in BIOS/Legacy mode. THIS WILL NOT WORK!
|
||||
|
||||
To remove this message you need to do \02ONE\07 of the following:
|
||||
o If this computer supports UEFI, go to the UEFI settings
|
||||
and disable or lower the priority of \09CSM/Legacy mode\07.
|
||||
o If this computer supports UEFI, go to your UEFI settings
|
||||
and lower or disable the priority of \09CSM/Legacy mode\07.
|
||||
o \02OR\07 Recreate the drive in Rufus and use:
|
||||
* \09Partition scheme\07 -> \09MBR\07.
|
||||
* \09Target system\07 -> \09BIOS (...)\07
|
||||
|
|
|
@ -15,7 +15,8 @@ the partition table lists the disk ID for the first partition as 0x81, then it
|
|||
will be swapped for 0x80.
|
||||
|
||||
An additional MBR (msg.S) also exists in this directory, that can be used to
|
||||
display an ASCII message contained in the sectors directly following the MBR.
|
||||
display an ASCII message contained in the sectors following the primary GPT
|
||||
(LBA sectors 34 and later).
|
||||
This can be used, for instance, to display a notice for media that cannot be
|
||||
booted in BIOS/Legacy mode.
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue