Processing I/O Operations

本文介绍了Windows过滤管理器如何简化minifilter驱动处理IO操作的过程。minifilter可以通过注册preoperation回调来处理特定的IO请求,通过不同返回值来指示过滤管理器如何继续处理请求。此外,还介绍了minifilter如何维护未决IO请求的安全取消队列以及如何使用postoperation回调进行安全的完成处理。

过滤管理器简化了minifilter驱动处理IO操作的过程,传统过滤驱动必须将IO请求传递至下一层驱动、正确处理挂起、同步、IO完成等,而minifilter只注册必须处理的IO请求。

对于一个给定的IO操作,只有当minifilter驱动注册了preoperation回调函数时,过滤管理器才会调用minifilter驱动。过滤管理器会代表minifilter驱动拷贝栈参数、传递IRP PendingReturned标志。

在preoperation回调函数中,返回值表示了应该如何继续处理这个IRP。如果只是将IRP发送至下一层驱动,而不需要完成例程,则返回FLT_PREOP_SUCCESS_NO_CALLBACK,如果需要完成例程。返回FLT_PREOP_SUCCESS_WITH_CALLBACK。请注意,这里的完成例程指的是minifilter驱动的postoperation回调函数。

在preoperation回调函数中,minifilter驱动可以调用FltQueueDeferredIoWorkItem将操作排队值一个工作线程中,并返回FLT_PREOP_PENDING,已表明IO操作被挂起,minifilter驱动负责完成或继续处理请求。minifilter驱动可以在工作线程中调用FltCompletePendedPreOperation 继续处理请求。


如果minifilter驱动需要维护自己的per-instance 未决IO请求安全取消队列。可以在InstanceSetupCallback 调用FltCbdqInitialize创建这样的队列,然后在preoperation函数中调用FltCbdqInsertIo 将IO请求插入队列。

在postoperation回调函数中,minifilter驱动可以调用FltDoCompletionProcessingWhenSafe确保完成处理在安全的IRQL上执行。或者调用FltQueueDeferredIoWorkItem将完成处理排队到一个工作线程上。上面两种情况下,minifilter驱动返回FLT_POSTOP_MORE_PROCESSING_REQUIRED终止过滤管理器的IO完成处理。为了继续完成处理,工作线程调用FltCompletePendedPostOperation函数。

过滤管理器支持排队一般的工作项,这个工作项与minifilter驱动或者实例关联,而不是与IO操作关联。minifilter驱动调用FltQueueGenericWorkItem将工作项插入系统工作队列。它和 ExQueueWorkItem类似,例如工作项是可重用的。但是FltQueueGenericWorkItem对minifilter驱动来说是安全的,因为当外部的工作项还在处理当中时,minifilter驱动或实例是不允许卸载的。


### I/O in Computer Science In the context of computer science, Input/Output (I/O) refers to the communication between an information processing system—such as a computer—and the outside world, possibly a human or another information processing system. Devices that are used for this purpose include keyboards, mice, printers, and displays among others[^1]. The primary function of input/output operations is to transfer data from external sources into the computing environment where it can be processed by software applications. Input devices allow users to send commands or provide raw material which gets transformed within the machine according to specific instructions encoded in algorithms. Output devices deliver results back outwards after computation has taken place inside the processor unit. Efficient management of these interactions ensures smooth operation across various levels including hardware interfaces up through operating systems down to application layers. For instance, when building search engines as part of introductory courses like CS101, efficient handling of web pages' content retrieval involves sophisticated mechanisms designed around optimizing both read/write speeds alongside minimizing latency during queries execution cycles. ```python # Example Python code demonstrating basic file I/O operations with open('example.txt', 'r') as file: contents = file.read() print(contents) with open('output.txt', 'w') as file: file.write("This text will be written to output.txt") ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值