Windows I/O 驱动程序中的主动等待
继续问题:
感谢在该问题中接受的答案我意识到让窗口等待数据是驾驶员的责任。
当我使用 Dokan 时,我能够查看驱动程序代码。当您没有返回数据时,Dokan 会使用 STATUS_END_OF_FILE 完成 IRP 请求,这显然会强制窗口停止等待数据并关闭文件。
我想要做的是保留请求文件数据的应用程序,直到数据可用为止,正如我在原始问题中所说,用户必须能够随时取消该过程。
完成请求的代码是:
PIRP irp
irp->IoStatus.Status = STATUS_END_OF_FILE
IoCompleteRequest(irp, IO_NO_INCREMENT);
实际上,我可以返回任何错误代码,并且我想知道是否某些状态代码( NTSTATUS 值之一)强制窗口等待数据,以及返回该状态代码是否足以保存窗口正在读取操作。
我已经尝试返回 STATUS_WAIT_0,但似乎不起作用。
再次感谢 :)
Continuing the question in:
Keep windows trying to read a file
Thanks to accepted answer in that question I realized that keeping windows waiting for data is a driver responsability.
As i'm using Dokan, I am be able to look into the driver code. Dokan complete the IRP request with a STATUS_END_OF_FILE when you return no data, that obvioulsy forces windows to stop waiting for data and close the file.
What i want to do is to hold the application that request file data until data is available and as i said in the original question, the user must be able to cancel the process at any time.
The code that completes the request is:
PIRP irp
irp->IoStatus.Status = STATUS_END_OF_FILE
IoCompleteRequest(irp, IO_NO_INCREMENT);
Actually, i can return any error code, and i wanted to know if some STATUS code ( one of NTSTATUS values ), force windows to wait for data, and if returning that status code is enough to hold windows in reading operation.
I already tried to return STATUS_WAIT_0, but it doesn't seem to work.
Thanks again :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该返回 STATUS_PENDING 并为 IRP 设置 CancelRoutine。当数据可用或发生错误时完成您的 IRP。请参阅异步 I/O 响应和取消 IRP 了解更多信息。
You should return STATUS_PENDING and set CancelRoutine for the IRP. Complete your IRP when the data is available or an error occurred. See Asynchronous I/O Responses and Canceling IRPs for more info.