winsunxu
驱动牛犊
驱动牛犊
  • 注册日期2007-05-15
  • 最后登录2010-11-23
  • 粉丝0
  • 关注0
  • 积分4分
  • 威望45点
  • 贡献值0点
  • 好评度14点
  • 原创分0分
  • 专家分0分
阅读:1151回复:1

求助--NDIS HOOK中对于protocolreceive的交互处理????

楼主#
更多 发布于:2007-09-24 14:14


   我HOOK了NDIS_OPEN_BLOCK中的receivehandler为new_receiverhandler,然后在new_receiverhandler中,我是这样处理的:
  
   第一步:
      申请一个结构体保存new_receivehandler函数的参数和其它相关数据;
   第二步:
      调用一个自己写的过滤函数,返回三种结果,分别是Allow,Deny,Ask
     第三步:
      再根据返回的三种结果做如下的相应处理:
      
       Allow:调用hook前的原函数receivehandler
              
              Deny:直接返回NDIS_STATUS_NOT_ACCEPTED
 

              Ask:把第一不的结构体放到一个队列里去,然后设置事件对象为singled,返回NDIS_STATUS_PENDING.
  对与Allow和Deny的处理都没问题,但是对与Ask的处理,我就有点纳闷了,我在系统线程里从队列里取出刚刚放进去的结构体,然后与用户交互过后,如果用户允许接受这个包的话我调用HOOK前的那个receivehandler函数,如果用户拒绝的话,我不知道该怎么处理???????
linkin__park
驱动牛犊
驱动牛犊
  • 注册日期2006-03-12
  • 最后登录2009-09-18
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望17点
  • 贡献值0点
  • 好评度16点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2007-09-25 16:21
Return Value
ProtocolReceive can return either of the following:

NDIS_STATUS_NOT_ACCEPTED
The protocol has no use for the indicated packet, that is, it has no current clients interested in the indicated network data.
Returning this status quickly for rejected packets yields higher performance for the protocol and the highest possible network I/O throughput for the system as a whole.

NDIS_STATUS_SUCCESS
ProtocolReceive has processed the header information and accepted the packet, that is, it has copied the indicated network data from the header and lookahead buffers and, possibly, called NdisTransferData to retrieve the remaining data if less than a full network packet was indicated.

貌似不能返回PENDING的吧。。。建议需要交互的数据都复制一次,然后丢弃,询问结果如果是Allow,那么再调回去,如果是Deny,那么释放。
游客

返回顶部