IoCallDriver()简析

NTSTATUS IofCallDriver(IN PDEVICE_OBJECT DeviceObject,
                      IN OUT PIRP Irp)
{
    if(*pIofCallDriver)//je 0x1d
    {
        return pIofCallDriver(DeviceObject,Irp);
    }
    Irp->CurrentLocation--;
    if(!Irp->CurrentLocation)//jg 0x30
    {
        KeBugCheckEx(0x35,Irp,0,0,0);//# define NO_MORE_IRP_STACK_LOCATIONS 0x35
        // int 3
    }
    Irp->PacketType-=0x24;//IRP结构体在偏移为0x60处是一个union结构
    Irp->CurrentStackLocation->DeviceObject=DeviceObject;
    if(Irp->CurrentStackLocation->MajorFunction==0x16) //jne 0x4e 
    {
        //#define IRP_MJ_POWER 0x16
        if((Irp->CurrentStackLocation->MinorFunction==2)||
            (Rrp->CurrentStackLocation->MinorFunctin==3))
        {
            return IopPoHandleIrp(Irp);
        }
    }
    //调用驱动程序提供的IRP处理函数
    return DeviceObject->DriverObject->MajorFunction[4*
        Irp->CurrentStackLocation->MajorFunction](DeviceObject,Irp);
}

IoCallDriver将参数往下传递调用IofCallDriver()。首先检查全局指针pIofCallDriver是否为空,不为空就调用;为空,去检查第二个参数,如果CurrentLoaction==1,调用KeBugCheckEx()进行相关Bug检测。之后对照注释看,比较详细。

你可能感兴趣的:(c)