|
-
May 4th, 2007, 01:18 AM
#1
Directly reading/writing a HDD
Hi,
I'm writing a console program to directly read from and write to an external USB HDD in sector level, and I'm wondering how to get started. I've only done file level I/O before on directly connected drives so I'm not sure how to identify the USB drive(USB VID/PID/serial number maybe?) and also how to address it directly. Are there any primers for this to help me get started?
Thanks!
-
May 4th, 2007, 01:37 AM
#2
Re: Directly reading/writing a HDD
See:
http://www.lvr.com/usb.htm (Information, tools, and links by Jan Axelson)
http://www.usb.org/developers (USB-IF Developers Area)
-
May 4th, 2007, 02:44 AM
#3
Re: Directly reading/writing a HDD
Hi,
I've visited the USB-IF website before. It seems to be more geared towards developers of USB devices. However, I'm simply trying to access the drive with C programming.
-
May 4th, 2007, 11:51 AM
#4
Re: Directly reading/writing a HDD
A USB HDD gets asssigned as a PhysicalDriveX right?
Try using CreateFile and WriteFile for opening and writing directly on to sectors. I have done it and its pretty simple.
Try looking at CreateFile in MSDN.
C++ is divine.
-
May 4th, 2007, 11:31 PM
#5
Re: Directly reading/writing a HDD
Thanks. I'll check that out. Is there any way of identifying which drive I'm writing to(other than drive/volume letter) to make sure I'm writing to the right drive?
-
May 6th, 2007, 09:58 PM
#6
Re: Directly reading/writing a HDD
OK so I tried CreateFile using the following syntax:
Code:
hUserPort = CreateFile("G:\"", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
but hUserPort keeps getting set to INVALID_HANDLE_VALUE.
I also tried GetLogicalDrives() and GetLogicalDriveStrings(), and while they work, they only give me the logical drive letter, so there's no way of physically identifying which drive I'm accessing...how do I do that?
-
May 7th, 2007, 01:44 AM
#7
Re: Directly reading/writing a HDD
Regards,
Ramkrishna Pawar
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|