|
小子打算在NDIS中间层接收时仅对TCP包的内容进行修改,然后上传其他层自动继续处理。修改过程中包长度有变化,并在修改前后分别对包内容进行输出比较,也没有问题,包内容确实修改成功。但不知道为什么拿一个简单TCP发包工具进行测试,发现根本没办法连接,哪位给小子看看,下面是修改和上传代码:
……已将包内容读入pPacketContent中,DataOffset为内容长度
Newpktstatus = NdisAllocateMemoryWithTag( &MyPacketContent, DataOffset, TAG);
if (Newpktstatus!=NDIS_STATUS_SUCCESS )
break ;
NdisZeroMemory( MyPacketContent, DataOffset ) ;
//内容修改 AllocatLength 是修改后数据长度
AllocatLength = PacketDecryption( pPacketContent, MyPacketContent, DataOffset);
MyPacket->Private.Head=NULL;
MyPacket->Private.Tail=NULL;
NdisAllocateBuffer(&Newpktstatus,&MyBuffer,pAdapt->RecvPacketPoolHandle,MyPacketContent,AllocatLength);
if (Newpktstatus!=NDIS_STATUS_SUCCESS )
break;
NdisChainBufferAtFront(MyPacket, MyBuffer);
MyPacket->Private.Head->Next=NULL;
MyPacket->Private.TotalLength = AllocatLength;
if (pAdapt->MiniportHandle != NULL)
{
NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES);
NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1);
NdisUnchainBufferAtFront(MyPacket,&MyBuffer);
NdisQueryBufferSafe(MyBuffer,&MyPacketContent,&BufLength,32);
if(MyPacketContent != NULL)
NdisFreeMemory(MyPacketContent,BufLength,0);
if(pPacketContent != NULL)
NdisFreeMemory(pPacketContent,TotalLength,0);
NdisFreeBuffer(MyBuffer);
NdisDprFreePacket(MyPacket);
break;
}
|
|