I/O request packets
Most of the requests that are sent to device drivers are packaged in I/O request packets (IRPs). An operating system component or a driver sends an IRP to a driver by calling IoCallDriver, which has two parameters: a pointer to a DEVICE_OBJECT and a pointer to an IRP. The DEVICE_OBJECT has a pointer to an associated DRIVER_OBJECT. When a component calls IoCallDriver, we say the component sends the IRP to the device object or sends the IRP to the driver associated with the device object. Sometimes we use the phrase passes the IRP or forwards the IRP instead of sends the IRP.
当我们需要和驱动进行通信的时候,常常采用发送IRP的方式来进行。IRP - I/O request packets是Windows内核概念,主要用于操作系统和各个内核模块之间的通信。IRP通常是由I/O Manager创建的以响应从用户层传递下来的I/O请求,同时PnP Manager, Power Manager 等系统的其他内核模块也是能创建这种Packages. Driver通过IoCallDriver来发送IRP。
Typically an IRP is processed by several drivers that are arranged in a stack. Each driver in the stack is associated with a device object. For more information, see Device nodes and device stacks. When an IRP is processed by a device stack, the IRP is usually sent first to the top device object in the device stack. For example, if an IRP is processed by the device stack shown in this diagram, the IRP would be sent first to the filter device object (Filter DO) at the top of the device stack.
通常情况下,一个IRP需要几个在同一个device stack的driver来处理。如下图所示,当一个device stack来处理IRP的时候,最顶层的device object (Filter DO)得到IRP。然后向下下发。

Passing an IRP down the device stack
Suppose the I/O manager sends an IRP to the Filter DO in the diagram. The driver associated with the Filter DO, AfterThought.sys, processes the IRP and then passes it to the functional device object (FDO), which is the next lower device object in the device stack. When a driver passes an IRP to the next lower device object in the device stack, we say the driver passes the IRP down the device stack.
Some IRPs are passed all the way down the device stack to the physical device object (PDO). Other IRPs never reach the PDO because they are completed by one of the drivers above the PDO.
传递IRP的过程
假设I/O manager给图中的Filter DO 发送了一个IRP,和该Filter DO的driver - AfterThought.sys会处理这个IRP然后将其传递给下层的FDO。有一些IRPs需要传递到最底层的PDO,而有一些不需要,因为在没到底层之前可能就被上层的Driver处理好了。

浙公网安备 33010602011771号