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

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

?? filemon.c

?? 文件監視FileMon 一個常用的監視軟件
?? C
?? 第 1 頁 / 共 5 頁
字號:

    //
    // Set the completion routine.
    //
    IoSetCompletionRoutine(irp, FilemonQueryFileComplete, 0, TRUE, TRUE, TRUE);

    //
    // Send it to the FSD
    //
    (void) IoCallDriver(DeviceObject, irp);

    //
    // Wait for the I/O
    //
    KeWaitForSingleObject(&event, Executive, KernelMode, TRUE, 0);

    //
    // Done! Note that since our completion routine frees the IRP we cannot 
    // touch the IRP now.
    //
    return NT_SUCCESS( IoStatusBlock.Status );
}


//----------------------------------------------------------------------
//
// FilemonGetFullPath
//
// Takes a fileobject and filename and returns a canonical path,
// nicely formatted, in fullpathname.
//
//----------------------------------------------------------------------
VOID 
FilemonGetFullPath( 
    BOOLEAN createPath, 
    PFILE_OBJECT fileObject, 
    PHOOK_EXTENSION hookExt, 
    PCHAR fullPathName 
    )
{
    ULONG               pathLen, prefixLen, slashes;
    PCHAR               pathOffset, ptr;
    BOOLEAN             gotPath;
    PFILE_OBJECT        relatedFileObject;
    PHASH_ENTRY         hashEntry, newEntry;
    ANSI_STRING         fileName;
    ANSI_STRING         relatedName;
    PFILE_NAME_INFORMATION fileNameInfo;
    FILE_INTERNAL_INFORMATION fileInternalInfo;
    UNICODE_STRING      fullUniName;
    ULONGLONG           mftIndex;

    //
    // Only do this if a GUI is active and filtering is on
    //
    if( fullPathName ) fullPathName[0] = 0;
    if( !FilterOn || !hookExt || !hookExt->Hooked || !fullPathName) {
     
        return;
    }

    //
    // Lookup the object in the hash table to see if a name 
    // has already been generated for it
    //
    KeEnterCriticalRegion();
    ExAcquireResourceSharedLite( &HashResource, TRUE );

    hashEntry = HashTable[ HASHOBJECT( fileObject ) ];
    while( hashEntry && hashEntry->FileObject != fileObject )  {

        hashEntry = hashEntry->Next;
    }

    //
    // Did we find an entry?
    //
    if( hashEntry ) {

        //
        // Yes, so get the name from the entry.
        //
        strcpy( fullPathName, hashEntry->FullPathName );
        ExReleaseResourceLite( &HashResource );
        KeLeaveCriticalRegion();
        return;
    }

    ExReleaseResourceLite( &HashResource );
    KeLeaveCriticalRegion();

    //
    // We didn't find the name in the hash table so let's either ask
    // the file system for it or construct it from the file objects.
    //

    //
    // Calculate prefix length
    //
    switch( hookExt->Type ) {
    case NPFS: 
        prefixLen = NAMED_PIPE_PREFIX_LENGTH;
        break;
    case MSFS: 
        prefixLen = MAIL_SLOT_PREFIX_LENGTH;
        break;
    default: 
        if( !fileObject ||
            fileObject->DeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM ) {

            prefixLen = 0;

        } else {

            prefixLen = 2; // "C:"
        }
        break;
    }

    //
    // If there's no file object, we can't even ask for a name.
    //
    if( !fileObject ) { 

        if( hookExt->Type == NPFS )      strcpy( fullPathName, NAMED_PIPE_PREFIX );
        else if( hookExt->Type == MSFS ) strcpy( fullPathName, MAIL_SLOT_PREFIX );
        else                             sprintf( fullPathName, "%C:", hookExt->LogicalDrive );
        return;
    }

    //
    // Initialize variables
    //
    fileName.Buffer = NULL;
    relatedName.Buffer = NULL;
    gotPath = FALSE;

    //
    // Check for special case first: NTFS volume and a file object
    // with no name. It might be a metadata file that we "know" the name of. This
    // special case also stops us from querying NTFS for the name of a metadata
    // file on versions of NTFS prior to Whistler, which is a good thing since
    // that causes hangs and crashes. On Whistler metadata files have file names.
    //
    if( !fileObject->FileName.Buffer && hookExt->FsAttributes &&
        !memcmp( hookExt->FsAttributes->FileSystemName, L"NTFS", sizeof(L"NTFS")-sizeof(WCHAR))) {

        //
        // The only file that is opened without a name is a volume
        //
        if( createPath ) {

            sprintf( fullPathName, "%C:", hookExt->LogicalDrive );

            //
            // Return right here without inserting this into the hash table, since this might
            // be the cleanup path of a metadata file and we can retrieve the metada's index
            // at a later point.
            //
            return;

        } else if( FilemonQueryFile( hookExt->FileSystem, fileObject, FileInternalInformation,
                              &fileInternalInfo, sizeof( fileInternalInfo ))) {
            
            //
            // Use the name in the metadata name index
            //
            mftIndex = fileInternalInfo.IndexNumber.QuadPart & ~0xF0000000;
            if( mftIndex <= MAX_NTFS_METADATA_FILE ) {

                sprintf( fullPathName, "%C:\\%s", hookExt->LogicalDrive, NtfsMetadataFileNames[ mftIndex ] );
                gotPath = TRUE;
            }                
        } 
    }

    //
    // If we are not in the create path, we can ask the file system for the name. If we
    // are in the create path, we can't ask the file system for the name of the file object, since
    // the file system driver hasn't even seen the file object yet.
    //
    if( !gotPath && !createPath ) {

        //
        // Ask the file system for the name of the file, which its required to be
        // able to provide for the Win32 filename query function. We could use the
        // undocumented ObQueryNameString, but then we'd have to worry about
        // re-entrancy issues, since that call generates the IRP that we create
        // manually here. Since we send the IRP to the FSD below us, we don't need
        // to worry about seeing the IRP in our dispatch entry point. This can fail
        // in some cases, so we fall back on constructing the name ourselves if
        // we have to.
        //
        fileNameInfo = (PFILE_NAME_INFORMATION) ExAllocatePool( NonPagedPool, 
                                                                MAXPATHLEN*sizeof(WCHAR) );

        if( fileNameInfo && 
            FilemonQueryFile(hookExt->FileSystem, fileObject, FileNameInformation, 
                             fileNameInfo, (MAXPATHLEN - prefixLen - 1)*sizeof(WCHAR) )) {

            fullUniName.Length = (SHORT) fileNameInfo->FileNameLength;
            fullUniName.Buffer = fileNameInfo->FileName;
            if( NT_SUCCESS( RtlUnicodeStringToAnsiString( &fileName, &fullUniName, TRUE ))) { 

                fullPathName[ fileName.Length + prefixLen ] = 0;

                if( hookExt->Type == NPFS ) {
                    
                    strcpy( fullPathName, NAMED_PIPE_PREFIX );

                } else if( hookExt->Type == MSFS ) {

                    strcpy( fullPathName, MAIL_SLOT_PREFIX );

                } else if( fileObject->DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM ) {

                    sprintf( fullPathName, "%C:", hookExt->LogicalDrive );

                } else {
                
                    //
                    // No prefix for network devices
                    //
                }

                memcpy( &fullPathName[prefixLen], fileName.Buffer, fileName.Length );
                gotPath = TRUE;
                RtlFreeAnsiString( &fileName );
                fileName.Buffer = NULL;
            }
        } 
        if( fileNameInfo ) ExFreePool( fileNameInfo );
    }

    //
    // If we don't have a name yet then we are in the create path, or we failed
    // when we asked the file system for the name. In that case we'll go ahead
    // and construct the name based on file object names.
    //
    if( !gotPath ) {

        //
        // If there is no file name at this point, just return "DEVICE" to indicate
        // raw access to a device
        //
        if( !fileObject->FileName.Buffer ) {

            if( hookExt->Type == NPFS )      strcpy( fullPathName, NAMED_PIPE_PREFIX );
            else if( hookExt->Type == MSFS ) strcpy( fullPathName, MAIL_SLOT_PREFIX );
            else                             sprintf( fullPathName, "%C:", hookExt->LogicalDrive );
            return;
        }
    
        //
        // Create the full path name. First, calculate the length taking into 
        // account space for seperators and the leading prefix
        //
        if( !NT_SUCCESS( RtlUnicodeStringToAnsiString( &fileName, &fileObject->FileName, TRUE ))) {

            if( hookExt->Type == NPFS )      sprintf( fullPathName, "%s: <Out of Memory>", NAMED_PIPE_PREFIX );
            else if( hookExt->Type == MSFS ) sprintf( fullPathName, "%s: <Out of Memory>", MAIL_SLOT_PREFIX );
            else                             sprintf( fullPathName, "%C: <Out of Memory>", hookExt->LogicalDrive );
            return;
        }

        pathLen = fileName.Length + prefixLen;
        relatedFileObject = fileObject->RelatedFileObject;
    
        //
        // Only look at related file object if this is a relative name
        //
        if( fileObject->FileName.Buffer[0] != L'\\' && 
            relatedFileObject && relatedFileObject->FileName.Length ) {
	        
			if( !NT_SUCCESS( RtlUnicodeStringToAnsiString( &relatedName, &relatedFileObject->FileName, TRUE ))) {

                if( hookExt->Type == NPFS )      sprintf( fullPathName, "%s: <Out of Memory>", NAMED_PIPE_PREFIX );
                else if( hookExt->Type == MSFS ) sprintf( fullPathName, "%s: <Out of Memory>", MAIL_SLOT_PREFIX );
                else                             sprintf( fullPathName, "%C: <Out of Memory>", hookExt->LogicalDrive );
                RtlFreeAnsiString( &fileName );
                return;
            }
            pathLen += relatedName.Length+1;
        }

        //
        // Add the drive letter first at the front of the name
        //
        if( hookExt->Type == NPFS )      strcpy( fullPathName, NAMED_PIPE_PREFIX );
        else if( hookExt->Type == MSFS ) strcpy( fullPathName, MAIL_SLOT_PREFIX );
        else if( fileObject->DeviceObject->DeviceType != FILE_DEVICE_NETWORK_FILE_SYSTEM ) {

            sprintf( fullPathName, "%C:", hookExt->LogicalDrive );
        }

        //
        // If the name is too long, quit now
        //
        if( pathLen >= MAXPATHLEN ) {
            
            strcat( fullPathName, " <Name Too Long>" );

        } else {
    
            //
            // Now we can build the path name
            //
            fullPathName[ pathLen ] = 0;
            
            pathOffset = fullPathName + pathLen - fileName.Length;
            memcpy( pathOffset, fileName.Buffer, fileName.Length + 1 );
    
            if( fileObject->FileName.Buffer[0] != L'\\' && 
                relatedFileObject && relatedFileObject->FileName.Length ) {

                //
                // Copy the component, adding a slash separator
                //
                *(pathOffset - 1) = '\\';
                pathOffset -= relatedName.Length + 1;
                    
                memcpy( pathOffset, relatedName.Buffer, relatedName.Length );

                //
                // If we've got to slashes at the front zap one
                //
                if( pathLen > 3 && fullPathName[2] == '\\' && fullPathName[3] == '\\' )  {
                    
                    strcpy( fullPathName + 2, fullPathName + 3 );
                }
            }
        }  
    } 
    if( fileName.Buffer ) RtlFreeAnsiString( &fileName );
    if( relatedName.Buffer ) RtlFreeAnsiString( &relatedName );

    //
    // Network redirector names already specify a share name that we 
    // have to strip:
    // 
    //     \X:\computer\share\realpath
    //
    // And we want to present:
    //
    //     X:\realpath
    //
    // to the user.
    //
    if( fileObject->DeviceObject->DeviceType == FILE_DEVICE_NETWORK_FILE_SYSTEM &&
        strlen( fullPathName ) >= strlen("\\X:\\") ) {

        //
        // If this is Win2k the name is specified like this:
        //
        //    \;X:0\computer\share\realpath
        //
        // so we have to handle that case as well
        //
        if( fullPathName[1] == ';' ) {
            
            //
            // Win2K-style name. Grab the drive letter
            // and skip over the share
            //
            fullPathName[0] = fullPathName[2];
            fullPathName[1] = ':';
            fullPathName[2] = '\\';

            //
            // The third slash after the drive is the
            // start of the real path (we start scanning
            // at the ':' since we don't want to make assumptions
            // about the length of the number).
            //
            slashes = 0;
            ptr = &fullPathName[3];
            while( *ptr && slashes != 3 ) {
                
                if( *ptr == '\\' ) slashes++;
                ptr++;
            }
            strcpy( &fullPathName[3], ptr );

        } else if( fullPathName[2] == ':' ) {

            //
            // NT 4-style name. Skip the share name 
            //
            fullPathName[0] = fullPathName[1];
            fullPathName[1] = ':';
            fullPathName[2] = '\\';
                
            //
            // The second slash after the drive's slash (x:\)
            // is the start of the real path
            //
            slashes = 0;
            ptr = &fullPathName[3];
            while( *ptr && slashes != 3 ) {
                
                if( *ptr == '\\' ) slashes++;
                ptr++;
            }
            strcpy( &fullPathName[3], ptr );

        } else {

            //
            // Its a UNC path, so add a leading slash
            //
            RtlMoveMemory( &fullPathName[1], fullPathName, strlen( fullPathName ) + 1);
            fullPathName[0] = '\\';
        }
    }

    //
    // Allocate a hash entry
    //
    newEntry = ExAllocatePool( NonPagedPool, 
                               sizeof(HASH_ENTRY ) + strlen( fullPathName ) + 1);

    //
    // If no memory for a new entry, oh well.
    //
    if( newEntry ) {

        //
        // Fill in the new entry 
        //
        newEntry->FileObject = fileObject;
        strcpy( newEntry->FullPathName, fullPathName );

        //
        // Put it in the hash table
        //
        KeEnterCriticalRegion();
        ExAcquireResourceExclusiveLite( &HashResource, TRUE );

        newEntry->Next = HashTable[ HASHOBJECT(fileObject) ];
        HashTable[ HASHOBJECT(fileObject) ] = newEntry;	

        ExReleaseResourceLite( &HashResource );
        KeLeaveCriticalRegion();
    }
}


//----------------------------------------------------------------------
//
// FilemonGetProcessNameOffset
//
// In an effort to remain version-independent, rather than using a
// hard-coded into the KPEB (Kernel Process Environment Block), we
// scan the KPEB looking for the name, which should match that
// of the system process. This is because we are in the system process'
// context in DriverEntry, where this is called.
//
//----------------------------------------------------------------------

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
高清av一区二区| 亚洲猫色日本管| 捆绑调教一区二区三区| 欧美精品自拍偷拍| 成人精品视频一区| 欧美日韩成人综合天天影院| 亚洲综合一二三区| 欧美精品久久一区二区三区| 天堂蜜桃91精品| 欧美zozozo| 99久久99久久精品免费看蜜桃| 日韩伦理免费电影| 欧美性三三影院| 秋霞电影一区二区| 国产色综合久久| 在线观看国产91| 玖玖九九国产精品| 综合欧美一区二区三区| 欧美影片第一页| 激情图片小说一区| 一区二区中文字幕在线| 欧美日韩国产免费一区二区 | 欧美日韩国产影片| 美国十次了思思久久精品导航| 欧美国产一区在线| 欧美日韩一区二区三区在线| 久草中文综合在线| 中文字幕永久在线不卡| 欧美片在线播放| 国产不卡视频在线播放| 亚洲一区二区三区在线看| 精品裸体舞一区二区三区| 99久久精品免费看国产免费软件| 五月婷婷激情综合| 国产精品免费观看视频| 欧美猛男超大videosgay| 国产精品中文字幕欧美| 亚洲自拍偷拍av| 国产色综合久久| 日韩欧美色综合网站| 色一情一伦一子一伦一区| 另类欧美日韩国产在线| 亚洲激情中文1区| 国产亚洲欧美日韩在线一区| 欧美在线观看18| 成人黄动漫网站免费app| 日韩 欧美一区二区三区| 成人欧美一区二区三区| 精品国产亚洲一区二区三区在线观看| 色综合天天综合网天天狠天天| 精品一区二区三区蜜桃| 午夜精品福利视频网站| 亚洲三级久久久| 国产欧美视频一区二区三区| 91精品国产91久久久久久最新毛片| 99久久婷婷国产精品综合| 国产精华液一区二区三区| 蜜桃传媒麻豆第一区在线观看| 一区二区三区四区国产精品| 中文字幕乱码一区二区免费| 精品国产亚洲一区二区三区在线观看| 欧美色视频在线| 色综合天天做天天爱| 99久久免费国产| 成人午夜激情在线| 国产精品中文字幕一区二区三区| 日本不卡一区二区| 亚洲国产精品久久人人爱蜜臀 | 欧美mv和日韩mv国产网站| 欧美精品第1页| 欧美日韩高清在线| 欧美日韩你懂得| 欧美伊人久久久久久久久影院| 91国偷自产一区二区使用方法| 95精品视频在线| 99re这里只有精品6| 97se狠狠狠综合亚洲狠狠| 99久久精品国产麻豆演员表| 99久免费精品视频在线观看| 粉嫩一区二区三区在线看| 成人午夜私人影院| 99国产精品视频免费观看| 在线免费亚洲电影| 欧美在线制服丝袜| 欧美精品日韩精品| 日韩欧美亚洲一区二区| 亚洲精品在线网站| 国产婷婷色一区二区三区在线| 国产日韩欧美高清在线| 中文字幕中文乱码欧美一区二区| 国产精品国产三级国产有无不卡| 国产精品成人一区二区艾草 | 一本到高清视频免费精品| 91女人视频在线观看| 欧洲日韩一区二区三区| 欧美四级电影网| 日韩一区二区高清| 久久女同性恋中文字幕| 国产精品成人一区二区三区夜夜夜 | 国产精品久久一级| 亚洲欧美日韩中文播放| 午夜精品免费在线| 精品一区二区影视| 99在线精品视频| 欧美日韩一区在线观看| 欧美大片一区二区| 亚洲欧美自拍偷拍| 三级不卡在线观看| 国产成人精品www牛牛影视| 91玉足脚交白嫩脚丫在线播放| 欧美日韩一区二区欧美激情 | 国产欧美va欧美不卡在线| 亚洲靠逼com| 美女脱光内衣内裤视频久久网站| 国产成人免费视频| 欧美亚洲一区二区在线| 欧美成人福利视频| 亚洲精品国产无天堂网2021| 蜜臀av性久久久久蜜臀aⅴ| 成人av网站大全| 91精品国产综合久久久蜜臀粉嫩 | 国产精品美女久久久久av爽李琼| 亚洲一区二区五区| 国产精品影视在线| 欧美日韩一卡二卡| 欧美国产日韩a欧美在线观看| 亚洲香肠在线观看| 国产成人小视频| 91精品麻豆日日躁夜夜躁| 亚洲丝袜制服诱惑| 激情五月激情综合网| 欧美日韩成人一区二区| 欧美国产日韩亚洲一区| 麻豆精品视频在线| 欧美日韩中文另类| 中文子幕无线码一区tr| 美国毛片一区二区三区| 在线观看免费视频综合| 国产精品电影一区二区| 久久99最新地址| 在线播放视频一区| 亚洲综合丁香婷婷六月香| 波多野结衣视频一区| 精品国产sm最大网站| 午夜国产精品影院在线观看| 99精品桃花视频在线观看| 久久久久高清精品| 毛片一区二区三区| 欧美日韩国产精选| 欧美午夜精品久久久| 一区二区三区免费在线观看| 国产精品影视在线| 亚洲欧美日韩中文字幕一区二区三区| 成人精品国产福利| 一区二区三区av电影| 国产高清不卡一区| 欧美成人bangbros| 欧美a一区二区| 欧美日韩国产免费一区二区 | 久久久国产午夜精品| 男女男精品视频网| 欧美一区二区视频在线观看2022 | 国产精品资源在线看| 久久精品夜色噜噜亚洲aⅴ| 麻豆视频观看网址久久| 日韩一区二区视频| 奇米一区二区三区| 日韩一区二区精品在线观看| 日本麻豆一区二区三区视频| 日韩一二三区不卡| 强制捆绑调教一区二区| 日韩一级完整毛片| 91麻豆产精品久久久久久| 精彩视频一区二区| 国产精品影音先锋| 99r精品视频| 在线一区二区三区四区五区 | 欧美喷水一区二区| 69久久99精品久久久久婷婷 | 国产老妇另类xxxxx| 精品国产91乱码一区二区三区| 久久超碰97人人做人人爱| 精品国产精品一区二区夜夜嗨| 蜜臀99久久精品久久久久久软件| 欧美一级生活片| 韩国精品主播一区二区在线观看| 国产欧美日韩亚州综合| 99r国产精品| 五月天视频一区| 日韩欧美高清dvd碟片| 国产一区二区三区日韩| 中文字幕欧美日韩一区| 在线视频你懂得一区二区三区| 三级久久三级久久久| 国产午夜精品福利| 91黄色免费看| 美女高潮久久久| 国产精品久久久久影视| 在线日韩一区二区| 韩国精品久久久|