How to load a Driver

Hi,
I have a situation where I need to load a driver(Driver1) from the Initialization thread OR DriverEntry() function of another driver (Driver2). Are there any specific calls to do that ??

Thanks,
Ravi


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Yes, there are several ways that you can physically get the other driver
into memory. The simplest way is to simply export a library and link
against. However, the real trick is to get DriverEntry to run with a
DEVICE_OBJECT and a Registry path. If it’s only a chunk of functions that
don’t need to worry about DriverEntry running, then importing as a library
might work, but if you need its DriverEntry to run then you have a real
problem. Generally, in NT4, this can be handled by setting the group, load
order and tag for the driver that must load first. In Win2k, this becomes
rocket science since the PnP manager.

Gary

-----Original Message-----
From: jags [mailto:xxxxx@atlanta.nsc.com]
Sent: Wednesday, December 20, 2000 1:40 PM
To: NT Developers Interest List
Subject: [ntdev] How to load a Driver

Hi,
I have a situation where I need to load a driver(Driver1) from the
Initialization thread OR DriverEntry() function of another driver (Driver2).
Are there any specific calls to do that ??

Thanks,
Ravi

You are currently subscribed to ntdev as: xxxxx@delphieng.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Some time ago, Gary Little wrote…

In Win2k, this becomes rocket science since the PnP manager.

Will it work if you make the Driver1 an upper filter over Driver2?

-kkm

-----Original Message-----
From: jags [mailto:xxxxx@atlanta.nsc.com]
Sent: Wednesday, December 20, 2000 1:40 PM
To: NT Developers Interest List
Subject: [ntdev] How to load a Driver

Hi,
I have a situation where I need to load a driver(Driver1) from the
Initialization thread OR DriverEntry() function of another driver (Driver2).
Are there any specific calls to do that ??

Thanks,
Ravi


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Another option is to use the (undocumented) call ZwLoadDriver(…) to load the driver and then use IoGetDeviceObjectPointer(…) to get a pointer to the second driver’s device object. This pointer can be used in calls to IoCallDriver(…) if you need that functionality. The call to ZwLoadDriver(…) will cause the loader to call the second driver’s DriverEntry(…) function. The prototype for ZwLoadDriver() is:

NTSYSAPI NTSTATUS NTAPI ZwLoadDriver(IN PUNICODE_STRING RegistryPath);

where RegistryPath is in the form:

\Registry\Machine\System\CurrentControlSet\Services\MyDriver

The registry key for your driver must exist. Also, the call must be made while your first driver is at PASSIVE_LEVEL (such as during DriverEntry()). Of course, this is an undocumented function, so use it at your own risk.

Ed Lau

MidCore Software, Inc.
900 Straits Tpke
Middlebury, CT 06762

www.midcore.com
----- Original Message -----
From: jags
To: NT Developers Interest List
Sent: Wednesday, December 20, 2000 4:40 PM
Subject: [ntdev] How to load a Driver

Hi,
I have a situation where I need to load a driver(Driver1) from the Initialization thread OR DriverEntry() function of another driver (Driver2). Are there any specific calls to do that ??

Thanks,
Ravi

You are currently subscribed to ntdev as: xxxxx@midcore.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

Hi Ed,
Thanks a lot for the info. It really worked !! But you have mentioned below that the ZwLoadDriver() causes the loader to call the second driver’s DriverEntry(). In our case, the driver got loaded but the DriverEntry() did not get executed.
Any idea why this might be happening ?? By the way, this is on a Windows 2000 system.

Thanks,
Ravi
----- Original Message -----
From: elau
To: NT Developers Interest List
Sent: Thursday, December 21, 2000 9:38 AM
Subject: [ntdev] Re: How to load a Driver

Another option is to use the (undocumented) call ZwLoadDriver(…) to load the driver and then use IoGetDeviceObjectPointer(…) to get a pointer to the second driver’s device object. This pointer can be used in calls to IoCallDriver(…) if you need that functionality. The call to ZwLoadDriver(…) will cause the loader to call the second driver’s DriverEntry(…) function. The prototype for ZwLoadDriver() is:

NTSYSAPI NTSTATUS NTAPI ZwLoadDriver(IN PUNICODE_STRING RegistryPath);

where RegistryPath is in the form:

\Registry\Machine\System\CurrentControlSet\Services\MyDriver

The registry key for your driver must exist. Also, the call must be made while your first driver is at PASSIVE_LEVEL (such as during DriverEntry()). Of course, this is an undocumented function, so use it at your own risk.

Ed Lau

MidCore Software, Inc.
900 Straits Tpke
Middlebury, CT 06762

www.midcore.com
----- Original Message -----
From: jags
To: NT Developers Interest List
Sent: Wednesday, December 20, 2000 4:40 PM
Subject: [ntdev] How to load a Driver

Hi,
I have a situation where I need to load a driver(Driver1) from the Initialization thread OR DriverEntry() function of another driver (Driver2). Are there any specific calls to do that ??

Thanks,
Ravi

You are currently subscribed to ntdev as: xxxxx@midcore.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com

You are currently subscribed to ntdev as: xxxxx@atlanta.nsc.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com


You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com