Hook Dispatch 实时监控[zz]

作者:pker

/*++

Module Name:

    FSHook.c


Abstract:

    I  wanted  to  build a filter driver when I first  thought about doing such
    kind of things.  But then I found that it's not realistic 'cause it have to
    hook every filesystem driver to prevent from missing any IRPs. But we don't
    know  when  there's a new driver  coming.  When we install a virtual CD-ROM
    program, for instance,  it installs a driver to control the virtual CD-ROM.
    There  can be  viruses in the  image of the  disk,  so we have to hook that
    driver as well.

    Then a new idea,  which then I found that it's being used by most of the AV
    softs, comes out of my head. The driver's final goal is to inercept all the
    I/O behavior to disk A~Z, so we can use  ObReferenceObjectByXXX  to get the
    _FILE_OBJECT of  /??/X:/,  then   we   can   get   the   device  chain   by
    IoGetRelatedDeviceObject.  We are interested in the MajorFunction  field of
    the _DEVICE_OBJECT. We can hook the IRP_MJ_XXX we interest by replacing the
    entries of the dispatch routines with our own.


Environment:

    Kernel mode.


Copyright:

    Copyright (c) 2005, pker / CVC.GB

--*/

#include "fshook.h"


///
//
//                             Global Variables
//
///

// save hooked device objects and driver objects

PDEVICE_OBJECT g_pDevObjTab[MAX_DISK]={NULL};
PDRIVER_OBJECT g_pDrvObjTab[MAX_DISK]={NULL};

// entries of original dispatch routines of each hooked driver

PAV_DRIVER_DISPATCH_ROUTINE g_pOriginalDispatch[MAX_DISK];

// process ID of the AV scanner

ULONG g_ulPid;

// shared memory address (kernel mode)

PVOID g_pKrnlSBuffer=NULL;


///
//
//                                 Functions
//
///

ULONG
PAV_GetObjectTabIndex (<

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值