Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to unload a kernel driver without a reboot?

I'm playing about with one of the kernel driver examples in the Win7 DDK. I can modify compile and build my *.sys file. I can install it too with its INF (using device manager or devcon) or using the Service control manager directly. When I make the next change though and generate an updated *.sys file I seem to get a conflict between this new file and my now stopped driver (I've tried using Servcie Control Manager 'stop' and 'delete service' etc). If I reboot, I can install the new driver and run it fine. Similarly, if I choose uninstall in Device Manager, Windows prompts me to reboot.

So, how can one easily test incremental modifications to a kernal driver easily? Thanks

like image 475
Brian Frost Avatar asked Jan 30 '11 17:01

Brian Frost


People also ask

How will you load and unload the module in kernel?

To unload a kernel module, we use the rmmod (remove module) command. The following example will unload or remove the speedstep-lib. ko module.

How do I prevent a kernel module from loading automatically?

In order to prevent kernel modules loading during boot, the module name must be added to a configuration file for the "modprobe" utility. This file must reside in /etc/modprobe. d . Ensure the module is not configured to get loaded in either /etc/modprobe.

Are kernel drivers safe?

Kernel driver code that is used for development, testing, or manufacturing might include dangerous capabilities that pose a security risk. This dangerous code should never be signed with a certificate that is trusted by Windows.


2 Answers

Looking at the Setup API logs might be a good place to start: http://msdn.microsoft.com/en-us/library/ff550887%28v=VS.85%29.aspx

If devcon prompts for a reboot, you could look at the code in the DDK, debug why it's asking and dig into the issue that way as well.

like image 90
Joshua Strouse Avatar answered Oct 24 '22 10:10

Joshua Strouse


Yes. sc stop <driver name> should stop your driver. If your driver is associated with a particular PnP devnode, it should be unloaded after the devnode is removed.

like image 4
ReinstateMonica Larry Osterman Avatar answered Oct 24 '22 10:10

ReinstateMonica Larry Osterman