在文件过滤驱动中追踪文件状态

文件过滤驱动开发 文件过滤驱动 一、文件透明加解密 关键字:透明、文件过滤驱动、加密标识,缓存   文件过滤驱动最重要的两点是搞定加密标识和缓存管理 1、透明概念: 透明指的是用户在操作的时候,虽然后台在自动的进行加解密,但是用户根本就不知道加密的存在,就像中间隔了一层透明的玻璃一样。      透明的好处在于不改变用户的操作,一切都和加密之前一样,甚至在有些企业安装加密后都无需通知所有的员工,就像加 阅读详情
Tracking State and Context - Reference Counting for File System Filter Drivers
The NT Insider, Vol 9, Issue 2, Mar-Apr 2002 | Published: 15-Apr-02| Modified: 06-May-03



One of the challenges for a file systems filter driver in the Windows NT, 2000 or XP environment is knowing precisely when it is “OK” to discard per-file state information.  While it is customary for file system filter drivers to track such state based on the FsContext field of the FILE_OBJECT, the new file system filter driver writer may be frustrated to find that some I/O operations are missed.



Analyzing this problem, it is easy to observe that matching IRP_MJ_CLOSE operations against IRP_MJ_CREATE operations is not enough to properly determine when it is OK to discard the FsContext-related file state within the filter driver. We have previously described why this is the case (the use of stream file objects by the file systems) but in this article the emphasis is on describing an algorithm that allows the filter driver not to discard the state until the last reference to the file is truly gone.



First, it is worth reviewing the reason that reference counting is not a trivial exercise for file system filter drivers, then we’ll review the various cases that any algorithm must take into account, and finally propose our algorithm for tracking references to the per-file data normally maintained by a file system filter driver.



A file system has several mechanisms for creating file objects that it may use for its own internal processing.  These include IoCreateStreamFileObject, IoCreateStreamFileObjectLite, and IoCreateStreamFileObjectEx.  Not all of these are available in all versions, but even the Windows NT 4.0 IFS Kit contained the IoCreateStreamFileObject call.  Both IoCreateStreamFileObject and IoCreateStreamFileObjectLite are documented in the Windows XP IFS Kit and each provides similar functionality – they create file objects based upon either an existing file object or device object.  The IFS Kit documentation sums up the problem for file system filter drivers, in the page for IoCreateStreamFileObjectLite:



“Thus filter drivers should expect to receive IRP_MJ_CLOSE requests for previously unseen file objects.”



Of course, the fact that a file system filter driver receives an IRP_MJ_CLOSE operation for file objects which were never indicated to the filter driver does complicate reference counting.



In looking at the sequence of events, we note that we are concerned about the overlap of the IRP_MJ_CREATE and IRP_MJ_CLOSE of normal user access along with the IRP_MJ_CLOSE of file system access.  Thus, we might observe the following scenarios:



An application program opens the file and then closes it; the filter never observes any stream file objects used against the given file.
The filter only observes stream file objects and does not observe any application access to a file.
The application opens the file and the filter observes both application and stream file objects used to access the file in question.
The filter observes stream file object usage for a file, and then subsequently observes an application open the file.


Whatever algorithm used by the file system filter driver to track this context and state information, it must be able to account for all of these scenarios.



In analyzing the various algorithms available for tracking this information, we noted that there may be cases where the techniques used can be simplified.  And thus we describe two separate algorithms here – one that is useful for tracking state in the general case, and a second case that is useful when only data operations are of interest to the file system filter driver.



For a file system filter driver that must track all instances of a file object, this unfortunately results in the need to not only track reference counts, but also to track the specific file object for which it has observed and IRP_MJ_CREATE.  Such a filter must typically maintain both a reference count (for file objects seen via the IRP_MJ_CREATE mechanism) and an explicit list (or other data structure for tracking these file objects) of stream file objects seen by the filter.  Thus, on each I/O operation, the filter examines the FO_STREAM_FILE bit in the Flags field of the FILE_OBJECT.  If this bit is set, the filter verifies that the file object is in its list – if not, it allocates the necessary storage for its tracking information and inserts it into its list.  Then, when it observes an IRP_MJ_CLOSE operation, it will either decrement the reference count or remove it from the list, as appropriate.  Only when both the list is empty and the reference count is zero does the filter delete the tracking data structure.



Thus, the filter must create the per-file tracking information whenever it observes an IRP_MJ_CREATE or a stream file object for a file for which it does not have tracking information, as a file object may be created entirely internal to the filter driver or because of an application program’s request to open the file.  The filter driver must still attempt to determine the appropriate action with respect to tracking such files, which can be difficult.  In the “simplified” algorithm that we describe later, we will suggest a technique for keeping the context even longer to allow the filter to avoid re-evaluating the need to track the given file.



There are four distinct scenarios we described earlier for consideration with this algorithm:



If the application program first opens the file and then closes it, with no intervening stream file object usage, this algorithm works because we will delete the file context when the reference count drops to zero.  There is no stream context, so the list will be empty.
If only stream file objects are observed, the filter driver might potentially only see an IRP_MJ_CLOSE operation for this file object, in which case the file was not of much interest.  Otherwise, on observing the first I/O operation using the stream file object the filter would create a context record and insert tracking information for the given file object.  When it observes the subsequent IRP_MJ_CLOSE operation, it will remove the entry from the list and delete the file context block.
If an application opens the file initially, the filter driver would create the per-stream file context information at that point. If it then subsequently observes an I/O using a stream file object, it will not find it in its list, and will create a new entry.  Then, regardless of the order in which the IRP_MJ_CLOSE operations arrive within the filter driver, it will not delete the per-file context until they have both been processed – the reference count will then be zero and the list of stream file objects will be empty.
If the stream file object is first observed, the filter driver will create its per-file context information at that point and insert a tracking block for the stream file object into the list. A subsequent application open of the file will cause the filter to increment the reference count.  Again, until both the stream file object list is empty and the reference count is zero, the per-file context information will be maintained.


Of course, there are numerous variations on these basic scenarios, involving multiple stream file objects and multiple application opens.  However, we have focused on the boundary cases because we maintain that additional stream file objects or application opens will work in a comparable fashion, albeit with additional entries or references.

 



Figure 1 — Section Object/File Object Relationship



Many filter drivers can use a simpler (and less costly) algorithm because they only care about data operations for user files.  In this case, we note that the only issue is when stream file objects are used to back a section object for the memory manager.



This is because any paging I/O operations that the memory manager performs will be based upon the file object referenced by the given section object.  The risk (for the filter driver) is that it will observe the following sequence:



(1)    The application opens the file;

(2)    The file system creates a stream file object and that object is then used as the file object to back the section (i.e. a call to CcInitializeCacheMap is made using that stream file object).

(3)    The application closes the file.  Because there are no outstanding references (other than the application handle) both IRP_MJ_CLEANUP and IRP_MJ_CLOSE are sent to the file system (and hence through the filter).  The filter deletes its per-file context information.

(4)    The Memory Manager flushes any changes to the data (perhaps through the section, as might be the case for memory mapped file access) back to the file system using paging I/O operations.



The problem with this scenario is that because the filter has deleted its per-file context information, the subsequent write operations are missed by the filter because they do not appear to be relevant.  Of course, using the previous algorithm we described, upon observing the new paging I/O operation the filter would create the per-file context information (again) and then ascertain if the file should have been tracked in the first place.  While this will work, we can simplify the process by adding an additional check for this case – specifically, before deleting the per-file context, the section object pointers from the file object must both be NULL.  Otherwise, we know that there is some file object backing the section and it has not yet been observed by our filter driver.



Thus, for a filter driver that is concerned about all I/O operations and tracking all file state, this can be added to the previous algorithm to keep state information when it still might be useful.



For a filter driver that is only concerned about data operations (read and write) this suggests a simpler algorithm:



For each IRP_MJ_CREATE, the filter driver increments the reference count on the per-file context structure.
For each IRP_MJ_CLOSE the filter driver decrements the reference count on the per-file context structure if the FO_STREAM_FILE bit is not set for the file object and if CcGetFileObjectFromSectionPtrs does not return this file object.
If the reference count for the per-file context structure reaches zero and both the ImageSectionObject and DataSectionObject of the SectionObjectPointers field from the FILE_OBJECT is zero, the filter driver may then delete the per-file context data.


This algorithm avoids the need to track individual file objects.  It deals with stream file objects by ignoring any of them that are not involved in paging I/O.  For many filter drivers, this solution will be sufficient for them to track their per-file state.



This works because the reference count represents the user-level opens against the file.  The reference count is decremented only when a user-level file object is closed (as evidenced by the FO_STREAM_FILE bit’s absence in the file object) and thus there are no user references to the file when the reference count is zero.  Similarly, the section objects represent the VM state for the file.  If these two section object pointers are NULL there are no VM references against the file – hence, no memory mappings of the file, whether by applications or the cache manager.  Since the filter is only interested in data operations, this is sufficient.  Any new data operations will require that the file be re-opened.  Do note that this algorithm only works if your filter observes all operations against this file - if you dynamically load your filter driver and the file has already been opened prior to that, this algorithm will not suffice.



For file system filter drivers that will run only on Windows XP or more recent versions, there is no need for tracking the per-file context information in this fashion.  Instead, the routines FsRtlInsertPerStreamContext and FsRtlRemovePerStreamContext can be used by a file system filter driver to allow the file system runtime library package to manage the per-stream file contexts.  For filter drivers that support both Windows XP as well as earlier versions, these two techniques can be used to implement one common mechanism that works for all platforms.

赛灵思KV260视觉AI套件实战:从模型到边缘部署全流程解析 边缘计算与AI推理加速是当前嵌入式系统和物联网领域的关键技术。其核心原理在于将计算任务从云端下沉至网络边缘的设备端,通过专用硬件加速器(如FPGA、ASIC或NPU)执行神经网络推理,从而显著降低延迟、减少带宽消耗并提升数据隐私性。这一技术为实时性要求高的应用场景(如工业视觉检测、智能安防、自动驾驶等)提供了关键支撑。以赛灵思(Xilinx)的Zynq UltraScale+ MPSoC平台为例,其集成了ARM处理器与可编程逻辑,通过预置的深度学习处理器单元(DPU)为卷积神经网络提供高效INT8加速。开发 阅读详情

相关推荐

13个GNS3 3.0.5 appliances设备模板镜像合集:IOSv/L2,IOU L2/L3,以及IOS-XE

13个GNS3 appliances设备模板:IOSv/L2,IOU L2/L3,以及IOS-XE合集

haierccc的博客 1085

sfilter开源驱动分析(一)--文件过滤的基本步骤

NT的I/O管理器支持分层的驱动程序模式。         当应用层的CreateFile() (R3层)  --> || NtCreateFile() [I/O管理器在这一层,ntdll.dll]  -->|| 内核驱动层(R0层) ,这里讨论的主要是针对最后的内核驱动层的处理。          当每个IRP被处理的时候,它会经过驱动层中的各个驱动程序,直到最终被某个驱动程序调用IoCo

jimk1983的专栏 2700

多模态情感识别(MER)数据集实战指南:从IEMOCAP到应用落地

本文提供了多模态情感识别(MER)从数据集到应用落地的完整实战指南。以经典IEMOCAP数据集为例,详细讲解了音频、视觉、文本等多模态数据的预处理、特征提取与融合技术,并分享了模型训练调优心得及面向智能客服、在线教育等场景的部署考量,帮助开发者快速构建高效可用的MER系统。

h3i4j的博客 1076

聊下最近出的一些wannacry勒索病毒防御工具

1. 瑞星之剑. 只能怪自己消息太过闭塞, 这工具出了两三天了, 好像瑞星还在大肆宣传其防御效果。于是好奇下载下来分析下。界面如下: 就是一个简单的EXE文件, 运行会释放一个dll和两个驱动文件.然后将驱动文件拖入IDA分析. 实现如下: 使用minifilter过滤文件io操作.IRP_MJ_CRATE,IRP_MJ_WRITE, IRP_MJ_SET_INFORMATION. 当有...

weixin_30384217的博客 269

Win10安装Nek5000

1 安装wsl 2 2 安装Nek5000 3 安装依赖项 4 安装openmpi 5 配置Nek5000 6 编译Nek5000 7 运行Nek5000算例 8 安装paraview并查看结果

weixin_43176703的博客 3456

爬取二手房数据:Python爬虫+Geopy实战,看透房价与地理位置的隐藏关系

哪些区域单价虚高(房源少但单价远高于周边);哪些小区性价比高(靠近地铁/学校,单价低于同地段平均水平);房价与地理位置的量化关系(如距离地铁每远1公里,单价下降多少)。如果想扩展分析范围,可爬取多个城市/区域的数据,对比不同城市的房价差异;或结合时间维度(定期爬取),分析房价的涨跌趋势。

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 952

反病毒引擎设计之实时监控篇

3.1实时监控概论3.2病毒实时监控实现技术概论3.3WIN9X下的病毒实时监控3.3.1实现技术详解3.3.2程序结构与流程3.3.3HOOKSYS.VXD逆向工程代码剖析3.3.3.1钩子函数入口代码3.3.3.2取得当前进程名称代码3.3.3.3通信部分代码 3.4 WINNT/2000下的病毒实时监控3.4.1实现技术详解3.4.2程序结构与流程...

weixin_30750335的博客 297

基于Transformer和图卷积网络的时空人体运动预测网络

本文主要介绍了基于Transformer和图卷积网络的时空人体运动预测网络。首先,文章详细阐述了Transformer模型的原理和优点,指出其通过自注意力机制实现序列数据的建模和处理,能够捕捉长距离依赖关系。然后,文章介绍了图卷积网络的基本概念和应用场景,强调其通过邻居节点信息聚合实现空间特征的提取和融合。接着,文章详细设计了时空人体运动预测网络的总体架构,包括基于Transformer的时间特征提取模块、基于图卷积的空间特征融合模块以及时空特征联合预测模块。

babyai996的博客 1487

IM推送保障及网络优化详解(一):如何实现不影响用户体验的后台保活

对于移动 APP 来说,IM 功能正变得越来越重要,它能够创建起人与人之间的连接。社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性。在复杂的 Android 生态环境下,多种因素都会造成消息推送不能及时达到客户端。另外,不稳定的移动网络也给数据传输的速率和可靠性增加了障碍。本文详解了网易云信 IM SDK 在应对弱网环境、移动端硬件限制以及 Android 复杂的生态现状时的探索与心得....

netease_im的博客 848

华为OD机试 - 仓库查询 - 树状数组(Java 新系统 200分)

华为OD机试 新系统 题库疯狂收录中,刷题。

学Java,找哪吒 170

番外篇 | 复现HIC-YOLOv5,助力小目标物体的检测

在本文中提出了一种改进的YOLOv5算法:HIC-YOLOv5,用于小目标检测,具有更好的性能和较低的计算成本。🌈

小哥谈 1136

IM 推送保障及网络优化详解(一):如何实现不影响用户体验的后台保活

对于移动 App 来说,IM 功能正变得越来越重要,它能够创建起人与人之间的连接。社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性。在复杂的 Android 生态环境下,多种因素都会造成消息推送不能及时达到客户端。另外,不稳定的移动网络也给数据传输的速率和可靠性增加了障碍。本文详解了网易云信 IM SDK 在应对弱网环境、移动端...

weixin_34348805的博客 138

R语言caret拟合模型:train函数构建xgBoost Dart模型、模型调优、自定义设置trainControl函数和tuneLength参数

R语言caret拟合模型:train函数构建xgBoost Dart模型、模型调优、自定义设置trainControl函数和tuneLength参数

statistics+insight+vista+power 532

即时通讯推送保障及网络优化详解(一)

如何实现不影响用户体验的后台保活对于移动APP来说,IM功能正变得越来越重要,它能够创建起人与人之间的连接。社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性。在复杂的 Android 生态环境下,多种因素都会造成消息推送不能及时达到客户端。另外,不稳定的移动网络也给数据传输的速率和可靠性增加了障碍。本文详解了网易云信IM SDK在应对弱网环境、移动端硬件限制以及Android复杂的生态现...

jessicaiu的博客 676

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

大中型超市收银系统(可直接运行)

光步前台收银系统系统功能:商品销售、商品退货、挂单、收银员权限、会员销售、单品取消、整单取消、商品查询、脱机销售、脱机数据上传,基本资料下载,开钱箱、小票打印、收款结算,支持多币种付款方式(现金、储值卡、礼券、微信等),支持多种促销。运行环境:.net 4.0登陆信息用户名:1001 密码:123456内置商品信息,商品编码可输入00001000 - 00010000,测试效果相关功能键F5 结算 F9挂单 F11商品查询 F8退货 Insert单品取消 Del整单取消 F12开钱箱F2 会员 Ctrl+Z退出系统 Home 锁屏 相关源码待公开

IM推送保障及网络优化详解(二):如何做长连接加推送组合方案

因此在MIUI上,从长连接到推送通道的切换流程仍然和前面的一样,只是不再使用自己的推送连接,而是将消息转发到MIUI的推送服务器,然后转给MIUI系统的推送代理,然后传递给网易云信的APP。第二个是断,手机跟着人不停的移动,网络也不停的在切换,从wifi到移动网络,从一个基站到另一个基站,从有信号到没信号,都可能导致网络中断。所有APP的消息都经过代理中转,代理到服务器的连接是加密的,安全的,但到了代理这里,消息都被解开了,因此代理理论上可以看到其他所有APP的来往消息。连接成功,需要有一次握手。

qq_44005305的博客 406

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

MobileIMSDK移动端推送优化:减少电量消耗的7个最佳实践

MobileIMSDK是一个原创多端IM通信层框架,历经8年久经考验,可能是市面上唯一同时支持UDP+TCP+WebSocket三种协议的同类开源框架。对于移动端IM应用来说,电量消耗是一个关键的性能指标,直接影响用户体验和留存率。 ## 📱 为什么移动IM应用需要电量优化? 移动设备电量有限,IM应用作为常驻后台的服务,如果不进行优化,会持续消耗大量电力。研究表明,超过60%的用户会因为应

gitblog_00939的博客 1175

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

保障IM推送、优化移动网络 网易云信解决移动IM稳定难题

引用内容“IM本身是一个比较复杂和庞大的系统,在客户端开发时,也就会涉及到很多繁杂的业务需求。当绝大多数IM平台商都在朝向功能化的一站化大潮流迈进时,唯有云信不忘静下心来沉淀内功。云信针对移动网络所做的弱网络优化工作,为IM云服务的稳定垫定了技术基础。”——网易云信Android端高级技术架构师周江华 对于移动APP来说,除了简单的工具类APP外,IM功能正变得越来越重要,它能够创建起人与人...

well_2000_82的博客 1204

IM 推送保障及网络优化详解(三):如何在弱网环境下优化大数据传输?

对于移动 App 来说,IM 功能正变得越来越重要,它能够创建起人与人之间的连接。社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性。在复杂的 Android 生态环境下,多种因素都会造成消息推送不能及时达到客户端。另外,不稳定的移动网络也给数据传输的速率和可靠性增加了障碍。本文详解了网易云信 IM SDK 在应对弱网环境、移动端...

weixin_33898233的博客 875

网易云信即时通讯推送保障及网络优化详解(三):如何在弱网环境下优化大数据传输

如何在弱网环境下优化大数据传输对于移动 APP 来说,IM 功能正变得越来越重要,它能够创建起人与人之间的连接。社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性。在复杂的 Android 生态环境下,多种因素都会造成消息推送不能及时达到客户端。另外,不稳定的移动网络也给数据传输的速率和可靠性增加了障碍。本文详解了 网易云信IM SDK 在应对弱网环境、移动端硬件限制以及 Android ...

netease_im的博客 1227

周江华:网易云信IM推送保障及网络优化实践

周江华,网易资深Android开发工程师,先后主导参与了易信、网易云信、网易七鱼的客户端开发工作,拥有非常丰富的功能开发以及代码优化经验。2016年9月23日,MDCC 2016中国移动...

netease_im的博客 704

IM推送保障及网络优化详解(三):如何在弱网环境下优化大数据传输

对于移动APP来说,IM功能正变得越来越重要,它能够创建起人与人之间的连接。社交类产品中,用户与用户之间的沟通可以产生出更好的用户粘性。在复杂的 Android 生态环境下,多种因素都会造成消息推送不能及时达到客户端。另外,不稳定的移动网络也给数据传输的速率和可靠性增加了障碍。本文详解了网易云信IM SDK在应对弱网环境、移动端硬件限制以及Android复杂的生态现状时的探索与心得.如何实现不影响...

weixin_34253126的博客 835
上一篇: 发掘文件系统过滤驱动的应用
下一篇: 文件加密标识 -隐藏文件头的黑客代码
iiprogram
博客等级 码龄25年 1068粉丝 1515原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址