博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
设备读写方式
阅读量:6741 次
发布时间:2019-06-25

本文共 2525 字,大约阅读时间需要 8 分钟。

1.缓冲区方式读写操作
1.1 ReadFile 
  读取字节数:stack->Parameters.Read.Length
  
偏移:stack->Parameters.Read.ByteOffset.QuadPart
  输出缓冲区:pIrp->AssociatedIrp.SystemBuffer
  输出字节数:pIrp->IoStatus.Information
 
1.2 WriteFile
  写入字节数:stack->Parameters.Write.Length
  
偏移:stack->Parameters.Write.ByteOffset.QuadPart
  写入缓冲区:pIrp->AssociatedIrp.SystemBuffer
  返回字节数:pIrp->IoStatus.Information
 
1.3 IRP_MJ_QUERY_INFORMATION
  FILE_INFORMATION_CLASS: stack->Parameters.QueryFile.FileInformation
  输入输出缓冲区:pIrp->AssociatedIrp.SystemBuffer
      返回字节数:pIrp->IoStatus.Information=stack->Parameters.QueryFile.Length
 
2.直接方式读写操作
2.1 ReadFile
  读取字节数:stack->Parameters.Read.Length
  
偏移:stack->Parameters.Read.ByteOffset.QuadPart
  输出缓冲区:MmGetSystemAddressForMdlSafe(pIrp->MdlAddress,NormalPagePriority)
  输出字节数:pIrp->IoStatus.Information
 
2.2 WriteFile
  写入字节数:stack->Parameters.Write.Length
  
偏移:stack->Parameters.Write.ByteOffset.QuadPart
  写入缓冲区:MmGetSystemAddressForMdlSafe(pIrp->MdlAddress,NormalPagePriority)
  返回字节数:pIrp->IoStatus.Information
 
3.其他方式读写操作
3.1 ReadFile
  读取字节数:stack->Parameters.Read.Length
  
偏移:stack->Parameters.Read.ByteOffset.QuadPart
  输出缓冲区:ProbeForWrite(pIrp->UserBuffer)
  输出字节数:pIrp->IoStatus.Information
 
3.2 WriteFile
  写入字节数:stack->Parameters.Write.Length
  
偏移:stack->Parameters.Write.ByteOffset.QuadPart
  写入缓冲区:ProbeForRead(pIrp->UserBuffer)
  返回字节数:pIrp->IoStatus.Information
 
 
IO设备控制操作
1.缓冲内存模式IOCTL
 
输入缓冲区大小:stack->Parameters.DeviceIoControl.InputBufferLength
输出缓冲区大小:stack->Parameters.DeviceIoControl.OutputBufferLength
    输入缓冲区:pIrp->AssociatedIrp.SystemBuffer
    输出缓冲区:pIrp->AssociatedIrp.SystemBuffer
 
2.直接内存模式IOCTL之METHOD_IN_DIRECT 
 
输入缓冲区大小:stack->Parameters.DeviceIoControl.InputBufferLength
输出缓冲区大小:stack->Parameters.DeviceIoControl.OutputBufferLength
    输入缓冲区:MmGetSystemAddressForMdlSafe(pIrp->MdlAddress,NormalPagePriority)
    输出缓冲区:pIrp->AssociatedIrp.SystemBuffer
 
 
3.直接内存模式IOCTL之METHOD_OUT_DIRECT 
 
输入缓冲区大小:stack->Parameters.DeviceIoControl.InputBufferLength
输出缓冲区大小:stack->Parameters.DeviceIoControl.OutputBufferLength
    输入缓冲区:MmGetSystemAddressForMdlSafe(pIrp->MdlAddress,NormalPagePriority)
    输出缓冲区:pIrp->AssociatedIrp.SystemBuffer
 
METHOD_IN_DIRECT与METHOD_OUT_DIRECT区别在于打开设备的权限
 
1) 只读权限打开设备,METHOD_IN_DIRECT的IOCTL操作成功,而METHOD_OUT_DIRECT的操作失败
2) 读写权限打开设备,METHOD_IN_DIRECT与METHOD_OUT_DIRECT的IOCTL操作都成功
 
4.其他内存模式IOCTL
 
输入缓冲区大小:stack->Parameters.DeviceIoControl.InputBufferLength
输出缓冲区大小:stack->Parameters.DeviceIoControl.OutputBufferLength
    输入缓冲区:ProbeForRead(stack->Parameters.DeviceIoControl.Type3InputBuffer)
    输出缓冲区:ProbeForWrite(pIrp->UserBuffer)

转载于:https://www.cnblogs.com/endenvor/p/9060645.html

你可能感兴趣的文章
Linux下搭建SVN服务器遇到的问题及解决方法
查看>>
Android Studio-Gradle项目中添加JNI生成文件(.so文件)
查看>>
IBM在加拿大投资9000万美元组建智能数据中心
查看>>
Perl获取机器hostname,ip(跨平台)
查看>>
iptables的基本语法格式
查看>>
Http协议和IO模型
查看>>
【数据结构】将一组数据升序排序(利用堆排序)
查看>>
linux中用户,组管理
查看>>
用什么开发软件
查看>>
makefile(07)_路径搜索
查看>>
数据结构(06)_栈
查看>>
openstack
查看>>
聊聊flink JobManager的High Availability
查看>>
聊聊Elasticsearch的SingleObjectCache
查看>>
运维CMDB系统
查看>>
面向对象基本概念
查看>>
计算机网络(一)——互联网层
查看>>
hive关联查询连接hbase的外部表时,内存溢出问题
查看>>
顺序结构的程序设计-考点
查看>>
Web前端面试指导(十四):如何居中一个元素(正常、绝对定位、浮动元素)?
查看>>