Low level disk/file info from 32bit VC? 
Author Message
 Low level disk/file info from 32bit VC?

I'm working in a 32 bit Visual C environment,
and need to obtain some low level disk/file
info.

Specifically, I need to find one or both
of the following:

1. The physical track/sector address of a
specified file,

and/or

2. The contents of a HD's bad sector
table.

I suspect that the appropriate Int 21 calls
may get me (1), but have no idea on the other.

I'm looking for example code which accesses
such low level info. I'm sure I'll have to
drop into assembler to do it - that's no
problem. However, I'm unfamiliar with mode
switches and passing data from one mode to
another.

thanks,

Peter Trei

Sent via Deja.com http://www.*-*-*.com/
Share what you know. Learn what you don't.



Sat, 24 Nov 2001 03:00:00 GMT  
 Low level disk/file info from 32bit VC?

Quote:

> I'm working in a 32 bit Visual C environment,
> and need to obtain some low level disk/file
> info.

> Specifically, I need to find one or both
> of the following:

> 1. The physical track/sector address of a
> specified file,

> and/or

> 2. The contents of a HD's bad sector
> table.

> I suspect that the appropriate Int 21 calls
> may get me (1), but have no idea on the other.

> I'm looking for example code which accesses
> such low level info. I'm sure I'll have to
> drop into assembler to do it - that's no
> problem. However, I'm unfamiliar with mode
> switches and passing data from one mode to
> another.

For W9x, you need to use a VxD to do low-level disk access. See the
online help at Platform, SDK and DDK Documentation -> Platform SDK ->
Windows Base Services -> Windows 95 features -> Using Windows 95
Features -> Input and Output -> Using VWIN32 to Carry Out MS-DOS
Functions.

For NT, you can use CreateFile to open the disk, for example:

        HANDLE hDisk = CreateFile ("\\\\.\\F:", GENERIC_READ,...

and then use ReadFile, DeviceIOControl etc functions.

HTH,
        AriL
--
Humans may send email (if absolutely necessary) to the
obvious non-spam address.



Sun, 25 Nov 2001 03:00:00 GMT  
 Low level disk/file info from 32bit VC?

says...

[ ... ]

Quote:
> Specifically, I need to find one or both
> of the following:

> 1. The physical track/sector address of a
> specified file,

This depends: under NT, you can open the disk partition as a file, and
read raw data from it.  Assuming it's a FAT partition, you chase
through the data just like you would from DOS, except that the actual
reading is a lot easier.  If it's NTFS, the basic idea is the same,
but finding things on NTFS is a bit more complex since you have to
search through a B-tree to find it.  In addition, MS hasn't been
particularly forthcoming about the details of NTFS, though they are
known; if you look hard enough, you can find them (one place to look
is the NTFS driver for Linux).

If you're trying to do this under Windows 95 or 98, things get ugly
very quickly.  The basic idea is that you open a file to one of the
VxDs (VMM32, IIRC) and then you can issue disk commands to it that are
a bit like int 13h commands.  I wrote code to do this only once, and
it was years ago, so I'm afraid I can't give much more detail than
that -- there is some information on MSDN, but at least at the time
the documentation was lousy.



Sun, 25 Nov 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Access disk Low level ?!

2. Low level disk services - Usual newbie needs help type of message

3. Low-level disk read/write

4. Low-level disk control

5. Low level hard disk access

6. Low level hard disk programming

7. Code to Low-Level read/write to Floppy Disks

8. Low level disk access

9. Floppy Disk Drive Low Level Programming Help!

10. Low level floppy disk stuff

11. Really Low Low Low Level Stuff.

12. Low-level disk i/o in DOS

 

 
Powered by phpBB® Forum Software