post mj_read and readBuffer in swapBuffer wdk sample

Hello,

Currently I’m reading swapBuffers sample and I would like to confirm behavior that is written in comments.
Basically in preRead operation there is allocation of new buffer that is going to be swapped with original one, then there is :
//
// Update the buffer pointers and MDL address, mark we have changed
// something.
//

iopb->Parameters.Read.ReadBuffer = newBuf;
iopb->Parameters.Read.MdlAddress = newMdl;
FltSetCallbackDataDirty( Data );
and finally there is saved CompletionContext with newbuff inside in order to pass it to postRead callback.

And finally in postRead callback there is comment:
//
// We need to copy the read data back into the users buffer. Note
// that the parameters passed in are for the users original buffers
// not our swapped buffers.
//

a) I thought exactly same structure will be passed down to post callback (same as in pre) - so it is different one?

b) If above is true and this structure is different - then why in this sample there is allocation of new buffer and switching (as well as call to FltSetCallbackDataDirty( Data ):wink: realized in pre callback and not in post callback?

Sorry if this to easy for you. Thank you very much for help.

A) It is the same set of parameters originally passed down, that is
their point.
B) You need to mark the CBD structure dirty so the new information is
passed down to the underlying drivers. They are doing this simply to
show you ‘how’ to implement a swap buffers design. For example, in an
encryption implementation, the passed in buffers may backed by the
system cache and for write requests you don’t want to encrypt the
content in the cache and then send it down so you would implement
something similar to swap buffers.

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: 3/4/2016 2:36:56 AM
Subject: [ntfsd] post mj_read and readBuffer in swapBuffer wdk sample

>Hello,
>
>Currently I’m reading swapBuffers sample and I would like to confirm
>behavior that is written in comments.
>Basically in preRead operation there is allocation of new buffer that
>is going to be swapped with original one, then there is :
>//
> // Update the buffer pointers and MDL address, mark we have
>changed
> // something.
> //
>
> iopb->Parameters.Read.ReadBuffer = newBuf;
> iopb->Parameters.Read.MdlAddress = newMdl;
> FltSetCallbackDataDirty( Data );
>and finally there is saved CompletionContext with newbuff inside in
>order to pass it to postRead callback.
>
>
>And finally in postRead callback there is comment:
>//
> // We need to copy the read data back into the users buffer.
>Note
> // that the parameters passed in are for the users original
>buffers
> // not our swapped buffers.
> //
>
>a) I thought exactly same structure will be passed down to post
>callback (same as in pre) - so it is different one?
>
>b) If above is true and this structure is different - then why in this
>sample there is allocation of new buffer and switching (as well as call
>to FltSetCallbackDataDirty( Data ):wink: realized in pre callback and not
>in post callback?
>
>Sorry if this to easy for you. Thank you very much for help.
>
>
>—
>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:>