Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Absolute Disk Read 2

Status
Not open for further replies.

Prattaratt

Technical User
Aug 6, 2000
291
0
0
US
Back in the good old days of MS DOS and small hard drives, I wrote a program that examined the boot sector using interrupt 25H.  After upgrading to a new system with a much larger HD, the INT 25H no longer works with the hard drive.  (It does work on floppies though.)  Any suggestions on absolute disk reads for FAT32 systems?
 
Interrupt 25h was used pretty much, exclusively, by Stacker. (Ah, those <i>were</i> the good old days. I gave up Stacker with more than a few kicks and screams.)<br><br>Unless you are running NT you might try Interrupt 13h, function 02h.<br><br>AH will be 02h<br>AL will contain the number of sectors to read<br>CH will contain the low eight bits of the cylinder number<br>CL (bits 0-5) will hold the sector number<br>&nbsp;&nbsp;&nbsp;&nbsp;bits 6-7 reference the drive number (leave it at 0 until it works well on the floppy in A:)<br>DH is the head number<br>DL is the drive number (bit 7 is set for hard drives)<br>ES:BX points to the address of the data buffer (which should be sized 200h times the number of sectors you intend to read.)<br><br>Interrupt 13h, function 03h mirrors function 02 but is intended to write disk sectors.<br><br>Don't bother to try these or any other low-level disk access calls under NT. The OS will get very weepy and complain that such a thing cannot be allowed.<br><br>And remember, <b>always test low-level disk access functions on a floppy or a throw-away hard drive!</b> I can't stress this enough.<br><br>I hope Int 13 is what you were looking for. Use the call with some caution.<br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
I did, but got nothing but received garbage from the read.&nbsp;&nbsp;However, after about four hours of research on the Microsoft developers site, found a little known function in the DOS services interrupt (21H); AX = 7305H.&nbsp;&nbsp;This works, but only for the first time.&nbsp;&nbsp;After that it gives me the same error that INT 25H gives me.&nbsp;&nbsp;I tried reseting the disk system with INT 13H, ah=0 and ah=0Dh, but to no avail.&nbsp;&nbsp;Would really like to get this to work.
 
The &quot;Old Ones&quot; used to recommend performing Int13 functions 2h or 3h at least four times, interspersed with calls to function 0 (reset disk system). I haven't had any problem reading a hard drive with a single call to function 0 followed by a call to function 2h but, with a floopy, you have to allow the media to get up to speed (at least, on the first sector read.<br><br>I haven't heard of the Int21 function you refered to. What is it intended to do? Is it third-party specific?<br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
&nbsp;&nbsp;Found the information for function 7305H on Microsorft's Developer Support website.&nbsp;&nbsp;Here is the address:&nbsp;&nbsp;<br><br><A HREF=" TARGET="_new"> on the TOC icon and a whole lot of info on the win32 SDK pops up.<br>&nbsp;&nbsp;I STILL can't find the DOS bootsector using INT 13H functions.&nbsp;&nbsp;Got the MBR, but no DOS Boot record any where on disk using INT 13H.&nbsp;&nbsp;Believe me, I've searched!&nbsp;&nbsp;I know it's there, Just can't find it.
 
After reviewing thre code for my INT 13h routine, found a problem with the address calculation sub-routine that prevented it from reading the disk sector where the DOS Master Boot Record was kept.&nbsp;&nbsp;After correcting that, everything worked perfectly.&nbsp;&nbsp;Thanks for all the help!
 
Any time, Prattaratt. And <i>thank you</i> for making my day. A few Tek-Tips members don't post back after they have solved the problem and one always wonders how it all turned out.<br><br>Pardon my curiosity... but were you attempting to address sector 0 instead of sector 1? The reason I ask is that I made that error the first time I tried to read a boot record. Logic suggested that sector numbers should begin with 0.... <br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
No, The problem was in the address calculation logic.&nbsp;&nbsp;I wasn't figuring the head/cylinder switch over properly, and wound up skipping several cylinders.&nbsp;&nbsp;STUPID Mistake on my part.&nbsp;&nbsp;However, there were a few kinks in the FAT 32 system that had to be taken into account;&nbsp;&nbsp;The BFB (BigFatBootsector) Structure is a tack-on to the regular bootsector structure and some of the info given by the regular boot sector structure was zeroed, giving me coniptions until I tracked down the structure info.
 
Excellent work! Will you be willing to release your findings to Tek-Tips? It sounds like it would make a killer FAQ for the members who reach for the low-level solutions.<br><br>If you say &quot;no&quot;, I think we will all understand. &lt;Sob&gt; We will just have to spend a few hours of frustrating research to replicate the problem you described and hunt down the solution on the Internet.<br><br>Really, my whining commentary is intended with good humor &lt;grin&gt;. I thought I had a fair grasp of the calls and their implications but, now, I realize I had overlooked some important issues. Windows and some third-party firmware solutions (like Maxtor EZ-Drive) do mysterious things to the hard disks.<br><br>Realizing that our code(s) should work on all machines, I was forced to don my tattered thinking cap.<br><br>The gears are beginning to turn...<br><img src=http:\\vorpalcom.com\images\gears.gif><br>Thanks, Prattaratt, for making my day twice in one day.<br> <p> <br><a href=mailto: > </a><br><a href= plain black box</a><br>
 
I'm a bit confused as to how i actually ask a question here but i'll give this a go.
I want to know if there is a way of reading/writing from the hard-drive(FAT32) under WIN2000. I thought int25 (abs disk read/write) would do it but am not so sure after reading the discussions above. I can't use BIOS int13h cos of NTs rejection of it.. (well I haven't tried, but am basing this on Alt255's discussion). There is the extended version of int25 for large hdisks but i really only want to read/write from the Master Boot Record to the end of the FAT tables (incl. everything in between).
It's part of a project to provide security for the hard drive.. if you want to know more just email me and i'll be happy to fill you in.(9727647@student.ul.ie)
Also is there a specific DOS functoin to return the master boot record. I need access to info such as num of sectors etc. At the moment i'm using int21 440Dh to get a drive parameters table, and am also using DOS function getfat(). These together give me enough info to calculate the disk size but i think the figures returned might be wrong because in windows the disk size is always different (by a factor of 10 even). The drive i'm using is 10Gb .. not sure of the make/model.
Any suggestions would be appreciated.
 
Returning to this thread after so long due in part to busy work at my job, I have learned the following items of interest to persons monitoring this thread:

In response to the above about getting hard disk specifications, the following is very helpful:

A. Getting the number of installed hard drives is found at the BYTE located at 40h:75h.

B. Ralph Brown's Interrupt List was extremely useful, particularly the information on INT 41h/48h (Hard Disk 0/1 Information Table Address). The BIOS INT 13H Get Disk Information routines are ALWAYS OFF! The tables located at the addresses stored in Interrupt Vector 41H and 48H always give good numbers.

C. There are extended BIOS functions for Fixed disks over 8 GB. These functions start at INT 13H AH = 41H.
 
howto write operating system in asm howto boot and write hello
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top