Changing the IRQL

Hi,
I want to modify swapBuffers sample example. I observed that when I copy any
file then Read callback routines are called such that pre-read callback is
called at IRQL = PASSIVE_LEVEL while post-read callback is at IRQL =
DISPATCH_LEVEL.
I want to change IRQL of post-read callback to PASSIVE_LEVEL.
How can I change the IRQL??


Kapil Bhadke

You can do this by returning FLT_PREOP_SYNCHRONIZE from pre-read/write, but
only for synchronous operation.

http://msdn.microsoft.com/en-us/library/ff552037(v=VS.85).aspx
“Minifilter drivers must never return FLT_PREOP_SYNCHRONIZE for asynchronous
read or write operations. Doing so can severely degrade both minifilter
driver and system performance and can even cause deadlocks if, for example,
the modified page writer thread is blocked. Before returning
FLT_PREOP_SYNCHRONIZE for an IRP-based read or write operation, a minifilter
driver should verify that the operation is synchronous by calling
FltIsOperationSynchronous.”

But why do you need PASSIVE_LEVEL in post-read?

Best regards,
Krystian Bigaj

On 16 April 2011 08:24, kapil bhadke wrote:

> Hi,
> I want to modify swapBuffers sample example. I observed that when I copy
> any file then Read callback routines are called such that pre-read callback
> is called at IRQL = PASSIVE_LEVEL while post-read callback is at IRQL =
> DISPATCH_LEVEL.
> I want to change IRQL of post-read callback to PASSIVE_LEVEL.
> How can I change the IRQL??
>
> –
> Kapil Bhadke
> — NTFSD is sponsored by OSR For our schedule of debugging and file
> system seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

You can user workitem at post callback

2011/4/16 Krystian Bigaj

> You can do this by returning FLT_PREOP_SYNCHRONIZE from pre-read/write, but
> only for synchronous operation.
>
> http://msdn.microsoft.com/en-us/library/ff552037(v=VS.85).aspx
> “Minifilter drivers must never return FLT_PREOP_SYNCHRONIZE for
> asynchronous read or write operations. Doing so can severely degrade both
> minifilter driver and system performance and can even cause deadlocks if,
> for example, the modified page writer thread is blocked. Before returning
> FLT_PREOP_SYNCHRONIZE for an IRP-based read or write operation, a minifilter
> driver should verify that the operation is synchronous by calling
> FltIsOperationSynchronous.”
>
> But why do you need PASSIVE_LEVEL in post-read?
>
> Best regards,
> Krystian Bigaj
>
>
>
> On 16 April 2011 08:24, kapil bhadke wrote:
>
>> Hi,
>> I want to modify swapBuffers sample example. I observed that when I copy
>> any file then Read callback routines are called such that pre-read callback
>> is called at IRQL = PASSIVE_LEVEL while post-read callback is at IRQL =
>> DISPATCH_LEVEL.
>> I want to change IRQL of post-read callback to PASSIVE_LEVEL.
>> How can I change the IRQL??
>>
>> –
>> Kapil Bhadke
>> — NTFSD is sponsored by OSR For our schedule of debugging and file
>> system seminars visit: http://www.osr.com/seminars To unsubscribe, visit
>> the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>
>
> — NTFSD is sponsored by OSR For our schedule of debugging and file
> system seminars visit: http://www.osr.com/seminars To unsubscribe, visit
> the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


driver newbie

There is an API,
FltDoCompletionProcessingWhenSafe(http://msdn.microsoft.com/en-us/library/ff
542047(v=vs.85).aspx) that you can use in a postOp callback that can be
called at DPC to perform operations that must be performed at PASSIVE.
However that there are some limitations in what you do in such a callback,
see the documentation.

Thanks,

Alex.

Thank you all for your replies.

I have decided to go with FltDoCompletionProcessingWhenSafe. But the problem
I am facing now is that the Callback routine is not getting called by
FltDoCompletionProcessinfWhenSafe() and it is returning FALSE. I guess the
worker thread is not created. Why this might be happening??

On Sun, Apr 17, 2011 at 7:47 AM, Alex Carp wrote:

> There is an API, FltDoCompletionProcessingWhenSafe(
> http://msdn.microsoft.com/en-us/library/ff542047(v=vs.85).aspx) that you
> can use in a postOp callback that can be called at DPC to perform operations
> that must be performed at PASSIVE. However that there are some limitations
> in what you do in such a callback, see the documentation.
>
>
>
> Thanks,
>
> Alex.
>
>
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Kapil Bhadke

The worker thread is not created in all cases. It is only created when it is
not safe to call the routine directly. If the IRQL is below DPC then
FltDoCompletionProcessingWhenSafe will directly call the routine inline
without any worker thread being created.

Are you sure you’re not calling this for something that’s not allowed (like
calling it for a paging operation or for something that’s not an IRP or for
an operation that is being drained) ?

Thank,

Alex.

Thanks Alex…
I am 100% sure that the operation is not draining and is IRP operation and
is running at DPC level.
Actually what I want to do is to use Crypto Next Generation API in post read
operation along with some FltXXX functions which are allowed to run at
PASSIVE_LEVEL only.
Is there any other way to do it??

On Mon, Apr 18, 2011 at 9:28 PM, Alex Carp wrote:

> The worker thread is not created in all cases. It is only created when it
> is not safe to call the routine directly. If the IRQL is below DPC then
> FltDoCompletionProcessingWhenSafe will directly call the routine inline
> without any worker thread being created.
>
>
>
> Are you sure you?re not calling this for something that?s not allowed (like
> calling it for a paging operation or for something that?s not an IRP or for
> an operation that is being drained) ?
>
>
>
> Thank,
>
> Alex.
>
> —
> NTFSD is sponsored by OSR
>
> For our schedule of debugging and file system seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>


Kapil Bhadke