I see you are doing this, which is how you should do it, using the Mdl
approach. When you complete the pended IO operation, don’t release the
mdl until post-read, unless you are passing in PREOP_COMPLETE, and you
need to update the VA in the read parameters, marking it dirty. The
underlying drivers will see a cached IO and expect the VA address to be
valid in that context so be sure to correctly update the VA.
Pete
–
Kernel Drivers
Windows File System and Device Driver Consulting
www.KernelDrivers.com http:</http:>
866.263.9295
------ Original Message ------
From: “PScott”
To: “Windows File Systems Devs Interest List”
Sent: 6/23/2016 5:47:58 AM
Subject: Re[2]: [ntfsd] Re[2]: Pending without
FLTFL_OPERATION_REGISTRATION_SKIP_CACHED_IO
>
>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.
>
>Pete
>
>–
>Kernel Drivers
>Windows File System and Device Driver Consulting
>www.KernelDrivers.com http:</http:>
>866.263.9295
>
>
>
>------ Original Message ------
>From: xxxxx@gmail.com
>To: “Windows File Systems Devs Interest List”
>Sent: 6/22/2016 7:59:58 PM
>Subject: RE:[ntfsd] Re[2]: Pending without
>FLTFL_OPERATION_REGISTRATION_SKIP_CACHED_IO
>
>>Hi Pete, there is no need for an apology!
>>
>>I think I am a step further but now I am stuck at
>>FltCompletePendedPreOperation.
>>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
>>FltSetCallbackDataDirty(Data)
>>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
>>http:
>
>
>—
>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
>http:</http:></http:></http:></http:>