• 驱动读写方式


     1 PIO_STACK_LOCATION isl = IoGetCurrentIrpStackLocation(pIrp);
     2 
     3     //Read & Write Length
     4     ULONG dwInSize = isl->Parameters.Read.Length;
     5     ULONG dwOutSize = isl->Parameters.Write.Length;
     6 
     7     //In & Out Buffer DO_BUFFERED_IO
     8     PVOID pInBuffer = pIrp->AssociatedIrp.SystemBuffer;
     9     PVOID pOutBuffer = pIrp->AssociatedIrp.SystemBuffer;
    10 
    11     //In & Out Buffer DO_DIRECT_IO 
    12     pInBuffer = MmGetSystemAddressForMdlSafe(pIrp->MdlAddress, NormalPagePriority);
    13     pOutBuffer = MmGetSystemAddressForMdlSafe(pIrp->MdlAddress, NormalPagePriority);
    14 
    15     //In & Out Buffer DO_DIRECT_IO 
    16     ProbeForRead(pIrp->UserBuffer, dwInSize, 4);
    17     pInBuffer = pIrp->UserBuffer;
    18     ProbeForWrite(pIrp->UserBuffer, dwOutSize, 4);
    19     pOutBuffer = pIrp->UserBuffer;
    20 
    21     //Io control device
    22     ULONG dwCtrlCoder = isl->Parameters.DeviceIoControl.IoControlCode;
    23     //Read & Write Length
    24     dwInSize = isl->Parameters.DeviceIoControl.InputBufferLength;
    25     dwOutSize = isl->Parameters.DeviceIoControl.OutputBufferLength;
    26     
    27     //In & Out Buffer METHOD_BUFFERED || METHOD_IN_DIRECT || METHOD_OUT_DIRECT || METHOD_NEITHER I/O
    28     pInBuffer = pIrp->AssociatedIrp.SystemBuffer;
    29     pOutBuffer = pIrp->AssociatedIrp.SystemBuffer;
    30 
    31     //In & Out Buffer METHOD_IN_DIRECT || METHOD_OUT_DIRECT
    32     pInBuffer = pIrp->AssociatedIrp.SystemBuffer;
    33     pOutBuffer = MmGetSystemAddressForMdlSafe(pIrp->MdlAddress, NormalPagePriority);
    34 
    35     //In & Out Buffer METHOD_NEITHER I/O
    36     
    37     pInBuffer = isl->Parameters.DeviceIoControl.Type3InputBuffer;
    38     ProbeForRead(pInBuffer, dwInSize, 4);
    39     pOutBuffer = pIrp->UserBuffer;
    40     ProbeForRead(pOutBuffer, dwOutSize, 4);
  • 相关阅读:
    面向对象与组合
    异常处理和三级菜单练习
    装饰器和生成器
    序列化模块
    leetcode_498. 对角线遍历
    leetcode_566. 重塑矩阵
    leetcode_59. 螺旋矩阵 II
    leetcode_54. 螺旋矩阵
    leetcode_396. 旋转函数
    leetcode_200. 岛屿数量
  • 原文地址:https://www.cnblogs.com/endenvor/p/11526464.html
Copyright © 2020-2023  润新知