IMG booting if modified with a jmp instruction

Discussions related to using VirtualBox on Mac OS X hosts.
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: IMG booting if modified with a jmp instruction

Post by fth0 »

Here's the key comment from the VirtualBox source code:

Code: Select all

    // There is *no* requirement whatsoever for a valid floppy boot sector
    // to have a 55AAh signature. UNIX boot floppies typically have no such
    // signature. In general, it is impossible to tell a valid bootsector
    // from an invalid one.
    // NB: It is somewhat common for failed OS installs to have the
    // 0x55AA signature and a valid partition table but zeros in the
    // rest of the boot sector. We do a quick check by comparing the first
    // and third word of boot sector; if identical, the boot sector is
    // extremely unlikely to be valid.
Congratulations, you've found an "extremely unlikely" MBR or boot sector! ;)

The comparison of the first and third 16-bit word is done for all boot media, so it wouldn't help to simply try a virtual HD or DVD. But if you used TetrOS in a boot sector within a partitioned medium, success or failure would depend on the checks in the MBR code of the partitioned medium.

I've created #21861 for this.
mpack
Site Moderator
Posts: 39134
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: IMG booting if modified with a jmp instruction

Post by mpack »

Can you be more specific than "VirtualBox source code"?

AFAIK 0x55AA was a DOS convention to help identify a formatted disk, it was not a BIOS requirement. So if it's in the BIOS source code, then... naturally.

{Edit} The ticket refers to the BIOS, so I assume my guess is correct.
fth0
Volunteer
Posts: 5678
Joined: 14. Feb 2019, 03:06
Primary OS: Mac OS X other
VBox Version: PUEL
Guest OSses: Linux, Windows 10, ...
Location: Germany

Re: IMG booting if modified with a jmp instruction

Post by fth0 »

mpack wrote: 29. Sep 2023, 10:45 Can you be more specific than "VirtualBox source code"?
With pleasure: In the VirtualBox legacy BIOS source code, the complete comment starts in src/VBox/Devices/PC/BIOS/boot.c?rev=98103#L330, and the pivotal comparison is in lines 348 and 349. On floppy disk boot sectors, the signature is not checked, only the word comparison takes place.

BTW, the original Bochs BIOS doesn't have the problematic check, so it's probably a VirtualBox enhancement. ;)
Post Reply