Is it safe to lower IRP in completion routine?

I am getting bugcheck C4 when I try to call KeEnterCriticalRegion in IO
Completion routine. Reason being completion routine is called dispatch
level.
So wondering if I can lower the irql in completion routine and how to
achieve it.

Thanks,

Ruby

>

I am getting bugcheck C4 when I try to call KeEnterCriticalRegion in IO
Completion routine. Reason being completion routine is called dispatch level.
So wondering if I can lower the irql in completion routine and how to achieve
it.

I guess you’d schedule a workitem and return STATUS_MORE_PROCESSING_REQUIRED, then do your work in the workitem.

You can’t just lower the IRQL arbitrarily with KeLowerIrql, if that’s what you are asking.

James

Ruby Siddhu wrote:

I am getting bugcheck C4 when I try to call KeEnterCriticalRegion in
IO Completion routine. Reason being completion routine is called
dispatch level.
So wondering if I can lower the irql in completion routine and how to
achieve it.

It is NEVER safe to lower the IRQL, unless you are restoring to a level
that you raised from earlier.

You’re already at a raised IRQL. Are you sure you need a critical
region? If you have something you need to protect at various different
IRQLs, perhaps you should choose a different primitive.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

> I am getting bugcheck C4 when I try to call KeEnterCriticalRegion in IO

Completion routine. Reason being completion routine is called dispatch
level.
So wondering if I can lower the irql in completion routine and how to
achieve it.

Thanks,

When you are in DISPATCH_LEVEL, you may not
(a) call any DDI function whose spec says < DISPATCH_LEVEL
(b) lower the IRQL

That’s what threads are for. You can use either a workitem with the
built-in thread queue or create a dedicated thread in your driver is a
design choice. Note that yoy must abandon the illusion that you can do
things sequentially; if, for example, your code is DL1(); PL1(); DL2(();
where DL is a function permitted at DISPATCH_LEVEL and PL Reqires
PASSIVE_LEVEL, you CANNOT write it as DL1(); QWI(); wait…; DL2();
because there is no way towait; instead, you must change your Queued Work
Item to be PL1(); DL2();.

You have to completely abandon the idea that textual sequentiality in the
source code must be used to represent sequentiality of execution.
joe

Ruby


NTDEV is sponsored by OSR

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other 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