Ignore:
Timestamp:
3/1/2010 2:57:41 AM (2 years ago)
Author:
lowjoel
Message:

For NTFS MFT Record lengths we need volume (data) read access so instead catch unauthorized access exceptions (i.e. when running under a split user token in 7) and return using the heuristic of one of volume cluster size and 1024 bytes, whichever is smaller

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/eraser6/Eraser.Util/NtfsApi.cs

    r1843 r1859  
    4848        public static long GetMftRecordSegmentSize(VolumeInfo volume) 
    4949        { 
    50             return GetNtfsVolumeData(volume).BytesPerFileRecordSegment; 
     50            try 
     51            { 
     52                return GetNtfsVolumeData(volume).BytesPerFileRecordSegment; 
     53            } 
     54            catch (UnauthorizedAccessException) 
     55            { 
     56                return Math.Min(volume.ClusterSize, 1024); 
     57            } 
    5158        } 
    5259 
     
    5865        /// <returns>The NTFS_VOLUME_DATA_BUFFER structure representing the data 
    5966        /// file systme structures for the volume.</returns> 
     67        /// <exception cref="UnauthorizedAccessException">Thrown when the current user 
     68        /// does not have the permissions required to obtain the volume information.</exception> 
    6069        internal static NativeMethods.NTFS_VOLUME_DATA_BUFFER GetNtfsVolumeData(VolumeInfo volume) 
    6170        { 
    6271            using (SafeFileHandle volumeHandle = volume.OpenHandle( 
    63                 NativeMethods.FILE_READ_ATTRIBUTES, FileShare.ReadWrite, FileOptions.None)) 
     72                FileAccess.Read, FileShare.ReadWrite, FileOptions.None)) 
    6473            { 
    6574                uint resultSize = 0; 
Note: See TracChangeset for help on using the changeset viewer.