Hard Disk Sector Editor in C - How do I make it work?
Author |
Message |
Dan Richards #1 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Hi All, ==================== 1. EXE Functionality ==================== I've found this little 1989 utility being capable of editing a FAT32 hard disk under Windows 98, at least regardsing the EXE file that came along. Here's an example screen printout of a BLANK hard disk sector, as it would appear at runtime. NOTE: it DOES actually work for sectors WITH data in them; this is just an example of the GUI: Laine's Mighty Disk Editor v0.0 02/13/89 ????? ??1 0 1 2 3 4 5 6 7 8 9 A B C D E Fo0123456789ABCDEFo ??1 o00o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o01o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o02o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o03o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o04o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o05o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o06o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o07o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o08o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o09o00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o0Ao00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o0Bo00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o0Co00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o0Do00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o0Eo00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o o0Fo00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00o................o ? PgUp/PgDn - Prev/Next Sector, F10 Updates Sector (alt+F10 enables update) G - Goto Sec, M - Modify byte, R/W - Read/Write Sec to/from File, ESC to quit ======================== 2. Attempted Compilation ======================== However, the author said that its source code (see below) was tested on Turbo C++ v1.5 and Zortech, yet I could NOT compile it with a Turbo C++ v3.0, which I suppose should have been backward compatible with Turbo C++ v1.5 ? It kept complaining about all sorts of missing variable declarations that WERE nicely declared within its various "include" files. ===================================== 3. Code Rearrangement for Compilation ===================================== So, what I did was, I took all "define" and declaration statements out of the "include" files and put them, along with all functions and other code, into a single file I called "edit_2.c" that I created especially for that. ================================= 4. Compile Successful: Now What ? ================================= Surprisingly enough it all compiled (using Turbo C++ v3.0) and a nice EXE was produced. However when I ran it, nothing happened - seemed like I should have called various functions myself - as there was no "main()" function at all. ================ 5. Advice Needed ================ Could anyone be kind and please take a look at the code - and tell me exactly what I should add to it in order to make it perform its intended purpose ? Appreciate any help, Thanks a lot, Dan Richardson NOTE: both original and modified source code listings will follow this post. ==================================================
|
Wed, 24 Aug 2005 00:39:54 GMT |
|
 |
Nick Stee #2 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
You are surely confused. How can a utility written in 1989 edit "FAT32 disks" whatever they are? I'd leave this well alone if I were you. There are much better ways of learning C
<stuff>
|
Wed, 24 Aug 2005 03:04:10 GMT |
|
 |
Morris Dove #3 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Quote:
> You are surely confused. How can a utility written in 1989 edit > "FAT32 disks" whatever they are? > I'd leave this well alone if I were you. There are much better ways of > learning C
Nick, what better way to learn than by trashing a system? Dan, just make certain that /everything/ you care about is backed up before you start. Nick is right in saying that such an editor offers a considerable risk factor - even after it's been thoroughly debugged. Before you hack on this code, it would be a really good idea to completely understand what you're doing (and your post indicates that you may not.) You've posted enough code for force most who want to help you to spend /hours/ of effort on your behalf. That's not necessarily a bad thing of itself, but it seriously reduces the number of people who'll be willing to help... A better strategy might be to ask 'smaller', more C language specific and less OS specific questions as you progress. -- Morris Dovey West Des Moines, Iowa USA C links at http://www.iedu.com/c
|
Wed, 24 Aug 2005 03:41:20 GMT |
|
 |
CBFalcone #4 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Quote:
> You are surely confused. How can a utility written in 1989 edit > "FAT32 disks" whatever they are?
By dealing with files, rather than raw disks. I think the OP is confused about what he is editing. I occasionally use an editor dated 1986. Works fine. --
Available for consulting/temporary embedded and systems. <http://cbfalconer.home.att.net> USE worldnet address!
|
Wed, 24 Aug 2005 10:33:30 GMT |
|
 |
Nick Stee #5 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Sorry, I was being too subtle. Unless I'm mistaken, in 1989, there was no such thing as FAT32, and even now there are FAT32 file-systems or partitions, not FAT32 disks. Such subtleties should be respected by anyone intending to write directly to the "raw disk" (in which case FAT32 is meaningless anyway) Playing with fire...
Quote:
>> You are surely confused. How can a utility written in 1989 edit >> "FAT32 disks" whatever they are? >By dealing with files, rather than raw disks. I think the OP is >confused about what he is editing. I occasionally use an editor >dated 1986. Works fine.
|
Wed, 24 Aug 2005 18:21:15 GMT |
|
 |
Dan Richards #6 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
======================================================== BETTER : Hard Disk Sector Editor in C - in plain English ======================================================== Hi All, I appreciate the quick responses (even though not yet technically specific, as I would later hope). -------------------------------------------------- 1. For all those worrying about my "beginnerness" - please be advised as to the following: 1.1. I've had as yet a little bit of experience in the computer field - well over 10 years :-) 1.2. About the same goes for my knowledge of various programming langauges - such as ASM, Basic, Pascal. 1.3. Everything I care about, data-wise, is backed up in multiple copies :-) 1.4. My system configuration (including all software installations and the like) is also backud up. 1.5. So, as one may figure out, I would NOT be afraid of messing around with my machine whatsoever... 1.6. I hope now that everybody's rest assured :-) -------------------------------------------------- 2. To Morris: your advice about asking 'smaller' was indeed an excellent one. I'll stick to it from now on, as much as I can, and NOT pour in a whole bunch of code lines; instead, I will do my best to explain the things I want to do in plain English. -------------------------------------------------- 3. Basically, my problem is very simple: 3.1. I need to be able to read/write absolute sectors of whichever drive on my machine - being a floppy, hard/fixed, CDROM or even a RamDisk. 3.2. Having looked at Turbo C++ v3.0's online help system, it seemed like there are two (2) functions that were designed for that purpose: - absread - abswrite 3.3. Unfortunately, when I copied their example and tried specifying "0x80" as the "Drive" (for the hard disk), having run the "absread" code gave me a "Disk Problem" error. 3.4. I tried to look at some other stuff within the online help system, and found two (2) other functions: - "biosdisk" - "_bios_disk" 3.5. Unfortunately, the examples for THOSE functions showed all kinds of interrupts OTHER than "Int 25" and "Int 26" (which are used for "absread/abswrite" stuff) which, again, wasn't much help either. -------------------------------------------------- 4. Therefore, would anyone please tell me how to do the following? 4.1. A "read/write" of absolute sectors - ESPECIALLY on a hard disk; please note that the 1989 utility worked WELL on my FAT32. I even saved, erased, and then successfully restored critical data from sectors, such as the bootstrap and portions of the FAT. 4.2. Is there code anywhere for reliably identifying all drives on a system ? - Regardless if I booted from a floppy or opened a DOS box ? 4.3. How could I use "Int 13" - which seems to be what the 1989 utility uses - instead of "Int 25" or "Int 26" ? * Also, please keep in mind that: 4.3.1. I don't have all too much knowledge about using interrupts in general; 4.3.2. I've programmed in C very little; 4.3.3. Should ASM code become necessary, I'd really like to use it either inline (as a "wrapper" function) or as a linkable OBJ code/file. -------------------------------------------------- I hope I've been clearer now about what it is I want to be able to accomplish, regarding that 1989 utility: I want to duplicate its functionality, which I can do only if am able to "read/write" absolute sectors. For all good people who wish to help - thank you! Best regards, Dan Richardson
|
Wed, 24 Aug 2005 23:53:30 GMT |
|
 |
Mark McIntyr #7 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
On 8 Mar 2003 07:53:30 -0800, in comp.lang.c , Quote:
>3. Basically, my problem is very simple: > 3.1. I need to be able to read/write absolute > sectors of whichever drive on my > machine - being a floppy, hard/fixed, > CDROM or even a RamDisk.
Okay, this is offtopic here, you've not already been told htat, I'm sure. You need to ask in a programming group specialising in your OS and compiler. Quote: > 3.2. Having looked at Turbo C++ v3.0's
This is a very old compiler. It probably predates Win9x, and certainly predates Win2K etc. Modern versions of windows do not allow direct disk access, since they're protected OSen. Quote: >4. Therefore, would anyone please tell me how to > do the following? > 4.1. A "read/write" of absolute sectors -
Ask in the right group -- Mark McIntyre CLC FAQ <http://www.eskimo.com/~scs/C-faq/top.html> CLC readme: <http://www.angelfire.com/ms3/bchambless0/welcome_to_clc.html>
|
Thu, 25 Aug 2005 00:21:32 GMT |
|
 |
Morris Dove #8 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Dan... I think you'll need to pursue X86 and DOS-ish aspects of this problem in newsgroups with those interests - comp.lang.c tries (more or less successfully) to maintain a focus on the portable standard C programming language. I'm aware that these other newsgroups exist; but not the group names. Perhaps someone who /does/ know would be willing to redirect?. I'm not sure how to even approach the 'identify all drives' problem. This could be a significant piece of work. There are so many ways of attaching drives (SCSI, USB, Firewire, ad quasi infinitum) that you might want to lower your sights just a bit for the /initial/ implementation - unless this is resolved for you by standard BIOS calls. I'd suggest isolating environment/hardware specific code so that this NG can help you with the rest of the code. This is usually not a bad design practice anyway and will keep the flamethrowers at idle. :-) -- Morris Dovey West Des Moines, Iowa USA C links at http://www.iedu.com/c
|
Thu, 25 Aug 2005 00:29:35 GMT |
|
 |
#9 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Dan Richards #10 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Hi All, 1. I will definitely redirect my question(s) to some other, more suitable groups. 2. To Morris: thanks for being so nice! 3. To all flamethrowers: you could be slightly nicer, don't you think? Good manners won't hurt you. All I wanted to do is ask a question about some topics that I don't know much about (as some of you have so unpleasantly mentioned). I really was asking for help, and if someone came up to me with ANY no-nonsense quetsion, I'd help that person right away! Have a nice day, Best regards, Dan Richardson !
|
Thu, 25 Aug 2005 06:43:23 GMT |
|
 |
pete #11 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
Quote:
> Good manners won't hurt you.
Agreed. Quote: > I really was asking for help, and if someone came up to > me with ANY no-nonsense quetsion, I'd help that > person right away!
Depending on how off topic the no-nonsense quetsion is, if you would do that on this newsgroup, you might get flamed for it. It's only because most of the regulars here are sincerely interested in C, that they're are also interested in topicality. Compared to this newsgroup, most others are zoos. -- pete
|
Thu, 25 Aug 2005 08:36:29 GMT |
|
 |
#12 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
 |
Black Phant #13 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
[...] Quote: > 1. For all those worrying about my > "beginnerness" - please be advised > as to the following: > 1.1. I've had as yet a little bit of > experience in the computer field - well > over 10 years :-) > 1.2. About the same goes for my knowledge > of various programming langauges - > such as ASM, Basic, Pascal.
Sorry, but what you say below contradicts this. Virtually everybody who was programming in assembly about 10+ years ago got to know the correct values for BIOS interrupts (on PC) as well as details of disk access. Quote: > 3. Basically, my problem is very simple: > 3.1. I need to be able to read/write absolute > sectors of whichever drive on my > machine - being a floppy, hard/fixed, > CDROM or even a RamDisk.
I don't think you'll be able to do it easily - all these have different low-level interfaces. At least not with that program of 1989, when CDROMs weren't too common and most hard disks didn't have LBA addressing mode. Quote: > 3.2. Having looked at Turbo C++ v3.0's > online help system, it seemed like > there are two (2) functions that > were designed for that purpose: > - absread > - abswrite > 3.3. Unfortunately, when I copied their > example and tried specifying "0x80" > as the "Drive" (for the hard disk), > having run the "absread" code gave > me a "Disk Problem" error.
Apparently because 0x80 means hard disk only for BIOS interrupts. DOS interrupts 0x25/0x26 use logical drive number. Quote: > 3.4. I tried to look at some other stuff > within the online help system, and > found two (2) other functions: > - "biosdisk" > - "_bios_disk" > 3.5. Unfortunately, the examples for THOSE > functions showed all kinds of interrupts > OTHER than "Int 25" and "Int 26" (which > are used for "absread/abswrite" stuff) > which, again, wasn't much help either.
Int 0x25 / 0x26 are DOS interrupts; BIOS uses int 0x13. Quote: > 4. Therefore, would anyone please tell me how to > do the following? > 4.1. A "read/write" of absolute sectors - > ESPECIALLY on a hard disk; please note > that the 1989 utility worked WELL on my > FAT32. I even saved, erased, and then > successfully restored critical data > from sectors, such as the bootstrap > and portions of the FAT.
I assume it should work WELL on NTFS or ext2, too. Quote: > 4.2. Is there code anywhere for reliably > identifying all drives on a system ? > - Regardless if I booted from a floppy > or opened a DOS box ?
Since sector-level access probably won't work in a "DOS box" on any sane OS, I fail to see why you need it. Quote: > 4.3. How could I use "Int 13" - which seems > to be what the 1989 utility uses - > instead of "Int 25" or "Int 26" ? > * Also, please keep in mind that: > 4.3.1. I don't have all too much > knowledge about using interrupts > in general; > 4.3.2. I've programmed in C very little; > 4.3.3. Should ASM code become necessary, > I'd really like to use it either > inline (as a "wrapper" function) > or as a linkable OBJ code/file.
So do you want to learn 4.3.1/2/3 or want somebody else to write a sector editor for you? In the latter case, just look for freeware sector editors - I believe there are a lot pf them available. In the former case - you have many questions and no one of them has anything to do with C (or any other programming language, too). What you need is: 1) A good reference of DOS/BIOS interrupts. Look in http://www.google.com for "Ralph Brown's Interrupt List" or "HelpPC". 2) Understanding of how disks work on low level 3) Interface to assembly language of your complier - check its reference manual The right groups for this topic are:
/BP
|
Fri, 26 Aug 2005 04:37:14 GMT |
|
 |
#14 / 19
|
 Hard Disk Sector Editor in C - How do I make it work?
|
Wed, 18 Jun 1902 08:00:00 GMT |
|
|
Page 1 of 2
|
[ 19 post ] |
|
Go to page:
[1]
[2] |
|