Error no. 87 when trying to read from a drive...
-
I'm trying to open a drive, by specifying the lpFileName argument to be of the format "\\.\:" in CreateFile. But when i use ReadFile to read from the disk, i get an error, number 87 which means invalid parameter, anyone know what's wrong?
char test\[32\]; HANDLE hDrive = CreateFile("\\\\\\\\.\\\\H:", GENERIC\_READ, FILE\_SHARE\_WRITE /\* | FILE\_SHARE\_READ\*/ , NULL, OPEN\_EXISTING, FILE\_ATTRIBUTE\_NORMAL, NULL); DWORD dwBytesRead; ReadFile(hDrive, &test, 32, &dwBytesRead, NULL); CloseHandle(hDrive);
Thanks all! -Rune SVendsen
-
I'm trying to open a drive, by specifying the lpFileName argument to be of the format "\\.\:" in CreateFile. But when i use ReadFile to read from the disk, i get an error, number 87 which means invalid parameter, anyone know what's wrong?
char test\[32\]; HANDLE hDrive = CreateFile("\\\\\\\\.\\\\H:", GENERIC\_READ, FILE\_SHARE\_WRITE /\* | FILE\_SHARE\_READ\*/ , NULL, OPEN\_EXISTING, FILE\_ATTRIBUTE\_NORMAL, NULL); DWORD dwBytesRead; ReadFile(hDrive, &test, 32, &dwBytesRead, NULL); CloseHandle(hDrive);
Thanks all! -Rune SVendsen
Redeemer-dk wrote: anyone know what's wrong? Yes, and so does the MSDN documentation: Note that all I/O buffers must be sector aligned (aligned on addresses in memory that are integer multiples of the volume's sector size), even if the disk device is opened without the FILE_FLAG_NO_BUFFERING flag.