GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.easefilter.com — Understanding I/O Request Packets(IRPs) What is I/O Request Packets(IRPs)?Start Building Your Security PoC TodayGet the full-featured 30-day trial SDK for free. Includes pre-built C# /C++/Python/Rust/Java templates to test file, process, and registry security instantly. I/O request packetI/O request packets (IRPs) are kernel mode structures that are used by Windows Driver Model (WDM) and Windows NT device drivers to communicate with each other and with the operating system. They are data structures that describe I/O requests, and can be equally well thought of as "I/O request descriptors" or similar. Rather than passing a large number of small arguments (such as buffer address, buffer size, I/O function type, etc.) to a driver, all of these parameters are passed via a single pointer to this persistent data structure. The IRP with all of its parameters can be put on a queue if the I/O request cannot be performed immediately. I/O completion is reported back to the I/O manager by passing its address to a routine for that purpose, IoCompleteRequest. The IRP may be repurposed as a special kernel APC object if such is required to report completion of the I/O to the requesting thread. IRPs are typically created by the I/O Manager in response to I/O requests from user mode. IRP structure typedef struct _IRP {
CSHORT Type;
USHORT Size;
PMDL MdlAddress;
ULONG Flags;
union {
struct _IRP *MasterIrp;
__volatile LONG IrpCount;
PVOID SystemBuffer;
} AssociatedIrp;
LIST_ENTRY ThreadListEntry;
IO_STATUS_BLOCK IoStatus;
KPROCESSOR_MODE RequestorMode;
BOOLEAN PendingReturned;
CHAR StackCount;
CHAR CurrentLocation;
BOOLEAN Cancel;
KIRQL CancelIrql;
CCHAR ApcEnvironment;
UCHAR AllocationFlags;
PIO_STATUS_BLOCK UserIosb;
PKEVENT UserEvent;
union {
struct {
union {
PIO_APC_ROUTINE UserApcRoutine;
PVOID IssuingProcess;
};
PVOID UserApcContext;
} AsynchronousParameters;
LARGE_INTEGER AllocationSize;
} Overlay;
__volatile PDRIVER_CANCEL CancelRoutine;
PVOID UserBuffer;
union {
struct {
union {
KDEVICE_QUEUE_ENTRY DeviceQueueEntry;
struct {
PVOID DriverContext[4];
};
};
PETHREAD Thread;
PCHAR AuxiliaryBuffer;
struct {
LIST_ENTRY ListEntry;
union {
struct _IO_STACK_LOCATION *CurrentStackLocation;
ULONG PacketType;
};
};
PFILE_OBJECT OriginalFileObject;
} Overlay;
KAPC Apc;
PVOID CompletionKey;
} Tail;
} IRP;
MembersType 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: IRP_MJ_READThe MDL describes an empty buffer that the device or driver fills in. IRP_MJ_WRITEThe MDL describes a buffer that contains data for the device or driver. IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROLIf the IOCTL code specifies the METHOD_IN_DIRECT transfer type, the MDL describes a buffer that contains data for the device or driver. If the IOCTL code specifies the METHOD_OUT_DIRECT transfer type, the MDL describes an empty buffer that the device or driver fills in. 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. If the driver is not using direct I/O, this pointer is 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. 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: SystemBuffer.IRP_MJ_READThe 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. NULL. SystemBuffer.IRP_MJ_WRITEThe 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. NULL. SystemBuffer.IRP_MJ_DEVICE_CONTROL or IRP_MJ_INTERNAL_DEVICE_CONTROLThe buffer represents both the input and output buffers that are supplied to DeviceIoControl and IoBuildDeviceIoControlRequest. Output data overwrites input data. For input, the buffer's length is specified by Parameters.DeviceIoControl.InputBufferLength in the driver's IO_STACK_LOCATION structure. For output, the buffer's length is specified by Parameters.DeviceIoControl.OutputBufferLength in the driver's IO_STACK_LOCATION structure. For more information, see Buffer Descriptions for I/O Control Codes. 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: ThreadListEntry IoStatus Contains the IO_STATUS_BLOCK structure in which a driver stores status and information before calling IoCompleteRequest. RequestorMode Indicates the execution mode of the original requester of the operation, one of UserMode or 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. StackCount CurrentLocation Cancel If set to TRUE, the IRP either is or should be canceled. CancelIrql Contains the IRQL at which a driver is running when IoAcquireCancelSpinLock is called. 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. UserBuffer Contains the address of an output buffer if both of the following conditions apply:
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. 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. 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. 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. Tail.Overlay.CurrentStackLocation Tail.Overlay.PacketType Tail.Overlay.OriginalFileObject Tail.Apc Tail.CompletionKey RemarksUndocumented members of the IRP structure are reserved, used only by the I/O manager or, in some cases, by 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 Major Function CodesEach driver-specific I/O stack location (IO_STACK_LOCATION) for every IRP contains a major function code (IRP_MJ_XXX), which tells the driver what operation it or the underlying device driver should carry out to satisfy the I/O request. Each kernel-mode driver must provide dispatch routines for the major function codes that it must support. The specific operations a driver carries out for a given IRP_MJ_XXX code depend somewhat on the underlying device, particularly for IRP_MJ_DEVICE_CONTROL and IRP_MJ_INTERNAL_DEVICE_CONTROL requests. For example, the requests sent to a keyboard driver are necessarily somewhat different from those sent to a disk driver. However, the I/O manager defines the parameters and I/O stack location contents for each system-defined major function code. Every higher-level driver must set up the appropriate I/O stack location in IRPs for the next-lower-level driver and call IoCallDriver, either with each input IRP, or with a driver-created IRP (if the higher-level driver holds on to the input IRP). Consequently, every intermediate driver must supply a dispatch routine for each major function code that the underlying device driver handles. Otherwise, a new intermediate driver will "break the chain" whenever an application or still higher-level driver attempts to send an I/O request down to the underlying device driver. File system drivers also handle a required subset of system-defined IRP_MJ_XXX function codes, some with subordinate IRP_MN_XXX function codes. Drivers handle IRPs set with some or all of the following major function codes: ABOUT USWe specialize in file system filter driver development. We architect, implement and test file system filter drivers for a wide range of functionalities. We can offer several levels of assistance to meet your specific needs. SUBSCRIBECONTACT US
COPYRIGHT EASEFILTER, ALL RIGHT RESERVED. |
| You are visitor 01402792 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |