IRP structure

IRP structure

description

The IRP structure is a partially opaque structure that represents an I/O request packet. Drivers can use the following members of the IRP structure.
IRP结构是表示I/O请求数据包的部分不透明结构。驱动程序可以使用 IRP 结构的以下成员。

struct fields

Type

Size

MdlAddress

Pointer to an MDL describing a user buffer, if the driver is using direct I/O, and the IRP major function code is one of the following:
指向一个描述用户缓冲区的, 如果驱动程序使用的是直接 i/o, 并且 IRP 主要功能代码是以下内容之一:

IRP_MJ_READ

The MDL describes an empty buffer that the device or driver fills in.
该MDL描述了设备或驱动程序填写的空缓冲区。

IRP_MJ_WRITE

The MDL describes a buffer that contains data for the device or driver.
该MDL描述了一个包含设备或驱动程序数据的缓冲区。

IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL

If the IOCTL code specifies the METHOD_IN_DIRECT transfer type, the MDL describes a buffer that contains data for the device or driver.
如果 IOCTL 代码指定了 METHOD_IN_DIRECT 传输类型, 则该转换器将描述一个包含设备或驱动程序数据的缓冲区。

If the IOCTL code specifies the METHOD_OUT_DIRECT transfer type, the MDL describes an empty buffer that the device or driver fills in.
如果 IOCTL 代码指定了 METHOD_OUT_DIRECT 传输类型, 则表示该设备或驱动程序填充的空缓冲区。

For more information about the buffers that are associated with METHOD_IN_DIRECT and METHOD_OUT_DIRECT transfer types in IOCTL codes, see Buffer Descriptions for I/O Control Codes.
有关与 IOCTL 代码中的 METHOD_IN_DIRECT 和 METHOD_OUT_DIRECT 传输类型关联的缓冲区的更多信息, 请参见 i/o控制代码的缓冲区说明.

If the driver is not using direct I/O, this pointer is NULL.
如果驱动程序没有使用直接 i/o, 则此指针为NULL.

Flags

File system drivers use this field, which is read-only for all drivers. Network and, possibly, highest-level device drivers also might read this field. This field is set either to zero or to the bitwise-OR of one or more of the following system-defined flag bits:
文件系统驱动程序使用此字段, 它对所有驱动程序都是只读的。网络以及可能是最高级别的设备驱动程序也可能读取此字段。此字段设置为零或按位或以下系统定义的标记位的一个或多个:

IRP_NOCACHE

IRP_PAGING_IO

IRP_MOUNT_COMPLETION

IRP_SYNCHRONOUS_API

IRP_ASSOCIATED_IRP

IRP_BUFFERED_IO

IRP_DEALLOCATE_BUFFER

IRP_INPUT_OPERATION

IRP_SYNCHRONOUS_PAGING_IO

IRP_CREATE_OPERATION

IRP_READ_OPERATION

IRP_WRITE_OPERATION

IRP_CLOSE_OPERATION

IRP_DEFER_IO_COMPLETION

IRP_OB_QUERY_NAME

IRP_HOLD_DEVICE_QUEUE

IRP_UM_DRIVER_INITIATED_IO

AssociatedIrp

AssociatedIrp.MasterIrp

Pointer to the master IRP in an IRP that was created by a highest-level driver’s call to IoMakeAssociatedIrp.
指向由最高级别的驱动程序调用 IoMakeAssociatedIrp 创建的 irp 中的主 irp 的指针.

AssociatedIrp.IrpCount

AssociatedIrp.SystemBuffer

Pointer to a system-space buffer.
指向系统空间缓冲区的指针。

If the driver is using buffered I/O, the buffer’s purpose is determined by the IRP major function code, as follows:
如果驱动程序使用缓冲 i/o, 则缓冲区的目的由 IRP 主要函数代码确定, 如下所示:

SystemBuffer.IRP_MJ_READ

The buffer receives data from the device or driver. The buffer’s length is specified by Parameters.Read.Length in the driver’s IO_STACK_LOCATION structure.
缓冲区从设备或驱动程序接收数据。缓冲区的长度由驱动程序的 IO_STACK_LOCATION 结构中的Parameters.Read.Length指定。

NULL.

SystemBuffer.IRP_MJ_WRITE

The buffer supplies data for the device or driver. The buffer’s length is specified by Parameters.Write.Length in the driver’s IO_STACK_LOCATION structure.
缓冲区为设备或驱动程序提供数据。缓冲区的长度由驱动程序的IO_STACK_LOCATION结构中的Parameters.Write.Length指定。

NULL.

SystemBuffer.IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL

The buffer represents both the input and output buffers that are supplied to DeviceIoControl and IoBuildDeviceIoControlRequest. Output data overwrites input data.
缓冲区既代表了提供给DeViCeIONANDIOBIODIVE控件的输入缓冲区和输出缓冲区。输出数据覆盖输入数据。

For input, the buffer’s length is specified by Parameters.DeviceIoControl.InputBufferLength in the driver’s IO_STACK_LOCATION structure.
对于输入, 缓冲区的长度由驱动程序的IO_STACK_LOCATION结构中的Parameters.DeviceIoControl.InputBufferLength指定。

For output, the buffer’s length is specified by Parameters.DeviceIoControl.OutputBufferLength in the driver’s IO_STACK_LOCATION structure.
对于输出, 缓冲区的长度由驱动程序的IO_STACK_LOCATION结构中的Parameters.DeviceIoControl.OutputBufferLength指定。

For more information, see Buffer Descriptions for I/O Control Codes.
有关详细信息, 请参阅 i/o控制代码的缓冲区说明.

The buffer represents the input buffer that is supplied to DeviceIoControl and IoBuildDeviceIoControlRequest.

The buffer’s length is specified by Parameters.DeviceIoControl.InputBufferLength in the driver’s IO_STACK_LOCATION structure.

For more information, see Buffer Descriptions for I/O Control Codes.

If the driver is using direct I/O, the buffer’s purpose is determined by the IRP major function code, as follows:
如果驱动程序使用直接 i/o, 则缓冲区的目的由 IRP 主要函数代码确定, 如下所示:

ThreadListEntry

IoStatus

Contains the IO_STATUS_BLOCK structure in which a driver stores status and information before calling IoCompleteRequest.
包含 IO_STATUS_BLOCK 结构, 驱动程序在调用 IoCompleteRequest 之前存储状态和信息.

RequestorMode

Indicates the execution mode of the original requester of the operation, one of UserMode or KernelMode.
指示操作的原始请求者的执行模式,用户模式或KernelMode的一个.

PendingReturned

If set to TRUE, a driver has marked the IRP pending. Each IoCompletion routine should check the value of this flag. If the flag is TRUE, and if the IoCompletion routine will not return STATUS_MORE_PROCESSING_REQUIRED, the routine should call IoMarkIrpPending to propagate the pending status to drivers above it in the device stack.
如果设置为TRUE, 则驱动程序已标记 IRP 待定。每个 IoCompletion 例程都应检查此标志的值。如果该标志为TRUE, 并且如果 IoCompletion 例程不返回 STATUS_MORE_PROCESSING_REQUIRED, 则该例程应调用 IoMarkIrpPending 将挂起状态传播到设备堆栈中它上面的驱动程序。

StackCount

CurrentLocation

Cancel

If set to TRUE, the IRP either is or should be canceled.
如果设置为TRUE, 则 IRP 可以是或应该被取消。

CancelIrql

Contains the IRQL at which a driver is running when IoAcquireCancelSpinLock is called.
包含在调用 IoAcquireCancelSpinLock 时驱动程序正在运行的 IRQL。

ApcEnvironment

AllocationFlags

UserIosb

UserEvent

Overlay

Overlay.AsynchronousParameters

Overlay.AsynchronousParameters.UserApcRoutine

Overlay.AsynchronousParameters.IssuingProcess

Overlay.AsynchronousParameters.UserApcContext

Overlay.AllocationSize

CancelRoutine

Contains the entry point for a driver-supplied Cancel routine to be called if the IRP is canceled. NULL indicates that the IRP is not currently cancelable.
包含在取消 IRP 时调用的驱动程序提供的取消例程的入口点。NULL指示 IRP 当前未取消。

UserBuffer

Contains the address of an output buffer if both of the following conditions apply:
如果适用以下两种情况, 则包含输出缓冲区的地址:

  • The major function code in the I/O stack location is IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROL. i/o 堆栈位置中的主要函数代码是 IRP_MJ_DEVICE_CONTROL 或 IRP_MJ_INTERNAL_DEVICE_CONTROL .
  • The I/O control code was defined with METHOD_NEITHER or METHOD_BUFFERED. i/o 控制代码是用 METHOD_NEITHER 或 METHOD_BUFFERED 定义的。

For METHOD_BUFFERED, the driver should use the buffer pointed to by Irp->AssociatedIrp.SystemBuffer as the output buffer. When the driver completes the request, the I/O manager copies the contents of this buffer to the output buffer that is pointed to by Irp->UserBuffer. The driver should not write directly to the buffer pointed to by Irp->UserBuffer. For more information, see Buffer Descriptions for I/O Control Codes.
对于 METHOD_BUFFERED, 驱动程序应使用由Irp > AssociatedIrp指向的缓冲区作为输出缓冲区. SystemBuffer。当驱动程序完成请求时, i/o 管理器将此缓冲区的内容复制到由Irp > UserBuffer指向的输出缓冲区。驱动程序不应直接写入由Irp > UserBuffer指向的缓冲区。有关详细信息, 请参阅 i/o控制代码的缓冲区说明.

Tail

Tail.Overlay

Tail.Overlay.DeviceQueueEntry

If IRPs are queued in the device queue associated with the driver’s device object, this field links IRPs in the device queue. These links can be used only while the driver is processing the IRP.
如果 IRPs 在与驱动程序的设备对象关联的设备队列中排队, 则此字段将在设备队列中链接 IRPs。这些链接只能在驱动程序处理 IRP 时使用。

Tail.Overlay.DriverContext

If IRPs are not queued in the device queue associated with the driver’s device object, this field can be used by the driver to store up to four pointers. This field can be used only while the driver owns the IRP.
如果 IRPs 未在与驱动程序的设备对象关联的设备队列中排队, 则驱动程序可使用此字段存储多达四个指针。此字段只能在驱动程序拥有 IRP 时使用。

Tail.Overlay.Thread

A pointer to the caller’s thread control block (TCB). For requests that originate in user-mode, the I/O manager always sets this field to point to the TCB of the thread that issued the request.
指向调用方线程控制块 (TCB) 的指针。对于源自用户模式的请求, i/o 管理器始终将此字段设置为指向发出请求的线程的 TCB。

Tail.Overlay.AuxiliaryBuffer

Tail.Overlay.ListEntry

If a driver manages its own internal queues of IRPs, it uses this field to link one IRP to the next. These links can be used only while the driver is holding the IRP in its queue or is processing the IRP.
如果驱动程序管理自己的 IRPs 内部队列, 则使用此字段将一个 IRP 链接到下一个。只有当驱动程序将 irp 放在队列中或正在处理 irp 时, 才能使用这些链接。

Tail.Overlay.CurrentStackLocation

Tail.Overlay.PacketType

Tail.Overlay.OriginalFileObject

Tail.Apc

Tail.CompletionKey

remarks

Undocumented members of the IRP structure are reserved, used only by the I/O manager or, in some cases, by FSDs.
IRP 结构的无记录成员是保留的, 只能由 i/o 管理器使用, 或者在某些情况下由 FSDs。

An IRP is the basic I/O manager structure used to communicate with drivers and to allow drivers to communicate with each other. A packet consists of two different parts:
IRP 是用于与驱动程序通信并允许驱动程序彼此通信的基本 i/o 管理器结构。一个包由两个不同的部分组成:

  • Header, or fixed part of the packet— This is used by the I/O manager to store information about the original request, such as the caller’s device-independent parameters, the address of the device object upon which a file is open, and so on. It is also used by drivers to store information such as the final status of the request. 头或数据包的固定部分-这由 i/o 管理器用来存储有关原始请求的信息, 如调用方的设备无关参数、打开文件的设备对象的地址等。驱动程序还使用它来存储诸如请求的最终状态之类的信息。
  • I/O stack locations— Following the header is a set of I/O stack locations, one per driver in the chain of layered drivers for which the request is bound. Each stack location contains the parameters, function codes, and context used by the corresponding driver to determine what it is supposed to be doing. For more information, see the IO_STACK_LOCATION structure. i/o堆栈位置-后面的标头是一组i/o 堆栈位置, 每个驱动程序在分层驱动程序链中为其绑定请求。每个堆栈位置都包含相应驱动程序使用的参数、函数代码和上下文来确定它应该执行的操作。有关详细信息, 请参阅 IO_STACK_LOCATION 结构。

While a higher-level driver might check the value of the Cancel Boolean in an IRP, that driver cannot assume the IRP will be completed with STATUS_CANCELLED by a lower-level driver even if the value is TRUE.
虽然较高级别的驱动程序可能检查 irp 中的取消布尔值, 但该驱动程序不能假设 irp 将由较低级别的驱动程序完成, 即使该值为TRUE STATUS_CANCELLED.

see also

IO_STACK_LOCATION

IO_STATUS_BLOCK

IoCreateDevice

IoGetCurrentIrpStackLocation

IoGetNextIrpStackLocation

IoSetCancelRoutine

IoSetNextIrpStackLocation

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值