/*++
Copyright (c) 1999 - 2002 Microsoft Corporation
Module Name:
SwapBuffers.c
Abstract:
This is a sample filter which demonstrates proper access of data buffer
and a general guideline of how to swap buffers.
For now it only swaps buffers for:
IRP_MJ_READ
IRP_MJ_WRITE
IRP_MJ_DIRECTORY_CONTROL
By default this filter attaches to all volumes it is notified about. It
does support having multiple instances on a given volume.
Environment:
Kernel mode
--*/
#include <fltKernel.h>
#include <dontuse.h>
#include <suppress.h>
#pragma prefast(disable:__WARNING_ENCODE_MEMBER_FUNCTION_POINTER, "Not valid for kernel mode drivers")
PFLT_FILTER gFilterHandle;
/*************************************************************************
Pool Tags
*************************************************************************/
#define BUFFER_SWAP_TAG 'bdBS'
#define CONTEXT_TAG 'xcBS'
#define NAME_TAG 'mnBS'
#define PRE_2_POST_TAG 'ppBS'
/*************************************************************************
Local structures
*************************************************************************/
//
// This is a volume context, one of these are attached to each volume
// we monitor. This is used to get a "DOS" name for debug display.
//
typedef struct _VOLUME_CONTEXT {
//
// Holds the name to display
//
UNICODE_STRING Name;
//
// Holds the sector size for this volume.
//
ULONG SectorSize;
} VOLUME_CONTEXT, *PVOLUME_CONTEXT;
#define MIN_SECTOR_SIZE 0x200
//
// This is a context structure that is used to pass state from our
// pre-operation callback to our post-operation callback.
//
typedef struct _PRE_2_POST_CONTEXT {
//
// Pointer to our volume context structure. We always get the context
// in the preOperation path because you can not safely get it at DPC
// level. We then release it in the postOperation path. It is safe
// to release contexts at DPC level.
//
PVOLUME_CONTEXT VolCtx;
//
// Since the post-operation parameters always receive the "original"
// parameters passed to the operation, we need to pass our new destination
// buffer to our post operation routine so we can free it.
//
PVOID SwappedBuffer;
} PRE_2_POST_CONTEXT, *PPRE_2_POST_CONTEXT;
//
// This is a lookAside list used to allocate our pre-2-post structure.
//
NPAGED_LOOKASIDE_LIST Pre2PostContextList;
/*************************************************************************
Prototypes
*************************************************************************/
NTSTATUS
InstanceSetup (
__in PCFLT_RELATED_OBJECTS FltObjects,
__in FLT_INSTANCE_SETUP_FLAGS Flags,
__in DEVICE_TYPE VolumeDeviceType,
__in FLT_FILESYSTEM_TYPE VolumeFilesystemType
);
VOID
CleanupVolumeContext(
__in PFLT_CONTEXT Context,
__in FLT_CONTEXT_TYPE ContextType
);
NTSTATUS
InstanceQueryTeardown (
__in PCFLT_RELATED_OBJECTS FltObjects,
__in FLT_INSTANCE_QUERY_TEARDOWN_FLAGS Flags
);
NTSTATUS
DriverEntry (
__in PDRIVER_OBJECT DriverObject,
__in PUNICODE_STRING RegistryPath
);
NTSTATUS
FilterUnload (
__in FLT_FILTER_UNLOAD_FLAGS Flags
);
FLT_PREOP_CALLBACK_STATUS
SwapPreReadBuffers(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__deref_out_opt PVOID *CompletionContext
);
FLT_POSTOP_CALLBACK_STATUS
SwapPostReadBuffers(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__in PVOID CompletionContext,
__in FLT_POST_OPERATION_FLAGS Flags
);
FLT_POSTOP_CALLBACK_STATUS
SwapPostReadBuffersWhenSafe (
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__in PVOID CompletionContext,
__in FLT_POST_OPERATION_FLAGS Flags
);
FLT_PREOP_CALLBACK_STATUS
SwapPreDirCtrlBuffers(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__deref_out_opt PVOID *CompletionContext
);
FLT_POSTOP_CALLBACK_STATUS
SwapPostDirCtrlBuffers(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__in PVOID CompletionContext,
__in FLT_POST_OPERATION_FLAGS Flags
);
FLT_POSTOP_CALLBACK_STATUS
SwapPostDirCtrlBuffersWhenSafe (
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__in PVOID CompletionContext,
__in FLT_POST_OPERATION_FLAGS Flags
);
FLT_PREOP_CALLBACK_STATUS
SwapPreWriteBuffers(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__deref_out_opt PVOID *CompletionContext
);
FLT_POSTOP_CALLBACK_STATUS
SwapPostWriteBuffers(
__inout PFLT_CALLBACK_DATA Data,
__in PCFLT_RELATED_OBJECTS FltObjects,
__in PVOID CompletionContext,
__in FLT_POST_OPERATION_FLAGS Flags
);
VOID
ReadDriverParameters (
__in PUNICODE_STRING RegistryPath
);
//
// Assign text sections for each routine.
//
#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, InstanceSetup)
#pragma alloc_text(PAGE, CleanupVolumeContext)
#pragma alloc_text(PAGE, InstanceQueryTeardown)
#pragma alloc_text(INIT, DriverEntry)
#pragma alloc_text(INIT, ReadDriverParameters)
#pragma alloc_text(PAGE, FilterUnload)
#endif
//
// Operation we currently care about.
//
CONST FLT_OPERATION_REGISTRATION Callbacks[] = {
{ IRP_MJ_READ,
0,
SwapPreReadBuffers,
SwapPostReadBuffers },
{ IRP_MJ_WRITE,
0,
SwapPreWriteBuffers,
SwapPostWriteBuffers },
{ IRP_MJ_DIRECTORY_CONTROL,
0,
SwapPreDirCtrlBuffers,
SwapPostDirCtrlBuffers },
{ IRP_MJ_OPERATION_END }
};
//
// Context definitions we currently care about. Note that the system will
// create a lookAside list for the volume context because an explicit size
// of the context is specified.
//
CONST FLT_CONTEXT_REGISTRATION ContextNotifications[] = {
{ FLT_VOLUME_CONTEXT,
0,
CleanupVolumeContext,
sizeof(VOLUME_CONTEXT),
CONTEXT_TAG },
{ FLT_CONTEXT_END }
};
//
// This defines what we want to filter with FltMgr
//
CONST FLT_REGISTRATION FilterRegistration = {
sizeof( FLT_REGISTRATION ), // Size
FLT_REGISTRATION_VERSION, // Version
0, // Flags
ContextNotifications, // Context
Callbacks, // Operation callbacks
FilterUnload, // MiniFilterUnload
InstanceSetup, // InstanceSetup
InstanceQueryTeardown, // InstanceQueryTeardown
NULL, // InstanceTeardownStart
NULL, // InstanceTeardownComplete
NULL, // GenerateFileName
NULL, // GenerateDestinationFileName
NULL // NormalizeNameComponent
};
/*************************************************************************
Debug tracing information
*************************************************************************/
//
// Definitions to display log messages. The registry DWORD entry:
// "hklm\system\CurrentControlSet\Services\Swapbuffers\DebugFlags" defines
// the default state of these logging flags
//
#define LOGFL_ERRORS 0x00000001 // if set, display error messages
#define LOGFL_READ 0x00000002 // if set, display READ operation info
#define LOGFL_WRITE 0x00000004 // if set, display WRITE operation info
#define LOGFL_DIRCTRL 0x00000008 // if set, display DIRCTRL operation info
#de
没有合适的资源?快使用搜索试试~ 我知道了~
微软微过滤器MiniFilter的源码

共81个文件
c:21个
h:15个
rc:11个


温馨提示
微软微过滤器MiniFilter的源码 Windows Server 2008 IFSDDK里面的东东 有兴趣的研究下
资源推荐
资源详情
资源评论











收起资源包目录


































































































共 81 条
- 1
资源评论

- u0106863902013-06-14下载后才发现已经安装过了,不过还是给分。
- wrgg02013-04-01之前在学习sfilter,后来发现minifilter好像更简单点,这应该是不错的东西。感谢分享。
- luohegongmin2013-03-22要是代码详细些就好了
- keary0932011-10-14就是WinDDK自带的东西,不过还是不错了~

888atao
- 粉丝: 5
- 资源: 1
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助


最新资源
- 获取指定zabbix 组的数据的脚本
- QCharts绘制正余弦曲线 Qt Charts 是Qt提供的图表模块,能够绘制常见的折线图、柱状图、饼图等图表
- 苹果cmsV10 仿8x8x 视频图片小说源码 在线充值VIP会员 三级分销 推广 提现 在线
- vmware tools安装步骤.zip
- Y轴云台底座.STEP
- 最新版易支付V6.99 支付程序需要的自取去授权版 支持自定义套餐价格功能权限
- 新版可运营级网盘系统网站源码 支持转存和限速
- C艹程序星空作者快乐星空
- sprinboot整合Oauth2.0、Spring Security,对接数据数据库,支持zuul路由
- 芒果在线咸鱼转转交易猫聊天客服源码-支持分享图
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈



安全验证
文档复制为VIP权益,开通VIP直接复制
