文件过滤驱动
一个典型的ifs filter,请参考ifs ddk的例子sfilter。这个例子已经足够了
Filemon
这是一个nt驱动, 源代码包括exe和sys两部分. exe里面的Instdrv.c负责安装驱动, Filemon.c负责UI显示和与驱动通信
sys里面主要文件为Filemon.c, 分发函数为FilemonDispatch和FastIOHook, 前者负责与UI通信FilemonDeviceRoutine和截获文件操作irp (FilemonHookRoutine). 而FilemonHookRoutine里面截获的文件操作包括IRP_MJ_CREATE, IRP_MJ_CREATE_NAMED_PIPE, IRP_MJ_CREATE_MAILSLOT, IRP_MJ_CLOSE, IRP_MJ_CLEANUP, IRP_MJ_READ, IRP_MJ_WRITE, IRP_MJ_CLOSE, IRP_MJ_FLUSH_BUFFERS, IRP_MJ_QUERY_INFORMATION, IRP_MJ_SET_INFORMATION, IRP_MJ_QUERY_EA, IRP_MJ_SET_EA, IRP_MJ_QUERY_VOLUME_INFORMATION, IRP_MJ_SET_VOLUME_INFORMATION, IRP_MJ_DIRECTORY_CONTROL, IRP_MJ_FILE_SYSTEM_CONTROL, IRP_MJ_SHUTDOWN, IRP_MJ_LOCK_CONTROL, IRP_MJ_DEVICE_CONTROL, IRP_MJ_QUERY_SECURITY, IRP_MJ_SET_SECURITY , IRP_MJ_POWER, IRP_MJ_PNP,
filemon驱动里面有个难点是如何获取文件操作的exe路径, 它采用了一个未文档函数, 通过自己构造irp, 设置完成例程, 来拿到相关信息, 见函数FilemonQueryFile