Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to:Access IDE-HDD by DeviceIOControl()

39 views
Skip to first unread message

Frank Hsu

unread,
Feb 17, 2004, 5:46:09 AM2/17/04
to
Dear all,
Could anybody help me? Thanks in advance!
I want to read a cluster/sector from IDE hard disk.
My environments are Windows XP/MS-VC 6.0/IDE hard disk.
I think I need to use CreateFile(),DeviceIoControl() function,
and send ATA-6 commands.Could anyone help me,and give me sample code.
Thanks!

Frank Hsu
s...@seed.net.tw


Tim Robinson

unread,
Feb 17, 2004, 2:16:46 PM2/17/04
to
Easier than that: open the hard disk using CreateFile, and read and write
using ReadFile/WriteFile in multiples of 512 bytes. See MSDN for details.

--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/

"Frank Hsu" <s...@seed.net.tw> wrote in message
news:c0srdf$ce$1...@news.seed.net.tw...

Frank Hsu

unread,
Feb 17, 2004, 9:01:03 PM2/17/04
to
Dear Tim,
Thanks your help!
But I need to read/write every sector/cluster (from LBA 0 to
maximum,
include : Master Boot Sector,Partition Boot Sector,FAT area,Root directory
area,
Storing Area) not only read/write a file. So, I think I need to send ATA
command
(Read Sector,OP code 0x20) to IDE HDD. My question is how to send ATA
command.
Is it possible to read/write every sector/cluster by ReadFile/WriteFile ?

Frank


"Tim Robinson" <tim.at.gaat.f...@invalid.com> 撰寫於郵件新聞
:c0tpgn$1c5lft$1...@ID-103400.news.uni-berlin.de...

Tim Robinson

unread,
Feb 18, 2004, 5:18:55 PM2/18/04
to
Maybe you missed the point of my post.

It is possible to open the hard disk as if it were a file. That is, you can
read from and write to raw sectors using ReadFile and WriteFile. Instead of
specifying a file name in CreateFile, pass "\\\\.\\PHYSICALDRIVE0" (for the
first physical hard disk) or "\\\\.\\C:" (for the partition known as 'drive
C').

See the MSDN page on CreateFile for more info. You do not need to send ATA
command to read and write sectors, nor should you.

--
Tim Robinson (MVP, Windows SDK)
http://mobius.sourceforge.net/

"Frank Hsu" <s...@seed.net.tw> wrote in message

news:c0uh0s$gd5$1...@news.seed.net.tw...

Frank Hsu

unread,
Feb 18, 2004, 11:03:53 PM2/18/04
to
Dear Tim,
Yes, It work!
Thank you very much!!!!!!
Frank

"Tim Robinson" <tim.at.gaat.f...@invalid.com> 撰寫於郵件新聞
:c10ocf$1c572m$1...@ID-103400.news.uni-berlin.de...

0 new messages