Device Driver IRQL and Thread/Context Switches
Posted
by Christian Hoglund
on Stack Overflow
See other posts from Stack Overflow
or by Christian Hoglund
Published on 2010-02-22T13:15:09Z
Indexed on
2010/04/03
12:23 UTC
Read the original article
Hit count: 752
Windows
|device-driver
Hi,
I'm new to Windows device driver programming. I know that certain operations can only be performed at IRQL PASSIVE_LEVEL
. For example, Microsoft have this sample code of how to write to a file from a kernel driver:
if (KeGetCurrentIrql() != PASSIVE_LEVEL)
return STATUS_INVALID_DEVICE_STATE;
Status = ZwCreateFile(...);
My question is this: What is preventing the IRQL from being raised after the KeGetCurrentIrql()
check above? Say a context or thread swithch occurs, couldn't the IRQL suddenly be DISPATCH_LEVEL
when it gets back to my driver which would then result in a system crash?
If this is NOT possible then why not just check the IRQL in the DriverEntry
function and be done with it once for all?
© Stack Overflow or respective owner