RE: [NTDev] Proper order of tearing down an MDL ...

Hi Dave,

Now that you’ve got me thinking about it again…

Have a look in a debugger at the actual disassembly of MmUnlockPages().
The first thing it does is test byte 6 of the MDL (MdlFlags) for bit 0x01
(MDL_MAPPED_TO_SYSTEM_VA), then conditionally calls MmUnmapLockedPages().

So, though IoFreeMdl() doesn’t unmap unless MDL_PARTIAL_HAS_BEEN_MAPPED
is set, ‘direct’ I/O MDLs are going to be unmapped by virtue of being
unlocked.

You are correct that MmUnlockPages() will do the unmap. But, Gary’s
original question was if we can rely on the i/o manager to issue the
MmUnlockPages() , or does it need to be done in the driver’s completion
routine. I suspect that if the driver allocates MDLs that are not of type
MDL_PARTIAL, then it’s the driver’s responsibilty to unlock/unmap.
Are you saying that IoCompleteRequest() will always issue MmUnlockPages()
for any MDL ?

Sara


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com