How can i load driver from kernel mode

Hello All!
Hope I’ll be more lucky this time…

How can I load another driver from within kernel mode?
(I need something similar to CreateService in usermode)

Thanks!


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

#ifdef __cplusplus
extern “C” {
#endif
NTSYSAPI
NTSTATUS
NTAPI
ZwLoadDriver(
IN PUNICODE_STRING DriverServiceName
);

NTSYSAPI
NTSTATUS
NTAPI
ZwUnloadDriver(
IN PUNICODE_STRING DriverServiceName
);
#ifdef __cplusplus
};
#endif

Mark J. Cariddi
Consulting Associate
Open Systems Resources, Inc.
http://www.osr.com/

-----Original Message-----
From: Gladkov Vladimir [mailto:gladkov@ru.openpages.com]
Sent: Monday, February 12, 2001 12:28 PM
To: NT Developers Interest List
Subject: [ntdev] How can i load driver from kernel mode

Hello All!
Hope I’ll be more lucky this time…

How can I load another driver from within kernel mode?
(I need something similar to CreateService in usermode)

Thanks!

You are currently subscribed to ntdev as: xxxxx@osr.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

There are two undoc. function for this goals

NTSYSAPI
NTSTATUS
NTAPI
ZwLoadDriver (
IN PUNICODE_STRING RegistryPath
);

NTSYSAPI
NTSTATUS
NTAPI
ZwUnloadDriver (
IN PUNICODE_STRING RegistryPath
);

RegistryPath is something like
“\Registry\Machine\System\CurrentControlSet\Services\YourDriverName”


Bye,
SaB
-----Original Message-----
From: Gladkov Vladimir [mailto:gladkov@ru.openpages.com]
Sent: Monday, February 12, 2001 7:28 PM
To: NT Developers Interest List
Subject: [ntdev] How can i load driver from kernel mode

Hello All!
Hope I’ll be more lucky this time…

How can I load another driver from within kernel mode?
(I need something similar to CreateService in usermode)

Thanks!

You are currently subscribed to ntdev as: xxxxx@mastereye.kiev.ua
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

ZwLoadDriver - see
http://www.numega.com/drivercentral/tech_tips/ntloaddriver.shtml
http:
for an explanation of how to call it (at least on a w98-style WDM platform.)

See also the dubiously public domain ntifs.h file that is floating around.

However, if I recall correctly there are issues with doing this. Offhand I
don’t remember what they were.

I can’t actually imagine why loading a driver directly from kernel mode is a
requirement. Why not have a service application that has nothing better to
do than to wait for your driver-that-wants-to-load-another-driver to signal
it so that it can use the DOCUMENTED and SUPPORTED interface for starting
kernel drivers? Certainly the minor extra overhead of waking up a user mode
thread is negligible compared to the time it actually takes to load and
start the driver.Most likely you would be waking up a kernel worker thread
to perform your driver loading anyhow, as this all must be done at
PASSIVE_LEVEL.

Mark Roddy
xxxxx@hollistech.com
www.hollistech.com
WindowsNT Windows 2000 Consulting Services

-----Original Message-----
From: Gladkov Vladimir [mailto:gladkov@ru.openpages.com]
Sent: Monday, February 12, 2001 12:28 PM
To: NT Developers Interest List
Subject: [ntdev] How can i load driver from kernel mode

Hello All!
Hope I’ll be more lucky this time…

How can I load another driver from within kernel mode?
(I need something similar to CreateService in usermode)

Thanks!

You are currently subscribed to ntdev as: xxxxx@stratus.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</http:>

You can use the (undocumented) call ZwLoadDriver(…) to load the driver and then use IoGetDeviceObjectPointer(…) to get a pointer to the 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

----- Original Message -----
From: Gladkov Vladimir
To: NT Developers Interest List
Sent: Monday, February 12, 2001 12:28 PM
Subject: [ntdev] How can i load driver from kernel mode

Hello All!
Hope I’ll be more lucky this time…

How can I load another driver from within kernel mode?
(I need something similar to CreateService in usermode)

Thanks!

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