Windows I/O 驱动程序中的主动等待

发布于 2024-08-08 15:13:55 字数 612 浏览 3 评论 0原文

继续问题:

让窗口尝试读取文件

感谢在该问题中接受的答案我意识到让窗口等待数据是驾驶员的责任。

当我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

粉红×色少女 2024-08-15 15:13:55

您应该返回 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文