diyer_xu
驱动牛犊
驱动牛犊
  • 注册日期2005-10-15
  • 最后登录2010-01-21
  • 粉丝0
  • 关注0
  • 积分3分
  • 威望21点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:1374回复:1

请教利用过滤驱动实现将缓存写入磁盘的方法

楼主#
更多 发布于:2010-01-13 15:42
The CcFlushCache routine flushes all or a portion of a cached file to disk.

VOID
  CcFlushCache(
    IN PSECTION_OBJECT_POINTERS  SectionObjectPointer,
    IN PLARGE_INTEGER  FileOffset  OPTIONAL,
    IN ULONG  Length,
    OUT PIO_STATUS_BLOCK  IoStatus  OPTIONAL
    );


在HelloDDKDeviceIOControl中实现CcFlushCache 函数调用
DriverObject->MajorFunction[IRP_MJ_DEVICE_CONTROL] = HelloDDKDeviceIOControl;

外面通过deviceiocontrol调用执行,大家认为可行吗?

还有我怎么打开我的过滤驱动设备,我安装了微软的过滤驱动,为什么以下调用返回错误代码2
HANDLE hDevice =
        CreateFile(_T("\\\\.\\Sfilter"),
        GENERIC_READ | GENERIC_WRITE,
        0,        // share mode none
        NULL,    // no security
        OPEN_EXISTING,
        FILE_ATTRIBUTE_NORMAL,
        NULL );        // no template
michaelgz
论坛版主
论坛版主
  • 注册日期2005-01-26
  • 最后登录2012-10-22
  • 粉丝1
  • 关注1
  • 积分150分
  • 威望1524点
  • 贡献值1点
  • 好评度213点
  • 原创分0分
  • 专家分2分
沙发#
发布于:2010-01-14 02:31
If I understand your question correct, I think you mis-understand the meaning of CcFlushCache(). This function is provided by CM to flush a particular file cache. It's not used to flush all system cache data. The SectionObject is a kernel structure which is not exposed to user mode. I don't think you can easily call CcFlushCache from IoControl.

As I remember, you need to make some changes, in MJ_CREATE I think, in SFilter before you can create an instance of it in user mode. There should be discussions in this forum before talking about it. Just search them.
游客

返回顶部