Mdl -> Userbuffer access in completion routine.

Hi,

I’m transfering the a user mode address to my driver with an IOCTL code.
In the driver I create a Mdl for accessing this memory address:
IoAllocateMdl(…)
MmProbeAndLockPages(…)
MmMapLockedPages(…)

Everything is working as expected but I want to access this user mode
address in my completion routine as well.
So I pass the Mdl, and the mapped system address via the context to the
completion routine and free it there.
MmUnmapLockedPages(…)
MmUnlockPages(…)
IoFreeMdl(…)

Everything is working again, but all these functions need to be called in
an IRQL<= DISPATCH_LEVEL, is it possible that a completion routine is
called
in an IRQL > DISPATCH_LEVEL ?
If so where should the Mdl be released then?

Best Regards
Michael

Why do you feel you need to create your own MDL for this user buffer? Why
not use a DIRECT buffering method with the request (read/write/ioclt) and
have the I/O manager create an MDL for you and let the I/O manager worry
about the cleanup? There are cases where this needs to be done, but I am
curious if this is one of those cases.

The MDL will be safe to access in your completion routine. Completion
routines are called in an arbitrary thread context at <=DISPATCH_LEVEL IRQL,
(typically at DISPATCH_LEVEL).


Bill McKenzie
Compuware Corporation
Watch your IRPs/IRBs/URBs/NDIS pkts with our free WDMSniffer tool:
http://frontline.compuware.com/nashua/patches/utility.htm

wrote in message news:xxxxx@ntdev…
>
>
> Hi,
>
> I’m transfering the a user mode address to my driver with an IOCTL code.
> In the driver I create a Mdl for accessing this memory address:
> IoAllocateMdl(…)
> MmProbeAndLockPages(…)
> MmMapLockedPages(…)
>
> Everything is working as expected but I want to access this user mode
> address in my completion routine as well.
> So I pass the Mdl, and the mapped system address via the context to the
> completion routine and free it there.
> MmUnmapLockedPages(…)
> MmUnlockPages(…)
> IoFreeMdl(…)
>
> Everything is working again, but all these functions need to be called in
> an IRQL<= DISPATCH_LEVEL, is it possible that a completion routine is
> called
> in an IRQL > DISPATCH_LEVEL ?
> If so where should the Mdl be released then?
>
>
> Best Regards
> Michael
>
>
>
>
>
>
>
>
>
>
>