20楼#
发布于:2002-11-01 09:47
guardee说得很对
我费了好大的劲终于搞明白windows的分区管理模型如下: FileSystemDriver (top) VolumeDriver DiskDriver (bottom) 而我的虚拟磁盘的就是没有底下的那个DiskDriver,自己来完成最终的数据读写工作 现在我只是新加入了一个分区到系统里面,在响应IRP_MJ_READ和IRP_MJ_WRITE的时候我都返回失败 下一步我就是要完成这两个proc,我觉得分区格式的识别应该是通过READ完成的吧? |
|
|
21楼#
发布于:2002-11-01 15:00
调用ZwReadFile,失败
返回status = 0xc0000024 这是什么意思?谢谢! |
|
|
22楼#
发布于:2002-11-01 15:10
我在google的讨论组里面查了:
status = 0xc0000024代表STATUS_OBJECT_TYPE_MISMATCH 但是为什么会这样呢?下面是我调用ZwReadFile的context: 我在DriverEntry里面调用ZwOpenFile打开我想读取的文件,打开成功(这里的确是成功了,我看到的)后把文件句柄放在DeviceExtension里面 当我的Driver响应IRP_MJ_READ的时候取出此句柄并用它调用ZwReadFile,然后就出错了。 大家看看是怎么回事? |
|
|
23楼#
发布于:2002-11-01 15:23
回复似乎比较慢,我找到上一个问题的答案了。连续发了三条,不是有意灌水的,请见谅
把答案贴出来大家共享: A theory - The call to ZwReadFile is probably only valid in the context in which you originally opened the file. If another driver (like a file system driver, for example) calls your driver\'s read handler from a different thread context (such as would happen often if the call to your driver were done in a DPC, worker thread, or work item callback), you could see this. There\'s two approaches you could use to test and then possibly work around this issue if it indeed turns out to be what\'s happening: 1. Put all of the Zw I/O calls into functions called by a worker thread. When a request comes in, signal the thread and have the thread handle the actual I/O. 2. A very different approach - Have a user app or service do the actual I/O and get rid of the Zw calls altogether. You could have the app/service queue up several DeviceIoControl IRPs to \'Listen\' for requests, and fill them in and complete them where you\'re currently doing the ZwReadFile. The User app could then fetch the appropriate data and call back into the driver. Likely not the fastest/highest performance approach, but very very flexible and gets a lot of code out of your driver. You can use this method to handle any user interface you need, as well. //这个贴子似乎已经可以封起来了,准备给分 |
|
|
24楼#
发布于:2004-04-13 15:54
好帖子
|
|
|
25楼#
发布于:2004-04-13 17:37
好,顶
|
|
|
上一页
下一页