Read/Write in RAW mode

Hi All,

I am trying to develop a test program to test our hardware ATA RAID
rebuild cabability.

The program needs to fill the entire drive from start to end with known
pattern (RAW data) and after the rebuild when we run the program again
should read the entire drive check for any errors in rebuild.

If I use createfile(), the windows controls where and which sector the
file will be located right? Is there way to specify which sector to
read/write from? any idea?

Thanks, shak.

Shak,

you wrote on Thursday, October 16, 2003, 18:16:32:

S> The program needs to fill the entire drive from start to end with known
S> pattern (RAW data) and after the rebuild when we run the program again
S> should read the entire drive check for any errors in rebuild.

S> If I use createfile(), the windows controls where and which sector the
S> file will be located right? Is there way to specify which sector to
S> read/write from? any idea?

Just use CreateFile() on \.\PhysicalDriveX and you’ll get a handle to
the physical disk from which you can read/write any sector.

Ralf.

lseek(). As usually.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

----- Original Message -----
From: “Shak”
To: “Windows File Systems Devs Interest List”
Sent: Thursday, October 16, 2003 8:16 PM
Subject: [ntfsd] Read/Write in RAW mode

> Hi All,
>
> I am trying to develop a test program to test our hardware ATA RAID
> rebuild cabability.
>
> The program needs to fill the entire drive from start to end with known
> pattern (RAW data) and after the rebuild when we run the program again
> should read the entire drive check for any errors in rebuild.
>
> If I use createfile(), the windows controls where and which sector the
> file will be located right? Is there way to specify which sector to
> read/write from? any idea?
>
> Thanks, shak.
>
> —
> You are currently subscribed to ntfsd as: xxxxx@storagecraft.com
> To unsubscribe send a blank email to xxxxx@lists.osr.com

Thanks Ralf,

I got the handle using use CreateFile() on \.\PhysicalDriveX.
Now how to read/write RAW data to hard disk?

I found ioctl for CDROM IOCTL_CDROM_RAW_READ. Is there something similar
for the HARD Drive? need help.

Thanks, Shak

Shak,

you wrote on Monday, October 20, 2003, 19:50:59:

S> Thanks Ralf,

S> I got the handle using use CreateFile() on \.\PhysicalDriveX.
S> Now how to read/write RAW data to hard disk?

Simply use ReadFile() and WriteFile() and SetFilePointer() to seek, if
necessary.

Ralf.

> I got the handle using use CreateFile() on \.\PhysicalDriveX.

Now how to read/write RAW data to hard disk?

I found ioctl for CDROM IOCTL_CDROM_RAW_READ. Is there something similar
for the HARD Drive? need help.

CD has the concept of “raw” and “cooked” sectors, raw are 2352 bytes, cooked
are 2048 bytes.

Hard disks has no such. 512bytes per sector are the lowest possible level for
the software. So, just use Read/WriteFile on a handle.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com

Great! Thank you Ralf and Maxim for your help.

Shak

“Ralf Buschmann” wrote in message news:xxxxx@ntfsd…
>
> Shak,
>
> you wrote on Monday, October 20, 2003, 19:50:59:
>
> S> Thanks Ralf,
>
> S> I got the handle using use CreateFile() on \.\PhysicalDriveX.
> S> Now how to read/write RAW data to hard disk?
>
> Simply use ReadFile() and WriteFile() and SetFilePointer() to seek, if
> necessary.

Make sure you do everything on sector boundaries. The offset must be an
integer multiple of SECTOR_SIZE, and so must be the length.

Phil

Philip D. Barila Windows DDK MVP
Seagate Technology, LLC
(720) 684-1842
As if I need to say it: Not speaking for Seagate.
E-mail address is pointed at a domain squatter. Use reply-to instead.

Thanks Ralf and Max,

Using CreateFile("PhysicalDriveX… to get the handle and I am able to
ReadFile() and WriteFile() to read/write RAW data. Using
SetFilePointerEx() to seek to a perticular sector that I want to
read/write from, it is giving me Error 1, ERROR_INVALID_FUNCTION.
Also, using SetFilePointerEx() to get the size of disk by moving to
FILE_END. I tried with GetFileSizeEx() getting the same ERROR as well.

any idea?

Thanks for your help.
shak

Shak,

you wrote on Friday, October 24, 2003, 19:29:58:

S> Using CreateFile("PhysicalDriveX… to get the handle and I am able to
S> ReadFile() and WriteFile() to read/write RAW data. Using
S> SetFilePointerEx() to seek to a perticular sector that I want to
S> read/write from, it is giving me Error 1, ERROR_INVALID_FUNCTION.
S> Also, using SetFilePointerEx() to get the size of disk by moving to
S> FILE_END. I tried with GetFileSizeEx() getting the same ERROR as well.

Try adding FILE_FLAG_NO_BUFFERING to dwFlagsAndAttributes in
CreateFile() and make sure you move the file pointer only to whole
multiples of the volumes sector size.

Ralf.