阅读:2528回复:8
PtReceive解密无效的问题!寻高人请指点!!!。。。
以下是PtReceive代码!
为什么按照以上步骤进行重新解密组包,上层接收到的仍然是密文! NDIS_STATUS PtReceive(....) { if (LookAheadBufferSize>=PacketSize) { Packet = NdisGetReceivedPacket(pAdapt->BindingHandle, MacReceiveContext); if (Packet != NULL) { NdisDprAllocatePacket(&Status, &MyPacket,pAdapt->RecvPacketPoolHandle); //申请数据包(MyPacket) if (Status == NDIS_STATUS_SUCCESS) { { NdisQueryPacket(Packet,&PhysicalBufferCount,&BufferCount,&NdisBuffer,&TotalPacketLength); status = NdisAllocateMemoryWithTag(&pPacketContent,TotalPacketLength,TAG); if(status != NDIS_STATUS_SUCCESS) {} 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; } ////////////////////////pPacketContent为密文///////////////////////////////////// //针对密文进行如下操作 已经检验以下步骤没有问题 1、解密操作 2、重新计算校验和 3、将解密后的明文重新拷贝到pPacketContent //////////////////////////////////////////////////////////////////////////////////////////////////////// NdisAllocateBuffer(&status,&MyBuffer,pAdapt->RecvPacketPoolHandle,pPacketContent,TotalPacketLength); NdisChainBufferAtFront(MyPacket,MyBuffer); MyPacket->Private.Head->Next = NULL; MyPacket->Private.Tail = NULL; Rsvd = (PRECV_RSVD)(MyPacket)->MiniportReserved; Rsvd->OriginalPkt = MyPacket; } } } //提交数据包 NdisMIndicateReceivePacket(pAdapt->MiniportHandle,&MyPacket,1); if(NDIS_GET_PACKET_STATUS(MyPacket)!=NDIS_STATUS_PENDING) { //释放 } } } //问题:为什么按照以上步骤进行重新解密组包,上层接收到的仍然是密文,我也就在NdisMIndicateReceivePacket后查看了MyPacket 发现里面的数据确实我解密后的明文,不知为何应用程序收到的数据却没有任何改变 ,奇怪的是如果我将NdisMIndicateReceivePacket注释掉的话 则网络一直处于连接不异常的状态! 另外我如果将MyPacket赋给Packet的话,则能正常,但是释放却是个问题! 请高手指点一二!在此先谢过了! |
|
沙发#
发布于:2010-04-27 10:43
还在用这么古老的方法。
建议参考pppoe等技术。 提醒:上层收到密文,说明收到的数据的函数不止这一个,或者没有走接密流程。 |
|
|
板凳#
发布于:2010-04-27 11:43
先谢谢了老大了!
您指的收到的函数不止一个?目前在ndis里面除了ptreceive之外,还有PtReceivePacket ,目前我没有提供此函数!..请问下老大!是不是走ptReceivePacket函数去了! 如果不是的话,那有可能走那个函数了... |
|
地板#
发布于:2010-04-27 12:48
如果没有提供PtReceivePacket 函数,就要看if (LookAheadBufferSize<PacketSize)的情况是否存在
|
|
|
地下室#
发布于:2010-04-28 03:18
谢谢老大!确实如此,但是我这边还有一个问题:
密文长度不一致! 按照上面一样进行却出现蓝屏。确实不知道哪里出了问题!.我如果用长度不变的包进行测试,则一点问题也没有! 难道NdisFreeMemory跟 IN PVOID HeaderBuffer, IN UINT HeaderBufferSize, IN PVOID LookAheadBuffer, IN UINT LookAheadBufferSize, IN UINT PacketSize 这个之中谁有关系?或者是pAdapt =(PADAPT)ProtocolBindingContext;有关系? 如果需要解决这种情况的话!有好的解决办法吗?.............非常感谢老大!.... 以下是调试情况: BAD_POOL_HEADER (19) The pool is already corrupt at the time of the current request. This may or may not be due to the caller. The internal pool links must be walked to figure out a possible cause of the problem, and then special pool applied to the suspect tags or the driver verifier to a suspect driver. Arguments: Arg1: 00000020, a pool block header size is corrupt. Arg2: 81381000, The pool entry we were looking for within the page. Arg3: 81381618, The next pool entry. Arg4: 0ac30000, (reserved) Debugging Details: ------------------ BUGCHECK_STR: 0x19_20 POOL_ADDRESS: 81381000 Nonpaged pool f9dc73f0 804f880d 00000003 f9dc774c 00000000 nt!RtlpBreakWithStatusInstruction f9dc743c 804f93fa 00000003 815b1130 81381000 nt!KiBugCheckDebugBreak+0x19 f9dc781c 804f9925 00000019 00000020 81381000 nt!KeBugCheck2+0x574 f9dc783c 80544c86 00000019 00000020 81381000 nt!KeBugCheckEx+0x1b f9dc788c f96e660f 81381008 00000000 f9dc7920 nt!ExFreePoolWithTag+0x2a0 f9dc789c f7c6eda6 81381008 00000610 00000000 NDIS!NdisFreeMemory+0x3b |
|
5楼#
发布于:2010-04-28 11:38
查看:
f9dc783c 80544c86 00000019 00000020 81381000 nt!KeBugCheckEx+0x1b f9dc788c f96e660f 81381008 00000000 f9dc7920 nt!ExFreePoolWithTag+0x2a0 f9dc789c f7c6eda6 81381008 00000610 00000000 NDIS!NdisFreeMemory+0x3b 明显内存写坏了 |
|
|
6楼#
发布于:2010-04-28 11:50
老大,非常感谢你的指点!
您说的内存写坏了?怎么说?是溢出了?还是 如果是溢出的话,我这边查看没有出现这种情况的啊! |
|
7楼#
发布于:2010-04-28 15:31
谢谢老大,已经解决了!
|
|
8楼#
发布于:2010-05-09 16:57
请问楼主解密无效的问题也解决了吗?怎么解决的?
|
|