CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2006
    Posts
    86

    File_open_by_file_id

    Can anyone tell me how I use this? I don't get what the value of ObjectName should be:
    The file name specified in the ObjectAttributes parameter includes the 8-byte file reference number for the file.
    So is the File ID a string or a long? And do we pass its value, or a pointer to its value? Thanks!

  2. #2
    Join Date
    Sep 2004
    Posts
    1

    Re: File_open_by_file_id

    something like this:
    (where frn = filereferencenumber = FileID and fctNtCreateFile is a pointer to NtCreateFile)

    /*static*/ NTSTATUS MiscUtil::HandleFromFrn(DWORDLONG frn, HANDLE hVolume, HANDLE* phFile)
    {
    UNICODE_STRING file;
    OBJECT_ATTRIBUTES fileAttributes;
    IO_STATUS_BLOCK ioStatusBlock;

    // set frn
    LARGE_INTEGER fileID;
    fileID.QuadPart = frn;

    // set frn
    file.Buffer = (WCHAR*)&fileID;
    file.Length = 8;
    file.MaximumLength = 8;

    InitializeObjectAttributes(&fileAttributes, &file, OBJ_CASE_INSENSITIVE, hVolume, NULL);

    return fctNtCreateFile
    (
    phFile,
    0, //SYNCHRONIZE | FILE_READ_DATA,
    &fileAttributes,
    &ioStatusBlock,
    NULL,
    FILE_ATTRIBUTE_NORMAL,
    FILE_SHARE_READ | FILE_SHARE_WRITE,
    FILE_OPEN,
    FILE_OPEN_BY_FILE_ID,
    NULL,
    0
    );
    }

  3. #3
    Join Date
    Dec 2006
    Posts
    86

    Re: File_open_by_file_id

    Thanks a lot! I'll try it!

    Just for future reference, could you please tell me where you got the documentation?
    Or did you just try different things until it worked? Or was it just me who wasn't getting it?!

  4. #4
    Join Date
    Dec 2006
    Posts
    86

    Thumbs down Status_object_path_syntax_bad

    I get STATUS_OBJECT_PATH_SYNTAX_BAD if I don't give it a volume handle. If I do (whether the actual volume or the root directory), I get STATUS_INVALID_PARAMETER.

    HELP!!!

  5. #5
    Join Date
    Jun 2002
    Location
    Cambridge, UK
    Posts
    28

    Re: File_open_by_file_id

    The bit you need is the access rights required to the file - they are commented out and replaced by 0 in the snippet. Just drop in the needed rights, and you will be away again. Apparently any open handle to a parent of the object ID you pass in will get you STATUS_SUCCESS.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured