John Fines bootf02 in *NIX?

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
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

John Fines bootf02 in *NIX?

Post by Brynet-Inc »

Hey, I've noticed John Fines boot loader needed to be written using his "Closed Source" DOS PARTCOPY application.

Apparently, It writes the first 3 bytes of the boot sector to the beginning of the disk and the rest to offset 3E.

Code: Select all

partcopy bootf.bin 0 3 -f0 0
partcopy bootf.bin 3E 1C2 -f0 3E
Could someone tell me how to do this using the dd command? or can recommend another *NIX tool, I'll forever be in your debt 8)
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
muisei
Member
Member
Posts: 79
Joined: Sat Sep 23, 2006 2:10 pm
Location: Bulgaria
Contact:

Post by muisei »

You coud create a simple C/C++ program to write the MBR to a file and then use dd if=[input file] of=[output file] to copy the MBR image file to where you want.
The another way is to read the whole manual page.

C/C++ sample program I wrote for you:

Code: Select all


#include <sys/types.h> /* unistd.h needs this */
#include <stdio.h>
#include <unistd.h> /* contains read/write */
#include <fcntl.h>

int main(int argc, char *argv[])
{
  int image_desc, mbr_desc;
  char *boot_buf[512];

  image_desc = open(argv[1], O_RDRW);
  mbr_desc = open(argv[1], O_RDONLY);

  read(mbr_desc, &boot_buf,512);

  lseek(image_desc, 0, SEEK_SET);
  write(image_desc,&boot_buf, 3);

  lseek(image_desc,0x3e,SEEK_SET);
  write(image_desc,&boot_buf+3,512-3);

  close(mbr_desc);
  close(image_desc);
}

User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Changing one of the argv[1]'s to argv[2]'s worked.. *PEACE :D *


Thanks a lot pal :wink:
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
B.E
Member
Member
Posts: 275
Joined: Sat Oct 21, 2006 5:29 pm
Location: Brisbane Australia
Contact:

Post by B.E »

You could of done

dd bs=1 count=3 if=boot.bin of=/dev/fd0
dd bs=1 count=450 seek=62 skip=62 if=boot.bin of=/dev/fd0
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Post by Brynet-Inc »

Gosh I'm slow today..:roll:

dd bs=1 if=boot.bin of=/dev/fd0a seems to work perfectly fine..
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
User avatar
gaf
Member
Member
Posts: 349
Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany

Post by gaf »

dd bs=1 if=boot.bin of=/dev/fd0a seems to work perfectly fine..
If you just overwrite the whole bootsector your FAT headers will get lost. This means that the disk won't be recognized as FAT formated by most systems althought the structures themself are still functional.

regards,
gaf
Post Reply