3.2 页面异常-2

系列文章目录

文章目录


IoPageRead()

c 复制代码
/*
 * @implemented
 */
NTSTATUS
NTAPI
IoPageRead(IN PFILE_OBJECT FileObject,
           IN PMDL Mdl,
           IN PLARGE_INTEGER Offset,
           IN PKEVENT Event,
           IN PIO_STATUS_BLOCK StatusBlock)
{
    PIRP Irp;
    PIO_STACK_LOCATION StackPtr;
    PDEVICE_OBJECT DeviceObject;
    IOTRACE(IO_API_DEBUG, "FileObject: %p. Mdl: %p. Offset: %p \n",
            FileObject, Mdl, Offset);

    /* Get the Device Object */
    DeviceObject = IoGetRelatedDeviceObject(FileObject);

    /* Allocate IRP */
    Irp = IoAllocateIrp(DeviceObject->StackSize, FALSE);
    if (!Irp) return STATUS_INSUFFICIENT_RESOURCES;

    /* Get the Stack */
    StackPtr = IoGetNextIrpStackLocation(Irp);

    /* Create the IRP Settings */
    Irp->MdlAddress = Mdl;
    Irp->UserBuffer = MmGetMdlVirtualAddress(Mdl);
    Irp->UserIosb = StatusBlock;
    Irp->UserEvent = Event;
    Irp->RequestorMode = KernelMode;
    Irp->Flags = IRP_PAGING_IO |
                 IRP_NOCACHE |
                 IRP_SYNCHRONOUS_PAGING_IO |
                 IRP_INPUT_OPERATION;
    Irp->Tail.Overlay.OriginalFileObject = FileObject;
    Irp->Tail.Overlay.Thread = PsGetCurrentThread();

    /* Set the Stack Settings */
    StackPtr->Parameters.Read.Length = MmGetMdlByteCount(Mdl);
    StackPtr->Parameters.Read.ByteOffset = *Offset;
    StackPtr->MajorFunction = IRP_MJ_READ;
    StackPtr->FileObject = FileObject;

    /* Call the Driver */
    return IofCallDriver(DeviceObject, Irp);
}


 
相关推荐
阿正的梦工坊1 小时前
Unix 进程的启动方式及经典和现代做法(中英双语)
服务器·unix
OpenC++1 小时前
【C++】线程池实现
开发语言·c++·经验分享·算法·leetcode·设计模式
阿正的梦工坊1 小时前
什么是 Shell?常见的 Unix Shell有哪些?(中英双语)
linux·服务器·unix
x-duck12 小时前
【SSM】Spring + SpringMVC + Mybatis
java·spring·mybatis
学会沉淀。3 小时前
redis实战(商品查询缓存)
java·redis·缓存
ufosuai5553 小时前
HTML基本语法
前端·html
yang_shengy4 小时前
【JavaEE】Spring(7):统一功能处理
java·spring·java-ee
gyeolhada4 小时前
2025蓝桥杯JAVA编程题练习Day2
java·数据结构·算法·蓝桥杯
慕斯-ing4 小时前
Vue指令v-on
前端·vue.js·经验分享
树毅vs素忆5 小时前
chrome浏览器chromedriver下载
前端·chrome