how to write a bare-bones-basic hard disk imaging program that runs in DOS

This is a discussion on how to write a bare-bones-basic hard disk imaging program that runs in DOS within the C++ Programming forums, part of the General Programming Boards category; I know this is VERY ambitious, especialy since my programming skills are relatively average (but I learn very quickly) but ...

  1. #1
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19

    Question how to write a bare-bones-basic hard disk imaging program that runs in DOS

    I know this is VERY ambitious, especialy since my programming skills are relatively average (but I learn very quickly) but does anyone have any suggestions or techniques as to how to write a very basic hard disk imaging program like "Norton Ghost 2003" the dos version? I don't want ALL the bells and whistles, just a springboard program that I can then add more functionality over time as my skill level increases. I have the concept of a system that keeps a computer in perfect working order, but I have to use 3rd party software to implement it now, so I can't market it with my business without having my clients also buy Ghost, and I don't think Symantec would smile at what I'm doing, even though it is perfectly leagal! (But if there darn Ghost software actually did what it was supposed to do I wouldn't have to write this system, ever since they moved away from Ghost 2003, nothing works right anymore!!) I need to write my own disk imaging program to be on the safe side. Does C++ (or C)have the ability to manipulate the file locations on a disk, regarding cluster moving etc? Please don't get overly technical with your suggestions (as I said my skills are about 4 from 1 to 10), just concepts or basic functions or algorithims and possibly a code example or 2 to help me get started on my project and learning. I would be very greatful for any comments or suggestions!

    By the way, I know this will complicate things but I need it to be able to manipulate FAT32 and NTFS partitions, but if all you can tell me is how to do just FAT16 manipulation I would still be ever so enlightened and greatful because at least I would have a foundation, then I could learn and figure out the FAT32 and NTFS file system perameters as time progresses!
    Last edited by Salem; 12-29-2006 at 02:34 AM. Reason: Remove bold from the title

  2. #2
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    DOS does not support Filesystems other then FAT16, are you sure you want a DOS program and not a Windows Command promt program?
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  3. #3
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    Ghost 2003 can image NTFS and it runs from DOS, I have a DOS partition with DRDOS installed that I can boot to, I then copied Ghost there and it definitely images my NTFS, so there must be some way of doing it. I know there are also programs out there such as ntfsfordos or something like that that has the ability of reading NTFS partitions, but I would like to write my own, I know it is going to be a daunting task though!

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,598
    DOS supports the following FATs:

    FAT12 - floppy drives
    FAT16/32 - hard drives

    And there was an earlier FAT but you probably won't encounter it on anything you have in your closet and certainly not in an XP DOS session.

    I could not begin to explain to you the details of the FAT system nor how a hard disk actually accesses the drive. But the first thing you would have to do is unmount the drive and gain exclusive access to it via an interrupt.

    From there you would simply use the low-level BIOS routines to access the drive which are readily available in DOS mode and once you have XP out of the way, you should be ok.

    I recommend trying to find information about FAT and NTFS on the internet as there is a ton of information available to you. I have the DOS 6.20 tech ref which explains how to do what you want...in a roundabout way but it is not possible to explain all of it here. Keep in mind that a filesystem is simply a format in which data is saved to a drive so that it can be read back at a later date and yet have the same data as when it was saved.

    FAT uses a table that has cluster numbers. Each cluster represents so many sectors which in turn tells you which head to use since only certain heads can access certain sectors. Each FAT entry points to the next entry until EOF is reached. That's FAT...in a very simplified nutshell.
    Last edited by VirtualAce; 12-29-2006 at 01:02 AM.

  5. #5
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    Where can I find documention for these low-level bios routines?

  6. #6
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    I will research the filesystems on the web, as well as try to get my hands on someones old and dusty DOS technical ref, thats going to be like finding th lost arc!

  7. #7
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    Quote Originally Posted by HyperCreep
    Ghost 2003 can image NTFS and it runs from DOS, I have a DOS partition with DRDOS installed that I can boot to, I then copied Ghost there and it definitely images my NTFS, so there must be some way of doing it. I know there are also programs out there such as ntfsfordos or something like that that has the ability of reading NTFS partitions, but I would like to write my own, I know it is going to be a daunting task though!
    I doubt that Ghost reads NTFS partition as NTFS...
    I suppose it reads partition as raw data to the image without trying to "decode" it as NTFS or FAT

    PS. FAT32 was brought by Microsoft with the Windows 95 OSR2 that's command promt was named DOS 7.0 - cannot say that it was a pure DOS...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  8. #8
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    Ghost must do some sort of file system read of NTFS because it has the option to only image the 'used' space of the partition, leaving out the empty space so as to reduce the size of the image and the time taken as well. I also DID find that there is a program called NTFS4DOS, that runs in DOS (not DOS mode, or DOS in Win95) but real DOS, and can read the files, but I wouldn't trust it with anything critical.....because they say not to...probably just a pet project that turned out pretty good, but not too good. How can these programs do this NTFS reading from DOS?!? I'm sorry to be so adamant about doing this from DOS, but if I did it in Windows, I'm certain Windows would screw it up eventually somehow.

  9. #9
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    In this case I think Ghost provides his own NTFS driver for reading contents of the partition
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  10. #10
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    Not to get off track or to ask too much, but how would one go about writing such an NTFS driver? That is, without having the resources of a multi-billion $ company (like Symantec) at your disposal?

    Also, how would one just manipulate the raw data/bits, disregarding the filesystems?

  11. #11
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,308

    Cool

    What makes you think you need to write your own?
    I have used a free tool one before to do disk imaging. I didn't stick with it, but there are probably some good ones. Writing your own is just asking for trouble.

    Or you could look into getting programs other than Norton ghost. PQDI is one I've used a lot at work and is very good.

  12. #12
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    I am writing an automatic computer maintenance app that I would like to market to my medical clients for my business, I'm sorry but I have to put food on the table, and I can't sell it as a 'complete' app if you must also buy someone else's commercial software for mine to work at all. I'm tired of making these big fish richer (when their products are pretty buggy anyway). As far as freeware.... you can't sell freeware, at least with a good conscience, you can only charge to install it, so I would like to write my own 'all-in-one' app, I have written all the rest of it so far, I just would like to tackle this imaging thing myself, even if it takes me years.

    Oh, and PowereQuest Disk Image was gobbled up by Symantec, and they butchered it, another one bites the dust!

  13. #13
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    FAT uses a table that has cluster numbers. Each cluster represents so many sectors which in turn tells you which head to use since only certain heads can access certain sectors.
    Can you access the disk heads (ha ha 'DISK HEADS') by using C++ or C?

  14. #14
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,761
    > Can you access the disk heads (ha ha 'DISK HEADS') by using C++ or C?
    Nothing like that is part of the language, you have to provide something yourself.

    The languages are portable, so there is no knowledge of such things.

    For what you're trying, it seems you need to write some kind of wrapper around the BIOS interrupt calls which manipulate the disk at the physical level.

    You might find this site useful
    http://www.nondot.org/sabre/os/articles

    There are also some Linux (and hence free source) for reading NTFS partitions. These are all based on reverse engineering the implementation. The actual specifications for NTFS are Microsoft proprietary information. Being RE, they're probably incomplete.
    I don't know if Microsoft would tell you, if you hand over large $$$ and sign an NDA or 10.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  15. #15
    Registered User
    Join Date
    Dec 2006
    Location
    Florida
    Posts
    19
    So did $ymantec and Powerquest make some sort of arrangement ($$$$$) with Micro$oft to get their NTFS standards? Both of those companies have software that seem to work 99.9% correctly with NTFS, either in a Window$ or DOS environment. Or did they just through mega-mucho bucks and man hours into their R&D to reverse engineer NTFS?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Plan
    By Programmer_P in forum C++ Programming
    Replies: 0
    Last Post: 05-11-2009, 02:42 AM
  2. read write from hard disk
    By bojan in forum C Programming
    Replies: 3
    Last Post: 05-17-2006, 02:15 AM
  3. program to check hard disk transfer rate
    By shadow99er in forum C Programming
    Replies: 3
    Last Post: 03-01-2002, 05:04 PM
  4. DOS program versus DOS console program
    By scromer in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 01-10-2002, 01:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21