Alright, what I want to do is simply copy the first sector of the hard disk onto a .bin file on my hard drive.

I've tried with dd but the Cygwin version of dd doesn't recognize /dev/hda as anything (hard drive or otherwise) and I can't seem to figure out how to get it to (quite annoying)

Anyway, I also seem to think the same thing can easily be done with DOS debug.

I'm thinking along the lines of

l cs:100 2 1 1
n mbr.bin

then I'm not really sure what to do next

Would I do
simply after the mbr.bin line? (that is, "w" with nothing else on the line)
How would that guarantee it would take the data from cs:100, though? and, more importantly, how would that ensure it would copy only the exact same number of bytes into that file? (512 bytes, I think)

correct me if I am wrong, but I do believe the sectors start their numbering at 1 instead of 0. Otherwise, I should have used
l cs:100 2 0 1 earlier.

I guess what I'm not so aware of is HOW exactly to get DEBUG.COM to write data from memory addresses into specific files. If someone would elaborate on how to do this, I would much appreciate that.:)

Currently, I have only used DEBUG.COM for sort sample DOS programs and for debugging DOS assembly language programs and for playing around with, but never have used it to actually write anything into a file (only read from a file).

The reason I wish to do this is so I can save my master boot record for use in a boot loader program so I can have this computer booting into WindowsXP, Windows98, Mandrake Linux, OpenBSD, Red Hat Linux, and whatever else I fancy after that. I am aware of the 4 partition limit, but also all of the Linux partitions can use the same physical partition.;) Thanks:)
Posted on 2003-12-22 16:31:12 by ShortCoder
I think Debug uses the value in the saved CX register for the length. It writes from 100h by default, but the address can be changed. Let's say you'd like to write 56 bytes from address 180h. Then you would use these commands:
Posted on 2003-12-23 08:36:07 by Sephiroth3
If I recall correctly, the command "w" writes as many bytes as specified in CX, and starts from CS:IP. You can use "n" to change the name of the output file.
Posted on 2003-12-23 19:01:44 by QvasiModo
Thanks to both of you.:) I really appreciate the input! Too bad WindowsXP will NOT allow any DOS program to directly access the hard disk, even if it is just for reading (GRRRR). I've tried it in Safe Mode, too, and same thing.

I guess I'll have to make a DOS-bootable floppy from a Windows98 machine, then boot off that and copy the MBR onto the floppy using debug and your information, then boot back into WindowsXP and copy from the floppy to the hard disk. --just seems that there should be an easier way than that :o.
Posted on 2004-01-01 17:11:14 by ShortCoder
When scrounging around this site
(which is a very good and up-to-date site on the Master Boot Record, unlike most of them), I managed to find this utility in a link.

Within that zip file is a program named MBRUTIL.EXE which runs natively under Windows.

I opened up the Command prompt, typed
mbrutil /s=MBR.bin
pressed enter, and in the shortest amount of time possible, I had an MBR.bin file sitting right there in the same directory....this being the file I wanted.:)

So, if anyone is wanting to do this but can't use debug.exe or dd to do this from within a WindowsNT-based machine, download that program and use it---much quicker and easier.

BTW, that site seems to be down a lot from "bandwidth exceeded". (The Geocities site, that is)

It is very informational though.
Posted on 2004-01-01 20:48:06 by ShortCoder
It's (l 100 2 0 1) for boot sector


n "your file name".bin


rcx 200 (sector size also size of your file)

rbx 0 (to make sure not several 64K segment)


Posted on 2004-01-01 20:57:29 by mrgone