473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Trying to design low level hard disk manipulation program

I posted this on comp.lang.asm.x86, alt.os.development, comp.arch,
comp.lang.c++

Im working with windows xp professional, NTFS and programming with
MASM, c++ (free compiler) or visual basic 6.0

=== question 1

Primarily Im trying to design a program that has full control over a
hard disk. What it needs to do is find out what sectors haven't been
written to and be able to write anything there, but doesn't count
towards disk space, IOW the data is user defined garbage with no
consequense if overwritten.

As a very gum-and-bandaid idea for an open space hard drive sweep,
could i simply create a file the size of the remaining data in the hard
drive save it then delete it? Would this in effect fill all available
space with user defined garbage? Although ideally Id like to pinpoint
empty sectors and write to them.

=== question 2

Secondarily make a full delete, thus where a file was is now just
zeros. For this, if I were to open a file with any given language
specific 'open' methood re-write the open data with the exact data
length of zeros then resave it, would that accomplish this task? Or
would the data be saved in a new sector and pointed to that leaving the
original data intact but unattainable?
IOW if you open a file from the hard disk make changes and save it,
does it save to the same physical location the file was pulled from?

== am i on the right track?

I've scoured the web with little success. What i am working towards is
using the Master Record Table (MRT) of the NTFS and seeing if i can
find the sectors that aren't written to and write there for the primary
task and follow the pointers and write there for the secondary task.
Does anyone have a reference on how to programmatically access the MRT?

Ive also come across BIOS function INT 13H which is low level disk
operations. This seems to be of help, has anyone had success in using
it?

Thanks for any help.

Jesse

Sep 19 '06 #1
13 4816
Im working with windows xp professional, NTFS and programming with
Try first working with FAT32 for HDD if you can repartition(PartitionMagic)
or FAT12 using FDD) cause some here may know NTFS internals but like many
like me have only looked into FAT## FS and unix/linux FSs... Using FDD is
better cause you only have to start looking at the disk at a 1.14MB scale
and since your HDD partition isn't near 99.999% full this file
EatUpFreeSpace.dat will be too big(many MBs) to read(you as a human[using
HEX editor] at first before you can code the program to read it) the cluster
chain to see where all those EatUpFreeSpace.dat sectors are...
As a very gum-and-bandaid idea for an open space hard drive sweep,
could i simply create a file the size of the remaining data in the hard
drive save it then delete it? Would this in effect fill all available
space with user defined garbage? Although ideally Id like to pinpoint
empty sectors and write to them.
Also note clustors and sectors can be different depending to FS so
##K(FAT32/NTFS) size cluter can take up ## * 1024 sectors and only part the
first 1 sector may really be used. Example Windows for some reason needed to
allocate clustor to a file ##,###,### bytes and Windows went thur and found
many clustors for all but 349 bytes so Window allocates one more of size ##K
and and saves the 349 bytes and the rest of clustor is wasted space [(## *
1024) - 1 sectors never getting anymore delete to hold untill the file is
deleted and Windows later allocate clustors]...
Secondarily make a full delete, thus where a file was is now just
zeros. For this, if I were to open a file with any given language
Doing this does will only make write zeros where EatUpFreeSpace.dat sectors
actucally contained the files data any clustors(I think only the last one)
allocated to EatUpFreeSpace.dat may contain wasted space [(## * 1024) - 1
sectors] in my prev example holding 349 bytes. Filling EatUpFreeSpace.dat
with zeros fills all the other allocated clustor with zero and the last zero
the 349 bytes... So the wasted space now contains what was there before
either an ASCII format charatcer that some drive formatters write or random
data the used to be valid in a old file deleted before EatUpFreeSpace.dat
was created...
would the data be saved in a new sector and pointed to that leaving the
original data intact but unattainable?
IOW if you open a file from the hard disk make changes and save it,
does it save to the same physical location the file was pulled from?
I don't know this...
I've scoured the web with little success. What i am working towards is
using the Master Record Table (MRT) of the NTFS and seeing if i can
find the sectors that aren't written to and write there for the primary
task and follow the pointers and write there for the secondary task.
Does anyone have a reference on how to programmatically access the MRT?
I don't know this... Like I say FAT12 or FAT32 is more well known interally
than NTFS in the public. So look for Master Boot Record(MBR - HDD only) and
Boot Parameter Block(BPB in the bootsector of FDD and bootsector of each HDD
partition pointed to by the MBR)...
Ive also come across BIOS function INT 13H which is low level disk
operations. This seems to be of help, has anyone had success in using
it?
I don't know this...

Sep 20 '06 #2
"ragtag99" <sp******@crayne.orgwrites:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch,
comp.lang.c++

Im working with windows xp professional, NTFS and programming with
MASM, c++ (free compiler) or visual basic 6.0

=== question 1

Primarily Im trying to design a program that has full control over a
hard disk. What it needs to do is find out what sectors haven't been
written to and be able to write anything there, but doesn't count
towards disk space, IOW the data is user defined garbage with no
consequense if overwritten.
So there's no consequence if it's not written at all.
Your solution is therefore to simply not do this.

Phil
--
"Home taping is killing big business profits. We left this side blank
so you can help." -- Dead Kennedys, written upon the B-side of tapes of
/In God We Trust, Inc./.

Sep 20 '06 #3
Oh my, so many nonos in one post :-)

ragtag99 wrote:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch,
comp.lang.c++
crossposting is great. Try posting in more than 50 groups for better
results though.
Im working with windows xp professional, NTFS and programming with
MASM, c++ (free compiler) or visual basic 6.0
wonderful. We would be especially interested in the VB parts of your
program.
Primarily Im trying to design a program that has full control over a
hard disk. What it needs to do is find out what sectors haven't been
written to and be able to write anything there, but doesn't count
towards disk space, IOW the data is user defined garbage with no
consequense if overwritten.
Sounds like an especially useful feature if you want to hide some kind
of malware. We are always interested in implementations like this, as
the standard way of doing things with <fstreamgets really boring over
time.
Secondarily make a full delete, thus where a file was is now just
zeros. For this, if I were to open a file with any given language
specific 'open' methood re-write the open data with the exact data
length of zeros then resave it, would that accomplish this task?
Perhaps. Of course this would depend largely on implementation specific
/ OS / fs details. As we always try to not focus too much on C++
specific issues, this is a perfect question to ask here.
Ive also come across BIOS function INT 13H which is low level disk
operations. This seems to be of help, has anyone had success in using
it?
Thanks for bringing the BIOS into play. This qualifies as being kind of
plattform independent, as both Linux and Windows PC's have a BIOS. Good
job.
Thanks for any help.
Im *really* sorry I couldn't help more.

Best luck, Felix

Sep 20 '06 #4

To bj7lewis

Thanks, that was a lot of good information, albeit I still have to look
a bit on NTFS beings that is the file system i prefer but thanks for
the help with all the internal workings :)

Sep 20 '06 #5

Phil Carmody wrote:
"ragtag99" <sp******@crayne.orgwrites:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch,
comp.lang.c++

Im working with windows xp professional, NTFS and programming with
MASM, c++ (free compiler) or visual basic 6.0

=== question 1

Primarily Im trying to design a program that has full control over a
hard disk. What it needs to do is find out what sectors haven't been
written to and be able to write anything there, but doesn't count
towards disk space, IOW the data is user defined garbage with no
consequense if overwritten.

So there's no consequence if it's not written at all.
Your solution is therefore to simply not do this.
If that were the case I wouldn't have asked. Not to mention academic
pursuits, in many cases, have no practical application. But thanks for
taking the time to respond.

Sep 20 '06 #6
ragtag99 wrote:
To bj7lewis

Thanks, that was a lot of good information, albeit I still have to look
a bit on NTFS beings that is the file system i prefer but thanks for
the help with all the internal workings :)
Take if off of Comp.lang.c++

followups set.

Sep 21 '06 #7
a bit on NTFS beings that is the file system i prefer but thanks for
the help with all the internal workings :)
By all means but NTFS and FAT is like apples and oranges they have
differences but are still fruits... NTFS is designed for security and FAT no
security... But at the "fruit" level they are basic the same NTFS is newer
than FAT32 and supports TB Drives but that is just a matter of ##K cluter
size... So if you start your design in FAT## and move your way to NTFS later
all you really need to learn is Master Record Table (MRT) thingy and NTFS
security but the cluster chains and the way files are allocated should be
the same...
a bit on NTFS beings that is the file system i prefer but thanks for
the help with all the internal workings :)
Also why is it prefer FAT32 is not dead is it?...

Sep 21 '06 #8
ragtag99 <sp******@crayne.orgwrote:
To bj7lewis

Thanks, that was a lot of good information, albeit I still have to look
a bit on NTFS beings that is the file system i prefer but thanks for
the help with all the internal workings :)
You seem to want to prevent recovery of deleted files. Have you checked
that this is not a feature of Vista (or XP - I haven't checked)?

MacOS X has had secure deletion of the trash or unused part of the disk
with your choice of paranoia level for some time now.

There is still the problem of used blocks that may have ghosts of older
data, of course.

--
Mvh./Regards, Niels Jørgen Kruse, Vanløse, Denmark

Sep 21 '06 #9

bj7lewis wrote:
a bit on NTFS beings that is the file system i prefer but thanks for
the help with all the internal workings :)
By all means but NTFS and FAT is like apples and oranges they have
differences but are still fruits... NTFS is designed for security and FAT no
security... But at the "fruit" level they are basic the same NTFS is newer
than FAT32 and supports TB Drives but that is just a matter of ##K cluter
size... So if you start your design in FAT## and move your way to NTFS later
all you really need to learn is Master Record Table (MRT) thingy and NTFS
security but the cluster chains and the way files are allocated should be
the same...

The layout and structures on an NTFS volume are *nothing* like on a FAT
volume. For example, NTFS doesn't have chains of clusters to define a
file's data area. It has a tree structure indexing runs of clusters.
Directories are stored in B-trees. Free space is managed via a bitmap.
NTFS can store multiple datastreams for each file. About the only
commonality is that FAT and NTFS both store data in sectors on a disk...

Sep 21 '06 #10
"ragtag99" <sp******@crayne.orgwrites:
Phil Carmody wrote:
"ragtag99" <sp******@crayne.orgwrites:
I posted this on comp.lang.asm.x86, alt.os.development, comp.arch,
comp.lang.c++
>
Im working with windows xp professional, NTFS and programming with
MASM, c++ (free compiler) or visual basic 6.0
>
=== question 1
>
Primarily Im trying to design a program that has full control over a
hard disk. What it needs to do is find out what sectors haven't been
written to and be able to write anything there, but doesn't count
towards disk space, IOW the data is user defined garbage with no
consequense if overwritten.
So there's no consequence if it's not written at all.
Your solution is therefore to simply not do this.

If that were the case I wouldn't have asked. Not to mention academic
pursuits, in many cases, have no practical application. But thanks for
taking the time to respond.
Perhaps you shouldn't have asked.

What you actually asked, that is.

Perhaps you should have asked how to implement the high level
functionality that you want rather than how to implement the
misguided choice of low level functionality that you think you
need.

My logic above is sound given the premises you provide.

Phil
--
"Home taping is killing big business profits. We left this side blank
so you can help." -- Dead Kennedys, written upon the B-side of tapes of
/In God We Trust, Inc./.

Sep 21 '06 #11

Phil Carmody wrote:
If that were the case I wouldn't have asked. Not to mention academic
pursuits, in many cases, have no practical application. But thanks for
taking the time to respond.

Perhaps you shouldn't have asked.

What you actually asked, that is.
Then Id be asking a question i didnt want to know the answer to. That
makes no sense.
>
Perhaps you should have asked how to implement the high level
functionality that you want
one of the reasons ive posted on comp.lang.c++ was hoping someone there
knew practical applications of the language.
rather than how to implement the
misguided choice of low level functionality that you think you
need.
....academic pursuits...
but if there is a high level way of doing it i would be interested in
getting the libraries to get the program running, then ill figure them
out after everything is all said and done.
My logic above is sound given the premises you provide.
Your logic is saying i shouldnt have asked a computer realted question
on computer related news groups. Thats pretty solid logic.

But perhaps all this bandwidth could have been saved if instead of
cryptic replies, "witty" one-liners and cyber tuffism the replies were
like: "youre looking at the problem wrong, this site deals with
something similar..." or "c++ has a library called 'sector write'
that..." or
"someone wrote a similar program and posted the source here..." or even
"a better newsgroup for this question would be..."

but i suppose some people gotta fill there free time some way or other.
But thanks to all those that helped though :)

Sep 21 '06 #12
The layout and structures on an NTFS volume are *nothing* like on a FAT
volume. For example, NTFS doesn't have chains of clusters to define a
file's data area. It has a tree structure indexing runs of clusters.
Directories are stored in B-trees. Free space is managed via a bitmap.
NTFS can store multiple datastreams for each file. About the only
commonality is that FAT and NTFS both store data in sectors on a disk...
I said I didn't know anything about NTFS internals but I can still
theorize(NTFS is enough like FAT that you have complex list/tree that you
need to read/follow to find file sectors on the disk) coming with only NTFS
knowledge from and basic Windows networking class while not giving code
help...

Sep 21 '06 #13
bj7lewis wrote:
>The layout and structures on an NTFS volume are *nothing* like on a FAT
volume. For example, NTFS doesn't have chains of clusters to define a
file's data area. It has a tree structure indexing runs of clusters.
Directories are stored in B-trees. Free space is managed via a bitmap.
NTFS can store multiple datastreams for each file. About the only
commonality is that FAT and NTFS both store data in sectors on a disk...
I said I didn't know anything about NTFS internals but I can still
theorize
Then you should explicitly label your uneducated guesses as 'theories'
rather then present them as fact.

You said, "NTFS is newer than FAT32 and supports TB Drives but that is
just a matter of ##K cluter size." That is incorrect:

1. NTFS is not, in fact, 'newer than FAT32': NTFS debuted with Windows
NT V3.1 in 1993, whereas FAT32 debuted with Windows 95 OSR2 in 1996.

2. NTFS as implemented (using 32-bit cluster IDs) supports drives up to
8 TB in size (possibly up to 16 TB - it's not clear whether it uses
signed or unsigned integers to count clusters) without deviating from
its 4 KB default cluster size at all, while its architecture (allowing
64-bit cluster IDs) supports drives up to 2^75 (or 2^76) in size using
the same standard 4 KB clusters (as well as both larger and smaller
clusters for situations where a different effective block size is
desirable for reasons unrelated to the total drive or file size).

In other words, NTFS's ability to support 'TB drives' (and files) has
nothing whatsoever to do with the cluster sizes that it supports.

By contrast, FAT32 depends heavily upon increasing its cluster size to
support large drives (and for that matter large files up to its 2 or 4
GB maximum file size, because scanning through close to a million linked
FAT32 entries to find a piece of data with a high file address can get
expensive - that's one reason why FAT32 cluster defaults reach their
maximum size of 32 KB quickly, on any drive larger than 32 GB). Its
architectural drive-size limit is 8 TB, and it requires use of 32 KB
clusters to get there.
You said, "the cluster chains and the way files are allocated should be
the same." That is also flat-out wrong:

1. NTFS does not 'chain' clusters at all, let alone use a single such
chain for the entire file as FAT32 does.

2. Unlike FAT32, NTFS uses bitmaps to track space allocation and embeds
small files in their MFT entries rather than allocating an entire
cluster as soon as a single byte exists.
You asked, "why is it prefer FAT32 is not dead is it?" I can help you
out with that as well: the larger a FAT32 file system gets, the longer
it takes to check it after an unclean shutdown (and there's *still* no
guarantee that any structural corruption resulting from that unclean
shutdown can be fixed), whereas being a journaled file system NTFS can
restart in a few seconds at most, regardless of the size of its file
system, and can recover from any normal unclean-shutdown corruption save
the incomplete write of a single, critical disk sector (which drives are
designed to protect against).

- bill

Sep 22 '06 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Erich Keane | last post by:
Ok, first a quick background: I, along with a small group of diehards came up with a way to disable the EU volume cap protection on the european ipods. Unfortunately, this way never caught on, as...
2
by: Nate | last post by:
Hello, I am trying to recover a SQL Server 7 database from another hard disk drive that has a corrupted Windows 2000 Advanced Server installation. I am not able to repair the corrupted Windows...
2
by: Jeevan | last post by:
Hi, I have an array of data (which I am getting from a socket connection). I am working on a program which acts on this data but the program is written to work on data from a file (not from an...
3
by: King W.Wang | last post by:
Hi all, I've deleted 2 folders and emptied the trash bin on a hard disk in Windows XP. And then I found that I've no back-up of these folders. I want to rescue the data in these folders. The hard...
1
by: Shrirang Ballal | last post by:
I am doing a project which requires to read the raw bytes from hard disk. It rrequires to access the partition table and then the individual partitions. I want some material related to these...
2
by: jatphat | last post by:
Somebody help me. How do i copy my Access database from one location on my hard disk to another . i tried file.copy(source, distination ) but the file would not move. i always get this error ...
6
by: Paul Bromley | last post by:
Ok - I have given up on trying to find the active IP address for a given PC. For licensing purposes I need to retrive a unique identifier from the PC that the program is installed on. The Hard disk...
2
by: =?Utf-8?B?R2VvcmR5?= | last post by:
Hello everyone, I would really appreciate if someone helped me in this matter cause I am going to lose my mind... I am using a Sony Vaio Laptop with Windows XP professional (512MB Ram, 1,7 GHz CPU...
4
by: max | last post by:
Hi all, I want to write a program in C/C++ which monitor any hard disk activity by a particular program which have assigned for WINXP. For example, the program are going to run like this.....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.