Example #1
0
 private static Tuple <string, string> GetFilePath(NtFile volume, long file_id, Dictionary <long, Tuple <string, string> > parent_paths)
 {
     if (!parent_paths.ContainsKey(file_id))
     {
         using (var file = NtFile.OpenFileById(volume, file_id, FileAccessRights.Synchronize | FileAccessRights.ReadAttributes,
                                               FileShareMode.None, FileOpenOptions.OpenReparsePoint | FileOpenOptions.OpenForBackupIntent, false)) {
             if (!file.IsSuccess)
             {
                 parent_paths[file_id] = Tuple.Create(string.Empty, string.Empty);
             }
             else
             {
                 parent_paths[file_id] = Tuple.Create(file.Result.FullPath.TrimEnd('\\'), file.Result.Win32PathName.TrimEnd('\\'));
             }
         }
     }
     return(parent_paths[file_id]);
 }
Example #2
0
        internal NtFileReparsePoint(NtFile volume, FileReparsePointInformation info)
        {
            FileReferenceNumber = info.FileReferenceNumber;
            Buffer    = new OpaqueReparseBuffer(info.Tag, new byte[0]);
            FullPath  = string.Empty;
            Win32Path = string.Empty;
            using (var file = NtFile.OpenFileById(volume, info.FileReferenceNumber, FileAccessRights.ReadAttributes,
                                                  FileShareMode.None, FileOpenOptions.OpenReparsePoint | FileOpenOptions.OpenForBackupIntent, false)) {
                if (!file.IsSuccess)
                {
                    return;
                }

                FileAttributes = file.Result.FileAttributes;
                FullPath       = file.Result.FullPath;
                Win32Path      = file.Result.GetWin32PathName(0, false).GetResultOrDefault(string.Empty);
                Buffer         = file.Result.GetReparsePoint(false).GetResultOrDefault(Buffer);
            }
        }
Example #3
0
 static FileData GetFileData(NtFile volume, ReparseTag tag, long fileid)
 {
     using (var file = NtFile.OpenFileById(volume, fileid, FileAccessRights.ReadAttributes | FileAccessRights.Synchronize,
                                           FileShareMode.None, FileOpenOptions.OpenReparsePoint | FileOpenOptions.SynchronousIoNonAlert | FileOpenOptions.OpenForBackupIntent))
     {
         var           filename = file.GetWin32PathName(NtApiDotNet.Win32.Win32PathNameFlags.None, false).GetResultOrDefault(fileid.ToString());
         ReparseBuffer reparse  = new OpaqueReparseBuffer(tag, new byte[0]);
         try
         {
             reparse = file.GetReparsePoint();
         }
         catch (NtException)
         {
         }
         return(new FileData()
         {
             FileName = filename,
             Reparse = reparse
         });
     }
 }