In WDMProgramAnd other features are transferred to the adddevice routine. Adddevice is an important difference between WDM drivers and legacy nt drivers.
When a device is inserted into a computer, the system bus driver (root Bus) will enumerate that a new device is inserted. Then, the PnP Manager will be notified to find the device driver to be loaded. Based on the bus of the device, the PnP Manager loads the corresponding bus driver device and obtains the physical device object (PDO, vendorid and other information are loaded to the driver of the device, and the created PDO is passed as a parameter to the adddevice routine. The adddevice routine mounts its own device object to the PDO. The device Stack has been created.
1. Functional Device objects
It is the device_object data structure, which is generally created by the adddevice routine and then loaded on the physical device object. The driver of the function device object will also set the entry of each dispatch function in DriverEntry.
2. Physical Device objects
You can use the device object viewer to observe.
When the system starts, the root bus driver is loaded, and then the driver device mounted on the Root bus is found. If a PCI device is found, the PDO of the PCI device is loaded and the appropriate fdo is searched for loading. For example, a USB adapter is used as a PCI device and loaded with PDO and fdo.
Physical Device objects are generally created by bus drivers. WDM enables people to focus more on fdo. One or more filter drivers can be added between PDO and fdo. The filter driver can intercept and modify the plug-and-play IRPs.
WDM is developed based on the concept of layered driving. WDM drivers are generally divided into bus drivers and functional drivers. The function driver is mounted on the bus, and the function driver processes some IRPs. Most plug-and-play IRPs are forwarded to the bus driver for processing.