-
April 25th, 2004, 04:07 PM
#1
Writing to specific disk areas.
Okay, here's the deal. I want to know how to write to specific area's on the hard disk in C++. Such as:
writing zeros to a specified sector
writing the MBR
formatting the disk w/out 'system("format c:");'
formatting a disk in a specific format, or a new one
writing to FAT tables
writing partitions
I know other languages can do this better, but I'd prefer C++, or the syntax for BAT files.
I'm quite interested in making one of those disk wiping programs, and creating a partitioning utility. A defragment utility, or a FAT table/MBR backup utility is also on the list.
So if you have specific information, or specific pages to view, that would be helpful as I can't seem to find too much via google.
AxessTerminated
Geek isn't just a four-letter word; it's a six-figure income.
-
April 25th, 2004, 06:34 PM
#2
Umm, maybe start by checking out the source code for something like mkfs.fat32? That should give you a general idea of how its done.
Chris Shepherd
The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
\"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
Is your whole family retarded, or did they just catch it from you?
-
April 25th, 2004, 08:27 PM
#3
I googled 'mkfs.fat32 "source code" ' and got nothing useful, i tried without the quotes as well. Where can I obtain the source? From what I did see, it seems to be a Linux app, is this so?
Geek isn't just a four-letter word; it's a six-figure income.
-
April 25th, 2004, 08:33 PM
#4
My bad, I have mkfs.fat32 set to alias a particular "mkfs.msdos" command.
Yes, it is a linux app, but it should at least give you a starting point on how to approach the design of the application.
Chris Shepherd
The Nelson-Shepherd cutoff: The point at which you realise someone is an idiot while trying to help them.
\"Well as far as the spelling, I speak fluently both your native languages. Do you even can try spell mine ?\" -- Failed Insult
Is your whole family retarded, or did they just catch it from you?
-
May 7th, 2004, 02:26 PM
#5
You have not specified what OS you are using, such operations are likely highly OS specific - there is no standard API to do it.
Under Linux you would have to determine what device file the device was (for example /dev/hda), and open the file, seek to the appropriate place and read/write as necessary.
On NT, it would be similar, you could use CreateFile with the raw disc device name (I believe they are called something like \\.\c or something). These NT device names are rather weird, you should look them up.
Of course in either case you'll need root or administrator privileges to open the raw device.
By the way, those backslashes above may get trashed by AO.
Slarty
-
May 7th, 2004, 02:26 PM
#6
You have not specified what OS you are using, such operations are likely highly OS specific - there is no standard API to do it.
Under Linux you would have to determine what device file the device was (for example /dev/hda), and open the file, seek to the appropriate place and read/write as necessary.
On NT, it would be similar, you could use CreateFile with the raw disc device name (I believe they are called something like \\.\c or something). These NT device names are rather weird, you should look them up.
Of course in either case you'll need root or administrator privileges to open the raw device.
By the way, those backslashes above may get trashed by AO.
Slarty
-
May 7th, 2004, 04:27 PM
#7
I always thought you'd do raw disk writing using BIOS, at least that's how I've seen it done before. Perhaps a good book on assembler would be what you need to learn some basics of it. I learned a bit of that kind of thing from "The revolutionary guide to assembly language". It's a little out of date, but if you like doing hardcore BIOS and DOS level programming, it's a good read. As for doing it in C++, I'd say familarize yourself with working with BIOS (I'm not a C++ programmer, so i don't know anything about it).
Is there a sum of an inifinite geometric series? Well, that all depends on what you consider a negligible amount.
-
May 7th, 2004, 04:27 PM
#8
I always thought you'd do raw disk writing using BIOS, at least that's how I've seen it done before. Perhaps a good book on assembler would be what you need to learn some basics of it. I learned a bit of that kind of thing from "The revolutionary guide to assembly language". It's a little out of date, but if you like doing hardcore BIOS and DOS level programming, it's a good read. As for doing it in C++, I'd say familarize yourself with working with BIOS (I'm not a C++ programmer, so i don't know anything about it).
Is there a sum of an inifinite geometric series? Well, that all depends on what you consider a negligible amount.
-
May 7th, 2004, 07:42 PM
#9
Flaming Rain, I believe you are a bit confused on what BIOS are...I'm very familiar with them, and they have nothing to do with writing to disk.
Anyways, This would be done on a Windows box, though could be used for a Linux box as well. I know there is no API, that's why I'm looking for sample code. For instance, I want to write all zeros to sector 5, how could I go about doing that? Also, I'd like to access the MBR via C++; editing, deleting, creating new ones...etc etc.
[edit]
P.S. I'm aware that learning assembly would make this easier in the long run and all that good stuff, but I'm looking for a way to do this in C++, without the asm() backdoor, or any assembly for that matter. I'm too lazy to learn that on my own.
[/edit]
Geek isn't just a four-letter word; it's a six-figure income.
-
May 7th, 2004, 07:42 PM
#10
Flaming Rain, I believe you are a bit confused on what BIOS are...I'm very familiar with them, and they have nothing to do with writing to disk.
Anyways, This would be done on a Windows box, though could be used for a Linux box as well. I know there is no API, that's why I'm looking for sample code. For instance, I want to write all zeros to sector 5, how could I go about doing that? Also, I'd like to access the MBR via C++; editing, deleting, creating new ones...etc etc.
[edit]
P.S. I'm aware that learning assembly would make this easier in the long run and all that good stuff, but I'm looking for a way to do this in C++, without the asm() backdoor, or any assembly for that matter. I'm too lazy to learn that on my own.
[/edit]
Geek isn't just a four-letter word; it's a six-figure income.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|