IoCallDriver source code analysis

Source: Internet
Author: User

 

IoCallDriver is a macro:

#define IoCallDriver(a,b)   \        IofCallDriver(a,b)

Apparently, IofCallDriver () is used ();

The IofCallDriver () code is as follows:

NTSTATUSFASTCALLIofCallDriver(    IN PDEVICE_OBJECT DeviceObject,    IN OUT PIRP Irp    ){    if (pIofCallDriver != NULL) {        //        // This routine will either jump immediately to IovCallDriver or        // IoPerfCallDriver.        //        return pIofCallDriver(DeviceObject, Irp, _ReturnAddress());    }    return IopfCallDriver(DeviceObject, Irp);}
PIofCallDriver seems to be (defined in the header file)
extern PIO_CALL_DRIVER        pIofCallDriver;

PIO_CALL_DRIVER is a function pointer.

typedefNTSTATUS(FASTCALL *PIO_CALL_DRIVER) (    IN      PDEVICE_OBJECT  DeviceObject,    IN OUT  PIRP            Irp,    IN      PVOID           ReturnAddress    );

 

IopfCallDriver
NTSTATUSFORCEINLINEIopfCallDriver (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 to point to the next location.
// The larger the array label of the visible Irp indicates the higher the top-layer device // Irp-> CurrentLocation --; if (Irp-> CurrentLocation <= 0) {KiBugCheck3 (NO_MORE_IRP_STACK_LOCATIONS, (ULONG_PTR) irp, 0, 0);} irpSp = IoGetNextIrpStackLocation (Irp); Irp-> Tail. overlay. currentStackLocation = irpSp; // Save a pointer to the 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; // Prevent the driver from unloading. // call status = driverObject-> MajorFunction [irpSp-> MajorFunction] (DeviceObject, Irp); return status ;}

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.