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?