阅读:1025回复:0
passthru的问题!
照搬Huyg的一段代码,安装后系统蓝屏,代码如下:
NDIS_STATUS PtReceive( IN NDIS_HANDLE ProtocolBindingContext, IN NDIS_HANDLE MacReceiveContext, IN PVOID HeaderBuffer, IN UINT HeaderBufferSize, IN PVOID LookAheadBuffer, IN UINT LookAheadBufferSize, IN UINT PacketSize ) /*++ Routine Description: LBFO - need to use primary for all receives Arguments: Return Value: --*/ { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; PNDIS_PACKET MyPacket, Packet; NDIS_STATUS Status = NDIS_STATUS_SUCCESS; //****************************************************** UINT PacketLen; PRSVD Resvd; NDIS_PHYSICAL_ADDRESS HighestAcceptableAddress; PUCHAR pPacketContent; PNDIS_BUFFER PacketBuffer; //****************************************************** if(!pAdapt->MiniportHandle) { Status = NDIS_STATUS_FAILURE; } else do { // We should not be getting Receives on a Secondary, this is just specific to our LBFO driver if(pAdapt->isSecondary) { DBGPRINT(\"PASSTHRU GETTING RECIEVES ON SECONDARY\\n\"); ASSERT(0); } // // If this was indicated by the miniport below as a packet, then get that packet pointer and indicate // it as a packet as well(with appropriate status). This way the OOB stuff is accessible to the // transport above us. // Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext); if(Packet != NULL) { // // Get a packet off the pool and indicate that up // NdisDprAllocatePacket allocates and initializes a packet descriptor when the caller is running at IRQL DISPATCH_LEVEL. NdisDprAllocatePacket(&Status, &MyPacket, pAdapt->RecvPacketPoolHandle); if(Status == NDIS_STATUS_SUCCESS) { MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; // // Get the original packet(it could be the same packet as one received or a different one // based on # of layered MPs) and set it on the indicated packet so the OOB stuff is visible // correctly at the top. // NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet)); NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize); // // Set Packet Flags // NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); // // Make sure the status is set to NDIS_STATUS_RESOURCES. // NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES); NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1); ASSERT(NDIS_GET_PACKET_STATUS(MyPacket) == NDIS_STATUS_RESOURCES); NdisDprFreePacket(MyPacket); break; } } //*************************************************************************************** HighestAcceptableAddress.LowPart = -1; HighestAcceptableAddress.HighPart = -1; if(PacketSize <= LookAheadBufferSize) { Status = NdisAllocateMemory(&pPacketContent, 2000, 0, HighestAcceptableAddress); if (Status != NDIS_STATUS_SUCCESS ) { DbgPrint(\"ptreceive :ndisallocatememory failed\\n\"); return NDIS_STATUS_NOT_ACCEPTED ; } if(pPacketContent == NULL) { DbgPrint(\"prreceive:pPacketContent == NULL\\n\"); return NDIS_STATUS_NOT_ACCEPTED ; } RtlZeroMemory(pPacketContent, 2000); RtlCopyMemory(pPacketContent,HeaderBuffer,HeaderBufferSize); RtlCopyMemory(pPacketContent+HeaderBufferSize,LookAheadBuffer,LookAheadBufferSize); PacketLen = PacketSize+HeaderBufferSize; NdisDprAllocatePacket(&Status, &MyPacket, pAdapt->RecvPacketPoolHandle); if(Status != NDIS_STATUS_SUCCESS) { DbgPrint(\"NdisDprAllocatePacket failed!\\n\"); return NDIS_STATUS_NOT_ACCEPTED ; } if(Status == NDIS_STATUS_SUCCESS) { NdisAllocateBuffer(&Status, &PacketBuffer, pAdapt->RecvBufferPoolHandle, pPacketContent,PacketLen); NdisChainBufferAtFront(MyPacket, PacketBuffer); MyPacket->Private.Head->Next=NULL; MyPacket->Private.Tail = NULL; Resvd =(PRSVD)(MyPacket->MiniportReserved); Resvd->OriginalPkt = NULL; NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize); NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1); //运行到这里就死翘翘了 if ( NDIS_GET_PACKET_STATUS( MyPacket ) != NDIS_STATUS_PENDING ) { NdisFreeBuffer(PacketBuffer); NdisFreeMemory(pPacketContent,2000,0); NdisDprFreePacket(MyPacket); } break; } } //***************************************************************************************** // // Fall through if the miniport below us has either not indicated a packet or we could not // allocate one // pAdapt->IndicateRcvComplete = TRUE; switch(pAdapt->Medium) { case NdisMedium802_3: NdisMEthIndicateReceive(pAdapt->MiniportHandle, MacReceiveContext, HeaderBuffer, HeaderBufferSize, LookAheadBuffer, LookAheadBufferSize, PacketSize); break; case NdisMedium802_5: NdisMTrIndicateReceive(pAdapt->MiniportHandle, MacReceiveContext, HeaderBuffer, HeaderBufferSize, LookAheadBuffer, LookAheadBufferSize, PacketSize); break; case NdisMediumFddi: NdisMFddiIndicateReceive(pAdapt->MiniportHandle, MacReceiveContext, HeaderBuffer, HeaderBufferSize, LookAheadBuffer, LookAheadBufferSize, PacketSize); break; default: ASSERT(0); break; } } while(FALSE); return Status; } 各位大虾帮忙看看!!! |
|
最新喜欢:linwn |