Does MBR sends to VBR partiton information?

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
Bonfra
Member
Member
Posts: 270
Joined: Wed Feb 19, 2020 1:08 pm
Libera.chat IRC: Bonfra
Location: Italy

Does MBR sends to VBR partiton information?

Post by Bonfra »

When the MBR loads the VBR in memory from a specific partition, the VBR runs as a normal bootloader but if it need to interact with the disk it should be aware of the fact that is not at the start of the disk but there is some bias.
For example the first bootable partition is at LBA = 2048 and when its bootloader is loaded it reads the file system starting from LBA = 2048 instead of the start of the disk. Is this something hardcoded or the MBR should send the information like the boot drive?
I know I can do it my self but I wanted to know if some sort of convention exists.
Regards, Bonfra.
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: Does MBR sends to VBR partiton information?

Post by nullplan »

Wikipedia claims that DS:SI will point to the partition table entry for the active partition. I don't know how reliable that is, though. Other members here have counselled against trusting that, only trusting that DL is the BIOS drive number.
Carpe diem!
PeterX
Member
Member
Posts: 590
Joined: Fri Nov 22, 2019 5:46 am

Re: Does MBR sends to VBR partiton information?

Post by PeterX »

There's not "the MBR" as a kind of standard. What comes close to being a standard are the MBR from Windows and from Grub2.

And, no, you can't expect an MBR to hand over that information. What you can do is writing your own MBR and VBR and let the MBR hand over:
(a) some "magic" to recognize whether the VBR is loaded by your MBR or some other MBR. The VBR would check for that and fail with a short error message if the wrong MBR is used. For example you could set eax = 0x1234ABCD.
(b) the info you want to pass.

Disadvantage: With this solution booting fails if the MBR is overwritten. But perhaps that's ok.

Greetings
Peter
Octocontrabass
Member
Member
Posts: 5568
Joined: Mon Mar 25, 2013 7:01 pm

Re: Does MBR sends to VBR partiton information?

Post by Octocontrabass »

nullplan wrote:Wikipedia claims that DS:SI will point to the partition table entry for the active partition. I don't know how reliable that is, though.
It doesn't work with the MBR written by Windows Vista or newer.
Post Reply