I suppose this is one way to do it (but it won’t quite work) but a much
easier approach is to call IoAllocateMdl() in the pre-read callback then
in the worker routine call MmGetSystemAddressForMdlSafe() passing the
the mdl you allocated. Of course you can check if the MdlAddress in the
read parameters is NULL or not since it is possible that someone above
you has already allocate an mdl for the request.

The problem with what you have is that it will give you the PA for the
first 4KB chunk for the VA you pass in. Rarely is a buffer which is
larger than 4KB physically contiguous in memory.


Kernel Drivers
Windows File System and Device Driver Consulting http:</http:>

------ Original Message ------
To: “Windows File Systems Devs Interest List”
Sent: 6/22/2016 7:59:58 PM
Subject: RE:[ntfsd] Re[2]: Pending without

>Hi Pete, there is no need for an apology!
>I think I am a step further but now I am stuck at
>Here is what I do:
>// Read preop:
>pa = MmGetPhysicalAddress(Data->Iopb->Parameters.Read.ReadBuffer)
>Insert io request into data queue (pa is part of the context which is
>inserted into the data queue)
>// Worker thread:
>va = MmMapIoSpace(pa, Data->Iopb->Parameters.Read.Length, MmNonCached)
>Data->Iopb->Parameters.Read.MdlAddress = 0
>Data->Iopb->Parameters.Read.ReadBuffer = va
>FltCompletePendedPreOperation(Data, FLT_PREOP_SUCCESS_NO_CALLBACK, 0)
>// <- never returns
>I guess this problem is also context related?
>I also tried:
>Data->Iopb->Parameters.Read.MdlAddress = IoAllocateMdl(va,
>Data->Iopb->Parameters.Read.Length, FALSE, FALSE, nullptr)
>and deleted the mdl in postop (completed with
>FLT_PREOP_SUCCESS_WITH_CALLBACK this time of course).
>I am doing this for all io requests which appear in read preop. not
>only for cached io, I guess this is fine?
>Thank you so much again!
>NTFSD is sponsored by OSR
>MONTHLY seminars on crash dump analysis, WDF, Windows internals and
>software drivers!
>Details at http:
>To unsubscribe, visit the List Server section of OSR Online at