阅读:1293回复:8
问一个简单的问题
用METHOD_IN_DIRECT方式时,驱动是通过
PVOID MmGetSystemAddressForMdlSafe( IN PMDL Mdl, IN MM_PAGE_PRIORITY Priority );得到输入的数据的吗? 例如: in = MmGetSystemAddressForMdlSafe(Irp->MdlAddress,NormalPagePriority); temp = *(ULONG*)in; 可以这样直接的处理数据(处理temp)吗? |
|
沙发#
发布于:2005-03-20 18:30
用METHOD_IN_DIRECT方式时,驱动是通过MmGetSystemAddressForMdlSafefanhui 返回的是内核缓冲区的基虚拟地址,,,不是数据。。。。 应该可以再用一个RtlCopyMemory()函数将其中的数据拷贝到要存储它的地方了。。。。。。。。。 |
|
|
板凳#
发布于:2005-03-20 18:47
试 试,还是不大懂你说的啊
MmGetSystemAddressForMdlSafe不是得到了mdl到系统空间的影射吗? 驱动不都是在系统空间里面吗? |
|
地板#
发布于:2005-03-20 18:52
哎呀,好像不行啊~~~
|
|
地下室#
发布于:2005-03-21 10:18
哎呀,好像不行啊~~~ 用户区要映射的内存加锁了吗?还有MDL建立的正确吗?如一切正常,这个函数就是返回的核心中映射的用户区的东东的指针 |
|
|
5楼#
发布于:2005-03-21 13:11
不管是METHOD_IN_DIRET还是METHOD_OUT_DIRECT,都是将in buffer的内容拷贝到systembuffer指向的内核空间,把out buffer所在的内存锁住然后创建一个MDL来描述之,即Irp->MdlAddress
因此,如果是得到输入数据,还是在systembuffer的 |
|
6楼#
发布于:2005-03-21 17:05
我看的是科欣翻译组的 programme wdm in microsofe 那本书,上面说的in_direct 就是锁定输入地址,创建输出buffer
out_direct 是锁定输出,创建输入, 不过,如果照你说的,那么这两种方式又有什么不同的地方呢? 那neither方式是不是在dispatch历程里,直接通过userbuffer得到呢? 企盼回复 |
|
7楼#
发布于:2005-03-21 18:19
给分了
arthurtu是对的 |
|
8楼#
发布于:2005-03-21 21:33
METHOD_IN_DIRECT or METHOD_OUT_DIRECT
For these transfer types, IRPs supply a pointer to a buffer at Irp->AssociatedIrp.SystemBuffer. This represents the input buffer that is specified in calls to DeviceIoControl and IoBuildDeviceIoControlRequest. The buffer size is specified by Parameters.DeviceIoControl.InputBufferLength in the driver\'s IO_STACK_LOCATION structure. For these transfer types, IRPs also supply a pointer to an MDL at Irp->MdlAddress. This represents the output buffer that is specified in calls to DeviceIoControl and IoBuildDeviceIoControlRequest. However, this buffer can actually be used as either an input buffer or an output buffer, as follows: METHOD_IN_DIRECT is specified if the driver that handles the IRP receives data in the buffer when it is called. The MDL describes an input buffer, and specifying METHOD_IN_DIRECT ensures that the executing thread has read-access to the buffer. METHOD_OUT_DIRECT is specified if the driver that handles the IRP will write data into the buffer before completing the IRP. The MDL describes an output buffer, and specifying METHOD_OUT_DIRECT ensures that the executing thread has write-access to the buffer. For both of these transfer types, Parameters.DeviceIoControl.OutputBufferLength specifies the size of the buffer that is described by the MDL. |
|