阅读:2019回复:1
passthru 如何在MpSendPacket回调函数里面截获数据包以后,对其修改,然后传递给上层应用程序,不发到外网
passthru 如何在MpSendPacket回调函数里面截获数据包以后,对其修改,然后传递给上层应用程序,不发送到外网。比如说为了让passthru实现
dhcp功能,就需要捕获到DHCP DISCOVER 包,让驱动去响应该数据包,不让该数据包到外网。 就需要在MpSendPacket里面把修改后的新包传递到上层应用程序,有哪位牛人做过的呀,请教,感激不尽! |
|
沙发#
发布于:2011-08-04 14:11
Re:passthru 如何在MpSendPacket回调函数里面截获数据包以后,对其修改,然后传递给上层应用程序,不发 ..
已经解决,下面的代码NdisDprAllocatePacket( &Status, &MyPacket, pAdapt->RecvPacketPoolHandle); if (NDIS_STATUS_SUCCESS != Status) { NdisFreeMemory(mypktdata, mypktlen, 0); //NdisFreePacket(MyPacket); NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_FAILURE); DbgPrint("allocate packet fail\r\n"); goto exit; } NdisAllocateBuffer(&Status, &RecvBuffer,pAdapt->RecvPacketPoolHandle, mypktdata, mypktlen); if (NDIS_STATUS_SUCCESS != Status) { NdisFreeMemory(mypktdata, mypktlen, 0); NdisDprFreePacket(MyPacket); NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_FAILURE); DbgPrint("allocate buffer fail\r\n"); goto exit; } //NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet)); NDIS_SET_PACKET_HEADER_SIZE(MyPacket,14); //NdisMoveMemory(NDIS_OOB_DATA_FROM_PACKET(MyPacket), // NDIS_OOB_DATA_FROM_PACKET(Packet), // sizeof(NDIS_PACKET_OOB_DATA)); // NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); // // By setting NDIS_STATUS_RESOURCES, we also know that we can reclaim // this packet as soon as the call to NdisMIndicateReceivePacket // returns. // NdisChainBufferAtFront(MyPacket, RecvBuffer); MyPacket->Private.Head->Next = NULL; MyPacket->Private.Tail = NULL; NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES); if (pAdapt->MiniportHandle != NULL) { DbgPrint("recv my packet\n"); NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1); } NdisMSendComplete(ADAPT_MINIPORT_HANDLE(pAdapt),Packet,NDIS_STATUS_SUCCESS); //if (Status == NDIS_STATUS_RESOURCES) { DbgPrint("free my pakcet\n"); FreeMyPacket(MyPacket); //NdisDprFreePacket(MyPacket); } goto exit; |
|