Winapi “什么会导致?”;MDL在同一进程列表中插入了两次;?

Winapi “什么会导致?”;MDL在同一进程列表中插入了两次;?,winapi,windows-xp,driver,ndis,Winapi,Windows Xp,Driver,Ndis,我们正在开发NDIS协议和微型端口驱动程序。当驱动程序正在使用且系统处于休眠状态时,我们会得到一个错误检查(蓝屏),错误如下: LOCKED_PAGES_TRACKER_CORRUPTION (d9) Arguments: Arg1: 00000001, The MDL is being inserted twice on the same process list. Arg2: 875da420, Address of internal lock tracking structure. Arg

我们正在开发NDIS协议和微型端口驱动程序。当驱动程序正在使用且系统处于休眠状态时,我们会得到一个错误检查(蓝屏),错误如下:

LOCKED_PAGES_TRACKER_CORRUPTION (d9)
Arguments:
Arg1: 00000001, The MDL is being inserted twice on the same process list.
Arg2: 875da420, Address of internal lock tracking structure.
Arg3: 87785728, Address of memory descriptor list.
Arg4: 00000013, Number of pages locked for the current process.
堆栈跟踪不是特别有用,因为我们的驱动程序没有出现在清单中:

nt!RtlpBreakWithStatusInstruction
nt!KiBugCheckDebugBreak+0x19
nt!KeBugCheck2+0x574
nt!KeBugCheckEx+0x1b
nt!MiAddMdlTracker+0xd8
nt!MmProbeAndLockPages+0x629
nt!NtWriteFile+0x55c
nt!KiFastCallEntry+0xfc
ntdll!KiFastSystemCallRet
ntdll!ZwWriteFile+0xc
kernel32!WriteFile+0xa9

什么类型的问题可能导致此MDL错误?

事实证明,问题与我们的IRP_MJ_写入处理程序中的代码有关:

/* If not in D0 state, don't attempt transmits */
if (ndisProtocolOpenContext && 
    ndisProtocolOpenContext->powerState > NetDeviceStateD0)
{
   DEBUG_PRINT(("NPD: system in sleep mode, so no TX\n"));
   return STATUS_UNSUCCESSFUL;
}
这意味着我们没有完全完成IRP,NDIS可能因此做了一些有趣的事情。添加对IoCompleteRequest的调用修复了该问题

/* If not in D0 state, don't attempt transmits */
if (ndisProtocolOpenContext && 
    ndisProtocolOpenContext->powerState > NetDeviceStateD0)
{
   DEBUG_PRINT(("NPD: system in sleep mode, so no TX\n"));
   pIrp->IoStatus.Status = STATUS_UNSUCCESSFUL;
   IoCompleteRequest(pIrp, IO_NO_INCREMENT);
   return STATUS_UNSUCCESSFUL;
}

您可能损坏了内核内存池。