user82690
user82690

Reputation:

Use the Windows raw access APIs to directly access the USB drive

At the end of USB physical drive, I want to write data directly using windows raw access API. I don't want to use kernel driver to do that.

As far as I know, HDD direct access is blocked from windows xp sp2 or sp3(?) for security reason. I'm not sure this is true for USB drive.

Please guide me how to get there. Thanks a lot.

Upvotes: 4

Views: 2933

Answers (2)

user541686
user541686

Reputation: 210755

It depends on how "direct" you want to be.

Something like

HANDLE hDrive = CreateFile("\\\\.\\F:", ...);
ReadFile(hDrive, ...);

should get you what you need in most situations, although you might need DeviceIoControl with

if you're doing something really advanced.

P.S.: This should be on StackOverflow, as other people have mentioned.

Upvotes: 3

khabraken
khabraken

Reputation: 166

Voted to move to Stack Overflow. I think regardless, using an external HDD connected by USB won't change anything, as it still appears as a normal disk to windows.

When you say "raw access API", do you mean functions like CreateFile, WriteFile etc as listed here? Because those functions should be able to be called from normal Win32 apps. Or do you want direct access to the disk itself, with no filesystem layer in between? (Some user apps such as HxD can directly open disks for reading/writing - use with caution)

Upvotes: 0

Related Questions