├── .gitignore ├── Driver.c ├── README.md ├── Sources └── makefile /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | 4 | # Libraries 5 | *.lib 6 | *.a 7 | 8 | # Shared objects (inc. Windows DLLs) 9 | *.dll 10 | *.so 11 | *.so.* 12 | *.dylib 13 | 14 | # Executables 15 | *.exe 16 | *.out 17 | *.app 18 | -------------------------------------------------------------------------------- /Driver.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fanggai/loadableDiskFilter/8a4d57e5980d9574cfcea0472081725fe39ac07e/Driver.c -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | loadableDiskFilter 2 | ================== 3 | 4 | a loadable windows disk filter driver 5 | 一个可动态加载/卸载的windows磁盘过滤驱动示例 6 | 7 | 大多数过滤驱动都通过INF文件说明为disk的UpFilter,然后将由系统在启动时自动加载,这带来了一些不方便。 8 | 9 | 本驱动实现可以动态加载/卸载的驱动。 10 | 1.驱动在被加载时通过向PNP管理器注册EventCategoryDeviceInterfaceChange事件, 11 | 将发现已经存在的盘并在新盘到来时收到通知,这时创建过滤设备对象attach到底层的设备对象上。 12 | 2.在底层的盘REMOVE时,将收到通知,这时驱动从底层的设备对象上detach。 13 | 14 | 主要流程: 15 | 1.DriverEntry里向PNP管理器注册,并在回调函数里做attach的工作; 16 | 2.Unload例程里做detach的工作; 17 | 3.PNP例程里做变化相关的处理,比如SURPRISE_REMOVAL,QUERY_REMOVE,CANCLE_REMOVE 18 | 19 | 20 | 包含文件:Driver.c, SOURCES, makefile, README.md 21 | 部分代码修改自WDK中的diskPerf 22 | 23 | 编译:用WDK自带的build环境进入项目路径下build即可 24 | 加载:测试时使用了osrLoader(这工具可以在网上找到),也可以自己通过SCM来加卸载驱动(参考MSDN)。 25 | 测试:在32位XP和64位WIN7上测试工作正常。 26 | 注意:本驱动会过滤包括系统盘在内的所有盘(本地盘、移动硬盘、U盘等),所以最好在虚拟机环境下进行测试!!! -------------------------------------------------------------------------------- /Sources: -------------------------------------------------------------------------------- 1 | TARGETNAME=diskFilter 2 | TARGETTYPE=DRIVER 3 | TARGETPATH=OBJ 4 | 5 | INCLUDES=$(DDKDIR)\inc;\ 6 | $(DDKDIR)\inc\ddk;\ 7 | 8 | SOURCES=Driver.c\ -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | # 2 | # DO NOT EDIT THIS FILE!!! Edit .\sources. If you want to add a new source 3 | # file to this component. This file merely indirects to the real make file 4 | # that is shared by all the driver components of the Windows NT DDK 5 | # 6 | 7 | !INCLUDE $(NTMAKEENV)\makefile.def --------------------------------------------------------------------------------