Hi,
What are the necessary steps to make overlapped I/O work in WDF?
I tried to implement overlapped I/O, but to no success.
At the user side, I use the following code:
OVERLAPPED overlapped;
HANDLE hEvent = CreateEvent(NULL,TRUE,FALSE,NULL);
overlapped.Offset = 0;
overlapped.OffsetHigh = 0;
overlapped.hEvent = hEvent;
ret = DeviceIoControl(hDevice,dwIoControlCode,lpInBuffer,inBufSize,
lpOutBuffer,outBufSize,(LPDWORD)&bytesReturned,(LPOVERLAPPED)&overlapped);
if (!ret) {
DWORD dwError = GetLastError();
switch (dwError) {
case ERROR_IO_PENDING:
switch (WaitForSingleObject(hEvent, (timeout == 0) ? INFINITE : timeout))
{
case WAIT_TIMEOUT:
/* time out occurred */
CancelIo(hDevice);
break;
case WAIT_OBJECT_0:
//success
break;
case WAIT_ABANDONED:
break;
default:
{
// UNSPECIFIED ERROR
break;
}
}
}
}
CloseHandle(hEvent);
At the driver side, in the IoDeviceControl, I just return (no WdfRequestComplete - this to simulate a never interrupting device).
I don’t mark requests as cancellable, I don’t requeue the request.
There is one device synchronized queue.
The above code, hangs while calling CancelIo.
I am sure I am missing something essential, like pending the request, requeueing the request, …
Can anyone point me in the right direction?
Thanks