Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ReadFile() fails with error Incorrect Parameter

0 views
Skip to first unread message

davidm...@gmail.com

unread,
May 21, 2008, 10:25:36 AM5/21/08
to
I am trying to call ReadFile() on a handle for a USB storage device,
however, ReadFile() returns false everytime with the error code:
"Parameter is Incorrect."

The handle that I create via CreateFile is valid


Here's where I create the handle (returns a valid handle for my
device)
hDevice = CreateFile(
devDetailData->DevicePath,
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED,
NULL);


I then create an event and an OVERLAPPED structure:
HANDLE hEvent = CreateEvent(
NULL,
TRUE,
FALSE,
NULL);

OVERLAPPED gOverLapped;
gOverLapped.Offset = 0;
gOverLapped.OffsetHigh = 0;
gOverLapped.hEvent = hEvent;


I then init some variables for the ReadFile() function and call it:
CHAR pBuf[3];
pBuf[0] = 0;
DWORD nBytesRead;
BOOL bResult;

bResult = ReadFile(hDevice, pBuf, 3, &nBytesRead, &gOverLapped);


The result I receive via GetLastError() is "The parameter is
incorrect."


Any help would be GREATLY appreciated.

chris.a...@gmail.com

unread,
May 21, 2008, 12:15:22 PM5/21/08
to
On May 21, 9:25 am, davidmurr...@gmail.com wrote:

> I am trying to call ReadFile() on a handle for a USB storage device,
> however, ReadFile() returns false everytime with the error code:
> "Parameter is Incorrect."

What makes you think you should be able to do this? What are you
trying to do?

davidm...@gmail.com

unread,
May 21, 2008, 12:52:49 PM5/21/08
to

i'm trying to establish a connection with my usb driver so that i can
call ioctl's on it. all USB device interfacing examples state that
ReadFile() should be called upon successful creation of the handle.

Doron Holan [MSFT]

unread,
May 21, 2008, 5:20:39 PM5/21/08
to
are you sure you are opening a handle to the storage device vs the file
system mounted on it? if this is the inbox driver, how will your custom
IOCTL work/

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


<davidm...@gmail.com> wrote in message
news:bda50d88-f31b-49d6...@e39g2000hsf.googlegroups.com...

Alexander Grigoriev

unread,
May 21, 2008, 10:40:54 PM5/21/08
to
If you want to send UICTL, why are you calling ReadFile?

<davidm...@gmail.com> wrote in message
news:bda50d88-f31b-49d6...@e39g2000hsf.googlegroups.com...

0 new messages