Page 2 of 2
Re: FAT32 Bootloader
Posted: Tue Jun 05, 2012 9:24 am
by trinopoty
First, use hex for the values, it's easier to understand.
In MBR formatted disks, only the first partition is set as bootable, this makes things a lot easier. The first partition resides at LBA 0x3F.
Re: FAT32 Bootloader
Posted: Tue Jun 05, 2012 11:38 am
by iansjack
trinopoty wrote:First, use hex for the values, it's easier to understand.
In MBR formatted disks, only the first partition is set as bootable, this makes things a lot easier. The first partition resides at LBA 0x3F.
More misinformation, unfortunately. Any partition on an MBR disk can be set to be the active partition. And you can never assume that a partition will start at a particular sector; that's why you have a partition table.
Re: FAT32 Bootloader
Posted: Tue Jun 05, 2012 5:24 pm
by Brynet-Inc
trinopoty wrote:In MBR formatted disks, only the first partition is set as bootable, this makes things a lot easier. The first partition resides at LBA 0x3F.
Code: Select all
Disk: wd0 geometry: 60801/255/63 [976773168 Sectors]
Offset: 0 Signature: 0xAA55
Starting Ending LBA Info:
#: id C H S - C H S [ start: size ]
-------------------------------------------------------------------------------
0: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
1: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
2: 00 0 0 0 - 0 0 0 [ 0: 0 ] unused
*3: A6 0 1 2 - 12269 254 63 [ 64: 197117486 ] OpenBSD
Liar.
Re: FAT32 Bootloader
Posted: Wed Jun 06, 2012 1:58 am
by Solar
Brynet-Inc wrote:Liar.
"Never attribute to malice that which is adequately explained by stupidity."
Re: FAT32 Bootloader
Posted: Thu Jun 07, 2012 5:02 pm
by Firestryke31
jbemmel wrote:Firestryke31 wrote:jbemmel wrote:Could consider to align the stack by 4 by using 0x8002 instead of 0x8000
0x8002 % 4 != 0, so 0x8002 is not 4-byte aligned. 0x8000 is, though.
If you read the code, you will see that the first thing pushed is bx, followed by a bunch of 32-bit pushes. The stack is currently misaligned for the latter cases.
Sorry, like I said it's been a long time since I've even last seen the code (and I still haven't looked at it). If I were to need a FAT32 bootsector today I'd probably end up starting over from scratch. It wouldn't surprise me if I had made plenty of stupid mistakes in that code.