Handling IRPs 4: Completing an IRP

本文详细解释了当I/O操作完成后,驱动程序如何通过调用IoCompleteRequest例行程序来完成I/O堆栈指针的移动,并进一步阐述了如何通过IoCompletion例行程序作为驱动程序处理I/O请求时的返回地址。文中还介绍了状态值,如STATUS_CONTINUE_COMPLETION和STATUS_MORE_PROCESSING_REQUIRED,用于控制I/O请求的继续完成或暂停。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

When I/O is complete, the driver that completed the I/O calls the IoCompleteRequest routine. This routine moves the IRP stack pointer to point to the next higher location in the IRP stack, as Figure 3 shows.

 

 

Figure 3. IRP completion and stack pointer

Figure 3 shows the current I/O stack location after driver C has called IoCompleteRequest. The solid arrow on the left indicates that the stack pointer now points to the parameters and callback for driver B. The dotted arrow indicates the previous stack location. The hollow arrow on the right indicates the order in which the IoCompletion routines are called.

Note: For ease of explanation, this paper shows the I/O stack locations in the IRP “upside-down,” that is, in inverted order from A to C instead of from C to A. Using an inverted diagram enables calls that proceed “down” the device stack to point downwards.

If a driver set an IoCompletion routine as it passed the IRP down the device stack, the I/O Manager calls that routine when the IRP stack pointer once again points to the I/O stack location for the driver. In this way, IoCompletion routines act as return addresses for the drivers that handled the IRP as it traversed the device stack.

An IoCompletion routine can return either of two status values:

·         STATUS_CONTINUE_COMPLETION—continues the upward completion of the IRP. The I/O Manager advances the IRP stack pointer and calls the next-higher driver’s IoCompletion routine.

·         STATUS_MORE_PROCESSING_REQUIRED—stops the upward completion of the IRP and leaves the IRP stack pointer at its current location. Drivers that return this status usually restart the upward completion of the IRP later by calling the IoCompleteRequest routine.

 

When every driver has completed its corresponding sub-request, the I/O request is complete. The I/O Manager retrieves the status of the request from the Irp‑>IoStatus.Status field and retrieves the number of bytes transferred from the Irp‑>IoStatus.Information field.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值