From: bmckenzie@bsquare.com Sent: Tuesday, March 05, 2002 1:16 AM To: NT Developers Interest List Subject: [ntdev] Re: Problem delaying the completion of an Irp Carlo, If there is even a remote chance you might delay the completion of the create IRP to some time after your completion routine returns, then you must, from your dispatch routine, call IoMarkIrpPending and return STATUS_PENDING explicitly. This is not documented very well, and I believe I entered a bug on this in the bug bash. Normally, your completion routine will complete the IRP, so you can just return what is returned to you from your IoCallDriver call in your dispatch routine. If the IRP is not completed in the completion routine, then your return from IoCallDriver may not reflect the true status of the IRP, in that you may get a STATUS_SUCCESS return from IoCallDriver, even though your driver has yet to complete the IRP. Then, if you return this STATUS_SUCCESS from your dispatch routine in this case the driver layered over yours will not know the IRP is still pending in your driver. To understand why this is so, I highly recommend you read this: http://www.osr.com/ntinsider/1997/iocomp/iocomp.htm Its complicated stuff, you definitely aren't the first to get your head wrapped around the axle on this one. Interestingly enough, everyone working on WDM drivers that are power policy owners, (that is most device drivers), should have run into this by now. You cannot properly handle system power IRPs without hitting this situation. According to the DDK docs system power IRPs should be completed by power policy owners in the associated device power IRP's power completion routine. But alas, most drivers aren't doing this, including most DDK samples. Bill M. In fact, reading the docs didn't solve my doubts. In all other Irps I set a completion routine for, I simply ended the dispatch routine with a "return IoCallDriver(...)"; this should work since I never had to further delay the Irp completion in my completion routine. In the case of the Create Irp, instead, IoCallDriver() surely doesn't return STATUS_PENDING, so mending the dispatch routine as you suggested solved the problem. My doubt is now the following: suppose I can't tell until my completion routine is called if the Irp completion has to be delayed; in this case I have to pend the Irp anyway in the dispatch routine and return from the completion routine STATUS_SUCCESS (or error) if the Irp has to be completed immediately and STATUS_MORE_PROCESSING_ REQUIRED if I need to delay the completion? Thank you again Carlo Andreoli --- You are currently subscribed to ntdev as: GlennEverhart@FirstUSA.com To unsubscribe send a blank email to leave-ntdev-247T@lists.osr.com