flat assembler
Message board for the users of flat assembler.

Index > OS Construction > NUMBR = Neville's User-friendly (Multi-)Master Boot Record

Author
Thread Post new topic Reply to topic
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
Most MBR code closely scrutinises the Partition Table, looking for any of several "errors" which will typically crash the PC with a very unfriendly JMP $, but after cheerfully displaying the error message. All of the Windows MBR's I've seen are certainly guilty of this. Some even do a checksum of the MBR including the Partition Table, so any changes will make the OS fail to boot.

NUMBR contains no error messages at all, and makes every attempt to boot the PC while keeping the user informed.

In addition, NUMBR turns some of the traditional MBR "errors" into opportunities.

Firstly, if none of the 4 possible partition boot flags are set, NUMBR assumes Multi-boot Mode and asks the user to select which of the up to 4 partitions it should boot from.

The attachment includes a demonstration of multi-boot mode, with fasm source, and contains 4 "operating systems" to choose from, in a total image size of 29696 bytes, occupying only 58 sectors! (3 of the operating systems are actually bootable games which may or may not be familiar to you!) NUMBR10.IMG should be written to ASN0 of a USB pendrive or any old hard disk. If your existing drive's first partition starts at ASN63 or greater (almost all do), only your existing MBR at ASN0 will be overwritten which you can backup first if you wish. You can use HxD for these tasks, as explained here.

Secondly NUMBR does not require consistency between the legacy CHS and 32-bit sector data in the partition records. NUMBR ignores the legacy data unless the user holds down either of the Shift keys while booting. If either Shift keys are depressed NUMBR attempts a legacy boot using INT13h/AH=2. Otherwise NUMBR defaults to an EDD boot using INT13h/AX=4200h and the specified 32-bit start sector offset. So if your BIOS supports both legacy and EDD booting you could potentially set up 8 different primary boot partitions with 8 different operating systems.

Thirdly for maximum flexibility NUMBR does not check partition size data, nor does it check for partition overlaps etc.

Lastly NUMBR presently ignores the Partition Type bytes in the Partition Table, although for compatibility I generally recommend legacy values, and certainly avoid the GPT Protective MBR value 0EEh (even if you have multiple partitions), and also avoid the EFI value 0EFh. However I've used (somewhat arbitrarily) the value 0BCH in each of the 4 partitions defined in NUMBR10. This value is one of several available which has not been formally defined.

NUMBR Main Features:
+ defaults to EDD booting using INT13h/AX=4200h
+ attempts legacy booting using INT13h/AX=2 if EDD fails
+ holding either SHIFT key down forces legacy booting
+ defaults to Multi-Boot mode if no boot flags detected
+ does not require the 0AA55h "boot signature"
+ does not check partition types
+ no partition table consistency checks
+ simple Multi-Boot menu displayed in Multi-Boot mode
(with 4 user-definable partition names)

In short, it is perhaps the most flexible and accommodating MBR ever written!


Issues & future development:

- in multi-boot mode the selected OS's stage 2 bootloader can not identify which partition it is booting from by examining the bootflags. This issue doesn't arise in this demonstration because there are no stage 2 bootloaders, but a simple workaround would be to pass the user keypress (1-4) to the stage 2 bootloader.
- at least one BIOS that I'm aware of (in a Sony Vaio notebook) doesn't update the keyboard status flags during IPL, so doesn't detect the SHIFT keys for legacy booting.
+ determine and display the actual number of partitions defined. Currently NUMBR just assumes there are 4 partitions and will accept any keypress from 1 to 4. The 4 defined partition names are also displayed on 4 consecutive lines whether they actually contain text, or are null, blank, or otherwise.
+ provide for up to 8 displayable partition names
+ default to Multi-Boot mode if more than 1 boot flag is detected
+ holding another key down (e.g. either CTRL key) forces Multi-Boot mode irrespective of boot flag(s). This would allow a normal default bootable partition to be defined.

Even without much code optimisation, and allowing 64 bytes for the displayable partition names, there are still about 34 bytes of spare code space to play with!

Note that Multi-boot Mode in NUMBR does NOT conform to the Multiboot Specification developed by gnu.org. That specification is much more complex and comprehensive, and is targeted at stage 2 bootloaders rather than the MBR itself.

Source code for NUMBR and the complete image with 4 selectable OS's is included in the attachment but the source for the individual OS's is all available elsewhere. If you use NUMBR please let me know. Remember that the NUMBR demo binary (NUMBR10.IMG) in the attached archive must be written to Absolute sector 0, replacing the existing MBR and the following 57 sectors.


Description: NUMBR Version 1.0
Download
Filename: NUMBR10.ZIP
Filesize: 9.4 KB
Downloaded: 235 Time(s)


_________________
FAMOS - the first memory operating system
Post 01 Sep 2014, 02:57
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 17639
Location: In your JS exploiting you and your system
revolution
Nice addition. Is it compatible with FDE software like truecrypt?

Also some software "protection" schemes use the first track to store information and "prevent" copying. I've seen this also render PCs unbootable because of the "protection data" overwriting boot code. You might also want to provide a method of how to restore back the simple boot loader in case of a problem.
Post 01 Sep 2014, 04:02
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
I'm not familiar with (and don't use) any FDE software so I don't know. I've provided the source so anybody familiar with FDE software should be able to identify any issues pretty quickly Wink

Back-up/restore suggestions are included in my post above, using external applications like HxD. If you mean an internal backup/restore option within a 512-byte MBR that might not be so easy! Shocked

_________________
FAMOS - the first memory operating system
Post 01 Sep 2014, 04:29
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
I haven't used an emulator for a long time so I'm not sure if any of them would support booting an image which includes the MBR. Does anybody know?

_________________
FAMOS - the first memory operating system
Post 02 Sep 2014, 04:30
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
neville wrote:
I haven't used an emulator for a long time so I'm not sure if any of them would support booting an image which includes the MBR. Does anybody know?


i just do kvm -m 512M /dev/sda and it works fine Wink
or kvm -m 512M -cdrom anyisofile if it is a cd iso, and system needs cdrom emulation
Post 02 Sep 2014, 07:28
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
Matrix wrote:
i just do kvm -m 512M /dev/sda and it works fine Wink
I assume this sets up some sort of virtual machine in linux. That's interesting. So it actually works with NUMBR on the pendrive?

_________________
FAMOS - the first memory operating system
Post 04 Sep 2014, 05:57
View user's profile Send private message Visit poster's website Reply with quote
Matrix



Joined: 04 Sep 2004
Posts: 1171
Location: Overflow
Matrix
neville wrote:
Matrix wrote:
i just do kvm -m 512M /dev/sda and it works fine Wink
I assume this sets up some sort of virtual machine in linux. That's interesting. So it actually works with NUMBR on the pendrive?


yes it does work with qemu, and i'm on linux,

"W: kvm binary is deprecated, please use qemu-system-x86_64 instead"

kvm always writes this amazing warning Wink
Post 04 Sep 2014, 13:48
View user's profile Send private message Visit poster's website Reply with quote
neville



Joined: 13 Jul 2008
Posts: 507
Location: New Zealand
neville
Ok, good to know. Thanks.

_________________
FAMOS - the first memory operating system
Post 05 Sep 2014, 04:53
View user's profile Send private message Visit poster's website Reply with quote
0ffer



Joined: 06 Sep 2014
Posts: 2
0ffer
Boot code from User-friendly (Multi-)Master Boot Record UFMBR.bin and DOS installer restrmbr.exe from PartitionMagic 8.0
For Boot flag manipulation EFDISK - SPACE toggles active flag if a partition is already active by Nagy Daniel

Install: restrmbr.exe UFMBR.bin

Uninstall: restrmbr.exe


Description:
Download
Filename: pack.zip
Filesize: 21.72 KB
Downloaded: 194 Time(s)

Post 07 Sep 2014, 17:44
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.

Website powered by rwasa.