Computing.Net > Forums > Disk Operating System > Low Level Disk Access (Progmatically)

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Low Level Disk Access (Progmatically)

Reply to Message Icon

Name: DoOMsdAY
Date: June 22, 2000 at 19:16:25 Pacific
Comment:

Anyone know how to access a drive (preferrably a hard drive) as raw data so that I can surf the directory structures and change bits and bytes at my own personal satisfaction? I am trying to write an MS-DOS security program that flags files and directories with security levels on the actual file entry in the directory. The one where 20 = file and 10 - directory...if you know what I mean. I can do it via debug, but want to know how to do so via Assembly or C or Pascal or whatever. Any help would be much appreciated!



Sponsored Link
Ads by Google

Response Number 1
Name: browser
Date: June 23, 2000 at 04:46:54 Pacific
Reply:

Search for a Hex Editor made for disk editing. I believe you can find some shareware or possibly freeware versions. Norton Utility is a good commercial one (newer versions of Norton might be using a different name for it, I'm not sure).


0

Response Number 2
Name: browser
Date: June 23, 2000 at 05:18:53 Pacific
Reply:

As a follow up, I'm not sure if you are aware of it or not, but there are 2 separate copies of the File Allocation Tables. If you start editing the FAT, you have to edit BOTH copies so that they agree with each other or you can create some really bad problems.


0

Response Number 3
Name: Greg
Date: June 23, 2000 at 06:41:58 Pacific
Reply:

Mick C has a copy of Norton Utilities 4.5A on his MS-DOS web pages at www.powerload.fsnet.co.uk

Correct me if I am wrong, but you only get a second FAT with 'Large Disk Support' (FAT32) on Windows 95B (OSR2) Onwards ? ?


0

Response Number 4
Name: DoOMsdAY
Date: June 23, 2000 at 07:16:38 Pacific
Reply:

I am attempting to do the same work as DiskEdit in Norton Utilities. I already know how to do it via Debug and Hex Editors and DiskEdit and the like. I want to be able to do it in a piece of software I am writing. I think it involves Assembly "int 13h" calls from my reading today. Still, thanks for the attempts. :) Also, thanks for the FAT info. I knew there were two, but assumed that if you edited one, the other would mirror it (assuming you edited the correct one...)


0

Response Number 5
Name: DoOMsdAY
Date: June 23, 2000 at 07:22:57 Pacific
Reply:

Greg: (I posted this once but it doesn't seem to want to show.) MS-DOS 6.20 (which I am running) also has two copies of the FAT. In Norton Utilities 5.0 I can edit each one individually. I dunno how long the two FAT trend has been going, but it's definitely there in DOS 6.x.


0

Related Posts

See More



Response Number 6
Name: mr o
Date: June 23, 2000 at 08:04:35 Pacific
Reply:

you could use the dos interrupts 21h, to construct a fcb(file control block) for the files.

as for the the fats, i always thuoght they where both updated by the operating system, but the first one is the only one thata checked by programs (eg chkdsk)


0

Response Number 7
Name: Jon Fox
Date: June 23, 2000 at 15:06:02 Pacific
Reply:

Hmmmmmm...... Ok......
Lets sort out the later replies first.

In the boot sector there's a data table which stores all kind of handy information about the disk/partition. In here (if you know where to look) you'll find the number of FAT's. I've never seen a FAT disk/partition that uses anything other than one copy but the fact that the number of FAT's is located in the boot sector suggest that it's not compulsory to have two.

The OS will update all the file allocation tables if you use the file functions it gives you, but this guy's talking about accessing the disk by bypassing the OS.

The FAT's do not contain file names, attributes, file size or anything like that at all, this info is all stored elsewhere (in the directory entries to be precise). All the file allocation tables store is numbers that either indicate that the cluster is free/bad or else they point to the next cluster in the file chain.

You can use BIOS INT 13h (In C++ biosdisk) or your other option is DOS INT 25 and DOS INT 26 (In C++ that's absread and abswrite, respectively).

The main difference between the two are:
1: INT 13h uses triplet format to specify the sector (SHC).
2: Hard drives start at 80h with INT 13H.

You should note that absread and abswrite will not access partitions >32M.

I would suggest that you go and get a copy of Ralf Browns Int list and read up on those interrupts before you do anything else(there's a link from my web site).

I'll sort out what information I have email it to you.

Good luck!


0

Response Number 8
Name: Greg
Date: June 23, 2000 at 15:39:56 Pacific
Reply:

First of all thank you DoOMsdAY for your feedback, I only wish more posters would be as interactive! You never hear from most of them at all. And to Jon Fox for his detailed reply. I learn a little every day, and only hope some of the other 'little helpers' would learn from thier mistakes!


0

Response Number 9
Name: DoOMsdAY
Date: June 23, 2000 at 15:58:07 Pacific
Reply:

Thanks so much, Jon! That's great. I have three assembly books and I was looking at the int 13h services this morning, but anything that goes into more detail that how to load the registers for the service would be great! Also, Greg, no problem. :) I have spent years teaching myself numerous languages and operating systems and the like, and it would have been great (as well as easier and faster) if people had helped me - but for some reason everyone seemed so guarded about their information. I'm so glad that I'm not alone in my willingness to share information with others, though! I just found this site and everyone here seems pretty good about helping out.


0

Response Number 10
Name: Jon Fox
Date: June 23, 2000 at 18:42:27 Pacific
Reply:

You're welcome. :-)


0

Response Number 11
Name: DoOMsdAY
Date: June 25, 2000 at 15:36:47 Pacific
Reply:

:)


0

Response Number 12
Name: mr o
Date: June 26, 2000 at 04:46:21 Pacific
Reply:

something ive just thought about, i realise the fat just points to the harddisk cluster(s) for the file, but does it also point to the directory structure for the file? erm cos isnt this what the guy needs wants to change?


0

Response Number 13
Name: DoOMsdAY
Date: June 26, 2000 at 07:08:05 Pacific
Reply:

I'm not sure of that either, but in a book I have it tells you where to look for certain information that you can use to get the entry to the root directory. With that, you can then follow offsets to other directories and files. So that's one way at least. I'll post the debug commands if you're interested...


0

Response Number 14
Name: DoOMsdAY
Date: June 26, 2000 at 13:04:43 Pacific
Reply:

That might be a good idea, Jon. I've looked for years for that sort of information and the best I found was this "Underground DOS 6.0" book. It shows you how to do it all via debug. I wish I didn't work full-time. I would have been leafing through that info you sent me by now. :)


0

Response Number 15
Name: Jon Fox
Date: June 26, 2000 at 13:17:03 Pacific
Reply:

Debug eh, are you using L? Because the thing is that that loads the first sector of the partition (the boot sector) rather than the actual first sector (MBR), a fact that I only realised about a couple days ago. I do have more info that you'll need BTW I just haven't sent it yet.


0

Response Number 16
Name: DoOMsdAY
Date: June 26, 2000 at 13:21:13 Pacific
Reply:

Yeps, L x 0 1. Then get a couple of bytes of info and do a quicky equation to get the root directory offset. I think one of the things you can figure out from the boot sector is where the MBR starts, though. I think... Okee, cool! You still have to tell me what kind of info you want to hear about if I learn anything neat...


0

Response Number 17
Name: Jon Fox
Date: June 26, 2000 at 13:27:19 Pacific
Reply:

MBR is the first sector on a hdd. It tells you where each partition starts and ends, what type it is etc. It also contains machine code to load the relevant boot sector into memory and transfer control to it. Don't worry I will.


0

Response Number 18
Name: DoOMsdAY
Date: June 26, 2000 at 13:48:34 Pacific
Reply:

Cool. The MBR is one of the things I played with the least in Debug. I LOVED modifying file and directory entries and seeing if Scandisk would "fix" them and stuff. I did one program to change files to directories or vice versa so you could make a directory, put a bunch of files in it, then turn it into a file...thus making it inaccessible. I did that with Batch and Debug. The Batch would output a Debug script with the appropriate info then execute Debug with it. Okee...hopefully I'll get to play around some tonight on this stuff.


0

Response Number 19
Name: Vishwanath
Date: August 2, 2000 at 01:35:14 Pacific
Reply:

Tooooooo Cool I am also working on a similar program I want to access the disk sectors of my floppy (IN Windows itself NOT IN DOS)

Can any one help me?


0

Response Number 20
Name: SlikTrik
Date: August 17, 2000 at 06:03:57 Pacific
Reply:

I wrote a program that modified floppy sector for copy protection. Int13h will only work with some Windows 95 and early 98 versions. It doesn't appear to work for later versions. The only way I have managed to modify disk sectors (including the boot sector) in Windows 98 onward is to use Int26h in a dos box, after previously issuing a LOCK command, also in the DOS box. I have been unable to lock the file and write to a sector within Windows directly, I guess this is due to virus protection.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: Low Level Disk Access (Progmatically)

Low Level Format? www.computing.net/answers/dos/low-level-format/10925.html

bios www.computing.net/answers/dos/bios/10087.html

low level format Eide hard disk www.computing.net/answers/dos/low-level-format-eide-hard-disk/4864.html