Handling IRPs 3: Passing an IRP to the Next Lower Driver
来源:互联网 发布:nodejs高级编程 中文 编辑:程序博客网 时间:2024/06/06 06:51
Passing an IRP to the Next Lower Driver
Passing an IRP to the next lower driver (also calledforwarding an IRP) is the IRP equivalent of a subroutine call. When a driver forwards an IRP, it must populate the next I/O stack location with parameters, advance the IRP stack pointer, and invoke the next driver’s dispatch routine. In essence, the driver is calling down the IRP stack.
To pass an IRP, a driver typically takes the following steps:
1. Set up the parameters for the next I/O stack location. The driver can either:
· Call the IoGetNextIrpStackLocation routine to get a pointer to the next I/O stack location, and then copy the required parameters to that location.
· Call the IoCopyCurrentIrpStackLocationToNext routine (if the driver sets anIoCompletion routine in step 2), or the IoSkipCurrentIrpStackLocation routine (if the driver does not set anIoCompletion routine in step 2) to pass the same parameters used for the current location.
Note: Drivers must not use theRtlCopyMemory routine to copy the current parameters. This routine copies the pointer to the current driver’sIoCompletion routine, thus causing the IoCompletion routine to be called more than once.
2. Set an IoCompletion routine for post-processing, if necessary, by calling theIoSetCompletionRoutine routine. If the driver sets an IoCompletion routine, it must callIoCopyCurrentIrpStackLocationToNext in step 1.
3. Pass the request to the next driver by calling theIoCallDriver routine. This routine automatically advances the IRP stack pointer and invokes the next driver’s dispatch routine.
After a driver passes the IRP to the next driver, it no longer owns the IRP and must not attempt to access it. The IRP could be freed or completed by another driver or on another thread. Attempting to access an IRP in such a situation can cause a system crash. If the driver requires access to the IRP after passing it down the stack, the driver must set anIoCompletion routine. When the I/O Manager calls the IoCompletion routine, the driver regains ownership of the IRP for the duration of theIoCompletion routine. Thus the IoCompletion routine can access the fields in the IRP.
If the driver’s dispatch routine must also process the IRP after lower drivers have completed it, theIoCompletion routine must return STATUS_MORE_PROCESSING_REQUIRED, which returns ownership of the IRP to the dispatch routine. As a result, the I/O Manager stops processing the IRP and leaves the ultimate completion of the IRP to the dispatch routine. The dispatch routine can later call IoCompleteRequest to finish completion or can mark the IRP pending for further processing.
- Handling IRPs 3: Passing an IRP to the Next Lower Driver
- Handling IRPs 4: Completing an IRP
- Handling IRPs: What Every Driver Writer Needs to Know -翻译
- Handling IRPs: Definition 1: IRP as a Container for an I/O Request
- Handling IRPs 8: Propagating the Pending Bit
- handling IRPs 15: Building IRPs
- Handling IRPs: Definition 2: IRP as a Thread-Independent Call Stack
- handling IRPs 14: Success, Error, and Warning Status for IRP Completion
- handling IRPs 17: Call to Action and Resources
- Handling IRPs: Introduction
- Handling IRPs 10: Optimizations
- Handling IRPs 9: Summary of Guidelines for Pending IRPs
- IRP Dispatching and Handling
- Handling IRPs 5: Synchronous I/O Responses
- Handling IRPs 6: Asynchronous I/O Responses
- handling IRPs 12: Data Transfer Mechanisms
- handling IRPs 16: Debugging I/O Problems
- The driver was unable to create a connection due to an inability to establish the client portion of
- Handling IRPs: Definition 2: IRP as a Thread-Independent Call Stack
- c#之执行SQL存储过程
- python 抓取腾讯微博数据并做简单的分析
- 数据结构要点归纳总结(转)
- Error: C3065E: type of input file 'XXX' unknown——已解决!
- Handling IRPs 3: Passing an IRP to the Next Lower Driver
- Handling IRPs 4: Completing an IRP
- 开发者所需要知道的iOS7 SDK新特性
- Handling IRPs 5: Synchronous I/O Responses
- 访问存储设备
- [黑马程序员]对两个整数变量的值进行交换的方法总结
- 自动构建 msbuild基础
- Handling IRPs 6: Asynchronous I/O Responses
- WPA Supplicant 在Windows下的编译