![]() |
Read a bit on the hard drive
What language would be the best language to read the hard drive bit by bit and then display it. for example I'd have a layout of the whole hard drive and then i could select a sector and it'd display the bits and each value. With the possibility of being able to write specifically to the bit. I'm used to VB.Net so if there is any chance it could be done in that, that'd be cool, if not I'm guessing C and C++ would be the way to go.
|
Re: Read a bit on the hard drive
The system usually accesses hard drive data in units of sectors, with sectors often being 512 bytes. There is also a logical unit, typically called a cluster, which is the smallest logical unit the OS deals with (it allocates space on disk as a number of clusters). You won't have bit-level addressability of disk contents; you won't even have this fine access to memory contents (for memory, a byte is the smallest addressable unit).
I'm not sure what your final goal is, but you can read in the contents of a file and display the data. How you display it is entirely up to you; you can display individual bits if that's what you want to do. Writing to an individual bit will entail reading in the cluster (into a buffer), locating the byte and bit within the byte, setting or clearing the bit with a bitwise operation, and then writing the buffer back to disk. However, there is a catch. As far as most application software is concerned, the disk exists in terms of files, and not absolute sectors. Some software, notably disk tools such as defragmenters, imagers, and partitioning tools, will operate at a level below that of the file system in question. I'm not sure how this is done, but in order to accomplish it from application code, you'd doubtless need special permissions from the OS to obtain this level of access. To answer your question, though, assuming you can call whatever API you need from the language in question, any language would be fine. C and C++ both make it easy to call native Win32 API methods, but you can also do it from the .NET family of languages through the use of p/invoke. |
Re: Read a bit on the hard drive
Here's an example from my blog using C# and as lectricpharaoh brings up, it uses Win32 API calls to function since the .NET framework classes available do not support such behaviour, seemingly by design. Anyway here it is, almost guaranteed to break your system with even slight changes...
:
.... |
Re: Read a bit on the hard drive
I want to be able to have this:
Input: StartReadSector EndReadSector For each sector between StartReadSector and EndReadSector Display bit values of the sector, in a binary form. I want to be able to extract an image of the hard drive into the binary form. so 101010111010101010010101010101, etc. But on the Fly and based on where I start and stop. next |
Re: Read a bit on the hard drive
I know this isn't what you preferred. But I have one for floppy, maybe you can figure it out for hdd.
http://www.codeguru.com/cpp/cpp/cpp_...le.php/c13809/ |
Re: Read a bit on the hard drive
PhilBon, just read bytes, then convert them to binary strings.
|
| All times are GMT -5. The time now is 3:59 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC