How does PnP manager determine the appropriate function driver? - windows

I am learing the loading process of Windows Driver.
But I cannot understand a part of the following article.
https://learn.microsoft.com/ja-jp/windows-hardware/drivers/install/step-3--the-driver-for-the-device-is-installed
In this article, there is the following description.
"4. The PnP manager loads the appropriate function driver and any optional filter drivers for the device."
I have a question about above description.
How does the PnP manager determine the appropriate function driver?
For example,
when a USB memory is plugged into a Windows PC then PnP manager will load disk.sys after loading a driver relating USB.
In this case, I want to know why PnP manager could judge that the device corresponds to disk.sys.
(seeing somewhere in registry? sending some requests to bus driver? and so on.. )

when bus driver detect and report PDO device PnP manager send several IRP_MJ_PNP to PDO device. including IRP_MN_QUERY_ID for get Device Identification Strings
then formated registry key path in form
\REGISTRY\MACHINE\SYSTEM\CurrentControlSet\Enum\<BusQueryDeviceID>\<BusQueryInstanceID>
in place <BusQueryDeviceID> string returned by device for BusQueryDeviceID and in place <BusQueryInstanceID> string returned by device for BusQueryInstanceID (Parameters.QueryId.IdType)
this key opened or created. then was query for BusQueryHardwareIDs and BusQueryCompatibleIDs. result of this query saved in HardwareID and CompatibleIDs REG_MULTI_SZ values.
and then PnP manager look for Service REG_SZ value under this key - if it already exist - the driver ( \REGISTRY\MACHINE\SYSTEM\CurrentControlSet\Services\<Service>) loaded and it AddDevice called with this PDO. if this value yet not set - was search via installed inf files in system - for best match HardwareID and CompatibleIDs. if found driver - result saved under Service REG_SZ value, for not search next time

Related

TPM Windows Key creation

Once Windows has taken ownership of the TPM chip inside my computer is it still possible to create a persistent key inside it ? (Given that I don't have the Owner Password because Windows throws it aways after initializing the TPM).
Is the Storage Root Key (SRK) created by Windows inside the TPM protected with a pin code to perform cipher operations ? If it is where is that password stored in windows ?
Thx!
For those who pass by, It is possible.
I did a dual boot with a Windows 10 and an Ubuntu. I put the excellent tools developped here tpm2-tools on the Ubuntu and I got to insert my own persistent primary key inside the chip.
The funny/weird thing is that I can create that key and make it persistent under linux (with these tools) also under EFI with a program that I wrote. But under Windows I can't get it to work. I'm going to ask why on another post.

How to install upper driver for class?

I created a filter driver and I just want to install it for the Serial port. I know that the existing driver class is "Ports" so I changed inf file as follows:
[Version]
Signature="$Windows NT$"
Class=Ports
ClassGUID={4D36E978-E325-11CE-BFC1-08002BE10318}
Provider=%Provider%
DriverVer=03/17/2001,1.0.0.1
CatalogFile=KmdfSamples.cat
Note that the classguid is the same as in system for serial port. So I does not know how to install it for specyfic class, I have to manally edit "UpperFilter" field in registry?
I also can not find out from the microsoft documentation if I have to specyfi device in such a way (I do not know the device name, but i know whole class id).
So the questions are:
How to install upper filter for existing class?
Have I specyfi the device hardware id that I do not know?
Any repsonses will be greatly appreciated ;)

Mapping DiskDrive to Storage Controllers

I have a task to gather information regarding the storage controller on which the disk drive is present for verification purpose. After some research, all I can find is use of devcon tool to gather necessary information.
I can get storage controller details using following commands
devcon drivernodes =SCSIAdapter
devcon drivernodes =hdc
These commands display information regarding the position of the controller. I can similarly gather information regarding the disk drives
devcon drivernodes =DiskDrive
But I cannot find a mapping between these 2. I have many drives and many controllers on servers and finding it hard to gather the mapping using either a command-line or programmable way.
But I did find the mapping detail using gui "Device Manager" and select the particular disk drive and then scrolling to a property "parent" that shows the info of the controller gathered before.
does anyone know how to get this parent property using command line on windwos ?
Try in powershell.
PS C:\Windows\system32> get-wmiobject -class Win32_SCSIControllerDevice

NDIS6 LWF installation problems via DPInst and DIFxAPI

We have a NDIS6 LWF driver which installs fine if installed from the adapter's property sheet, but does not install neither via DPInst, nor via DriverPackageInstall function from DIFxAPI.dll
Apart from vendor info and descriptions, it differs from the NDIS6 LWF Passthru sample in the following ways:
binds only to WLAN medium:
HKR, Ndi\Interfaces, FilterMediaTypes,,"wlan"
specifies DriverPackageType=Network (a requirement of DIFxAPI)
passthru sample says "compression" here, we say "custom"
HKR, Ndi,FilterClass,, custom
The current full version of the INF is stored at https://docs.google.com/file/d/0By4TPkL7aR-RelRSZC1PZmdQYnc/edit?pli=1 because it's too big to quote it here.
So, the question is: what else does this INF require in order to be installed via DIFxAPI? (It currently installs fine via the adapter's property sheet)
You will need to update NetCfgInstanceId in inf file and have same id as UniqueName in registration attributes at driver entry.
You can use following site to have a new id generated and replace your present:
www.uuidgen.com

Storing data in Kernel mode driver

I have an array in my kernel mode driver. Is it possible for the driver to save the array data and on load restore the same?
Assuming your array is not incredibly large you can use the registry to store this type of information.
You can set your driver to open a specific registry location relative to your driver instance. If it's missing your driver should contain a default value (you can also set your INF file to put this value in the registry on install). Then, as your data changes and your device unloads rewrite the data to the registry to be looked up the next time your device loads.

Resources