阅读:1161回复:1
救救我我通过注册假协议hook系统原来的发送函数,现在我们在发送ip报文之前对他进行处理(加密),由于加密可能会需要更多的地址空间, 这里我先做了一个试验,把原来的packet复制一个发送,但是不知为什么总是无法试验成功,现象是:ping的时候可以,但是一到使用ie浏览网页的时候,就不行了,好像是分配内存有问题,求求那位大虾救救我 !!!!!! NDIS_STATUS NDIS_API xIpsecCopyPacket( IN PNDIS_PACKET Packet, IN PNDIS_PACKET *NewtPacket ) { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; UINT PhysicalBufferCount; UINT BufferCount; PNDIS_BUFFER FirstBuffer; UINT TotalPacketLength; PUCHAR VirtualAddress; PNDIS_PACKET pNdisPacket; UINT i; UINT BytesCopied; NdisQueryPacket( Packet, &PhysicalBufferCount, &BufferCount, &FirstBuffer, &TotalPacketLength ); NdisAllocatePacket(&Status, &pNdisPacket, XipsecPacketPoolHandle); if (Status != NDIS_STATUS_SUCCESS) { DebugPrint((\"NdisAllocatePacket fail ,return error code = %d \\n\",Status)); return Status; } for(i = 0; i < BufferCount; i++) { UINT Length; PUCHAR pDataBufferDst = NULL,pDataBufferSrc = NULL; PNDIS_BUFFER NewBuffer; NdisQueryBuffer(FirstBuffer, &pDataBufferSrc, &Length); // pDataBufferDst = ExAllocatePoolWithTag(NonPagedPool,Length,\'HFPA\'); // XIPSEC_ALLOC_MEM(pDataBufferDst,Length); NdisAllocateMemoryWithTag(&pDataBufferDst,Length,\'HFPA\'); if( pDataBufferDst == NULL ) { DebugPrint((\"NdisAllocateBuffer fail ,return error code = %d \\n\",Status)); return Status; } NdisAllocateBuffer( &Status, &NewBuffer, XipsecBufferPoolHandle, pDataBufferDst, Length); if(Status != NDIS_STATUS_SUCCESS) { DebugPrint((\"NdisAllocateBuffer fail ,return error code = %d \\n\",Status)); return Status; } NdisChainBufferAtBack(pNdisPacket,NewBuffer); NdisGetNextBuffer(FirstBuffer, &FirstBuffer); } NdisCopyFromPacketToPacket( pNdisPacket, 0, TotalPacketLength, Packet, 0, &BytesCopied); if( BytesCopied != TotalPacketLength) { DebugPrint((\"NdisCopyFromPacketToPacket fail ,return error code = %d \\n\",Status)); return Status; } pNdisPacket->Private.Flags = NdisGetPacketFlags(Packet); pNdisPacket->ProtocolReserved[0] = Packet->ProtocolReserved[0]; _DebugPrint((\"pNdisPacket = %p !\\n\",pNdisPacket)); *NewtPacket = pNdisPacket; return Status; } NDIS_STATUS NDIS_API IpsecEncryptPacket( IN NDIS_HANDLE MacBindingHandle, IN PNDIS_PACKET Packet, SEND_HANDLER m_OrigSendHandler) { NDIS_STATUS Status = NDIS_STATUS_SUCCESS; PNDIS_PACKET NewPacket; Status = xIpsecCopyPacket(Packet,&NewPacket); if (Status != NDIS_STATUS_SUCCESS) { _DebugPrint((\"xIpsecCopyPacket fail ,return error code = %d \\n\",Status)); return Status; } //m_OrigSendHandler 是原来系统的函数地址 Status = m_OrigSendHandler(MacBindingHandle,NewPacket); if (Status != NDIS_STATUS_PENDING) { _DebugPrint((\"Free NewPacket !\\n\")); xIpsecFreePacket(NewPacket); } return NDIS_STATUS_PENDING; } // return Status; } |
|
沙发#
发布于:2002-11-09 21:13
用户被禁言,该主题自动屏蔽! |
|