阅读:1492回复:2
高手进来看看吧!我快要疯了!
一个截获ICMP包的程序,调了一个星期,就是搞不定啊。
经过跟踪我发现是PtTransferDataComplete函数中的问题 代码基本上是模仿论坛上贴出的代码,就是高不定啊! 具体如下: { PADAPT pAdapt =(PADAPT)ProtocolBindingContext; PUCHAR pPacketContent; PRSVD Rsvd; UINT Result,uiPacketLen; PNDIS_BUFFER pPacketBuffer; PNDIS_PACKET pBakPacket; PNDIS_BUFFER pBakBuffer; PUCHAR pBakContent; UINT BufferLen; DBGPRINT((\"In PtTransferDataComplete\\n\")); // // Returning the Send on the Primary, will point to itself if there is no LBFO // pAdapt = pAdapt->pPrimaryAdapt; Rsvd =(PRSVD)(PartOfPacket->MiniportReserved); pBakPacket=(PNDIS_PACKET)(Rsvd->OriginalPkt); if(pAdapt->MiniportHandle) { if(pBakPacket == NULL) { NdisMTransferDataComplete(pAdapt->MiniportHandle, PartOfPacket, Status, BytesTransferred); } else { Status=NdisAllocateMemory(&pPacketContent, // pPacket is used for keeping the Whole packet contents BUFFER_SIZE, 0, HighestAcceptableMax); NdisZeroMemory(pPacketContent, BUFFER_SIZE); /*--------------------------------------------------------------------------------------- GetDataFromPacket(PartOfPacket,pPacketContent+uiOffsetSize,&PacketLen); Free the memory, allocated in PtReceive Function and used for containing the first part of the packet -------------------------------------------------------------------------------------------*/ uiPacketLen = GetDataFromPacket(pBakPacket, pPacketContent ); uiPacketLen += (GetDataFromPacket(PartOfPacket, pPacketContent+uiPacketLen ) ); /******************************************************************* /* the modual is used for releasing the resource of pBakBuffer */ NdisUnchainBufferAtFront(pBakPacket,&pBakBuffer); NdisQueryBufferSafe(pBakBuffer, &pBakContent, &BufferLen, 32); NdisFreeBuffer(pBakBuffer); NdisFreeMemory(pBakContent,BUFFER_SIZE,0); NdisFreePacket(pBakPacket); /************************************************************************/ NdisZeroMemory(PartOfPacket->MiniportReserved, sizeof(PartOfPacket->MiniportReserved) ); NdisUnchainBufferAtFront(PartOfPacket,&pPacketBuffer); NdisQueryBufferSafe(pPacketBuffer, &pBakContent, &BufferLen, 32); NdisFreeBuffer(pPacketBuffer); NdisFreeMemory(pBakContent,BUFFER_SIZE,0); NdisAllocateBuffer(&Status, &pPacketBuffer, pAdapt->RecvBufferPoolHandle, pPacketContent, uiPacketLen); NdisChainBufferAtFront(PartOfPacket,pPacketBuffer); PartOfPacket->Private.Head->Next=NULL; PartOfPacket->Private.Tail=NULL; NDIS_SET_PACKET_HEADER_SIZE(PartOfPacket,MAC_HEADER_LENGTH); if (IcmpWithPacket(PartOfPacket) != NDIS_STATUS_ICMP) { NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &PartOfPacket, 1); //就是这句话,总是出错。系统提示driver_irql_not_less_or_equal } if( NDIS_GET_PACKET_STATUS(PartOfPacket) != NDIS_STATUS_PENDING ) { MPReturnPacket((NDIS_HANDLE)pAdapt,PartOfPacket); } } } return; } 希望写过类似程序的朋友一定帮帮忙。小弟实在受不了了! |
|
沙发#
发布于:2003-11-26 10:03
过滤ICMP要跑到transferdatacomplete去干什么?
如果你的数据走:ptreceive那么在一般情况下ICMP的数据都不要 transferdata, 如果走PTRECEIVEPACKER,那么根本就不会有transferdatacomplete出现 |
|
|
板凳#
发布于:2003-11-26 10:39
是这样的。
这个东西只是熟悉一下整个流程,所以我尽量的写了所有的函数。 而且现在只是一个过滤icmp报文, 后面我将逐步完善所有的功能,如过滤其他的报文 。 不过谢谢楼上的,这个代码我已经搞定了。 我发现有时贴代码,不自己写的,出了错,都不知道哪儿错了。到最后还要自己的一行行的看。这个代码花了我将近一个星期,简直最后就没信心了。不过最后还是搞定了! 谢谢大家了! |
|