taianmonkey
驱动牛犊
驱动牛犊
  • 注册日期2006-03-23
  • 最后登录2014-08-18
  • 粉丝0
  • 关注0
  • 积分163分
  • 威望602点
  • 贡献值0点
  • 好评度10点
  • 原创分0分
  • 专家分0分
阅读:1942回复:0

关于ndis 6 修改发送的数据包

楼主#
更多 发布于:2014-07-29 14:06
1、复制截获到发送的NBL
2、修改复制的NBL,比如加一个数据头;
3、发送自己的NBL

导致了蓝屏。

下面是代码片段:

pNewBufList = allocateNetBufferAndList( pFilter, PacketSize , TRUE );
if (  pNewBufList == NULL ) break;

NtStatus =
NdisCopyFromNetBufferToNetBuffer(NET_BUFFER_LIST_FIRST_NB(pNewBufList),

0,
PacketSize,
NET_BUFFER_LIST_FIRST_NB(pSendPacketList),
0,
&BytesCopied);

if( NtStatus != STATUS_SUCCESS )

{
*pNewNetBufferLists = NULL;
FreeMdlAndNetBufferList( pNewBufList );
break;
}

NtStatus = ModifySendPacket( pFilter , pNewBufList );

if( NtStatus != STATUS_SUCCESS )

{
*pNewNetBufferLists = NULL;
FreeMdlAndNetBufferList( pNewBufList );
break;
}

NET_BUFFER_LIST_INFO(pNewBufList, TcpIpChecksumNetBufferListInfo) =
NET_BUFFER_LIST_INFO(pSendPacketList, TcpIpChecksumNetBufferListInfo);

NET_BUFFER_DATA_LENGTH(NET_BUFFER_LIST_FIRST_NB(pNewBufList)) = BytesCopied;

pNewBufList->SourceHandle = pFilter->SendNetBufferListPool;

if(*pNewNetBufferLists == NULL)  
{  
*pNewNetBufferLists = pCopyNBLTail = pNewBufList;  
}  
else  
{  
NET_BUFFER_LIST_NEXT_NBL(pCopyNBLTail) = pNewBufList;  
}
(3).in FilterSendNetBufferListsComplete:
 
if(NdisGetPoolFromNetBufferList(NetBufferLists) ==
pFilter->SendNetBufferListPool)  
{  
//Please just free this NBL  
bRet =  FreeMdlAndNetBufferList(NetBufferLists);  
if(bRet == TRUE)  
{  
PRINTLOG(("Free my own NBL ====== FilterSendNetBufferListsComplete \n"));  
}

return;
}
游客

返回顶部