I am learing the loading process of Windows Driver.
But I cannot understand a part of the following article.
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