阅读:3481回复:15
关于NDIS协议驱动的一个初始化问题 ,请高手进来看一看!
我在编写一个NDIS协议驱动的时候 用NdisRegisterProtocol 注册了一个NDIS_PROTOCOL_CHARACTERISTICS ,里面包括所有的协议入口函数
其中在我的 绑定网络适配器的入口函数BindHandler 中,我对每一个网络适配器进行绑定 , 我这样的逻辑没有错吧? 按照我的理解 , 当我调用用完NdisRegisterProtocol 的时候 , 紧接着ndis会自动调用BindHandler来我的协议驱动, 但是当我在DriverEntry中调用完NdisRegisterProtocol后,系统根本就没调用我的BindHandler进行初始化 , 请问这是怎么回事? 我的NDIS_PROTOCOL_CHARACTERISTICS初始化如下: NDIS_STRING ProtoName = NDIS_STRING_CONST(\"NtNdisProto\"); NDIS50_PROTOCOL_CHARACTERISTICS ProtoChar; ///协议描述符 ////NdisZeroMemory( &ProtoChar , sizeof( NDIS50_PROTOCOL_CHARACTERISTICS )); ProtoChar.Ndis40Chars.Ndis30Chars.MajorNdisVersion = 5; ProtoChar.Ndis40Chars.Ndis30Chars.MinorNdisVersion = 0; ProtoChar.Ndis40Chars.Ndis30Chars.Name = ProtoName; ProtoChar.Ndis40Chars.Ndis30Chars.OpenAdapterCompleteHandler = TOpenAdapterComplete; ProtoChar.Ndis40Chars.Ndis30Chars.CloseAdapterCompleteHandler = TCloseAdapterComplete; ProtoChar.Ndis40Chars.Ndis30Chars.SendCompleteHandler = TSendComplete; ProtoChar.Ndis40Chars.Ndis30Chars.TransferDataCompleteHandler = TTransferDataComplete; ProtoChar.Ndis40Chars.Ndis30Chars.ResetCompleteHandler = TResetComplete; ProtoChar.Ndis40Chars.Ndis30Chars.RequestCompleteHandler =TRequestComplete; ProtoChar.Ndis40Chars.Ndis30Chars.ReceiveHandler = TReceiveIndicate; ProtoChar.Ndis40Chars.Ndis30Chars.ReceiveCompleteHandler = TReceiveComplete; ProtoChar.Ndis40Chars.Ndis30Chars.StatusHandler = TStatus; ProtoChar.Ndis40Chars.Ndis30Chars.StatusCompleteHandler = TStatusComplete; ProtoChar.Ndis40Chars.BindAdapterHandler = BindHandler; ProtoChar.Ndis40Chars.UnbindAdapterHandler = UnBindHandler; ProtoChar.Ndis40Chars.ReceivePacketHandler = TReceivePacket; ProtoChar.Ndis40Chars.PnPEventHandler = TPNPHandler; ProtoChar.CoAfRegisterNotifyHandler=NULL; ProtoChar.CoReceivePacketHandler=NULL; ProtoChar.CoSendCompleteHandler=NULL; ProtoChar.CoStatusHandler=NULL; ProtoChar.Ndis40Chars.UnloadHandler=NULL; ProtoChar.Ndis40Chars.Ndis30Chars.WanTransferDataCompleteHandler=NULL; ProtoChar.Ndis40Chars.Ndis30Chars.Filler=0; ProtoChar.Ndis40Chars.Ndis30Chars.Flags=0; ProtoChar.Ndis40Chars.Ndis30Chars.Reserved=0; ProtoChar.Ndis40Chars.Ndis30Chars.WanSendCompleteHandler=NULL; ProtoChar.Ndis40Chars.Ndis30Chars.WanReceiveHandler=NULL; ///Register as a protocol driver NdisRegisterProtocol((NDIS_STATUS*)&status, &NdisProtocalHandle ,(NDIS_PROTOCOL_CHARACTERISTICS*)&ProtoChar , sizeof(NDIS50_PROTOCOL_CHARACTERISTICS) ); |
|
沙发#
发布于:2003-10-25 19:19
你的inf里面的servername要是“NtNdisProto”才行
//你用的HOOK? |
|
|
板凳#
发布于:2003-10-26 21:24
我没有用inf文件来装载驱动,我直接用startservice来启动的,
servername 是指什么 |
|
地板#
发布于:2003-10-26 21:40
为什么没有人帮助我啊! 我等了这么长时间,才有一位好心的仁兄
回复我的贴子 |
|
地下室#
发布于:2003-11-02 21:21
是不是我的驱动的装载过程有问题,那位高人指点一下,我的系统是 win2000professional,应该支持ndis5。0的一些初始化函数吧
|
|
5楼#
发布于:2003-11-02 22:24
建议你先用inf文件安装,如果可以安装,那么就不是你的驱动的问题了。
|
|
|
6楼#
发布于:2003-11-02 22:26
是不是我的驱动的装载过程有问题,那位高人指点一下,我的系统是 win2000professional,应该支持ndis5。0的一些初始化函数吧 win2000的ndis主版本号应该是4。 |
|
|
7楼#
发布于:2003-11-02 22:31
// // Initialize the protocol characterstic structure // NdisZeroMemory(&protocolChar,sizeof(NDIS_PROTOCOL_CHARACTERISTICS)); protocolChar.MajorNdisVersion = 5; protocolChar.MinorNdisVersion = 0; protocolChar.Name = protoName; protocolChar.OpenAdapterCompleteHandler = PacketOpenAdapterComplete; protocolChar.CloseAdapterCompleteHandler = PacketCloseAdapterComplete; protocolChar.SendCompleteHandler = PacketSendComplete; protocolChar.TransferDataCompleteHandler = PacketTransferDataComplete; protocolChar.ResetCompleteHandler = PacketResetComplete; protocolChar.RequestCompleteHandler = PacketRequestComplete; protocolChar.ReceiveHandler = PacketReceiveIndicate; protocolChar.ReceiveCompleteHandler = PacketReceiveComplete; protocolChar.StatusHandler = PacketStatus; protocolChar.StatusCompleteHandler = PacketStatusComplete; protocolChar.BindAdapterHandler = PacketBindAdapter; protocolChar.UnbindAdapterHandler = PacketUnbindAdapter; protocolChar.UnloadHandler = NULL; protocolChar.ReceivePacketHandler = PacketReceivePacket; protocolChar.PnPEventHandler = PacketPNPHandler; // // Register as a protocol driver // NdisRegisterProtocol( &status, &Globals.NdisProtocolHandle, &protocolChar, sizeof(NDIS_PROTOCOL_CHARACTERISTICS)); if (status != NDIS_STATUS_SUCCESS) { DebugPrint((\"Failed to register protocol with NDIS\\n\")); status = STATUS_UNSUCCESSFUL; goto ERROR; } 这一段是2000ddk中packet例子中的初始化部分。 |
|
|
8楼#
发布于:2003-11-12 19:54
我还是没有成功,我把protochar的所有的历程都设了断点,只有TPNPHandler有响应 ,真是没办法!
问一个小问题: 我定义的NDIS50_PROTOCOL_CHARACTERISTICS ProtoChar 中的变量不能写成ProtoChar.OpenAdapterCompleteHandler=MyOpenAdapter; 编译时错误为: error C2039: \'OpenAdapterCompleteHandler\' : is not a member of \'_NDIS50_PROTOCOL_CHARACTERISTICS\' 如果写成ProtoChar.Ndis40Chars.Ndis30Chars.OpenAdapterCompleteHandler = MyOpenAdapter; 就可以,这是为什么? 还请各位高手继续帮助我,我先谢谢了! |
|
9楼#
发布于:2003-11-13 22:19
问题还是没解决阿,有 哪位高手能帮我看看,小弟不胜感激!
|
|
10楼#
发布于:2003-11-22 09:32
NDIS no longer supports calling NdisOpenAdapter from the DriverEntry function, which was an option available to legacy (V3.0) protocols. NDIS no longer supports V3.0 protocols. NDIS fails any attempt to call NdisOpenAdapter outside the context of ProtocolBindAdapter.
|
|
|
11楼#
发布于:2003-12-15 21:12
可问题是我现在在DriverEntry中调用NdisRegisterProtocol(...)
注册了 NDIS_PROTOCOL_CHARACTERISTICS ProtoChar; 该成员变量, 而且已经对其结构体成员BindAdapter初始化 , ProtoChar.BindAdapter = MyBindFunction; 可注册成功后MyBindFunction 始终没有被调用,这是怎么回事啊? 求神帮助我啊! |
|
12楼#
发布于:2009-03-14 22:37
回 2楼(steven_kane) 的帖子
先用INF文件安装,INF中ServiceStart项设置成手动启动,然后再用StartService加载就好了.如果ServiceStart项设置成自启动的话,就不需要StartService了 |
|
13楼#
发布于:2009-04-02 16:10
我也遇到这样的问题,是安装的问题,改用inf安装就成功了
还有这个: NDIS_STRING ProtoName = NDIS_STRING_CONST(\"NtNdisProto\"); Name An NDIS_STRING type containing a caller-initialized counted string, in the system-default character set, naming the driver. For Windows 2000 and later drivers, this string contains Unicode characters. That is, for Windows 2000 and later, NDIS defines the NDIS_STRING type as a UNICODE_STRING type. This string must match that specified in the registry (under Services) when the protocol was installed. NdisRegisterProtocol converts the supplied string to upper case, so a protocol driver writer cannot assume that changing the case of an already registered protocol name creates a unique name for the driver. |
|
14楼#
发布于:2009-05-19 13:00
请问你的程序是拿什么调试的?最后生成的是一个.sys文件,没办法调试啊!
|
|
15楼#
发布于:2010-04-02 21:59
我也遇到同样的问题。请求解答。。。
|
|