阅读:1916回复:1
急急急 哪位能帮忙看看为什么老是蓝屏啊(win7 BAD_POOL_CALLER)VOID MPSendPackets( IN NDIS_HANDLE MiniportAdapterContext, IN PPNDIS_PACKET PacketArray, IN UINT NumberOfPackets ) { PADAPT pAdapt = (PADAPT)MiniportAdapterContext; NDIS_STATUS Status; UINT i; PVOID MediaSpecificInfo = NULL; UINT MediaSpecificInfoSize = 0; PNDIS_BUFFER MyBuffer; for (i = 0; i < NumberOfPackets; i++) { PNDIS_PACKET Packet, MyPacket; PSEND_RSVD Resvd; PSEND_RSVD MyResvd; Packet = PacketArray; //add by gongxz 20150319 { UINT PhysicalBufferCount; UINT BufferCount; PIP_HEADER pIPHeader; BOOLEAN Status = FALSE; PNDIS_BUFFER NdisBuffer ; PUCHAR pPacketContent = NULL; PUCHAR tembuffer = NULL ; ULONG length = 0; UINT TotalPacketLength = 0; UINT copysize = 0; UINT DataOffset = 0 ; NdisAllocateMemoryWithTag(&pPacketContent, 2048, TAG); if (pPacketContent == NULL) { continue; } NdisZeroMemory(pPacketContent, 2048) ; DBGPRINT(("===>MPSendPackets 0 <===\n")); NdisQueryPacket(Packet, &PhysicalBufferCount, &BufferCount, &NdisBuffer, &TotalPacketLength); DBGPRINT(("===>MPSendPackets 0.1,PhysicalBufferCount=%d,BufferCount=%d,TotalPacketLength=%d<===\n", PhysicalBufferCount, BufferCount, TotalPacketLength)); while(TRUE) { NdisQueryBufferSafe(NdisBuffer, &tembuffer, ©size, NormalPagePriority); DBGPRINT(("===>MPSendPackets 0.1,copysize = %d<===\n", copysize)); if(tembuffer != NULL) { NdisMoveMemory(pPacketContent + DataOffset, tembuffer, copysize); DataOffset += copysize; } NdisGetNextBuffer(NdisBuffer , &NdisBuffer) ; if(NdisBuffer == NULL) { break ; } DBGPRINT(("===>MPSendPackets 0.2 <===\n")); } pIPHeader = (PIP_HEADER)(pPacketContent + IP_OFFSET); if(pPacketContent[12] == 8 && pPacketContent[13] == 0 && pIPHeader->Protocol == PROT_TCP) { DBGPRINT(("===>MPSendPackets 1 <===\n")); NdisAcquireSpinLock(&pAdapt->Lock); // // If the below miniport is going to low power state, stop sending down any packet. // if (pAdapt->PTDeviceState > NdisDeviceStateD0) { NdisReleaseSpinLock(&pAdapt->Lock); NdisFreeMemory(pPacketContent, 2048, 0); NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, NDIS_STATUS_FAILURE); continue; } pAdapt->OutstandingSends++; NdisReleaseSpinLock(&pAdapt->Lock); NdisAllocatePacket(&Status, &MyPacket, pAdapt->SendPacketPoolHandle); if (Status == NDIS_STATUS_SUCCESS) { DBGPRINT(("===>MPSendPackets 1.1 <===\n")); //AlterPacketWind(pPacketContent); NdisAllocateBuffer(&Status, &MyBuffer, pAdapt->SendPacketPoolHandle, pPacketContent, length); if (Status == NDIS_STATUS_SUCCESS) { Resvd =(PSEND_RSVD)(MyPacket->ProtocolReserved); Resvd->OriginalPkt = (PNDIS_PACKET)Packet; DBGPRINT(("===>MPSendPackets 2.1 <===\n")); NdisChainBufferAtFront(MyPacket, MyBuffer); DBGPRINT(("===>MPSendPackets 2.2 <===\n")); MyPacket->Private.Head->Next = NULL; MyPacket->Private.Tail = NULL; DBGPRINT(("===>MPSendPackets 2.3 <===\n")); MyResvd =(PSEND_RSVD)(MyPacket->MiniportReserved); MyResvd->OriginalPkt = (PNDIS_PACKET)MyPacket; DBGPRINT(("===>MPSendPackets 2.4 <===\n")); NdisSend(&Status, pAdapt->BindingHandle, MyPacket); KdPrint(("Status = %x", Status)); if(Status != NDIS_STATUS_PENDING) { #ifndef WIN9X NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket); #endif NdisUnchainBufferAtFront(MyPacket ,&MyBuffer); if (MyBuffer) { NdisFreeBuffer(MyBuffer); } NdisFreeMemory(pPacketContent, 2048, 0); NdisFreePacket(MyPacket); ADAPT_DECR_PENDING_SENDS(pAdapt); } if (Status != NDIS_STATUS_PENDING) { NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, Status); } continue; } } NdisFreeMemory(pPacketContent, 2048, 0); ADAPT_DECR_PENDING_SENDS(pAdapt); if (Status != NDIS_STATUS_PENDING) { NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, Status); } continue; } else { DBGPRINT(("===>MPSendPackets 4 <===\n")); NdisFreeMemory(pPacketContent, 2048, 0); DBGPRINT(("===>MPSendPackets 4.1 <===\n")); } } //add by gongxz 20150319 // // The driver should fail the send if the virtual miniport is in low // power state // if (pAdapt->MPDeviceState > NdisDeviceStateD0) { NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, NDIS_STATUS_FAILURE); continue; } DBGPRINT(("===>MPSendPackets 4.2 <===\n")); #ifdef NDIS51 DBGPRINT(("===>MPSendPackets 4.3 <===\n")); // // Use NDIS 5.1 packet stacking: // { PNDIS_PACKET_STACK pStack; BOOLEAN Remaining; // // Packet stacks: Check if we can use the same packet for sending down. // pStack = NdisIMGetCurrentPacketStack(Packet, &Remaining); DBGPRINT(("===>MPSendPackets 4.4 <===\n")); if (Remaining) { DBGPRINT(("===>MPSendPackets 4.5 <===\n")); // // We can reuse "Packet". // // NOTE: if we needed to keep per-packet information in packets // sent down, we can use pStack->IMReserved[]. // ASSERT(pStack); // // If the below miniport is going to low power state, stop sending down any packet. // NdisAcquireSpinLock(&pAdapt->Lock); if (pAdapt->PTDeviceState > NdisDeviceStateD0) { NdisReleaseSpinLock(&pAdapt->Lock); NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, NDIS_STATUS_FAILURE); } else { pAdapt->OutstandingSends++; NdisReleaseSpinLock(&pAdapt->Lock); NdisSend(&Status, pAdapt->BindingHandle, Packet); if (Status != NDIS_STATUS_PENDING) { NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, Status); ADAPT_DECR_PENDING_SENDS(pAdapt); } } DBGPRINT(("===>MPSendPackets 4.7 <===\n")); continue; } } #endif do { NdisAcquireSpinLock(&pAdapt->Lock); // // If the below miniport is going to low power state, stop sending down any packet. // if (pAdapt->PTDeviceState > NdisDeviceStateD0) { NdisReleaseSpinLock(&pAdapt->Lock); Status = NDIS_STATUS_FAILURE; break; } pAdapt->OutstandingSends++; NdisReleaseSpinLock(&pAdapt->Lock); NdisAllocatePacket(&Status, &MyPacket, pAdapt->SendPacketPoolHandle); if (Status == NDIS_STATUS_SUCCESS) { PSEND_RSVD SendRsvd; SendRsvd = (PSEND_RSVD)(MyPacket->ProtocolReserved); SendRsvd->OriginalPkt = Packet; NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); NDIS_PACKET_FIRST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_FIRST_NDIS_BUFFER(Packet); NDIS_PACKET_LAST_NDIS_BUFFER(MyPacket) = NDIS_PACKET_LAST_NDIS_BUFFER(Packet); #ifdef WIN9X // // Work around the fact that NDIS does not initialize this // to FALSE on Win9x. // NDIS_PACKET_VALID_COUNTS(MyPacket) = FALSE; #endif // WIN9X // // Copy the OOB data from the original packet to the new // packet. // NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket), NDIS_OOB_DATA_FROM_PACKET(Packet), sizeof(NDIS_PACKET_OOB_DATA)); // // Copy relevant parts of the per packet info into the new packet // #ifndef WIN9X NdisIMCopySendPerPacketInfo(MyPacket, Packet); #endif // // Copy the Media specific information // NDIS_GET_PACKET_MEDIA_SPECIFIC_INFO(Packet, &MediaSpecificInfo, &MediaSpecificInfoSize); if (MediaSpecificInfo || MediaSpecificInfoSize) { NDIS_SET_PACKET_MEDIA_SPECIFIC_INFO(MyPacket, MediaSpecificInfo, MediaSpecificInfoSize); } NdisSend(&Status, pAdapt->BindingHandle, MyPacket); if (Status != NDIS_STATUS_PENDING) { #ifndef WIN9X NdisIMCopySendCompletePerPacketInfo (Packet, MyPacket); #endif NdisFreePacket(MyPacket); ADAPT_DECR_PENDING_SENDS(pAdapt); } } else { // // The driver cannot allocate a packet. // ADAPT_DECR_PENDING_SENDS(pAdapt); } } while (FALSE); if (Status != NDIS_STATUS_PENDING) { NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt), Packet, Status); } } DBGPRINT(("==>MPSendPackets end\n")); } |
|
沙发#
发布于:2015-04-04 11:09
建议把dump分析贴上来比较好。蓝掉,通常是内存飞了,irql不合适等。也可以用verifier程序监控下
|
|
|