Reputation:
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
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
IOCTL_USB_USER_REQUEST
with USBUSER_PASS_THRU
if you're doing something really advanced.
P.S.: This should be on StackOverflow, as other people have mentioned.
Upvotes: 3
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