• 驱动读写方式


     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);
  • 相关阅读:
    2013.11.3
    计算机面试书籍
    SDPLR的安装过程(matlab)
    Semi-definite programming优化工具
    R-note1
    Ubuntu---2
    C#中DataTable转换为string
    MFC获取字符串长度的5中方法
    根据不同的操作系统(64/32),设置文件以64位运行。又可解决问题:“试图加载不正确的程序”。
    WinServer2008下通过powershell获取IIS等角色功能列表,保存至txt
  • 原文地址:https://www.cnblogs.com/endenvor/p/11526464.html
Copyright © 2020-2023  润新知