Windows Minifilter驱动 - DriverEntry (3)

DriverEntry作为Windows Minifilter驱动的入口点,负责调用FltRegisterFilter进行驱动注册,并通过FltStartFiltering启动I/O操作过滤。在DriverEntry中,驱动对象和回调函数设置是关键,尤其是预处理和后处理回调,它们在IRP传递前后的不同阶段发挥作用。
摘要由CSDN通过智能技术生成

驱动里面的DriverEntry就相当于main()或者DllMain()函数,这是个入口点。当驱动被加载的时候,DriverEntry会被调用。

VS2013给我们生成的DriverEntry函数如下:

NTSTATUS
DriverEntry (
    _In_ PDRIVER_OBJECT DriverObject,
    _In_ PUNICODE_STRING RegistryPath
    )
/*++

Routine Description:

    This is the initialization routine for this miniFilter driver.  This
    registers with FltMgr and initializes all global data structures.

Arguments:

    DriverObject - Pointer to driver object created by the system to
        represent this driver.

    RegistryPath - Unicode string identifying where the parameters for this
        driver are located in the registry.

Return Value:

    Routine can return non success error codes.

--*/
{
    NTSTATUS status;

    UNREFERENCED_PARAMETER( RegistryPath );

    PT_DBG_PRINT( PTDBG_TRACE_ROUTINES,
                  ("MyMiniFilter!DriverEntry: Entered\n") );

    //
    //  Register with FltMgr to tell it our callback routines
    //

    status = FltRegisterFilter( DriverObject,
                                &FilterRegistration,
                                &gFilterHandle );

    FLT_ASSERT( NT_SUCCESS( status ) );

    if (NT_SUCCESS( status )) {

        //
        //  Start filtering i/o
        //

        status = FltStartFiltering( gFilterHandle );

        if (!NT_SUCCESS( status )) {

            FltUnregisterFilter( gFilterHandle );
        }
    }

    return status;
}

FltRegisterFilter

这是DriverEntry里面需要调用的第一个函数,用来注册当前这个minifilter。下面是SDN上的描述:

翻译一下:

每一个minifilter驱动必须在DriverEntry里面调用FltRegisterFilter来把它自己注册到minifilte

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值