阅读:1714回复:0
请教各位高手,PtReceive中对数据进行解密的问题!..先谢了!
PtReceive中对数据进行解密的问题!
在ptReceive中对数据包进行解密: NDIS_STATUS status; UINT PhysicalBufferCount; UINT BufferCount; PNDIS_BUFFER NdisBuffer; PNDIS_BUFFER MyBuffer; UINT TotalPacketLength = 0; //总体数据包的长度 PUCHAR pPacketContent = NULL; int nNewDataLen = 0; PUCHAR tembuffer = NULL; UINT copysize = 0; UINT DataOffset = 0 ; Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext); if (Packet != NULL) { NdisDprAllocatePacket(&Status, &MyPacket,pAdapt->RecvPacketPoolHandle); //申请数据包(MyPacket) if (Status == NDIS_STATUS_SUCCESS) { MyPacket->Private.Head = Packet->Private.Head; MyPacket->Private.Tail = Packet->Private.Tail; ////////////////////////////////////////////////////////////////////////////////////// { __try { NdisQueryPacket(Packet,&PhysicalBufferCount,&BufferCount,&NdisBuffer,&TotalPacketLength); status = NdisAllocateMemoryWithTag(&pPacketContent,TotalPacketLength,TAG); DbgPrint(" 申请PtReceive pPacketContent地址:%08x 长度:%d\r\n",pPacketContent,TotalPacketLength); if(status != NDIS_STATUS_SUCCESS) { __leave; return; } NdisZeroMemory(pPacketContent,TotalPacketLength); while (TRUE) { NdisQueryBufferSafe(NdisBuffer,&tembuffer,©size,NormalPagePriority); if(tembuffer != NULL) { NdisMoveMemory(pPacketContent + DataOffset,tembuffer,copysize); DataOffset += copysize; } NdisGetNextBuffer(NdisBuffer,&NdisBuffer); if(NdisBuffer == NULL) break; } if(pPacketContent[12] ==8 && pPacketContent[13] ==0) { //解密操作 } ///////////////////////////////////////////////////////////////////////////////////////////////////// NdisAllocateBuffer(&status,&MyBuffer,pAdapt->RecvPacketPoolHandle,pPacketContent,TotalPacketLength); if(NDIS_STATUS_SUCCESS != status) DbgPrint(" 申请ndisallocateBuffer失败!....\r\n"); MyPacket->Private.Head->Next = NULL; MyPacket->Private.Tail = NULL; Rsvd = (PRECV_RSVD)(MyPacket)->MiniportReserved; Rsvd->OriginalPkt = NULL; //Rsvd->OriginalPkt = (PNDIS_PACKET)1; DbgPrint(" PtReceive MyPacket地址:%08x\r\n",MyPacket); NdisChainBufferAtFront(MyPacket,MyBuffer); } ////////////////////////////////////////////////////////////////////////////////////// NDIS_SET_ORIGINAL_PACKET(MyPacket, NDIS_GET_ORIGINAL_PACKET(Packet)); NDIS_SET_PACKET_HEADER_SIZE(MyPacket, HeaderBufferSize); NdisGetPacketFlags(MyPacket) = NdisGetPacketFlags(Packet); NDIS_SET_PACKET_STATUS(MyPacket, NDIS_STATUS_RESOURCES); NdisMIndicateReceivePacket(pAdapt->MiniportHandle, &MyPacket, 1); //为什么我在释放 MyBuffer 和pPacketContent,NdisDprFreePacket(MyPacket) 会蓝屏! MyBuffer 和pPacketContent 该如何释放! NdisDprFreePacket(MyPacket); break; } } 另外我这样进行解密操作!上层接受到的数据没有做任何改变,依旧是是密文,校验和解密操作都是对的! 高手请帮忙看看!谢了! |
|