亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
视频一区二区三区入口| 欧美日韩黄色一区二区| 欧美精品久久天天躁| 国产日韩一级二级三级| 日精品一区二区| 在线视频欧美区| 国产精品久久久久婷婷| 国产在线视视频有精品| 日韩一区二区三区精品视频| 亚洲狠狠丁香婷婷综合久久久| 国产成人av自拍| 精品国产一区久久| 麻豆一区二区三| 欧美日韩成人一区| 亚洲第一会所有码转帖| 色系网站成人免费| 亚洲蜜桃精久久久久久久| 成人美女视频在线看| 国产欧美精品一区aⅴ影院| 韩国三级中文字幕hd久久精品| 欧美少妇一区二区| 亚洲午夜免费电影| 色狠狠一区二区| 夜夜精品浪潮av一区二区三区| 成人免费视频国产在线观看| 久久久久久**毛片大全| 国模大尺度一区二区三区| 欧美成人乱码一区二区三区| 日本大胆欧美人术艺术动态| 91精品国产综合久久香蕉麻豆| 亚洲福利视频一区二区| 欧美在线观看视频一区二区三区| 亚洲精品成人在线| 欧美性色黄大片| 天天色图综合网| 欧美xxx久久| 国产精品自拍三区| 中文字幕日韩av资源站| 99这里只有精品| 亚洲国产成人av网| 4438亚洲最大| 国产乱理伦片在线观看夜一区| 国产欧美日韩亚州综合 | 国产精品免费网站在线观看| 成年人午夜久久久| 亚洲乱码国产乱码精品精可以看| 欧美中文字幕久久| 久久国产精品99久久人人澡| 久久丝袜美腿综合| 91小视频在线免费看| 午夜精品久久久久| 久久综合色之久久综合| 成人福利视频网站| 亚洲综合在线电影| 精品少妇一区二区三区| 国产69精品一区二区亚洲孕妇| 亚洲日本va在线观看| 7777精品伊人久久久大香线蕉超级流畅 | 欧美一区二区三区四区久久| 久久99国产精品成人| 国产精品视频看| 欧美日韩成人综合天天影院| 国产成人综合在线观看| 亚洲乱码一区二区三区在线观看| 日韩视频中午一区| 99在线热播精品免费| 日韩电影在线观看网站| 中文字幕在线不卡国产视频| 欧美肥妇毛茸茸| 99久久精品国产麻豆演员表| 人人爽香蕉精品| 亚洲另类在线一区| 久久天天做天天爱综合色| 欧美性色黄大片| 成人高清视频在线观看| 蜜桃一区二区三区四区| 伊人开心综合网| 国产日韩欧美一区二区三区乱码| 欧美日韩国产影片| 99r国产精品| 国产伦精品一区二区三区免费| 一级精品视频在线观看宜春院| 国产丝袜美腿一区二区三区| 9191成人精品久久| 日本精品裸体写真集在线观看| 国产乱码精品一区二区三区av | 日本欧美在线看| 亚洲欧美日韩电影| 久久精品亚洲乱码伦伦中文| 欧美日韩情趣电影| 在线观看av一区| 成人av在线资源网| 国产一区二区在线视频| 热久久久久久久| 婷婷久久综合九色综合伊人色| 国产精品久久国产精麻豆99网站 | 91精品国产综合久久精品麻豆| 99久久综合99久久综合网站| 国产福利一区二区三区视频在线 | 日韩av一区二区三区四区| 亚洲日本丝袜连裤袜办公室| 中文字幕+乱码+中文字幕一区| 久久一区二区三区四区| 欧美电影免费观看高清完整版在 | 蜜臀久久久99精品久久久久久| 亚洲一级电影视频| 亚洲国产精品久久一线不卡| 亚洲午夜三级在线| 91搞黄在线观看| 成人免费毛片片v| 国产精品中文字幕欧美| 午夜欧美视频在线观看| 亚洲一二三区在线观看| 亚洲午夜免费电影| 偷拍一区二区三区| 日韩不卡在线观看日韩不卡视频| 亚洲美女在线国产| 一级中文字幕一区二区| 亚洲福利一区二区三区| 亚洲成人动漫在线免费观看| 婷婷综合五月天| 久久99精品久久久久| 蜜臂av日日欢夜夜爽一区| 国内一区二区在线| 成人午夜短视频| 91国偷自产一区二区三区观看| 欧美中文字幕一区二区三区| 在线不卡中文字幕| 精品乱人伦小说| 亚洲国产精品99久久久久久久久 | 不卡区在线中文字幕| 91丨九色丨黑人外教| 在线一区二区三区四区五区| 欧美视频一区二区三区| 日韩欧美一区二区久久婷婷| 国产亚洲一区二区三区四区| 亚洲婷婷综合色高清在线| 视频精品一区二区| 国产一区二区0| 99re这里只有精品视频首页| 欧美老人xxxx18| 国产视频视频一区| 一区二区三区精品视频在线| 麻豆91在线播放免费| 成人精品视频网站| 精品视频一区二区不卡| 欧美xfplay| 一区二区三区免费| 国产麻豆91精品| 在线中文字幕一区| 久久香蕉国产线看观看99| 亚洲欧美成人一区二区三区| 美女脱光内衣内裤视频久久影院| 成人免费观看av| 日韩欧美一区电影| 亚洲美女视频一区| 国产在线不卡视频| 欧美嫩在线观看| 国产精品短视频| 六月丁香综合在线视频| 在线免费av一区| 欧美—级在线免费片| 亚洲成人免费在线| 99久久久久免费精品国产| 欧美mv和日韩mv国产网站| 亚洲在线中文字幕| 成人黄色在线视频| 精品国产一区二区三区av性色| 亚洲人成精品久久久久久| 久久国产剧场电影| 欧美日韩在线不卡| 亚洲视频在线一区观看| 国产精品69久久久久水密桃| 欧美日本一道本| 一区二区在线看| www.欧美精品一二区| 国产亚洲美州欧州综合国 | 亚洲精品免费在线播放| 国产福利视频一区二区三区| 日韩一区二区三区四区| 天天综合天天做天天综合| 色综合久久精品| 国产精品久久久久久久午夜片 | 日本欧美大码aⅴ在线播放| 色悠悠久久综合| 亚洲视频一二三区| 成人ar影院免费观看视频| 国产亚洲综合av| 国产精品一品二品| 国产日产欧产精品推荐色| 国产精品影音先锋| 国产欧美中文在线| 国产乱子伦视频一区二区三区 | 亚洲成人免费视| 欧美日韩一区二区电影| 亚洲国产日韩a在线播放| 欧美三电影在线| 日本欧美在线看| 日韩视频一区二区三区在线播放| 视频一区视频二区在线观看|