从 IRQL=DISPATCH_LEVEL 发送 IOCTL (KbFilter/KMDF)
我正在 WDK 中使用 KbFilter 示例,尝试在由 KbFilter_ServiceCallback 调用的函数中发送 IOCTL,因此在 DISPATCH_LEVEL 执行。该函数只需发送 IOCTL 并返回,无需等待输出缓冲区被填充,因此它可以是异步的,即发即忘。
我目前正在使用 WDF 函数 WdfIoTargetFormatRequestForIoctl 和 WdfRequestSend 尝试在 DISPATCH_LEVEL 上发送,但一无所获。对 WdfRequestSend 的调用成功,但似乎未收到 IOCTL。
使用 WdfIoTargetSendIoctlSynchronously 或 WDM 模式 IoBuildDeviceIoControlRequest() 和 IoCallDriver() 需要 PASSIVE_LEVEL,我知道在 PASSIVE_LEVEL 调用这些的唯一方法是创建一个运行的单独线程在 PASSIVE_LEVEL 并通过缓冲区或队列向其传递指令,与自旋锁和信号量同步。
有人可以告诉我是否有更简单的方法将 IOCTL 传递给过滤器下面的驱动程序,或者当您需要以更高的 IRQL 执行操作时,线程/队列方法是否是正常模式?什么情况下可以使用 KeRaiseIrql这是我应该使用的吗?谢谢。
I am using the KbFilter example in the WDK, trying to send an IOCTL in a function that is called by KbFilter_ServiceCallback and therefore is executed at DISPATCH_LEVEL. The function just has to send an IOCTL and return, am not waiting for an output buffer to be filled so it can be asynchronous, fire and forget.
I am currently using the WDF functions WdfIoTargetFormatRequestForIoctl and WdfRequestSend to try and send at DISPATCH_LEVEL and getting nothing. The call to WdfRequestSend is succeeding but the IOCTL doesn't appear to be received.
Using either of WdfIoTargetSendIoctlSynchronously or the WDM pattern IoBuildDeviceIoControlRequest() and IoCallDriver() requires PASSIVE_LEVEL and the only way I know to call these at PASSIVE_LEVEL is to create a separate thread that runs at PASSIVE_LEVEL and pass it instructions via a buffer or a queue, synchronized with a spinlock and semaphore.
Can someone tell me if there is an easier way to pass IOCTLs to the drivers below my filter, or is the thread/queue approach the normal pattern when you need to do things at a higher IRQL? Under what circumstances can I use KeRaiseIrql and is this what I should use? Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用 IoAllocateIrp 和 IoCallDriver。它们可以在 IRQL <= DISPATCH_LEVEL 下运行。
您不能降低 IRQL(除非是您提高的)。 KeRaiseIrql 仅用于引发 IRQL。如果调用方指定 NewIrql >= CurrentIrql,则对 KeRaiseIrql 的调用有效。
请注意:您的 IOCTL 预期为 DISPATCH_LEVEL 吗?
这是一个代码片段:
Use IoAllocateIrp and IoCallDriver. They can be run at IRQL <= DISPATCH_LEVEL.
You cannot lower your IRQL (unless it is you who raised it). KeRaiseIrql is used only to raise IRQL. A call to KeRaiseIrql is valid if the caller specifies NewIrql >= CurrentIrql.
Be careful: Is your IOCTL expected at DISPATCH_LEVEL?
Here is a code snippet: