IO_STACK_LOCATION 结构 (wdm.h)

IO_STACK_LOCATION 结构定义 I/O 堆栈位置,该位置是 I/O 堆栈中与每个 IRP 关联的条目。 IRP 中的每个 I/O 堆栈位置都有一些通用成员和一些特定于请求类型的成员。

语法

typedef struct _IO_STACK_LOCATION {
  UCHAR                  MajorFunction;
  UCHAR                  MinorFunction;
  UCHAR                  Flags;
  UCHAR                  Control;
  union {
    struct {
      PIO_SECURITY_CONTEXT     SecurityContext;
      ULONG                    Options;
      USHORT POINTER_ALIGNMENT FileAttributes;
      USHORT                   ShareAccess;
      ULONG POINTER_ALIGNMENT  EaLength;
    } Create;
    struct {
      PIO_SECURITY_CONTEXT          SecurityContext;
      ULONG                         Options;
      USHORT POINTER_ALIGNMENT      Reserved;
      USHORT                        ShareAccess;
      PNAMED_PIPE_CREATE_PARAMETERS Parameters;
    } CreatePipe;
    struct {
      PIO_SECURITY_CONTEXT        SecurityContext;
      ULONG                       Options;
      USHORT POINTER_ALIGNMENT    Reserved;
      USHORT                      ShareAccess;
      PMAILSLOT_CREATE_PARAMETERS Parameters;
    } CreateMailslot;
    struct {
      ULONG                   Length;
      ULONG POINTER_ALIGNMENT Key;
      ULONG                   Flags;
      LARGE_INTEGER           ByteOffset;
    } Read;
    struct {
      ULONG                   Length;
      ULONG POINTER_ALIGNMENT Key;
      ULONG                   Flags;
      LARGE_INTEGER           ByteOffset;
    } Write;
    struct {
      ULONG                   Length;
      PUNICODE_STRING         FileName;
      FILE_INFORMATION_CLASS  FileInformationClass;
      ULONG POINTER_ALIGNMENT FileIndex;
    } QueryDirectory;
    struct {
      ULONG                   Length;
      ULONG POINTER_ALIGNMENT CompletionFilter;
    } NotifyDirectory;
    struct {
      ULONG                                                Length;
      ULONG POINTER_ALIGNMENT                              CompletionFilter;
      DIRECTORY_NOTIFY_INFORMATION_CLASS POINTER_ALIGNMENT DirectoryNotifyInformationClass;
    } NotifyDirectoryEx;
    struct {
      ULONG                                    Length;
      FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
    } QueryFile;
    struct {
      ULONG                                    Length;
      FILE_INFORMATION_CLASS POINTER_ALIGNMENT FileInformationClass;
      PFILE_OBJECT                             FileObject;
      union {
        struct {
          BOOLEAN ReplaceIfExists;
          BOOLEAN AdvanceOnly;
        };
        ULONG  ClusterCount;
        HANDLE DeleteHandle;
      };
    } SetFile;
    struct {
      ULONG                   Length;
      PVOID                   EaList;
      ULONG                   EaListLength;
      ULONG POINTER_ALIGNMENT EaIndex;
    } QueryEa;
    struct {
      ULONG Length;
    } SetEa;
    struct {
      ULONG                                  Length;
      FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
    } QueryVolume;
    struct {
      ULONG                                  Length;
      FS_INFORMATION_CLASS POINTER_ALIGNMENT FsInformationClass;
    } SetVolume;
    struct {
      ULONG                   OutputBufferLength;
      ULONG POINTER_ALIGNMENT InputBufferLength;
      ULONG POINTER_ALIGNMENT FsControlCode;
      PVOID                   Type3InputBuffer;
    } FileSystemControl;
    struct {
      PLARGE_INTEGER          Length;
      ULONG POINTER_ALIGNMENT Key;
      LARGE_INTEGER           ByteOffset;
    } LockControl;
    struct {
      ULONG                   OutputBufferLength;
      ULONG POINTER_ALIGNMENT InputBufferLength;
      ULONG POINTER_ALIGNMENT IoControlCode;
      PVOID                   Type3InputBuffer;
    } DeviceIoControl;
    struct {
      SECURITY_INFORMATION    SecurityInformation;
      ULONG POINTER_ALIGNMENT Length;
    } QuerySecurity;
    struct {
      SECURITY_INFORMATION SecurityInformation;
      PSECURITY_DESCRIPTOR SecurityDescriptor;
    } SetSecurity;
    struct {
      PVPB           Vpb;
      PDEVICE_OBJECT DeviceObject;
      ULONG          OutputBufferLength;
    } MountVolume;
    struct {
      PVPB           Vpb;
      PDEVICE_OBJECT DeviceObject;
    } VerifyVolume;
    struct {
      struct _SCSI_REQUEST_BLOCK *Srb;
    } Scsi;
    struct {
      ULONG                       Length;
      PSID                        StartSid;
      PFILE_GET_QUOTA_INFORMATION SidList;
      ULONG                       SidListLength;
    } QueryQuota;
    struct {
      ULONG Length;
    } SetQuota;
    struct {
      DEVICE_RELATION_TYPE Type;
    } QueryDeviceRelations;
    struct {
      const GUID *InterfaceType;
      USHORT     Size;
      USHORT     Version;
      PINTERFACE Interface;
      PVOID      InterfaceSpecificData;
    } QueryInterface;
    struct {
      PDEVICE_CAPABILITIES Capabilities;
    } DeviceCapabilities;
    struct {
      PIO_RESOURCE_REQUIREMENTS_LIST IoResourceRequirementList;
    } FilterResourceRequirements;
    struct {
      ULONG                   WhichSpace;
      PVOID                   Buffer;
      ULONG                   Offset;
      ULONG POINTER_ALIGNMENT Length;
    } ReadWriteConfig;
    struct {
      BOOLEAN Lock;
    } SetLock;
    struct {
      BUS_QUERY_ID_TYPE IdType;
    } QueryId;
    struct {
      DEVICE_TEXT_TYPE       DeviceTextType;
      LCID POINTER_ALIGNMENT LocaleId;
    } QueryDeviceText;
    struct {
      BOOLEAN                                          InPath;
      BOOLEAN                                          Reserved[3];
      DEVICE_USAGE_NOTIFICATION_TYPE POINTER_ALIGNMENT Type;
    } UsageNotification;
    struct {
      SYSTEM_POWER_STATE PowerState;
    } WaitWake;
    struct {
      PPOWER_SEQUENCE PowerSequence;
    } PowerSequence;
#if ...
    struct {
      union {
        ULONG                      SystemContext;
        SYSTEM_POWER_STATE_CONTEXT SystemPowerStateContext;
      };
      POWER_STATE_TYPE POINTER_ALIGNMENT Type;
      POWER_STATE POINTER_ALIGNMENT      State;
      POWER_ACTION POINTER_ALIGNMENT     ShutdownType;
    } Power;
#else
    struct {
      ULONG                              SystemContext;
      POWER_STATE_TYPE POINTER_ALIGNMENT Type;
      POWER_STATE POINTER_ALIGNMENT      State;
      POWER_ACTION POINTER_ALIGNMENT     ShutdownType;
    } Power;
#endif
    struct {
      PCM_RESOURCE_LIST AllocatedResources;
      PCM_RESOURCE_LIST AllocatedResourcesTranslated;
    } StartDevice;
    struct {
      ULONG_PTR ProviderId;
      PVOID     DataPath;
      ULONG     BufferSize;
      PVOID     Buffer;
    } WMI;
    struct {
      PVOID Argument1;
      PVOID Argument2;
      PVOID Argument3;
      PVOID Argument4;
    } Others;
  } Parameters;
  PDEVICE_OBJECT         DeviceObject;
  PFILE_OBJECT           FileObject;
  PIO_COMPLETION_ROUTINE CompletionRoutine;
  PVOID                  Context;
} IO_STACK_LOCATION, *PIO_STACK_LOCATION;

成员

MajorFunction

指示要执行的 I/O 操作类型的 IRP 主要函数代码

MinorFunction

MajorFunction 的子函数代码。 PnP 管理器、电源管理器、文件系统驱动程序和 SCSI 类驱动程序为某些请求设置此成员。

Flags

特定于请求类型的值几乎完全由文件系统驱动程序使用。 可移动媒体设备驱动程序检查是否为读取请求设置此成员SL_OVERRIDE_VERIFY_VOLUME,以确定是否继续读取操作,即使设备对象的标志设置为DO_VERIFY_VOLUME。 分层在可移动媒体设备驱动程序上的中间驱动程序必须将此成员复制到所有传入 IRP_MJ_READ 请求中下一个较低驱动程序的 I/O 堆栈位置。

有关IRP_MJ_CREATE的其他 SL_* 标志的文档,请参阅 IRP_MJ_CREATE (IFS)

可能的标志值包括:

标志 说明
SL_KEY_SPECIFIED 0x01 指示 IO_STACK_LOCATION.Parameters.Read(OrWrite).Key 包含启用冗余时应读取给定扇区的副本。 目前,此标志仅用于IRP_MJ_READ操作。
SL_OVERRIDE_VERIFY_VOLUME 0x02 此标志用于确定是否继续读取操作,即使设备对象的 Flags 是使用 DO_VERIFY_VOLUME 设置的。
SL_WRITE_THROUGH 0x04 此标志通知存储驱动程序设置适当的标志,以便磁盘绕过写入缓存,以强制磁盘写入其永久性存储媒体。 此标志特定于设备;并非所有磁盘驱动器都支持绕过磁盘缓存。
SL_FT_SEQUENTIAL_WRITE 0x08 预留给系统使用。
SL_FORCE_DIRECT_WRITE 0x10 此标志允许内核模式驱动程序写入由于阻止文件系统和存储驱动程序堆栈中的直接写入而通常无法写入的卷区域。 直接写入阻止有助于提高安全性。 此标志在文件系统层和存储堆栈层进行检查。 有关直接写入阻止的详细信息,请参阅 阻止对卷和磁盘的直接写入操作
SL_REALTIME_STREAM 0x20 此标志提示 IO 用于对 CD-ROM 类驱动程序的实时流式处理请求。 这提示驱动程序以保证的速度执行读取/写入操作,以便进行实时流式处理。 此标志仅对光学介质有效。
SL_PERSISTENT_MEMORY_FIXED_MAPPING 0x20 处理此写入请求时,写入请求中字节的永久性内存映射无法更改。 此标志仅对永久性内存设备和IRP_MJ_WRITE有效。

对于永久性内存设备,重新映射 (修改永久性内存设备上给定 LBA) 的物理地址的原因之一是提供高效的扇区级原子性。 如果未设置标志,则允许重新映射,尤其是当它导致驱动程序提供扇区原子性时。 文件系统 (或请求者) 首选永久性内存设备驱动程序提供扇区原子性。 如果设置了标志,则永久性内存驱动程序不应重新映射与 LBA 对应的物理地址。 如果这意味着无法提供扇区原子性,那么就这样吧。 但是,只要没有重新映射,驱动程序就非常欢迎提供扇区原子性。

Control

驱动程序可以检查此成员,以确定它是否使用 SL_PENDING_RETURNED 进行设置,并在什么条件下调用 CompletionRoutine。 驱动程序对此成员具有只读访问权限。 驱动程序调用 IoSetCompletionRoutineIoSetCompletionRoutineEx 来指定这些条件。

Parameters

依赖于 MajorFunction 和 MinorFunction 中包含的主 IRP 函数代码值和次要 IRP 函数代码值的 联合。 下表显示了哪些 IRP 使用 Parameters 联合的各个成员。

成员名称 使用此成员的 IRP
创建 IRP_MJ_CREATE
读取 IRP_MJ_READ
写入 IRP_MJ_WRITE
QueryFile IRP_MJ_QUERY_INFORMATION
SetFile IRP_MJ_SET_INFORMATION
QueryVolume IRP_MJ_QUERY_VOLUME_INFORMATION
DeviceIoControl IRP_MJ_DEVICE_CONTROLIRP_MJ_INTERNAL_DEVICE_CONTROL
MountVolume IRP_MN_MOUNT_VOLUME
VerifyVolume IRP_MN_VERIFY_VOLUME
Scsi IRP_MJ_INTERNAL_DEVICE_CONTROL (SCSI)
QueryDeviceRelations IRP_MN_QUERY_DEVICE_RELATIONS
QueryInterface IRP_MN_QUERY_INTERFACE
DeviceCapabilities IRP_MN_QUERY_CAPABILITIES
FilterResourceRequirements IRP_MN_FILTER_RESOURCE_REQUIREMENTS
ReadWriteConfig IRP_MN_READ_CONFIGIRP_MN_WRITE_CONFIG
SetLock IRP_MN_SET_LOCK
QueryId IRP_MN_QUERY_ID
QueryDeviceText IRP_MN_QUERY_DEVICE_TEXT
UsageNotification IRP_MN_DEVICE_USAGE_NOTIFICATION
WaitWake IRP_MN_WAIT_WAKE
PowerSequence IRP_MN_POWER_SEQUENCE
电源 IRP_MN_SET_POWERIRP_MN_QUERY_POWER
StartDevice IRP_MN_START_DEVICE
WMI WMI 次要 IRP
其他 特定于驱动程序的 IRP

有关详细信息,请参阅 IRP 主要函数代码

Parameters.Create

NtCreateFile 的系统服务参数。

Parameters.Create.SecurityContext

Parameters.Create.Options

Parameters.Create.FileAttributes

Parameters.Create.ShareAccess

Parameters.Create.EaLength

Parameters.CreatePipe

系统服务参数 fo NtCreateNamedPipeFile

Parameters.CreatePipe.SecurityContext

Parameters.CreatePipe.Options

Parameters.CreatePipe.Reserved

Parameters.CreatePipe.ShareAccess

Parameters.CreatePipe.Parameters

Parameters.CreateMailslot

NtCreateMailslotFile 的系统服务参数。

Parameters.CreateMailslot.SecurityContext

Parameters.CreateMailslot.Options

Parameters.CreateMailslot.Reserved

Parameters.CreateMailslot.ShareAccess

Parameters.CreateMailslot.Parameters

Parameters.Read

NtReadFile 的系统服务参数。

Parameters.Read.Length

Parameters.Read.Key

Parameters.Read.Flags

Parameters.Read.ByteOffset

Parameters.Write

NtWriteFile 的系统服务参数。

Parameters.Write.Length

Parameters.Write.Key

Parameters.Write.Flags

Parameters.Write.ByteOffset

Parameters.QueryDirectory

NtQueryDirectoryFile 的系统服务参数。

Parameters.QueryDirectory.Length

Parameters.QueryDirectory.FileName

Parameters.QueryDirectory.FileInformationClass

Parameters.QueryDirectory.FileIndex

Parameters.NotifyDirectory

NtNotifyChangeDirectoryFile 的系统服务参数。

Parameters.NotifyDirectory.Length

Parameters.NotifyDirectory.CompletionFilter

Parameters.NotifyDirectoryEx

NtNotifyChangeDirectoryFileEx 的系统服务参数。

Parameters.NotifyDirectoryEx.Length

Parameters.NotifyDirectoryEx.CompletionFilter

Parameters.NotifyDirectoryEx.DirectoryNotifyInformationClass

Parameters.QueryFile

NtQueryInformationFile 的系统服务参数。

Parameters.QueryFile.Length

Parameters.QueryFile.FileInformationClass

Parameters.SetFile

NtSetInformationFile 的系统服务参数。

Parameters.SetFile.Length

Parameters.SetFile.FileInformationClass

Parameters.SetFile.FileObject

Parameters.SetFile.ReplaceIfExists

Parameters.SetFile.AdvanceOnly

Parameters.SetFile.ClusterCount

Parameters.SetFile.DeleteHandle

Parameters.QueryEa

NtQueryEaFile 的系统服务参数。

Parameters.QueryEa.Length

Parameters.QueryEa.EaList

Parameters.QueryEa.EaListLength

Parameters.QueryEa.EaIndex

Parameters.SetEa

NtSetEaFile 的系统服务参数。

Parameters.SetEa.Length

Parameters.QueryVolume

NtQueryVolumeInformationFile 的系统服务参数。

Parameters.QueryVolume.Length

Parameters.QueryVolume.FsInformationClass

Parameters.SetVolume

NtSetVolumeInformationFile 的系统服务参数。

Parameters.SetVolume.Length

Parameters.SetVolume.FsInformationClass

Parameters.FileSystemControl

NtFsControlFile 的系统服务参数。

Parameters.FileSystemControl.OutputBufferLength

Parameters.FileSystemControl.InputBufferLength

Parameters.FileSystemControl.FsControlCode

Parameters.FileSystemControl.Type3InputBuffer

Parameters.LockControl

LockFile/NtUnlockFile 的系统服务参数。

Parameters.LockControl.Length

Parameters.LockControl.Key

Parameters.LockControl.ByteOffset

Parameters.DeviceIoControl

NtDeviceIoControlFile 的系统服务参数。

Parameters.DeviceIoControl.OutputBufferLength

Parameters.DeviceIoControl.InputBufferLength

Parameters.DeviceIoControl.IoControlCode

Parameters.DeviceIoControl.Type3InputBuffer

Parameters.QuerySecurity

NtQuerySecurityObject 的系统服务参数。

Parameters.QuerySecurity.SecurityInformation

Parameters.QuerySecurity.Length

Parameters.SetSecurity

NtSetSecurityObject 的系统服务参数。

Parameters.SetSecurity.SecurityInformation

Parameters.SetSecurity.SecurityDescriptor

Parameters.MountVolume

MountVolume 的系统服务参数。

Parameters.MountVolume.Vpb

Parameters.MountVolume.DeviceObject

Parameters.MountVolume.OutputBufferLength

Parameters.VerifyVolume

VerifyVolume 的系统服务参数。

Parameters.VerifyVolume.Vpb

Parameters.VerifyVolume.DeviceObject

Parameters.Scsi

具有内部设备控制的 Scsi 的参数。

Parameters.Scsi.Srb

Parameters.QueryQuota

NtQueryQuotaInformationFile 的系统服务参数。

Parameters.QueryQuota.Length

Parameters.QueryQuota.StartSid

Parameters.QueryQuota.SidList

Parameters.QueryQuota.SidListLength

Parameters.SetQuota

NtSetQuotaInformationFile 的系统服务参数。

Parameters.SetQuota.Length

Parameters.QueryDeviceRelations

IRP_MN_QUERY_DEVICE_RELATIONS的参数。

Parameters.QueryDeviceRelations.Type

Parameters.QueryInterface

IRP_MN_QUERY_INTERFACE的参数。

Parameters.QueryInterface.InterfaceType

Parameters.QueryInterface.Size

Parameters.QueryInterface.Version

Parameters.QueryInterface.Interface

Parameters.QueryInterface.InterfaceSpecificData

Parameters.DeviceCapabilities

IRP_MN_QUERY_CAPABILITIES的参数。

Parameters.DeviceCapabilities.Capabilities

Parameters.FilterResourceRequirements

IRP_MN_FILTER_RESOURCE_REQUIREMENTS的参数。

Parameters.FilterResourceRequirements.IoResourceRequirementList

Parameters.ReadWriteConfig

IRP_MN_READ_CONFIG和IRP_MN_WRITE_CONFIG的参数。

Parameters.ReadWriteConfig.WhichSpace

Parameters.ReadWriteConfig.Buffer

Parameters.ReadWriteConfig.Offset

Parameters.ReadWriteConfig.Length

Parameters.SetLock

IRP_MN_SET_LOCK的参数。

Parameters.SetLock.Lock

Parameters.QueryId

IRP_MN_QUERY_ID的参数。

Parameters.QueryId.IdType

Parameters.QueryDeviceText

IRP_MN_QUERY_DEVICE_TEXT的参数。

Parameters.QueryDeviceText.DeviceTextType

Parameters.QueryDeviceText.LocaleId

Parameters.UsageNotification

IRP_MN_DEVICE_USAGE_NOTIFICATION的参数。

Parameters.UsageNotification.InPath

Parameters.UsageNotification.Reserved[3]

Parameters.UsageNotification.Type

Parameters.WaitWake

IRP_MN_WAIT_WAKE的参数。

Parameters.WaitWake.PowerState

Parameters.PowerSequence

IRP_MN_POWER_SEQUENCE的参数。

Parameters.PowerSequence.PowerSequence

Parameters.Power

IRP_MN_SET_POWER和IRP_MN_QUERY_POWER的参数。

Parameters.Power.SystemContext

Parameters.Power.SystemPowerStateContext

Parameters.Power.Type

Parameters.Power.State

Parameters.Power.ShutdownType

Parameters.StartDevice

StartDevice 的参数。

Parameters.StartDevice.AllocatedResources

Parameters.StartDevice.AllocatedResourcesTranslated

Parameters.WMI

WMI IRP 的参数。

Parameters.WMI.ProviderId

Parameters.WMI.DataPath

Parameters.WMI.BufferSize

Parameters.WMI.Buffer

Parameters.Others

其他特定于驱动程序的操作的参数。

Parameters.Others.Argument1

Parameters.Others.Argument2

Parameters.Others.Argument3

Parameters.Others.Argument4

DeviceObject

指向驱动程序创建的 DEVICE_OBJECT 结构的指针,该结构表示此驱动程序要处理 IRP 的目标物理、逻辑或虚拟设备。

FileObject

指向 FILE_OBJECT 结构的指针,该结构表示与 DeviceObject 指针关联的文件对象(如果有)。

CompletionRoutine

根据此结构的 Control 字段中的标志调用的完成例程。

Context

驱动程序定义的上下文,用于存储传递给 CompletionRoutine 的上下文参数的地址。

注解

对于每个 IRP,驱动程序堆栈中的每个驱动程序都有一个IO_STACK_LOCATION结构。 每个 IRP 的 I/O 堆栈位置集都追加到 IRP,遵循 IRP 结构。

每个更高级别的驱动程序都负责为每个 IRP 中下一个较低级别的驱动程序设置 I/O 堆栈位置。 驱动程序必须调用 IoGetCurrentIrpStackLocation 以获取指向每个 IRP 的自己的堆栈位置的指针。 更高级别的驱动程序可以调用 IoGetNextIrpStackLocation 来获取指向下一个较低级别驱动程序的堆栈位置的指针。

在调用 IoCallDriver 将 IRP 传递给较低级别的驱动程序之前,较高级别的驱动程序必须设置堆栈位置内容。 如果驱动程序将输入 IRP 传递到下一个较低级别的驱动程序,则调度例程应调用 IoSkipCurrentIrpStackLocationIoCopyCurrentIrpStackLocationToNext 来设置下一个较低级别的驱动程序的 I/O 堆栈位置。

更高级别的驱动程序对 IoCallDriver 的调用将 DeviceObject 成员设置为较低级别驱动程序的 I/O 堆栈位置中的下一个较低级别驱动程序的目标设备对象。 当 IRP 完成后调用 IoCompletion 例程时,I/O 管理器会将每个更高级别驱动程序的 IoCompletion 例程传递指向其自己的设备对象的指针。

如果较高级别的驱动程序分配 IRP 以发出自己的请求,则如果该驱动程序既不为自己分配堆栈位置,也没有在新分配的 IRP 的自己的堆栈位置中设置 DeviceObject 指针,则会向其 IoCompletion 例程传递 NULLDeviceObject 指针。

在某些情况下,在大容量存储设备驱动程序上分层的更高级别驱动程序负责拆分基础设备驱动程序的大型传输请求。 具体而言,SCSI 类驱动程序必须检查 Parameters.Read.LengthParameters.Write.Length,确定请求的传输大小是否超出基础 HBA 的传输功能,如果是,则将原始请求的 Length 拆分为部分传输序列以满足原始 IRP。

要求

要求
标头 wdm.h(包括 Wdm.h、Ntddk.h、Ntifs.h)

另请参阅

IO_STATUS_BLOCK

IRP

IoCallDriver

IoCopyCurrentIrpStackLocationToNext

IoGetCurrentIrpStackLocation

IoGetNextIrpStackLocation

IoSetCompletionRoutine

IoSetNextIrpStackLocation

IoSkipCurrentIrpStackLocation