kahn@xanth.cs.odu.edu (Gary I Kahn) (12/25/88)
The boot sector on a floppy disk is at head 0, track 0, sector 1. Can someone tell me where the corresponding sector is on a hard disk? I'm trying to locate the bytes on the disk which give information about the number of sectors, heads, and tracks. I tried using INT 13 to read the sector mentioned above (0/0/1), but it turned out to not be the boot sector. The disk-editor utilities I tried use logical sector numbers, not tracks and heads. Thanks in advance.
dougm@kuhub.cc.ukans.edu (Douglas Miller) (12/26/88)
You are on the right track using INT13h. The sector at Cylinder 0, Head 0, Sector 1 is something you do need to find the boot record you're looking for. Contained in that sector is something called the Partition Table. It begins at offset 1BEh. The BYTE at that location is the Boot Indicator which must be 80h for a bootable partition. The next three (3) BYTES contain the stuff you want, namely the Head, Sector and Cylinder address of the DOS boot record of the first partition. (Incidentally, the other three partition records start at 1CE, 1DE, and 1EE). Anyway, the Head is offset 1BF, the Sector is offset 1C0, and the Cylinder is at 1C1. Cylinder contains the low-order 8 bits of the cylinder number and the sector byte contains the sector address plus the high-order two bits of the cylinder number. This happens (strictly by chance, mind you) to be exactly what the BIOS routine needs in its registers. Thus, only two MOV instructions are needed to set up DX and CX. Have fun, but be VERY VERY SURE that AH has a 2 in it when you do this.
philip@amdcad.AMD.COM (Philip Freidin) (12/26/88)
In article <6941@xanth.cs.odu.edu> kahn@xanth.cs.odu.edu (Gary I Kahn) writes: >The boot sector on a floppy disk is at head 0, track 0, sector 1. >Can someone tell me where the corresponding sector is on a hard disk? >I'm trying to locate the bytes on the disk which give information about >the number of sectors, heads, and tracks. I tried using INT 13 to read >the sector mentioned above (0/0/1), but it turned out to not be the >boot sector. The disk-editor utilities I tried use logical sector numbers, >not tracks and heads. Thanks in advance. Since I did this half an hour ago, it is still fresh in my little mind: assume you want to look at drive C, (drives are numbered from 0 (A), 1 (B), 2 (C). you want the first sector of the hard drive (512 bytes). go into debug (the worlds best word processing editor), and look at the value of CS. This is where you will have some free room. C:>debug rcs CS 4532 : Dont type anything, just return L 4532:0 2 0 1 load at the specified address (4532:0 you got this number from the rcs enquiry) from drive 2 (you got this from me, assuming you want drive C), starting at sector 0, for 1 sector(s). d 4532:0 l 200 there is the boot sector. first 3 bytes are a jump to the boot code. the next 20 or so bytes are the drive format descriptor table you are looking for. n bootblk.bin get ready to write it out as separate file rbx BX ???? :0000 set BX to 0 rcx CX ???? :0200 set up to write out 512 bytes w 4532:0 write the boot block (512 bytes) to a file called botblk.bin And there you have it. lots of fun. Philip Freidin @ AMD SUNYVALE on {favorite path!amdcad!philip) Section Manager of Product Planning for Microprogrammable Processors (you know.... all that 2900 stuff...) "We Plan Products; not lunches" (a quote from a group that has been standing around for an hour trying to decide where to go for lunch) Turns out, we can't even plan products.
feg@clyde.ATT.COM (Forrest Gehrke) (12/27/88)
In article <6941@xanth.cs.odu.edu>, kahn@xanth.cs.odu.edu (Gary I Kahn) writes: > The boot sector on a floppy disk is at head 0, track 0, sector 1. > Can someone tell me where the corresponding sector is on a hard disk? > I'm trying to locate the bytes on the disk which give information about > the number of sectors, heads, and tracks. I tried using INT 13 to read > the sector mentioned above (0/0/1), but it turned out to not be the > boot sector. The disk-editor utilities I tried use logical sector numbers, > not tracks and heads. Thanks in advance. Unlike floppy disks, the HD uses the first sector as the partition sector, and this is the sector you accessed. The last 4 paragraphs of the 512 bytes of this sector list the data of the 4 possible partitions of the HD. The bootable partition paragraph begins with hex 80 and this paragraph will have the head, cyl and sector info for the boot sector. If memory serves me, using INT 13, the boot sector is located as 0/1/0. You can identify the boot sector by looking at bytes (decimal) 4 through 11. This will give information including the msdos version number. Somewhere around the end of this sector you will see listed the two hidden file names. If you are not sure what the boot sector looks like, try this: In debug: l ds:1000 2 0 1 d ds:1000 l200 The first command loads the first relative sector of the C disk to memory starting at ds:1000 The second command reads the 512 (decimal) bytes of the boot sector. Debug can not access the partition sector. Forrest Gehrke