Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3215050
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:07:57+00:00 2026-05-17T15:07:57+00:00

The function GetFileInformationByHandle gives us a structure with the values nFileIndexHigh and nFileIndexLow which

  • 0

The function GetFileInformationByHandle gives us a structure with the values nFileIndexHigh and nFileIndexLow which comprise of a fileIndex.

What is this number? Is it the same as the USN?

Is there a way to get this fileIndex of a file without opening it (any other method except GetFileInformationByHandle)?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:07:57+00:00Added an answer on May 17, 2026 at 3:07 pm

    You can use ZwQueryDirectoryFile with FileObjectIdInformation, FileIdBothDirectoryInformation, FileIdFullDirectoryInformation to query for object ID information for the files in a directory. In the case you have to open only the directory having the file and not the file itself. It can be useful for example if the file is opened for exclusive access or of cause if you has no permission to open a file and not have or want not use backup privilege.

    UPDATED: The following test example

    #include <windows.h>
    #include <stdio.h>
    #include <tchar.h>
    
    typedef LONG NTSTATUS;
    #define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
    #define NT_STATUS(x)((NTSTATUS) { x })
    #define STATUS_SUCCESS            ((NTSTATUS)0x00000000L)
    #define STATUS_NO_MORE_FILES      ((NTSTATUS)0x80000006L)
    #define STATUS_INVALID_INFO_CLASS ((NTSTATUS)0xC0000003L)
    
    typedef struct _UNICODE_STRING
    {
        USHORT Length;
        USHORT MaximumLength;
        PWSTR Buffer;
    } UNICODE_STRING, *PUNICODE_STRING;
    
    typedef struct _IO_STATUS_BLOCK {
        union {
            NTSTATUS Status;
            PVOID Pointer;
        } DUMMYUNIONNAME;
    
        ULONG_PTR Information;
    } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
    
    typedef VOID (NTAPI *PIO_APC_ROUTINE) (PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved);
    
    typedef enum _FILE_INFORMATION_CLASS {
        FileDirectoryInformation         = 1,
        FileFullDirectoryInformation,   // 2
        FileBothDirectoryInformation,   // 3
        FileBasicInformation,           // 4
        FileStandardInformation,        // 5
        FileInternalInformation,        // 6
        FileEaInformation,              // 7
        FileAccessInformation,          // 8
        FileNameInformation,            // 9
        FileRenameInformation,          // 10
        FileLinkInformation,            // 11
        FileNamesInformation,           // 12
        FileDispositionInformation,     // 13
        FilePositionInformation,        // 14
        FileFullEaInformation,          // 15
        FileModeInformation,            // 16
        FileAlignmentInformation,       // 17
        FileAllInformation,             // 18
        FileAllocationInformation,      // 19
        FileEndOfFileInformation,       // 20
        FileAlternateNameInformation,   // 21
        FileStreamInformation,          // 22
        FilePipeInformation,            // 23
        FilePipeLocalInformation,       // 24
        FilePipeRemoteInformation,      // 25
        FileMailslotQueryInformation,   // 26
        FileMailslotSetInformation,     // 27
        FileCompressionInformation,     // 28
        FileObjectIdInformation,        // 29
        FileCompletionInformation,      // 30
        FileMoveClusterInformation,     // 31
        FileQuotaInformation,           // 32
        FileReparsePointInformation,    // 33
        FileNetworkOpenInformation,     // 34
        FileAttributeTagInformation,    // 35
        FileTrackingInformation,        // 36
        FileIdBothDirectoryInformation, // 37
        FileIdFullDirectoryInformation, // 38
        FileValidDataLengthInformation, // 39
        FileShortNameInformation,       // 40
        FileIoCompletionNotificationInformation, // 41
        FileIoStatusBlockRangeInformation,       // 42
        FileIoPriorityHintInformation,           // 43
        FileSfioReserveInformation,              // 44
        FileSfioVolumeInformation,               // 45
        FileHardLinkInformation,                 // 46
        FileProcessIdsUsingFileInformation,      // 47
        FileNormalizedNameInformation,           // 48
        FileNetworkPhysicalNameInformation,      // 49
        FileIdGlobalTxDirectoryInformation,      // 50
        FileIsRemoteDeviceInformation,           // 51
        FileAttributeCacheInformation,           // 52
        FileNumaNodeInformation,                 // 53
        FileStandardLinkInformation,             // 54
        FileRemoteProtocolInformation,           // 55
        FileMaximumInformation
    } FILE_INFORMATION_CLASS, *PFILE_INFORMATION_CLASS;
    
    typedef struct _FILE_ID_FULL_DIR_INFORMATION {
        ULONG NextEntryOffset;
        ULONG FileIndex;
        LARGE_INTEGER CreationTime;
        LARGE_INTEGER LastAccessTime;
        LARGE_INTEGER LastWriteTime;
        LARGE_INTEGER ChangeTime;
        LARGE_INTEGER EndOfFile;
        LARGE_INTEGER AllocationSize;
        ULONG FileAttributes;
        ULONG FileNameLength;
        ULONG EaSize;
        LARGE_INTEGER FileId;
        WCHAR FileName[1];
    } FILE_ID_FULL_DIR_INFORMATION, *PFILE_ID_FULL_DIR_INFORMATION;
    
    typedef struct _FILE_ID_BOTH_DIR_INFORMATION {
        ULONG NextEntryOffset;
        ULONG FileIndex;
        LARGE_INTEGER CreationTime;
        LARGE_INTEGER LastAccessTime;
        LARGE_INTEGER LastWriteTime;
        LARGE_INTEGER ChangeTime;
        LARGE_INTEGER EndOfFile;
        LARGE_INTEGER AllocationSize;
        ULONG FileAttributes;
        ULONG FileNameLength;
        ULONG EaSize;
        CCHAR ShortNameLength;
        WCHAR ShortName[12];
        LARGE_INTEGER FileId;
        WCHAR FileName[1];
    } FILE_ID_BOTH_DIR_INFORMATION, *PFILE_ID_BOTH_DIR_INFORMATION;
    
    typedef struct _FILE_ID_GLOBAL_TX_DIR_INFORMATION {
        ULONG NextEntryOffset;
        ULONG FileIndex;
        LARGE_INTEGER CreationTime;
        LARGE_INTEGER LastAccessTime;
        LARGE_INTEGER LastWriteTime;
        LARGE_INTEGER ChangeTime;
        LARGE_INTEGER EndOfFile;
        LARGE_INTEGER AllocationSize;
        ULONG FileAttributes;
        ULONG FileNameLength;
        LARGE_INTEGER FileId;
        GUID LockingTransactionId;
        ULONG TxInfoFlags;
        WCHAR FileName[1];
    } FILE_ID_GLOBAL_TX_DIR_INFORMATION, *PFILE_ID_GLOBAL_TX_DIR_INFORMATION;
    
    #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_WRITELOCKED         0x00000001
    #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_VISIBLE_TO_TX       0x00000002
    #define FILE_ID_GLOBAL_TX_DIR_INFO_FLAG_VISIBLE_OUTSIDE_TX  0x00000004
    
    typedef struct _FILE_OBJECTID_INFORMATION {
        LONGLONG FileReference;
        UCHAR ObjectId[16];
        union {
            struct {
                UCHAR BirthVolumeId[16];
                UCHAR BirthObjectId[16];
                UCHAR DomainId[16];
            } DUMMYSTRUCTNAME;
            UCHAR ExtendedInfo[48];
        } DUMMYUNIONNAME;
    } FILE_OBJECTID_INFORMATION, *PFILE_OBJECTID_INFORMATION;
    
    typedef NTSTATUS (WINAPI *PZW_QUERY_DIRECTORY_FILE) (HANDLE FileHandle,
        HANDLE Event, PIO_APC_ROUTINE ApcRoutine, PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock,
        PVOID FileInformation, ULONG Length, FILE_INFORMATION_CLASS FileInformationClass,
        BOOLEAN ReturnSingleEntry, PUNICODE_STRING FileName, BOOLEAN RestartScan);
    
    void DumpFileInformation (LPCWSTR pszDirName, LPCWSTR pszFileName)
    {
        WCHAR szFileName[32767];
        UNICODE_STRING fn;
        IO_STATUS_BLOCK iosb;
        NTSTATUS status;
        LONGLONG byBuffer[(32767+sizeof(FILE_ID_FULL_DIR_INFORMATION))/sizeof(LONGLONG)];
        PFILE_ID_FULL_DIR_INFORMATION pFullInfo = (PFILE_ID_FULL_DIR_INFORMATION)byBuffer;
        //PFILE_ID_GLOBAL_TX_DIR_INFORMATION pGlobalTxDirInfo = (PFILE_ID_GLOBAL_TX_DIR_INFORMATION)byBuffer;
        HANDLE hDir = INVALID_HANDLE_VALUE;
        PZW_QUERY_DIRECTORY_FILE ZwQueryDirectoryFile = (PZW_QUERY_DIRECTORY_FILE)
            GetProcAddress(GetModuleHandle(L"ntdll.dll"),"ZwQueryDirectoryFile");
    
        __try {
            hDir = CreateFileW (pszDirName, FILE_LIST_DIRECTORY, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
                                OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
            if (hDir == INVALID_HANDLE_VALUE) {
                _tprintf(TEXT("Can't open directory '%ls': Error %d\n"), pszDirName, GetLastError());
                __leave;
            }
    
            lstrcpyW (szFileName, pszFileName);
            fn.Buffer = (LPWSTR) szFileName;
            fn.Length = lstrlen(szFileName)*sizeof(WCHAR);
            fn.MaximumLength = sizeof(szFileName);
            RtlZeroMemory ((PVOID)&iosb, sizeof(iosb));
            status =  ZwQueryDirectoryFile (hDir, NULL, NULL, NULL, &iosb, byBuffer, sizeof(byBuffer),
                                            FileIdFullDirectoryInformation, TRUE, &fn, FALSE);
            if (NT_SUCCESS(status)) {
                _tprintf (TEXT("The file '%ls%ls%ls' has FileId: 0x%08X%08X\n"),
                    pszDirName,
                    fn.Length>0 && pszDirName[fn.Length/sizeof(WCHAR)-1] == L'\\' ? L"": L"\\",
                    szFileName,
                    pFullInfo->FileId.HighPart, pFullInfo->FileId.LowPart);
            }
        }
        __finally {
            if (hDir != INVALID_HANDLE_VALUE)
                CloseHandle (hDir);
        }
    }
    
    int _tmain ()
    {
        DumpFileInformation (L"C:\\", L"System Volume Information");
        DumpFileInformation (L"C:\\", L"pagefile.sys");
        return 0;
    }
    

    produce on my computer as the output:

    The file 'C:\\System Volume Information' has FileId: 0x000100000000A2F0
    The file 'C:\\pagefile.sys' has FileId: 0x006B00000000A673
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

function Obj1(param) { this.test1 = param || 1; } function Obj2(param, par) { this.test2
This function is global and is defined in the header file ( temporarily I
function returnsAnArray () { return array ('test'); } echo returnsAnArray ()[0]; generates a syntax
Function FillAdminAccount() As Boolean FillAdminAccount = True Try SQLconn.ConnectionString = connect timeout=9999999; & _
function Submit_click() { if (!bValidateFields()) return; } function bValidateFields() { /// <summary>Validation rules</summary> ///
function main() { Hello(); } function Hello() { // How do you find out
function AddTheatres() { Services.AdminWebServices.AddTheatresSVC(oTheatres, OnSuccessTheatres, OnError, OnTimeOut); } function OnSuccessTheatres(result1) { Services.AdminWebServices.AddTicketPricesSVC(oTicketPrices, OnSuccessTicketPrices, OnError,
function holiday_hitlist($tablename, $hit_user){ global $host, $user, $pass, $dbname; $link = mysql_connect($host, $user, $pass, $dbname);
function register_contact ($person = array()) { $nogood = false; foreach ($person as $val) {
function get_total_adults() { $sql = SELECT SUM(number_adults_attending) as number_of_adults FROM is_nfo_rsvp; $result = mysql_query($sql)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.