如果你写中间层驱动遇到NdisReturnPackets+0x48处崩溃,原因在于:
底层提交给了的packet,而此包是不能被重用的;而你却又通过NdisReturnpackets返回给底层;
解决方法:
1)确认底层给你的包如果是不能被重用的,你不能通过NdisReturnpackets返回给他;
2)在MPReturnPackets中通过
PNDIS_PACKET_STACK NdisIMGetCurrentPacketStack(
PNDIS_PACKET Packet,
BOOLEAN* StacksRemaining
);对提交给底层的packet进行进一步判断:
PNDIS_PACKET_STACK stack;
BOOLEAN StacksRemaining;
stack=NdisIMGetCurrentPacketStack(oldPacket,&StacksRemaining);
if(StacksRemaining) //must have!!!
{
NdisReturnPackets(&oldPacket,1);
}
{
DbgPrint("we can not return the packet,becase the down layer maybe has Freed the packet,if you return the packet,it may be free twice!");
}