emailoftest
驱动牛犊
驱动牛犊
  • 注册日期2002-03-18
  • 最后登录2002-06-03
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1460回复:6

DeviceIoControl()-BUFFERED方式下的疑问?

楼主#
更多 发布于:2002-04-22 17:09
Method
 Input Buffer Parameter
 Output Buffer Parameter
 
METHOD_BUFFERED
 KIrp::IoctlBuffer
 KIrp::IoctlBuffer
 
METHOD_IN_DIRECT
 KIrp::IoctlBuffer
 KIrp::Mdl
 
METHOD_OUT_DIRECT
 KIrp::IoctlBuffer
 KIrp::Mdl
 
METHOD_NEITHER
 KIrp::IoctlType3InputBuffer
 KIrp::UserBuffer

问题:在METHOD_BUFFERED 方式下面输入缓冲器和输出缓冲器都是KIrp::IoctlBuffer 。那么如何区分呢?

最新喜欢:

flyfoxflyfox
pjf
pjf
驱动中牛
驱动中牛
  • 注册日期2001-07-08
  • 最后登录2006-10-23
  • 粉丝0
  • 关注0
  • 积分42分
  • 威望4点
  • 贡献值0点
  • 好评度4点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2002-04-22 17:35
那里需要区分呀
IoctlBuffer里是传给你的数据,用完后用没用了,再用它把你的数据传回去呀。若你愿意,自己分配个Buffer保存一下传来的数据
Tom_lyd
驱动大牛
驱动大牛
  • 注册日期2001-09-02
  • 最后登录2016-01-09
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2002-04-22 17:37
Managing IOCTL Buffers
IOCTL requests can specify both an input and an output buffer in the same call. As a result, they present a read-after-write abstraction to the caller. IOCTL requests differ in user buffer access in two ways.

The buffer transfer mechanism is specified with the IOCTL control-code definition, independent of the overall device object strategy.

There are two buffers involved, one for input, one for output.

The following sections describe how the different buffer strategies work with IOCTL control codes.

METHOD_BUFFERED
The I/O Manager allocates a single temporary buffer from nonpaged pool, large enough to hold the larger of the caller\'s input or output buffer. The address of this pool buffer is placed in the IRP\'s AssociatedIrp. SystemBuffer field. It then copies the requestor\'s input buffer into the pool buffer and sets the UserBuffer field of the IRP to the user-space output buffer address.

Upon completion of the IOCTL request, the I/O Manager copies the contents of the system buffer into the requestor\'s user-space buffer. Notice that only a single internal buffer is presented to the driver code, even though the user has specified independent input and output buffers. The driver code must take care to extract all necessary information from the requestor\'s input before performing writes into the output buffer.

METHOD_IN_DIRECT
The I/O Manager checks the accessibility of the requester\'s input buffer and locks it into physical memory. It then builds an MDL for the input buffer and stores a pointer to the MDL in the MdlAddress field of the IRP.

It also allocates a temporary output buffer from nonpaged pool and stores the address of this buffer in the IRP\'s AssociatedIrp.SystemBuffer field. The IRP\'s UserBuffer field is set to the original caller\'s output buffer address. When the IOCTL IRP is completed, the contents of the system buffer are copied into the caller\'s original output buffer.

METHOD_OUT_DIRECT
The I/O Manager checks the accessibility of the caller\'s output buffer and locks it down in physical memory. It then builds an MDL for the output buffer and stores a pointer to the MDL in the MdlAddress field of the IRP.

The I/O Manager also allocates a temporary input buffer from non-paged pool and stores its address in the IRP\'s AssociatedIrp. SystemBuffer field. It copies the contents of the caller\'s original input buffer into the system buffer and sets the IRP\'s UserBuffer field to NULL.

METHOD_NEITHER
The I/O Manager puts the address of the caller\'s input buffer in the Parameters.DeviceIoControl.Type3InputBuffer field of the IRP\'s current I/O stack location. It stores the address of the output buffer in the IRP\'s UserBuffer field. Both of these are user-space addresses.

Tom_lyd
Tom.Cat
禁止发言
禁止发言
  • 注册日期2001-10-10
  • 最后登录2019-07-29
  • 粉丝1
  • 关注0
  • 积分-53792分
  • 威望197411点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
  • 社区居民
地板#
发布于:2002-04-22 19:47
用户被禁言,该主题自动屏蔽!
emailoftest
驱动牛犊
驱动牛犊
  • 注册日期2002-03-18
  • 最后登录2002-06-03
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2002-04-22 19:48
如果我没有理解错误的话
我们的操作一般是先从KIrp::IoctlBuffer中取出user的inbuffer中的有用信息,然后将需要的数据写入KIrp::IoctlBuffer 中,user就在outbuffer中获取了信息,而在数据写入KIrp::IoctlBuffer
的同时,原来inbuffer的内容在KIrp::IoctlBuffer 中被覆盖。
Iamme
驱动小牛
驱动小牛
  • 注册日期2001-03-23
  • 最后登录2005-10-11
  • 粉丝0
  • 关注0
  • 积分10分
  • 威望1点
  • 贡献值0点
  • 好评度1点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2002-04-23 09:38
在往这个缓冲里写之前用ZeroMemory清一下
Go,go ahead
Tom.Cat
禁止发言
禁止发言
  • 注册日期2001-10-10
  • 最后登录2019-07-29
  • 粉丝1
  • 关注0
  • 积分-53792分
  • 威望197411点
  • 贡献值0点
  • 好评度5点
  • 原创分0分
  • 专家分0分
  • 社区居民
6楼#
发布于:2002-04-23 15:20
用户被禁言,该主题自动屏蔽!
游客

返回顶部