Driver loading mechanism Windows vs Linux - windows

Why do we have to restart windows in order to bring newly installed device driver into effect ? How does the driver loading mechanism differ from that of Linux ?

Windows could load your function driver dynamically by using CreateService and StartService. Also, you can use ZwLoadDriver to load a driver.
But, you have to load some types of driver after restart such as class driver, filter driver etc. Because these drivers are depended on other system drivers. If your driver is loaded too late. Your driver won't work correctly.
For more detail, please check MSDN. You can control the order of driver loading accurately by using registry.

Related

How can I load/start my device driver as early as possible on system bootup

I have a KMDF device driver that has an inf file and I would like to know how would I start/load my device driver before any other application or kernel mode drivers on boot up but load after the kernel has completely loaded ? My device driver targets Windows 8.1 at the moment have yet to ensure compatibility with Windows 10/11. Would creating a service be the only way to ensure that this driver loads first ?
Thanks

How to automatically remove driver after crash?

I'm remote-debugging a Windows kernel-mode driver using WinDbg. The driver has issues in the initialization routine, leading to a bugcheck/crash when installing the device driver. When I detach the debugger, the target PC reboots and runs again into the same bugcheck.
In order to test a new version of the driver, I therefore have to boot into safe mode, uninstall the device using device manager and reboot into normal mode.
Is there any way to simplify this workflow so that the device driver is automatically removed upon rebooting after a bugcheck?
Additional infos:
I'm using dpinst to install the driver on the target PC
use .Kdfiles to pull a replacement driver during boot
Documentation From MS
Write Up in Nt Insider From Osr Online
if you are using windows 10 then you can leverage the -m option to provide a partial name
and forego the dospath C:\ NtPath \.\xx , %SystemRoot%
confusions in the map file formats ,
or as described here

Filter Drive is not loaded - Startup

I have configured my filter driver start type as SERVICE_SYSTEM_START in .inf file, Installed the filter driver manually using the instructions on the Light weight filter driver sample, rebooted the virtual machine to know if my driver is loaded. in the ntbtlog.txt which has all the driver information it says "Did not load driver ".
Starting with Windows Vista x64 platform, All the drivers that are not signed will not be loaded by the Windows, So that was the reason for Not loading Driver. To fix this I have used "Disable Signature Enforcement" option in the Boot menu by pressing F8 during the boot. This would disable the restriction while development of the driver.

Does Windows load a driver that is loaded using OsrLoader at the startup?

I start learning Windows drivers development and I wrote my first driver. I use OsrLoader for loading and unloading the drivers. So far everything is fine. However, As we know, if a driver crashes the whole system crashes. The worst thing can happen is that Windows loads that buggy driver at the system start-up.
My question is that does Windows load a driver that is loaded using OsrLoader at the startup?
No, OsrLoader only loads the driver for the current session. It does not cause it to be loaded next time you reboot.

New driver installation on Windows

I am trying to find what happens when new driver is installed for windows. (What kernel data structures are modified.) Does anyone know any good documentation on this topic. It is a bit painful to debug this.
Thanks
When a driver is installed is it placed into the Driver Store (see http://msdn.microsoft.com/en-us/library/ff544868%28v=vs.85%29.aspx)
When a new device is discovered that does not have a current driver association the PNP manager looks at the driver store to see if any of the stored drivers will match the new device.
If the PNP manager finds a driver to match the device it will execute the directives in the drivers inf file. This typically creates a service entry in the registry (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services), copies the driver binaries to somewhere like \Windows\System32\drivers etc. Also the PNP manager will create an association of that device to that driver (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum I think) so that next time it can shortcut the process.
I don't think any kernel data structures are modified when a driver is installed. Do you mean to ask when a driver is loaded?

Resources