That has been my concern.
Can there be a PreInCallerContext routine and a PostInCallerContext routine so that before and after an ICOTL, a driver can be guaranteed of running in the caller’s context?
Short of that, I guess I’ll have to handle the entire request in the InCallerContext routine. I thought I read in the docs a recommendation not to do that though. I’ll have to re-read them.
Beverly
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Wednesday, July 05, 2006 12:11 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
If you are powered off and the i/o arrives, it will pended until you are powered on. This can occur when you have idled out (if you enabled it) *AND* during an Sx transition where your device has powered off and the app is still running.
You cannot prevent drivers from loading on top of you, but they have to respect the contract that your FDO dictates (so if that means IOCTLs are not pended, then that must be respected). With that said, KMDF has creates a model where InCallerContext is the spot where you are guaranteed context and that your actual EvtIoXxx routines are *not guaranteed a context*. One improvement coming down the pipe for the KMDF verifier is to force the context switch.
Do not make the assumption that your EvtIoXxx routines will occur in the context of the app.
d
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Wednesday, July 05, 2006 8:24 AM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
So far so good, but my IoDeviceControl routine is being called in the process context so it’s not really a good test of whether it would work if it wasn’t in the process context.
For now it seems that if I use a parallel default queue with synchronizationsocpenone and exectuionleveldispatch, my IoDeviceControl routine will predictably be called in the context of the calling process (provided no filters are above me in the stack). Is there any reason why this assumption (based on observation) will ever be wrong? Is there a way I can prevent other drivers from sitting above mine in the stack?
Beverly
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, June 26, 2006 8:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
Let us know how it works after you try it. Like I said I’m not sure … if I’m wrong we should document that for the archives.
-p
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Monday, June 26, 2006 4:46 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
That simplifies things a great deal! Thank you!
Beverly
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Peter Wieland
Sent: Monday, June 26, 2006 7:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
I believe that you can call MmUnlockPages from any context, as long as you’re at or below DISPATCH_LEVEL.
Not positive about that, but a quick look at the code seems to imply that it handles it okay.
-p
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Monday, June 26, 2006 3:29 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
In WDM, I could be fairly certain (provided no filters were installed above my driver) that the entire processing of an IOCTL would take place in the context of the calling process. I had control over that.
With WDF, the only time I am certain that is the case is in IoInCallerContext. When my EvtIoDeviceControl routine is called, I have no idea what the framework has done between incallercontext and this callback executing. It may be running in a work item for all I know. I need to call MmUnlockPages on a user buffer that was locked in InCallerContext (please - no lectures about using direct IO instead - I understand all of the issues. For this particular implementation, this is really what is called for). Or is it not necessary that MmUnlockPages be called in the context of the user-mode process that owns the buffer described by the MDL? I always assumed that it was, but maybe I have been overly cautious?
Beverly
-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Doron Holan
Sent: Monday, June 26, 2006 6:13 PM
To: Windows System Software Devs Interest List
Subject: RE: [ntdev] KMDF InCallerContext question
What do you need to cleanup that needs to be in the caller’s context? Not even in WDM do you have a facility to move back into the calling process’s context after you leave it. KMDF makes no guarantees about the context in which a request’s cleanup routine is called. By knowing what you need to cleanup in the caller’s context, I or somebody on the list might able to give a better answer to what you want to accomplish
d
– I can spell, I just can’t type.
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Brown, Beverly
Sent: Monday, June 26, 2006 2:09 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] KMDF InCallerContext question
If I have an EvtIoInCallerContext function and need to to do some cleanup after the request has been queued and that cleanup must be done in the caller’s context, what is the best?way to do that? Does a request’s cleanup callback function get called in the caller’s context? If not, what is the recommended way to handle this?
?
Beverly
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer
Questions? First check the Kernel Driver FAQ at http://www.osronline.com/article.cfm?id=256
To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer