Re: IRP_MJ_READ asynchronous completion

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Are there other drivers in the stack above you? Maybe they aren't
propagating the pending bit via IoMarkIrpPending in their completion
routines? If you break in the kernel debugger at the point of completion
(when the app gets the data), what does the IRP stack look like? Thanks.

--
This posting is provided "AS IS" with no warranties, and confers no rights.
Use of any included script samples are subject to the terms specified at
http://www.microsoft.com/info/cpyright.htm
"werner999" <werner999@xxxxxx> wrote in message
news:44cdcb53$0$31544$c3e8da3@xxxxxxxxxxxxxxxxxxxx

"Ali" <abdulrazaq@xxxxxxxxx> schrieb im Newsbeitrag
news:1154336090.468844.158620@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

werner999 wrote:
"Ali" <abdulrazaq@xxxxxxxxx> schrieb im Newsbeitrag
news:1154333553.781087.59640@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

werner wrote:
Hi,

I am writing a driver for a device, which offers several interfaces -
one
of
it is a virtual serial port. Within DispatchRead (for IRP_MJ_READ) I
did
as
I read and thought that's correct, i.e. mark the irp pending, set a
cancel
routine, que it, and returned pending.
I wrote a simple Win32 test program, which opened the port for
overlapped
IO
and got the data back (if any available) with GetOverlappedResult.
But
the
status returned by a call to GetLastError was still ERROR_IO_PENDING.
When used with Microsoft Hyperterminal it seems that Hyperterminal
did
not
get the information, that the IRP was completed at all.

Thus I disabled all other interfaces and minimized my DispatchRead to
the
code below. It doesn't make much sense to mark the irp pending in
that
way
but according the docs and info found on the web it should be allowed
and
working.

IoMarkIrpPending(Irp);
*((BYTE *)Irp->AssociatedIrp.SystemBuffer) = 'a';
Irp->IoStatus.Information = 1;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_SERIAL_INCREMENT);
return (STATUS_PENDING);

Still the same result. My Win32 program gets the data but does not
get
correct status information via GetLasterror and Hyperterminal does
not
recognize that the irp has been completed.

Any idea what I do wrong or where I could have messed up my driver?

Many thanks
Werner
Can you comment IoMarkIrpPending(Irp); in your code and try? its
looking suspicious to me.


ali

If I don't call IoMarkIrpPending(Irp) and return STATUS_SUCCESS it works
perfectly. But I need asynchronous IO and thus I have to mark the irp
pending, que it, wait for data in another driver thread, and return in
the
meantime STATUS_PENDING in the Dispatch Read function. Above code is
only
the most simplyfied version, which should work (but doesn't)

Werner

In this case I guess you need to save or copy the irp before you
return.
download.microsoft.com/download/5/7/7/577a5684-8a83-43ae-9272-ff260a9c20e2/IRPs.doc


ali


Hi Ali,

I saved the irp in my initial version, where I completed it in a different
thread. But in above code - just the very,very simple asynchronous IO -
IoCompleteRequest is called for the irp and thus there is no use to save
it. It is even dangerous, because it is usually no longer valid after
calling IoCompleteRequest.

Many thanks for your inputs
Werner



.


Quantcast