阅读:2633回复:16
如何把Passthru作成可以动太加载和卸的
如何把Passthru作成可以动态加载和卸载的?
不用什么INF又“网上邻居",用程序CreateService加载 其源程序不出动态卸载,点击删除,有时也会出现蓝屏死机. |
|
最新喜欢:ljmmar...
|
沙发#
发布于:2004-02-25 11:52
用passthru中的bindview的例子修改就可以。
|
|
板凳#
发布于:2004-02-27 17:02
bindview是什么东东?是2000DDK提供的吗?请问在哪里可以找到?
我也想做passthru的动态加载,用snetcfg只能是系统调用的,不爽! |
|
|
地板#
发布于:2004-03-01 09:47
听专家说,passthru动态加载也必须使用CreateService,可是我调用之后根本起不来,不知道为什么,可能是参数设置不正确,可是谁能说说:DriverName、DispalayName等参数究竟应该如何设置为何值?
|
|
|
地下室#
发布于:2004-03-02 09:42
到目前为止,还没有见到过IMD/TDI驱动有动态加载的(W2K平台),例如:ADSL―PPPOE驱动、sniffer。
但是我坚信理论上应该是可以的;) |
|
|
5楼#
发布于:2004-03-03 10:12
" 到目前为止,还没有见到过IMD/TDI驱动有动态加载的(W2K平
台),例如:ADSL―PPPOE驱动、sniffer" 呃句 |
|
|
6楼#
发布于:2004-03-03 12:42
我看了一下winpcap的源代码,驱动是动态加载的;
可是有谁对IMD驱动的动态加载熟知呢? 原理可能是一样的,但是我调试了几天,象passthru这样的驱动就是启动不了,唉,水平有限啊;0 |
|
|
7楼#
发布于:2004-03-06 18:27
2k不行 ,这是一个bug
|
|
8楼#
发布于:2004-03-08 13:57
如此说法,有足够的证据吗?
|
|
|
9楼#
发布于:2004-03-09 13:47
呵呵,看看讨论组上老外给的代码:
I have been getting emails from lot of customers that if they try to implement a WDM interface (to send ioctls from user-mode) in the Win2K passthru driver similar to the NT4.0 Imsamp driver, it doesn't load. What is the problem? The reason is that the PASSTHRU driver is a root enumerated PnP driver. So the driver gets all the PnP IRPs like any other driver and NDIS takes the responsibility of handling them. So if you set all the dispatch handlers like IMSAMP does, and fail the IRPs that you aren't interested in, you end of failing all the PnP, power and SystemControl Irps which are crucial for the driver to load and play in tune with the rest of the system. So the right way to do this is by using NdisMRegisterDevice(). I have included here the modified source of wdmsup.c that shows how to use this function. You should call WDMInitialize before returning from DriverEntry. Try out and let me know how it works. /*++ Copyright (c) 1996 Microsoft Corporation Module Name: wdmsup.c Abstract: Author: Environment: Kernel Mode Revision History: --*/ #undef BINARY_COMPATIBLE #define BINARY_COMPATIBLE 0 #include "precomp.h" #pragma hdrstop #if DBG #define DebugPrint(_x_) \ DbgPrint("Passthru: ");\ DbgPrint _x_; #else #define DebugPrint(_x_) #endif NTSTATUS WDMInitialize( PDRIVER_OBJECT DriverObject, NDIS_HANDLE NdisWrapperHandle ); NTSTATUS PassThru( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ); NDIS_HANDLE NdisDeviceHandle; PDEVICE_OBJECT ControlDeviceObject; #define LINKNAME_STRING L"\\DosDevices\\Passthru" #define NTDEVICE_STRING L"\\Device\\Passthru" NTSTATUS WDMInitialize( PDRIVER_OBJECT DriverObject, NDIS_HANDLE NdisWrapperHandle ) /*++ Routine Description: Perform initialization supported by WDM Arguments: DriverObject - pointer to DriverObject from DriverEntry InitShutdownMask - pointer to mask used to indicate which events have been successfully init'ed Return Value: STATUS_SUCCESS if everything worked ok --*/ { NTSTATUS ntStatus = STATUS_SUCCESS; NDIS_STATUS ndisStatus; UNICODE_STRING DeviceName; UNICODE_STRING DeviceLinkUnicodeString; PDRIVER_DISPATCH DispatchTable[IRP_MJ_MAXIMUM_FUNCTION]; UINT i; // // Register our dispatch handler // for (i = 0; i < IRP_MJ_MAXIMUM_FUNCTION; i++) { DispatchTable = PassThru; } NdisInitUnicodeString(&DeviceName, NTDEVICE_STRING); NdisInitUnicodeString(&DeviceLinkUnicodeString, LINKNAME_STRING); ndisStatus = NdisMRegisterDevice( NdisWrapperHandle, &DeviceName, &DeviceLinkUnicodeString, &DispatchTable[0], &ControlDeviceObject, // global variable &NdisDeviceHandle //global variable ); if (NDIS_STATUS_SUCCESS != ndisStatus) { return STATUS_UNSUCCESSFUL; } return ntStatus; } NTSTATUS PassThru( IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp ) /* Routine Description: Process the IRPs sent to this device. Arguments: DeviceObject - pointer to a device object Irp - pointer to an I/O Request Packet Return Value: None */ { PIO_STACK_LOCATION irpStack; NTSTATUS status = STATUS_SUCCESS; irpStack = IoGetCurrentIrpStackLocation(Irp); ASSERT(DeviceObject == ControlDeviceObject); switch (irpStack->MajorFunction) { case IRP_MJ_CREATE: break; case IRP_MJ_CLOSE: break; case IRP_MJ_DEVICE_CONTROL: break; default: break; } Irp->IoStatus.Status = status; IoCompleteRequest(Irp, IO_NO_INCREMENT); return status; } Good Luck, Eliyas |
|
10楼#
发布于:2004-03-09 14:47
你这段代码实在是驱动安装之后的调用加载的内核初始化代码;)
我们要讨论的就是驱动如何动态安装,就象协议驱动一样,如NT平台CreateService就可以,当然通过系统安装或者snetcfg都可以,可那不是动态的安装过程啊! |
|
|
11楼#
发布于:2004-03-09 16:44
winpcap的驱动 并没有把自己注册成为一个协议来安装到系统里面。而passthru是安装到系统里面的,即便改变了bind关系,passthru驱动也并没有被卸载。
我还没有听到过有把passthru做成动态加载和卸载的。 |
|
|
12楼#
发布于:2004-03-09 17:22
凭感觉目前技术上都行不通,NT当时动态安装是支持实现动态bind网卡,可以passthru能实现动态bind吗?我把动态bind代码加进去根本没有起作用,passthru对所有媒体都进行了bind了,不管是网卡还是modem,不过多网卡我没有测试过,我想也应该都被bind了。
除非微软提供一套样例代码实现动态bind,当然可能性太小;) |
|
|
13楼#
发布于:2004-03-09 17:41
考虑到中间层驱动要绑定到下层的网卡,可以试一下在处理irp_create的消息时候,调用绑定bindadapter的函数。
我觉得应该是有办法的。 |
|
14楼#
发布于:2004-03-09 18:02
可是在驱动装载的时候,NDIS就调用了你的PtBindAdapter,装载完成之后,你再调用irp_create进行bind的话,可能已经没有任何作用了哦;)
|
|
|
15楼#
发布于:2004-03-09 18:10
我感觉理论上是可以的,只不过没找到方法,
只会用网络邻居安装,不过不用重起就行。 |
|
16楼#
发布于:2005-03-17 14:32
不能动态停止,那调试岂不是很麻烦 每次改点代码都要重启才能看到效果. |
|
|