How can we run a PASSIVE_LEVEL API in DISPATCH_LEVEL?

Ask your beginner questions here.
Post Reply
Carlbyte
Posts: 74
Joined: Fri Mar 21, 2014 12:18 pm

How can we run a PASSIVE_LEVEL API in DISPATCH_LEVEL?

Post by Carlbyte » Wed May 31, 2017 5:00 pm

In a code snippet of a dispatch from my driver that works with irql = dispatch_level, I have a zw ... function that works on passive_level. How to solve this problem? Kelowerirql? Pscreatethread?

User avatar
Vrtule
Posts: 461
Joined: Sat Mar 13, 2010 9:14 pm
Location: Czech Republic
Contact:

Re: How can we run a PASSIVE_LEVEL API in DISPATCH_LEVEL?

Post by Vrtule » Wed May 31, 2017 7:15 pm

PsCreateSystemThread can be called only on PASSIVE_LEVEL.

KeLowerIrql SHOULD NOT be used this way.

One of the right ways of doing this is to execute the Zw routine in a workitem (ExInitializeWorkItem/IoAllocateWorkItem, ExQueueWorkItem). The execution is asynchronous.

Carlbyte
Posts: 74
Joined: Fri Mar 21, 2014 12:18 pm

Re: How can we run a PASSIVE_LEVEL API in DISPATCH_LEVEL?

Post by Carlbyte » Wed May 31, 2017 7:50 pm

On the internet I also found this way. Is this the only way to solve this problem? thanks

User avatar
Vrtule
Posts: 461
Joined: Sat Mar 13, 2010 9:14 pm
Location: Czech Republic
Contact:

Re: How can we run a PASSIVE_LEVEL API in DISPATCH_LEVEL?

Post by Vrtule » Wed May 31, 2017 8:06 pm

It probably depends on what are you trying to accomplish and what causes that the code runts at DISPATCH_LEVEL.

Workitems are a general solution but might not be suitable for all cases. But each of the alternatives means, more or less, implementing your own workitems... sort of.

Post Reply