I’m a newbie with kernel drivers, but not a total one. I wrote a non-PnP driver that works and I’m trying to now add access to driver’s interface. I’m calling WdfDeviceAddQueryInterface right after successfully creating the device, but the driver keeps crashing because it appear IRQL is already 2 - don’t quite understand why and whether the message is maybe misleading. This is from the MEMORY.DMP:
IRQL_NOT_LESS_OR_EQUAL (a)
An attempt was made to access a pageable (or completely invalid) address at an
interrupt request level (IRQL) that is too high. This is usually
caused by drivers using improper addresses.
If a kernel debugger is available get the stack backtrace.
Arguments:
Arg1: 00000000000000b0, memory referenced
Arg2: 0000000000000002, IRQL
Arg3: 0000000000000001, bitfield :
bit 0 : value 0 = read operation, 1 = write operation
bit 3 : value 0 = not an execute operation, 1 = execute operation (only on chips which support this level of status)
Arg4: fffff8017340b52e, address which referenced memory
And the call stack is:
_STACK_TEXT:
ffff9a878bba2fd8 fffff801
73609269 : 000000000000000a 00000000
000000b0 0000000000000002 00000000
00000001 : nt!KeBugCheckEx
ffff9a878bba2fe0 fffff801
73605569 : 000a99928bbaffff 00000000
000000ff 00000000ffffffff ffffe183
00000000 : nt!KiBugCheckDispatch+0x69
ffff9a878bba3120 fffff801
7340b52e : 0000000000000000 00000000
00000fff 0000000000000103 00000000
00000000 : nt!KiPageFault+0x469
ffff9a878bba32b0 fffff801
765aecf2 : 00000000000000b0 ffffe183
00000000 0000000000000000 fffff801
765a9300 : nt!KeWaitForSingleObject+0x18e
ffff9a878bba33a0 fffff801
7661e947 : 0000000000000000 00000000
00000000 ffffe183b6dae250 fffff801
00000000 : Wdf01000!FxWaitLockInternal::AcquireLock+0x56 [minkernel\wdf\framework\shared\inc\private\common\FxWaitLock.hpp @ 266]
ffff9a878bba33e0 fffff801
765e0a11 : 0000000000000000 ffff9a87
8bba3510 ffff9a878bba3510 ffffe183
b05ca230 : Wdf01000!FxPkgPnp::AddQueryInterface+0x27 [minkernel\wdf\framework\shared\irphandlers\pnp\fxpkgpnp.cpp @ 5417]
ffff9a878bba3410 fffff801
70f42516 : ffffe183b75d1ce0 00000000
00000000 0000000000000000 00000000
00000000 : Wdf01000!imp_WdfDeviceAddQueryInterface+0x2d1 [minkernel\wdf\framework\kmdf\src\support\fxqueryinterfaceapi.cpp @ 219]
ffff9a878bba3490 fffff801
70f4156a : 00001e7c48a2e318 ffff9a87
8bba3510 fffff80170f440c0 00000000
00000000 : KMDF_RTC!WdfDeviceAddQueryInterface+0x46 [C:\Program Files (x86)\Windows Kits\10\Include\wdf\kmdf\1.15\WdfQueryInterface.h @ 175]
ffff9a878bba34d0 fffff801
70f41140 : 00001e7c48a2e318 ffff9a87
8bba36c8 ffff9a878bba3698 00000000
00000000 : KMDF_RTC!SetupDeviceInterface+0x13a [C:\Users\durovicm\source\repos\KMDF_RTC\KMDF_RTC\KRTCTimer.cpp @ 78] _
The driver code that leads up to this unfortunate outcome is:
_PAGED_CODE();
RTCTIMER_INTERFACE timerInterface;
WDF_QUERY_INTERFACE_CONFIG timerInterfaceConfig;
RtlZeroMemory(&timerInterface, sizeof(timerInterface));
timerInterface.InterfaceHeader.Size = sizeof(timerInterface);
timerInterface.InterfaceHeader.Version = 1;
timerInterface.InterfaceHeader.Context = device;
timerInterface.InterfaceHeader.InterfaceReference = WdfDeviceInterfaceReferenceNoOp;
timerInterface.InterfaceHeader.InterfaceDereference = WdfDeviceInterfaceDereferenceNoOp;
timerInterface.intValue = 1789;
timerInterface.TimerName.Buffer = timerInterface.TimerNameStr;
timerInterface.TimerName.MaximumLength = sizeof(timerInterface.TimerNameStr) / sizeof(timerInterface.TimerNameStr[0]) - 1;
DECLARE_CONST_UNICODE_STRING(movie, L"Good, bad, ugly");
RtlCopyUnicodeString(&timerInterface.TimerName, &movie);
WDF_QUERY_INTERFACE_CONFIG_INIT(&timerInterfaceConfig, (PINTERFACE)&timerInterface,
&GUID_RTCTIMER_INTERFACE_STANDARD,
NULL);
timerInterfaceConfig.ImportInterface = FALSE;
NTSTATUS status = WdfDeviceAddQueryInterface(device, &timerInterfaceConfig);_
The last line is the line 78 at which the crash happens.
I’m at my wits’ end trying to understand this error. The driver works fine without this code that attempts to add the ability to add query interface ability. Any help is much appreciated…