tanm2000
驱动牛犊
驱动牛犊
  • 注册日期2005-05-12
  • 最后登录2008-07-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望12点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
阅读:3378回复:9

Add a IP HEADER before original IP HEADER

楼主#
更多 发布于:2005-06-07 14:36
I am developing a ndis hook driver!I need to add a ip header
before original ip header in client side and analyze the added
header in server side.
I can get the ndis packet. so whats the folllowing step should I
do?

I thinked about it:

1 allocate a ndis buffer and VM
2 copy the data (in front of ip header, in the first buffer) into my
own buffer
3 add my own ip header into my buffer
4 copy the remain data in the first buffer into my own buffer
5 chain my own buffer into ndispacket
6 chain other buffer in the original packet.
cyliu
论坛版主
论坛版主
  • 注册日期2003-06-13
  • 最后登录2014-04-11
  • 粉丝5
  • 关注0
  • 积分1238分
  • 威望2531点
  • 贡献值0点
  • 好评度577点
  • 原创分14分
  • 专家分10分
沙发#
发布于:2005-06-08 09:16
I am developing a ndis hook driver!I need to add a ip header
before original ip header in client side and analyze the added
header in server side.
I can get the ndis packet. so whats the folllowing step should I
do?

I thinked about it:

1 allocate a ndis buffer and VM
2 copy the data (in front of ip header, in the first buffer) into my
own buffer
3 add my own ip header into my buffer
4 copy the remain data in the first buffer into my own buffer
5 chain my own buffer into ndispacket
6 chain other buffer in the original packet.
 


Note: U need think about MTU !
走走看看开源好 Solaris vs Linux
tanm2000
驱动牛犊
驱动牛犊
  • 注册日期2005-05-12
  • 最后登录2008-07-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望12点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2005-06-09 10:11
我准备更改windows发包的MTU,这样就不用分大包了!
cyliu
论坛版主
论坛版主
  • 注册日期2003-06-13
  • 最后登录2014-04-11
  • 粉丝5
  • 关注0
  • 积分1238分
  • 威望2531点
  • 贡献值0点
  • 好评度577点
  • 原创分14分
  • 专家分10分
地板#
发布于:2005-06-09 15:43
如何修改?

使用修改注册表方法吗?

[编辑 -  6/9/05 by  cyliu]
走走看看开源好 Solaris vs Linux
tanm2000
驱动牛犊
驱动牛犊
  • 注册日期2005-05-12
  • 最后登录2008-07-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望12点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2005-06-11 17:49
我在http://groups.yahoo.com/group/discussion-pcausa/
上看到一些这方面的资料,准备试试。
我现在想知道,如何在NDIS PACKET中加个ip包头
cyliu你不是做过吗,能给点建议吗?
cyliu
论坛版主
论坛版主
  • 注册日期2003-06-13
  • 最后登录2014-04-11
  • 粉丝5
  • 关注0
  • 积分1238分
  • 威望2531点
  • 贡献值0点
  • 好评度577点
  • 原创分14分
  • 专家分10分
5楼#
发布于:2005-06-13 11:31
加个ip头不难啊!你有什么困难吗?
走走看看开源好 Solaris vs Linux
herolib
驱动牛犊
驱动牛犊
  • 注册日期2005-03-21
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分531分
  • 威望86点
  • 贡献值0点
  • 好评度51点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2005-06-13 15:27
我也遇到类似的问题;

我修改了系统了MTU,为1496

然后,我截获了数据包,将包MTU改回1500;

然后在TCP/IP数据包尾部,加上4个字节自己的东西;

SPI是不能做到的;

TDI据说有些包会漏抓,而且也不知道是否能修改数据;

NDIS太补了,不太象那么做;

谁能给点意见;
tanm2000
驱动牛犊
驱动牛犊
  • 注册日期2005-05-12
  • 最后登录2008-07-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望12点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2005-06-14 11:16
我写了以下代码,组包,发包

NDIS_STATUS NDIS_API
XF_SendPacket(
IN NDIS_HANDLE MacBindingHandle,
IN PNDIS_PACKET Packet
)
{

PNDIS_PACKET OurPacket = NULL;
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PNDIS_BUFFER pNdisBuffer,pOurBuffer;
ULONG PacketLength = 0;
ULONG bytescopied = 0;
PVOID virtualaddr = NULL;
NDIS_HANDLE MyPacketPool;
NDIS_HANDLE MyBufferPool;

NdisAllocatePacketPoolEx(&Status,
&MyPacketPool,
MIN_PACKET_POOL_SIZE,
MAX_PACKET_POOL_SIZE - MIN_PACKET_POOL_SIZE,
PROTOCOL_RESERVED_SIZE_IN_PACKET);
NdisAllocateBufferPool(&Status,&MyBufferPool,0xff);
NdisDprAllocatePacket(&Status, &OurPacket, MyPacketPool);
NdisQueryPacket(Packet,NULL,NULL,&pNdisBuffer,&PacketLength );

NdisAllocateMemoryWithTag(&virtualaddr,PacketLength,\'DMSA\');

NdisAllocateBuffer(&Status,&pOurBuffer,MyBufferPool,virtualaddr,PacketLength);

NdisChainBufferAtFront(OurPacket,pOurBuffer);
NdisCopyFromPacketToPacket(OurPacket,0,PacketLength,Packet,0,&bytescopied);

Status=m_pSendHandler(MacBindingHandle, OurPacket);
if(Status != NDIS_STATUS_PENDING)
{
NdisFreePacket(OurPacket);
}
return Status;

}

但系统没登陆就重启了,如果把Status=m_pSendHandler(MacBindingHandle, OurPacket);改成Status=m_pSendHandler(MacBindingHandle, Packet);也就是发原来的包,系统就不重启
请问我的程序哪错了?
cyliu
论坛版主
论坛版主
  • 注册日期2003-06-13
  • 最后登录2014-04-11
  • 粉丝5
  • 关注0
  • 积分1238分
  • 威望2531点
  • 贡献值0点
  • 好评度577点
  • 原创分14分
  • 专家分10分
8楼#
发布于:2005-06-15 10:40
NdisCopyFromPacketToPacket does not copy any out-of-band information associated with the given Source to the Destination. To copy this information, the driver can use pointers returned by NDIS_OOB_DATA_FROM_PACKET and then call NdisMoveMemory.

还有,你跟踪一下,看看是在哪里出来错误!

[编辑 -  6/15/05 by  cyliu]
走走看看开源好 Solaris vs Linux
tanm2000
驱动牛犊
驱动牛犊
  • 注册日期2005-05-12
  • 最后登录2008-07-04
  • 粉丝0
  • 关注0
  • 积分1分
  • 威望12点
  • 贡献值0点
  • 好评度6点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2005-06-18 19:55
我现在在NDIS PACKET中又加了个IP包头,但加上后 以太桢的CRC出错,不知道这是为什么啊,CRC是硬件加上去的吧,为什么会出错!
游客

返回顶部