Crash when calling NdisMIndicateReceiveNetBufferLists

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



I am writing a virtual NDIS 6.0 miniport adapter.

In MiniportSendNetBufferList I am NATing packets and indicates them back:
1. Copy packet data from incoming NetBufferList to a buffer on the stack
2. NAT packet
3. Create 2 MDLs, one for ethernet header and one for the rest:
headerMdl = NdisAllocateMdl(Adapter->AdapterHandle, &data.buf[0], sizeof(CTEthernetHeader));
dataMdl = NdisAllocateMdl(Adapter->AdapterHandle, &data.buf[sizeof(CTEthernetHeader)], data.total_size - sizeof(CTEthernetHeader));
headerMdl->Next = dataMdl;

4. Allocate a new net buffer list:
NdisAllocateNetBufferAndNetBufferList(Adapter->RecvNetBufferListPool,
0, 0,
headerMdl, 0,
data.total_size);

5. Trying to indicate the packet with resources flags set.
NdisMIndicateReceiveNetBufferLists(
Adapter->AdapterHandle,
netlist,
NDIS_DEFAULT_PORT_NUMBER,
1,
NDIS_RECEIVE_FLAGS_RESOURCES);

When calling NdisMIndicateReceiveNetBufferLists it crashes so bad WinDbg doesn't even catch it. Sometimes it successfully indicates one packet, but mostly not.

When I have debugged it has not been running at dispatch level.

Is it ok to indicate packets from MiniportSendNetBufferList at all?
Is there anything obvious (to anyone but me ;) ) I have missed?
If the stack buffer is the problem, how do I handle the case when MiniportSendNetBufferList is called in dispatch level since NdisMoveMemory doesn't work then?

Thanks!
Fredrik

.



Relevant Pages

  • EnterCriticalSection crash from NDIS
    ... Basically a bunch of Windows functions are getting called when my miniport ... indicates NDIS packet send completion by calling NdisMSendComplete and the ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Packet Reserved areas in MPTransferData
    ... NdisMIndicateReceivePacket or perhaps NdisMEthIndicateReceive packet. ... It should also be clear that as soon as you indicate the packet upwards ... > the protocol above us to underlying miniport to copy its packet. ...
    (microsoft.public.development.device.drivers)
  • Re: Receive send packet
    ... > a send packet by the stack. ... A protocol driver binds to this Miniport ...
    (microsoft.public.development.device.drivers)
  • Re: Capturing network packets on Vista
    ... surely packet sends to the miniport in D2 are noise. ... and I expect TCPIP to cease all sends after getting this notification. ... there could be an NDIS issue. ...
    (microsoft.public.development.device.drivers)
  • Re: Problem of receiving TCP packets on Virtual adapter
    ... I have created a virtual miniport ... So all the packets are coming to that VA with IP and MAC ... When original miniport receive the packet IM change ... the IP and MAC of original to the VA and indicate to the upper layer ...
    (microsoft.public.development.device.drivers)