WDM Input Output Concepts
WDM Input Output Concepts
I/O Flow through Device Stack Driver contains a collection of routines that can be called by the I/O Manager. The I/O Manager typically calls a driver routine at the following conditions: i. When a driver is loaded ii. When a driver is unloaded or the system is shutting down iii. When a device is inserted or removed iv. When a user-mode program issues an I/O request (which is routed through the device object) v. When a shared hardware resource becomes available for driver use I/O request packets (IRPs) are kernel mode structures that are used to facilitate communication between each of the WDM drivers as well as when the operating system needs to communicate with the drivers. Life-cycle of IRP: I. With each user-mode request for I/O, the I/O Manager allocates an IRP from nonpaged system memory. The I/O Manager is responsible to pass the IRP to the appropriate driver. II. When the operation is complete, the driver stores a final status code in the IRP and returns it to the I/O Manager. III. The I/O Manager uses the information in the IRP to complete the request and send the user the final status.
I/O stack location(s) The I/O manager gives each driver in a chain of layered drivers an I/O stack location for every IRP that it sets up. Each I/O stack location consists of an IO_STACK_LOCATION structure. Each stack location corresponds to a particular driver in the chain of layered drivers. The lowest-level driver in a chain of layered drivers can safely access only its own I/O stack location in any IRP. A higher-level driver in a chain of layered drivers can safely access only its own and the next-lower-level driver's I/O stack locations in any IRP. Such a driver must set up the I/O stack location for the next-lower-level driver in IRPs. However, when designing a higher-level driver, you cannot predict when (or whether) a new driver will be added to the current format of chain just below your driver. However we can safely assume that any subsequently added (intermediate) driver will handle the same IRP major function codes (IRP_MJ_XXX) as the displaced next-lower-level driver did.