Page 1 of 1
Partition tables and MBR
Posted: Fri Oct 18, 2013 10:41 am
by lopidas
Nearly everywhere I read that partition tables are always part of MBR.
What will happen, if I overwrite these tables by executable code?
Re: Partition tables and MBR
Posted: Fri Oct 18, 2013 10:45 am
by madanra
You will no longer have any partitions on your disk.
Re: Partition tables and MBR
Posted: Fri Oct 18, 2013 10:52 am
by lopidas
Which calls will be affected by doing this? I think drive tables of int 0x13. Anything else?
Re: Partition tables and MBR
Posted: Fri Oct 18, 2013 11:10 am
by Antti
lopidas wrote:What will happen, if I overwrite these tables by executable code?
I do not recommend using executable code there. If there are no partitions, fill it with zeros.
In fact, I always keep that area filled with zeros even in FAT12 floppy images (that do not contain partitions anyway). If I copy the image to a USB stick, it is definitely interpreted as a floppy. On the contrary, for my "HD images" with partitions I always leave the Bios Parameter Block filled with zeros (except the first short jump, of course).
Re: Partition tables and MBR
Posted: Sat Oct 19, 2013 9:18 am
by lopidas
Why do you not recommend it?
Re: Partition tables and MBR
Posted: Sat Oct 19, 2013 10:13 am
by Brendan
Hi,
lopidas wrote:Why do you not recommend it?
If you're unlucky (e.g. the "random" bytes in the partition table happen to look valid) any other OS can think there's valid partitions when there are none (possibly asking the user if the partitions it sees should be formatted, destroying data if the user says "yes").
If you're lucky (e.g. the "random" bytes in the partition table don't look valid) any other OS will assume the hard drive isn't partitioned properly yet and wipe the partition table in an attempt to install partitions/file systems (corrupting your code, but not trashing file system/s and user data).
Note: There is one and only one case where not having a partition table (and putting executable code there) is safe; and that's floppy disks (where no OS expects to see partitions). For all other cases you break the expectations of every other OSs that the user may have installed or may want to install later.
[EDIT: Actually, I forgot about CDs, which are also never partitioned but boot very differently anyway.[/EDIT]
Cheers,
Brendan
Re: Partition tables and MBR
Posted: Sat Oct 19, 2013 4:14 pm
by Love4Boobies
lopidas wrote:Which calls will be affected by doing this? I think drive tables of int 0x13. Anything else?
No BIOS functions will be affected; not even INT 13h, which is for controlling drives rather than file systems.