Hi
I just want to add a asynchronous IOCTL in my sample KMDF driver.
From what I’ve learned The framework will pend all io so that I do not have do any work to mark the request Pending. Right ?
Just for testing, I use a WDF timer to completed my async request.
In the driver dispatch function I just return after setup a timer.
Later on when the timer expires, I complete the pending request.
My driver code looks like:
VOID
GageEvtIoDeviceControl(
IN WDFQUEUE Queue,
IN WDFREQUEST Request,
IN size_t OutputBufferLength,
IN size_t InputBufferLength,
IN ULONG IoControlCode
)
{
…
switch (IoControlCode) {
case MY_ASYNC_IOCTL:
deviceData->pendingRequest = Request;
inTimerQueue = WdfTimerStart( deviceData->Timer, WDF_REL_TIMEOUT_IN_MS(1000) );
return;
} // end switch
…
}
VOID MyTimerFunc ( IN WDFTIMER Timer )
{
…
WdfRequestCompleteWithInformation(deviceData->pendingRequest, STATUS_SUCCESS, 0);
}
From my test application, I open the diver with FILE_FLAG_OVERLAP and I call DeviceIoControl with OVERLAPPED structure attached
an event that will be signaled when my requested is completed.
My application code looks like
u32RetCode = DeviceIoControl( hDriver, MY_ASYNC_IOCTL, NULL, 0, NULL, 0, &BytesRead, &OverlapStruct );
if ( 0 == u32RetCode )
{
uInt32 u32ErrorCode = GetLastError();
if ( ERROR_IO_PENDING == u32ErrorCode )
TRACE(“The request is pending …\n”);
WaitForSingleObject( OverlapStruct.hEvent, INFINITE );
TRACE(“The request is completed\n”);
}
It seems to work. The request is completed after the expected eslapped time.
THE PROBLEM IS
From the application I do not receive the ERROR_IO_PENDING. The call DeviceIoControl() returns 0 and GetLatError() also returns 0.
What am I doing wrong ?
Thanks for help
QV