|
[求助]关于passthru中间层驱动发送自定义包
我先截取一段Filter自带的 发送数据的代码给你看看。 然后,我再把我是如何发送数据包的代码贴出来给你看看。 下面是WDK Filter自带的例子代码,它未做过任何的修改。 VOID FilterSendNetBufferListsComplete( IN NDIS_HANDLE FilterModuleContext, IN PNET_BUFFER_LIST NetBufferLists, IN ULONG SendCompleteFlags ) { PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext; ULONG NumOfSendCompletes = 0; BOOLEAN DispatchLevel; PNET_BUFFER_LIST CurrNbl; DEBUGP(DL_TRACE, ("===>SendNBLComplete, NetBufferList: %p.\n", NetBufferLists)); if (pFilter->TrackSends) { CurrNbl = NetBufferLists; while (CurrNbl) { NumOfSendCompletes++; CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl); } DispatchLevel = NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendCompleteFlags); FILTER_ACQUIRE_LOCK(&pFilter->Lock, DispatchLevel); pFilter->OutstandingSends -= NumOfSendCompletes; FILTER_LOG_SEND_REF(2, pFilter, PrevNbl, pFilter->OutstandingSends); FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel); } NdisFSendNetBufferListsComplete(pFilter->FilterHandle, NetBufferLists, SendCompleteFlags); DEBUGP(DL_TRACE, ("<===SendNBLComplete.\n")); } VOID FilterSendNetBufferLists( IN NDIS_HANDLE FilterModuleContext, IN PNET_BUFFER_LIST NetBufferLists, IN NDIS_PORT_NUMBER PortNumber, IN ULONG SendFlags ) { PMS_FILTER pFilter = (PMS_FILTER)FilterModuleContext; PNET_BUFFER_LIST CurrNbl; BOOLEAN DispatchLevel; BOOLEAN bFalse = FALSE; DEBUGP(DL_TRACE, ("===>SendNetBufferList: NBL = %p.\n", NetBufferLists)); do { DispatchLevel = NDIS_TEST_SEND_AT_DISPATCH_LEVEL(SendFlags); #if DBG FILTER_ACQUIRE_LOCK(&pFilter->Lock, DispatchLevel); if (pFilter->State != FilterRunning) { FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel); CurrNbl = NetBufferLists; while (CurrNbl) { NET_BUFFER_LIST_STATUS(CurrNbl) = NDIS_STATUS_PAUSED; CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl); } NdisFSendNetBufferListsComplete(pFilter->FilterHandle, NetBufferLists, DispatchLevel ? NDIS_SEND_COMPLETE_FLAGS_DISPATCH_LEVEL : 0); break; } FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel); #endif /******************发送网络数据包********************/ //我们必须要在这里添加代码 /************************************************/ if (pFilter->TrackSends) { FILTER_ACQUIRE_LOCK(&pFilter->Lock, DispatchLevel); CurrNbl = NetBufferLists; while (CurrNbl) { pFilter->OutstandingSends++; FILTER_LOG_SEND_REF(1, pFilter, CurrNbl, pFilter->OutstandingSends); CurrNbl = NET_BUFFER_LIST_NEXT_NBL(CurrNbl); } FILTER_RELEASE_LOCK(&pFilter->Lock, DispatchLevel); } NdisFSendNetBufferLists(pFilter->FilterHandle, NetBufferLists, PortNumber, SendFlags); } while (bFalse); DEBUGP(DL_TRACE, ("<===SendNetBufferList. \n")); } |
|
[求助]关于passthru中间层驱动发送自定义包
楼主,你说的情况和我遇到的一样。我目前在做64位Windows7的 NDIS中间层驱动开发。但是我已经没有使用你说的 Passthru例子了。 事情是这样的: Passthru这个例子是WDK自带的。它是针对NDID6.0之前的版本的。 而从Vista开始,到现在的Windows7系统, 编写NDIS中间层驱动程序可以参考WDK的程序例子叫着Filter, Filter在 \src\network\ndis\filter目录下可以找到. 这个例子把原来Passthru例子提供的 MiniportXXX函数和ProtocolXXX函数都给包装起来了。变成了 FilterAttach、FilterPause、等回调函数。 而原来的ProtocolReceive()、ProtocolReceivePacket()、ProtocoltReceiveComplete被合并成FilterReceiveNetBufferLists(); 原来的MiniportSend()、MiniportSendPackets()、被合并成FilterSendNetBufferLists函数,ProtocolSendComplete()被修改成FilterSendNetBufferListsComplete函数。 原来的MiniportTransferData、ProtocolTransferDataComplete函数被封装隐藏起来了。 你刚才说道的问题,发送数据包,就要在FilterSendNetBufferLists()和FilterSendNetBufferListsComplete()函数里面实现代码了。 |
|
[原创]利用HookAPI制作的注册表监控程序(附VC源码)
支持,这个代码很实用 |
操作理由
RANk
{{ user_info.golds == '' ? 0 : user_info.golds }}
雪币
{{ experience }}
课程经验
{{ score }}
学习收益
{{study_duration_fmt}}
学习时长
基本信息
荣誉称号:
{{ honorary_title }}
能力排名:
No.{{ rank_num }}
等 级:
LV{{ rank_lv-100 }}
活跃值:
在线值:
浏览人数:{{ visits }}
最近活跃:{{ last_active_time }}
注册时间:{{ user_info.create_date_jsonfmt }}
勋章
兑换勋章
证书
证书查询 >
能力值