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.
Brynet-Inc
Member
Posts: 2426 Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:
Post
by Brynet-Inc » Sat Oct 21, 2006 4:02 pm
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
Twitter: @canadianbryan . Award by smcerm, I stole it. Original was larger.
muisei
Member
Posts: 79 Joined: Sat Sep 23, 2006 2:10 pm
Location: Bulgaria
Contact:
Post
by muisei » Sat Oct 21, 2006 5:00 pm
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);
}
Brynet-Inc
Member
Posts: 2426 Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:
Post
by Brynet-Inc » Sat Oct 21, 2006 5:20 pm
Changing one of the argv[1]'s to argv[2]'s worked.. *PEACE
*
Thanks a lot pal
Twitter: @canadianbryan . Award by smcerm, I stole it. Original was larger.
B.E
Member
Posts: 275 Joined: Sat Oct 21, 2006 5:29 pm
Location: Brisbane Australia
Contact:
Post
by B.E » Sat Oct 21, 2006 6:12 pm
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
Brynet-Inc
Member
Posts: 2426 Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:
Post
by Brynet-Inc » Sat Oct 21, 2006 6:25 pm
Gosh I'm slow today..
dd bs=1 if=boot.bin of=/dev/fd0a seems to work perfectly fine..
Twitter: @canadianbryan . Award by smcerm, I stole it. Original was larger.
gaf
Member
Posts: 349 Joined: Thu Oct 21, 2004 11:00 pm
Location: Munich, Germany
Post
by gaf » Sun Oct 22, 2006 6:12 am
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