Io_stack_location Structure
The io_stack_location structure defines an I/O
Stack location
, Which is an entry in the I/O stack that is
Associated with Each IRP. Each I/O stack location in an IRP has some
Common members and some request-type-specific members.
Typedef struct _ io_stack_location {<br/> uchar majorfunction; <br/> uchar minorfunction; <br/> uchar flags; <br/> uchar control; <br/> // The following user parameters are based on the service that is being <br/> // invoked. drivers and file systems can determine which set to use based <br/> // on the above major and minor function codes. <br/> // <br/> Union {<br/> // system service parameters: ntcreatefile <br/> // <br/> struct {<br/> pio_security_context securitycontext; <br/> ulong options; <br/> ushort pointer_alignment fileattributes; <br/> ushort encrypted access; <br/> ulong pointer_alignment ealength; <br/>} create; </P> <p> // <br/> // system service parameters for: ntreadfile <br/> // <br/> struct {<br/> ulong length; <br/> ulong pointer_alignment key; <br/> large_integer byteoffset; <br/>} read; <br/> // system service parameters: ntwritefile <br/> // <br/> struct {<br/> ulong length; <br/> ulong pointer_alignment key; <br/> large_integer byteoffset; <br/>} write; </P> <p> // <br/> // system service parameters: ntqueryinformationfile <br/> // <br/> struct {<br/> ulong length; <br/> file_information_class pointer_alignment fileinformationclass; <br/>} queryfile; <br/> // system service parameters for: ntsetinformationfile <br/> // <br/> struct {<br/> ulong length; <br/> file_information_class pointer_alignment fileinformationclass; <br/> pfile_object fileobject; <br/> Union {<br/> struct {<br/> Boolean replaceifexists; <br/> Boolean advanceonly; <br/>}; <br/> ulong clustercount; <br/> handle deletehandle; <br/>}; <br/>} setfile; </P> <p> // <br/> // system service parameters for: ntqueryvolumeinformationfile <br/> // <br/> struct {<br/> ulong length; <br/> fs_information_class pointer_alignment fsinformationclass; <br/>}queryvolume; </P> <p> // <br/> // system service parameters: ntflushbuffersfile <br/> // no extra user-supplied parameters. <br/> // </P> <p> // <br/> // system service parameters: ntdeviceiocontrolfile <br/> // note that the user's output buffer is stored in the userbuffer field <br/> // and the user's input buffer is stored in the systembuffer field. <br/> // <br/> struct {<br/> ulong outputbufferlength; <br/> ulong pointer_alignment inputbufferlength; <br/> ulong pointer_alignment iocontrolcode; <br/> pvoid type3inputbuffer; <br/>} deviceiocontrol; <br/> // end_wdm <br/> // system service parameters: ntquerysecurityobject <br/> // <br/> struct {<br/> security_information securityinformation; <br/> ulong pointer_alignment length; <br/>} querysecurity; <br/> // system service parameters for: ntsetsecurityobject <br/> // <br/> struct {<br/> security_information securityinformation; <br/> psecurity_descriptor securitydescriptor; <br/>}setsecurity; <br/> // begin_wdm <br/> // non-system service parameters. <br/> // parameters for mountvolume <br/> // <br/> struct {<br/> pvpb VPB; <br/> pdevice_object deviceobject; <br/>} mountvolume; <br/> // parameters for verifyvolume <br/> // <br/> struct {<br/> pvpb VPB; <br/> pdevice_object deviceobject; <br/>} verifyvolume; <br/> // parameters for SCSI with internal device contorl. <br/> // <br/> struct {<br/> struct _ scsi_request_block * sulfate; <br/>} SCSI; </P> <p> // <br/> // parameters for irp_mn_query_device_relations <br/> // <br/> struct {<br/> device_relation_type; <br/>} querydevicerelations; <br/> // parameters for irp_mn_query_interface <br/> // <br/> struct {<br/> const guid * interfacetype; <br/> ushort size; <br/> ushort version; <br/> pinterface interface; <br/> pvoid interfacespecificdata; <br/>} QueryInterface; <br/> // end_ntifs <br/> // parameters for irp_mn_query_capabilities <br/> // <br/> struct {<br/> pdevice_capabilities capabilities; <br/>} devicecapabilities; <br/> // parameters for irp_mn_filter_resource_requirements <br/> // <br/> struct {<br/> pio_resource_requirements_list ioresourcerequirementlist; <br/>} filterresourcerequirements; <br/> // parameters for irp_mn_read_config and irp_mn_write_config <br/> // <br/> struct {<br/> ulong whicheat ace; <br/> pvoid buffer; <br/> ulong offset; <br/> ulong pointer_alignment length; <br/>} readwriteconfig; <br/> // parameters for irp_mn_set_lock <br/> // <br/> struct {<br/> Boolean lock; <br/>} setlock; <br/> // parameters for irp_mn_query_id <br/> // <br/> struct {<br/> bus_query_id_type idtype; <br/>} queryid; <br/> // parameters for irp_mn_query_device_text <br/> // <br/> struct {<br/> device_text_type devicetexttype; <br/> lcid pointer_alignment localeid; <br/>} querydevicetext; <br/> // parameters for irp_mn_device_usage_notification <br/> // <br/> struct {<br/> Boolean inpath; <br/> Boolean reserved [3]; <br/> device_usage_icationication_type pointer_alignment type; <br/>} usagenotification; <br/> // parameters for irp_mn_wait_wake <br/> // <br/> struct {<br/> system_power_state powerstate; <br/>} waitwake; <br/> // parameter for irp_mn_power_sequence <br/> // <br/> struct {<br/> ppower_sequence powersequence; <br/>} powersequence; <br/> // parameters for irp_mn_set_power and irp_mn_query_power <br/> // <br/> struct {<br/> ulong systemcontext; <br/> power_state_type pointer_alignment type; <br/> power_state pointer_alignment state; <br/> power_action pointer_alignment shutdowntype; <br/>} power; <br/> // parameters for startdevice <br/> // <br/> struct {<br/> pcm_resource_list allocatedresources; <br/> pcm_resource_list allocatedresourcestranslated; <br/>} startdevice; <br/> // begin_ntifs <br/> // parameters for cleanup <br/> // no extra parameters supplied <br />/< br/> // <br/> // WMI IRPs <br/> // <br/> struct {<br/> ulong_ptr providerid; <br/> pvoid datapath; <br/> ulong buffersize; <br/> pvoid buffer; <br/>} WMI; <br/> // others-driver-specific <br/> // <br/> struct {<br/> pvoid argument1; <br/> pvoid argument2; <br/> pvoid argument3; <br/> pvoid argument4; <br/>}others; <br/>} parameters; <br/> // save a pointer to this device driver's device object for this request <br/> // so it can be passed to the completion routine if needed. <br/> // <br/> pdevice_object deviceobject; <br/> // The following location contains a pointer to the file object for this <br/> // <br/> pfile_object fileobject; <br/> // The following routine is invoked depending on the flags in the above <br/> // flags field. <br/> // <br/> pio_completion_routine completionroutine; <br/> // The following is used to store the address of the context parameter <br/> // That shocould be passed to the completionroutine. <br/> // <br/> pvoid context; <br/>} io_stack_location, * pio_stack_location;
Io_stack_location processing process
Define ioskipcurrentirpstacklocation (IRP )/
(IRP)-> currentlocation ++;
/
(IRP)-> tail. Overlay. currentstacklocation ++;
# Define
Iocopycurrentirpstacklocationtonext (IRP)
Value:
{/
Pio_stack_location irpsp ;/
Pio_stack_location nextirpsp ;/
Irpsp = iogetcurrentirpstacklocation (IRP ));/
Nextirpsp =
Iogetnextirpstacklocation (IRP ));/
Rtlcopymemory (nextirpsp,
Irpsp, field_offset (io_stack_location, completionroutine ));/
Nextirpsp-> control = 0 ;}
Ntstatus
Iocalldriver (
In
Pdevice_object deviceobject,
In out pirp
)
{
Return iofcalldriver (deviceobject, IRP );
}
Ntstatus
Fastcall
Iofcalldriver (
In pdevice_object deviceobject,
In out pirp
)
{
//
// This routine will either jump immediately
Iopfcalldriver, or rather
// Iovcalldriver.
//
Return piofcalldriver (deviceobject, IRP );
}
Ntstatus
Fastcall
Iopfcalldriver (
In pdevice_object deviceobject,
In out pirp
)
/* ++
Routine description:
This routine is invoked to pass an I/O
Request Packet (IRP) to another
Driver at its Dispatch routine.
Arguments:
Deviceobject-pointer to device object
To which the IRP shoshould be passed.
IRP-pointer to IRP for request.
Return Value:
Return status from driver's dispatch
Routine.
--*/
{
Pio_stack_location irpsp;
Pdriver_object driverobject;
Ntstatus status;
//
// Ensure that this is really
An I/O request packet.
//
Assert (IRP-> type = io_type_irp );
//
// Update the IRP stack
Point to the next location.
//
IRP-> currentlocation --;
If (IRP-> currentlocation <= 0 ){
Kebugcheckex (no_more_irp_stack_locations, (ulong_ptr) IRP, 0, 0, 0 );
}
Irpsp = iogetnextirpstacklocation (IRP
);
IRP-> tail. Overlay. currentstacklocation = irpsp;
//
// Save a pointer to
Device object for this request so that it can
// Be used later in
Completion.
//
Irpsp-> deviceobject = deviceobject;
//
// Invoke the driver at its
Dispatch routine entry point.
//
Driverobject =
Deviceobject-> driverobject;
Perfinfo_driver_majorfunction_call (IRP,
Irpsp, driverobject );
Status =
Driverobject-> majorfunction [irpsp-> majorfunction] (deviceobject,
IRP );
Perfinfo_driver_majorfunction_return (IRP, irpsp, driverobject );
Return status;
}