So, I got a card reader, wrote data from the device, put the card in the reader, saw it in winhex.
Next step, doing it programatically.
Code:
cout << "attempting CreateFile() on F:" << endl;
HANDLE vol = CreateFile(
"\\.\F:", //read a volume
0, //GENERIC_READ | GENERIC_WRITE, //access
0, //disables any sharing operation
NULL, //no security descriptor
OPEN_EXISTING, //it's a volume, that's what MSDN recommends
FILE_ATTRIBUTE_NORMAL, //wtf should go here?
NULL); //a template file something
if (GetLastError != 0)
coutError("main");
CloseHandle(vol);
(coutError is simply a wrapper to show the windows system error in cout).
Running the code above returns 123: System error #123 in main: The filename, directory name, or volume label syntax is incorrect.
MSDN says volumes should be opened this way: \\.\letter:
Anyway, I try using F:, and I get access denied, although nothing else is using it (no explorer open on it).
Maybe I should open it as a \\.\PhysicalDrive
To get a volume's physical drive, i have to pass to DeviceIOControl a handle from.. CreateFile! Which of course, dies in access denied. Maybe I'm not using the right sharing/access request?
I've also read at some point that I can request an explicit unmount. How do I do that?
edit: Hmm, it looks like "\\\\.\\F:" does the trick. it figures.