亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? context.c

?? miniFilter.rar所有框架代碼以及對應的PPT資料,可以直接拿來進行修改即可完成各種驅動,是你開發微軟新過濾構架驅動所必下資料
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*++

Copyright (c) 1999 - 2002  Microsoft Corporation

Module Name:

    context.c

Abstract:

    This is the stream nd stream handle context module of the kernel mode
    context sample filter driver


Environment:

    Kernel mode


--*/


#include "pch.h"


#ifdef ALLOC_PRAGMA
#pragma alloc_text(PAGE, CtxFindOrCreateFileContext)
#pragma alloc_text(PAGE, CtxCreateFileContext)
#pragma alloc_text(PAGE, CtxFindOrCreateStreamContext)
#pragma alloc_text(PAGE, CtxCreateStreamContext)
#pragma alloc_text(PAGE, CtxUpdateNameInStreamContext)
#pragma alloc_text(PAGE, CtxCreateOrReplaceStreamHandleContext)
#pragma alloc_text(PAGE, CtxCreateStreamHandleContext)
#pragma alloc_text(PAGE, CtxUpdateNameInStreamHandleContext)
#endif




NTSTATUS
CtxFindOrCreateFileContext (
    __in PFLT_CALLBACK_DATA Cbd,
    __in BOOLEAN CreateIfNotFound,
    __in_opt PUNICODE_STRING FileName,
    __deref_out PCTX_FILE_CONTEXT *FileContext,
    __out_opt PBOOLEAN ContextCreated
    )
/*++

Routine Description:

    This routine finds the file context for the target file.
    Optionally, if the context does not exist this routing creates
    a new one and attaches the context to the file.

Arguments:

    Cbd                   - Supplies a pointer to the callbackData which
                            declares the requested operation.
    CreateIfNotFound      - Supplies if the file context must be created if missing
    FileName              - Supplies the file name
    FileContext           - Returns the file context
    ContextCreated        - Returns if a new context was created

Return Value:

    Status

--*/
{
    NTSTATUS status;
    PCTX_FILE_CONTEXT fileContext;
    PCTX_FILE_CONTEXT oldFileContext;

    PAGED_CODE();

    *FileContext = NULL;
    if (ContextCreated != NULL) *ContextCreated = FALSE;

    //
    //  First try to get the file context.
    //

    DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                ("[Ctx]: Trying to get file context (FileObject = %p, Instance = %p)\n",
                 Cbd->Iopb->TargetFileObject,
                 Cbd->Iopb->TargetInstance) );

    status = FltGetFileContext( Cbd->Iopb->TargetInstance,
                                  Cbd->Iopb->TargetFileObject,
                                  &fileContext );

    //
    //  If the call failed because the context does not exist
    //  and the user wants to creat a new one, the create a
    //  new context
    //

    if (!NT_SUCCESS( status ) &&
        (status == STATUS_NOT_FOUND) &&
        CreateIfNotFound) {


        //
        //  Create a file context
        //

        DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                    ("[Ctx]: Creating file context (FileObject = %p, Instance = %p)\n",
                     Cbd->Iopb->TargetFileObject,
                     Cbd->Iopb->TargetInstance) );

        status = CtxCreateFileContext( FileName, &fileContext );

        if (!NT_SUCCESS( status )) {

            DebugTrace( DEBUG_TRACE_ERROR | DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                        ("[Ctx]: Failed to create file context with status 0x%x. (FileObject = %p, Instance = %p)\n",
                        status,
                        Cbd->Iopb->TargetFileObject,
                        Cbd->Iopb->TargetInstance) );

            return status;
        }


        //
        //  Set the new context we just allocated on the file object
        //

        DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                    ("[Ctx]: Setting file context %p (FileObject = %p, Instance = %p)\n",
                     fileContext,
                     Cbd->Iopb->TargetFileObject,
                     Cbd->Iopb->TargetInstance) );

        status = FltSetFileContext( Cbd->Iopb->TargetInstance,
                                      Cbd->Iopb->TargetFileObject,
                                      FLT_SET_CONTEXT_KEEP_IF_EXISTS,
                                      fileContext,
                                      &oldFileContext );

        if (!NT_SUCCESS( status )) {

            DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                        ("[Ctx]: Failed to set file context with status 0x%x. (FileObject = %p, Instance = %p)\n",
                        status,
                        Cbd->Iopb->TargetFileObject,
                        Cbd->Iopb->TargetInstance) );
            //
            //  We release the context here because FltSetFileContext failed
            //
            //  If FltSetFileContext succeeded then the context will be returned
            //  to the caller. The caller will use the context and then release it
            //  when he is done with the context.
            //

            DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                        ("[Ctx]: Releasing file context %p (FileObject = %p, Instance = %p)\n",
                         fileContext,
                         Cbd->Iopb->TargetFileObject,
                         Cbd->Iopb->TargetInstance) );

            FltReleaseContext( fileContext );

            if (status != STATUS_FLT_CONTEXT_ALREADY_DEFINED) {

                //
                //  FltSetFileContext failed for a reason other than the context already
                //  existing on the file. So the object now does not have any context set
                //  on it. So we return failure to the caller.
                //

                DebugTrace( DEBUG_TRACE_ERROR | DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                            ("[Ctx]: Failed to set file context with status 0x%x != STATUS_FLT_CONTEXT_ALREADY_DEFINED. (FileObject = %p, Instance = %p)\n",
                            status,
                            Cbd->Iopb->TargetFileObject,
                            Cbd->Iopb->TargetInstance) );

                return status;
            }

            //
            //  Race condition. Someone has set a context after we queried it.
            //  Use the already set context instead
            //

            DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                        ("[Ctx]: File context already defined. Retaining old file context %p (FileObject = %p, Instance = %p)\n",
                         oldFileContext,
                         Cbd->Iopb->TargetFileObject,
                         Cbd->Iopb->TargetInstance) );

            //
            //  Return the existing context. Note that the new context that we allocated has already been
            //  realeased above.
            //

            fileContext = oldFileContext;
            status = STATUS_SUCCESS;

        } else {

            if (ContextCreated != NULL) *ContextCreated = TRUE;
        }
    }

    *FileContext = fileContext;

    return status;
}


NTSTATUS
CtxCreateFileContext (
    __in PUNICODE_STRING FileName,
    __deref_out PCTX_FILE_CONTEXT *FileContext
    )
/*++

Routine Description:

    This routine creates a new file context

Arguments:

    FileName            - Supplies the file name
    FileContext         - Returns the file context

Return Value:

    Status

--*/
{
    NTSTATUS status;
    PCTX_FILE_CONTEXT fileContext;

    PAGED_CODE();

    //
    //  Allocate a file context
    //

    DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS,
                ("[Ctx]: Allocating file context \n") );

    status = FltAllocateContext( Globals.Filter,
                                 FLT_FILE_CONTEXT,
                                 CTX_FILE_CONTEXT_SIZE,
                                 PagedPool,
                                 &fileContext );

    if (!NT_SUCCESS( status )) {

        DebugTrace( DEBUG_TRACE_FILE_CONTEXT_OPERATIONS | DEBUG_TRACE_ERROR,
                    ("[Ctx]: Failed to allocate file context with status 0x%x \n",
                     status) );
        return status;
    }

    //
    //  Initialize the newly created context
    //

    //
    //  Allocate and copy off the file name
    //

    fileContext->FileName.MaximumLength = FileName->Length;
    status = CtxAllocateUnicodeString( &fileContext->FileName );
    if (NT_SUCCESS( status )) {

        RtlCopyUnicodeString( &fileContext->FileName, FileName );
    }

    *FileContext = fileContext;

    return STATUS_SUCCESS;
}


NTSTATUS
CtxFindOrCreateStreamContext (
    __in PFLT_CALLBACK_DATA Cbd,
    __in BOOLEAN CreateIfNotFound,
    __deref_out PCTX_STREAM_CONTEXT *StreamContext,
    __out_opt PBOOLEAN ContextCreated
    )
/*++

Routine Description:

    This routine finds the stream context for the target stream.
    Optionally, if the context does not exist this routing creates
    a new one and attaches the context to the stream.

Arguments:

    Cbd                   - Supplies a pointer to the callbackData which
                            declares the requested operation.
    CreateIfNotFound      - Supplies if the stream must be created if missing
    StreamContext         - Returns the stream context
    ContextCreated        - Returns if a new context was created

Return Value:

    Status

--*/
{
    NTSTATUS status;
    PCTX_STREAM_CONTEXT streamContext;
    PCTX_STREAM_CONTEXT oldStreamContext;

    PAGED_CODE();

    *StreamContext = NULL;
    if (ContextCreated != NULL) *ContextCreated = FALSE;

    //
    //  First try to get the stream context.
    //

    DebugTrace( DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                ("[Ctx]: Trying to get stream context (FileObject = %p, Instance = %p)\n",
                 Cbd->Iopb->TargetFileObject,
                 Cbd->Iopb->TargetInstance) );

    status = FltGetStreamContext( Cbd->Iopb->TargetInstance,
                                  Cbd->Iopb->TargetFileObject,
                                  &streamContext );

    //
    //  If the call failed because the context does not exist
    //  and the user wants to creat a new one, the create a
    //  new context
    //

    if (!NT_SUCCESS( status ) &&
        (status == STATUS_NOT_FOUND) &&
        CreateIfNotFound) {


        //
        //  Create a stream context
        //

        DebugTrace( DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                    ("[Ctx]: Creating stream context (FileObject = %p, Instance = %p)\n",
                     Cbd->Iopb->TargetFileObject,
                     Cbd->Iopb->TargetInstance) );

        status = CtxCreateStreamContext( &streamContext );

        if (!NT_SUCCESS( status )) {

            DebugTrace( DEBUG_TRACE_ERROR | DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                        ("[Ctx]: Failed to create stream context with status 0x%x. (FileObject = %p, Instance = %p)\n",
                        status,
                        Cbd->Iopb->TargetFileObject,
                        Cbd->Iopb->TargetInstance) );

            return status;
        }


        //
        //  Set the new context we just allocated on the file object
        //

        DebugTrace( DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                    ("[Ctx]: Setting stream context %p (FileObject = %p, Instance = %p)\n",
                     streamContext,
                     Cbd->Iopb->TargetFileObject,
                     Cbd->Iopb->TargetInstance) );

        status = FltSetStreamContext( Cbd->Iopb->TargetInstance,
                                      Cbd->Iopb->TargetFileObject,
                                      FLT_SET_CONTEXT_KEEP_IF_EXISTS,
                                      streamContext,
                                      &oldStreamContext );

        if (!NT_SUCCESS( status )) {

            DebugTrace( DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                        ("[Ctx]: Failed to set stream context with status 0x%x. (FileObject = %p, Instance = %p)\n",
                        status,
                        Cbd->Iopb->TargetFileObject,
                        Cbd->Iopb->TargetInstance) );
            //
            //  We release the context here because FltSetStreamContext failed
            //
            //  If FltSetStreamContext succeeded then the context will be returned
            //  to the caller. The caller will use the context and then release it
            //  when he is done with the context.
            //

            DebugTrace( DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                        ("[Ctx]: Releasing stream context %p (FileObject = %p, Instance = %p)\n",
                         streamContext,
                         Cbd->Iopb->TargetFileObject,
                         Cbd->Iopb->TargetInstance) );

            FltReleaseContext( streamContext );

            if (status != STATUS_FLT_CONTEXT_ALREADY_DEFINED) {

                //
                //  FltSetStreamContext failed for a reason other than the context already
                //  existing on the stream. So the object now does not have any context set
                //  on it. So we return failure to the caller.
                //

                DebugTrace( DEBUG_TRACE_ERROR | DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                            ("[Ctx]: Failed to set stream context with status 0x%x != STATUS_FLT_CONTEXT_ALREADY_DEFINED. (FileObject = %p, Instance = %p)\n",
                            status,
                            Cbd->Iopb->TargetFileObject,
                            Cbd->Iopb->TargetInstance) );

                return status;
            }

            //
            //  Race condition. Someone has set a context after we queried it.
            //  Use the already set context instead
            //

            DebugTrace( DEBUG_TRACE_STREAM_CONTEXT_OPERATIONS,
                        ("[Ctx]: Stream context already defined. Retaining old stream context %p (FileObject = %p, Instance = %p)\n",
                         oldStreamContext,
                         Cbd->Iopb->TargetFileObject,
                         Cbd->Iopb->TargetInstance) );

            //
            //  Return the existing context. Note that the new context that we allocated has already been
            //  realeased above.
            //

            streamContext = oldStreamContext;
            status = STATUS_SUCCESS;

        } else {

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区在线观看免费| 国产成人精品在线看| 国内精品嫩模私拍在线| 91免费看`日韩一区二区| 欧美精品久久久久久久久老牛影院| 2021久久国产精品不只是精品| 亚洲色图视频网| 国产乱码字幕精品高清av | 精品国产网站在线观看| 国产精品素人视频| 蜜桃视频免费观看一区| 色婷婷精品大在线视频| 国产精品免费视频网站| 国产精品一区二区你懂的| 7777精品伊人久久久大香线蕉超级流畅 | 成人美女视频在线看| 972aa.com艺术欧美| 一区精品在线播放| 久久一区二区视频| 免费的成人av| 欧美精品第1页| 亚洲激情欧美激情| 成人激情免费网站| 久久精品亚洲一区二区三区浴池 | 亚洲美女在线一区| 成人国产精品免费| 国产人成亚洲第一网站在线播放| 六月丁香综合在线视频| 制服视频三区第一页精品| 亚洲大型综合色站| 欧美电影一区二区| 日韩av不卡在线观看| 欧美顶级少妇做爰| 蜜桃精品视频在线| 精品国产免费一区二区三区香蕉| 日韩av电影天堂| 日韩免费一区二区| 麻豆精品在线观看| 欧美精品一区二区在线播放| 久久99九九99精品| 国产区在线观看成人精品 | 中文字幕在线一区| 91麻豆免费在线观看| 亚洲人成影院在线观看| 色欧美88888久久久久久影院| 综合在线观看色| 欧美日韩视频在线第一区| 亚洲成人中文在线| 精品理论电影在线| 国产成人鲁色资源国产91色综| 中文字幕国产精品一区二区| 91麻豆国产福利在线观看| 亚洲va欧美va人人爽午夜| 91精品国产高清一区二区三区蜜臀| 免费观看日韩av| 中文字幕av一区二区三区| av在线综合网| 日韩经典一区二区| 久久日一线二线三线suv| www.爱久久.com| 午夜精品一区二区三区免费视频| 日韩精品在线看片z| 不卡一区二区在线| 亚洲成人tv网| 国产日韩欧美麻豆| 欧美日韩精品二区第二页| 狂野欧美性猛交blacked| 国产精品成人一区二区三区夜夜夜| 欧美色国产精品| 国产精品一区免费在线观看| 一区二区三区视频在线观看| 欧美大片日本大片免费观看| 91网站最新网址| 麻豆视频观看网址久久| 亚洲视频一区在线观看| 7777精品伊人久久久大香线蕉完整版 | 久久久精品中文字幕麻豆发布| 91同城在线观看| 久久se这里有精品| 一区二区三区中文字幕在线观看| 欧美v日韩v国产v| 色妞www精品视频| 国产激情一区二区三区| 首页国产丝袜综合| 亚洲乱码一区二区三区在线观看| 日韩视频中午一区| 91国偷自产一区二区开放时间 | 七七婷婷婷婷精品国产| 亚洲同性同志一二三专区| 日韩欧美一级特黄在线播放| 欧洲av在线精品| 成人一道本在线| 老司机精品视频导航| 亚洲国产视频直播| 最新日韩av在线| 2022国产精品视频| 欧美成人激情免费网| 欧美性感一区二区三区| 91在线视频免费观看| 国产成人在线视频网站| 狠狠狠色丁香婷婷综合久久五月| 丝袜亚洲另类欧美| 亚洲第一成人在线| 亚洲小说欧美激情另类| 综合电影一区二区三区| 国产精品三级在线观看| 久久精品亚洲乱码伦伦中文| 亚洲精品在线免费观看视频| 欧美一级一区二区| 在线播放/欧美激情| 欧美日韩国产首页在线观看| 在线影视一区二区三区| 欧美在线视频不卡| 欧美调教femdomvk| 欧美日韩成人一区二区| 欧美熟乱第一页| 欧美人妇做爰xxxⅹ性高电影| 欧美三级日韩三级国产三级| 欧美日韩专区在线| 欧美日本视频在线| 在线成人免费观看| 日韩女优视频免费观看| 精品毛片乱码1区2区3区| 久久夜色精品一区| 欧美国产亚洲另类动漫| 中文成人综合网| 椎名由奈av一区二区三区| 亚洲乱码国产乱码精品精的特点 | 国产人成一区二区三区影院| 中日韩免费视频中文字幕| 最近日韩中文字幕| 性做久久久久久免费观看欧美| 免费在线观看一区| 国产美女一区二区| 波多野结衣欧美| 欧美无乱码久久久免费午夜一区| 欧美美女网站色| 国产偷v国产偷v亚洲高清| 国产精品久久免费看| 亚洲国产cao| 久久99国产精品免费网站| 国产成人h网站| 欧洲av一区二区嗯嗯嗯啊| 91精品国模一区二区三区| 久久日一线二线三线suv| 亚洲天堂中文字幕| 奇米影视一区二区三区小说| 成人成人成人在线视频| 欧美日韩一级片在线观看| 精品噜噜噜噜久久久久久久久试看 | 国产成人精品三级| 欧美性受xxxx| 国产亚洲精久久久久久| 伊人婷婷欧美激情| 国产一区二区三区蝌蚪| 色综合天天综合网天天狠天天 | 欧美国产一区视频在线观看| 亚洲中国最大av网站| 国产永久精品大片wwwapp | 不卡视频在线看| 欧美日韩电影一区| 国产无一区二区| 日韩二区三区四区| 99国产精品国产精品久久| 欧美在线播放高清精品| 久久天天做天天爱综合色| 亚洲国产精品一区二区尤物区| 国产精品一二三四| 欧美日本在线视频| 国产精品护士白丝一区av| 免费成人小视频| 欧美日韩一区二区三区在线看| 久久精品视频一区二区三区| 三级久久三级久久久| 色婷婷精品久久二区二区蜜臂av | 欧美一区二区二区| 亚洲另类在线一区| 成人手机在线视频| 久久婷婷一区二区三区| 日韩av中文字幕一区二区三区 | 日韩欧美区一区二| 亚洲国产综合在线| 91女神在线视频| 国产日本欧洲亚洲| 在线看一区二区| 国产精品全国免费观看高清 | 欧美mv日韩mv国产网站| 性做久久久久久久久| 日本久久一区二区三区| 国产精品国产自产拍高清av王其| 韩国精品久久久| 精品卡一卡二卡三卡四在线| 日韩国产一二三区| 91精品欧美一区二区三区综合在| 亚洲福利一区二区三区| 在线亚洲一区观看| 亚洲 欧美综合在线网络| 欧美在线999| 亚洲成av人在线观看| 欧美日韩国产精品成人|