阅读:1739回复:1
修改passthru的MPSendPackets的一个问题
是想利用NDIS中间层对要发送的一个特定内容的UDP包进行拦截,然后修改,发送,我修改MPSendPackets里内容如下
PADAPT pAdapt = (PADAPT)MiniportAdapterContext; NDIS_STATUS Status; PNDIS_PACKET MyPacket; PRSVD Rsvd; PVOID MediaSpecificInfo = NULL; ULONG MediaSpecificInfoSize = 0; ASSERT (pAdapt->pSecondaryAdapt); pAdapt = pAdapt->pSecondaryAdapt; if (IsIMDeviceStateOn (pAdapt) == FALSE) { return NDIS_STATUS_FAILURE; } NdisAllocatePacket(&Status, &MyPacket, pAdapt->SendPacketPoolHandle); if (Status == NDIS_STATUS_SUCCESS) { PUCHAR pPacketContent; PUCHAR pBuf; ULONG nBufferSize; MDL * pNext; UINT i,j; BOOLEAN transFlag = FALSE; PNDIS_BUFFER MyBuffer; PIPHeader pIPHeader; PUDPHeader pUDPHeader; PUDPHeaderHH psdhdr; Status= NdisAllocateMemory( &pPacketContent, 2000, 0,HighestAcceptableMax); NdisQueryBufferSafe(Packet->Private.Head,&pBuf,&nBufferSize,32); NdisMoveMemory(pPacketContent,pBuf,nBufferSize); i = nBufferSize; pNext = Packet->Private.Head; //把包的数据拷贝到pPacketContent里面 for(;;) { if(pNext == Packet->Private.Tail) break; pNext = pNext->Next; if(pNext == NULL) break; NdisQueryBufferSafe(pNext,&pBuf,&nBufferSize,32); NdisMoveMemory(pPacketContent,pBuf,nBufferSize); pPacketContent= pPacketContent+nBufferSize; } 之后想根据pPacketContent中的内容进行判断,但是我把pPacketContent的内容打印出来和用wireshark截的包进行分析,根本对不上啊,感觉并没有把数据包的内容放进pPacketContent里面,不知道哪出问题了,请大牛指教 |
|
沙发#
发布于:2008-07-23 16:44
1 为什么 NdisQueryBufferSafe(Packet->Private.Head,&pBuf,&nBufferSize,32)写?
好好的有了packet为什么不直接用呢?如NdisQueryBufferSafe(Packet, &pBuf,.... 2 32代表什么呢?为什么不直接使用Normalxxxx之类的定义呢? 3 NdisMoveMemory(pPacketContent,pBuf,nBufferSize); 这历的buf并不是数据buffer阿? 4 。。。。后面的循环没仔细看,但是感觉乱 重点:没有弄明白packet->buffer->char之间的关系,建议再仔细看看。 |
|
|