Ignore:
Timestamp:
6/18/2010 2:36:03 PM (2 years ago)
Author:
lowjoel
Message:
  • Define a VolumeStream? class which is a FileStream? customised for raw volume access. This results in the VolumeLock? class being merged into the VolumeStream? class, automatically handling locking and unlocking of volumes.
  • Change all internal OpenHandle? functions to private, since they should not be callable from outside the class.
  • Perform error checking in OpenHandle? so that even callers of OpenHandle? gets error checking.
File:
1 edited

Legend:

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

    r1873 r2189  
    6969        internal static NativeMethods.NTFS_VOLUME_DATA_BUFFER? GetNtfsVolumeData(VolumeInfo volume) 
    7070        { 
    71             using (SafeFileHandle volumeHandle = volume.OpenHandle( 
    72                 FileAccess.Read, FileShare.ReadWrite, FileOptions.None)) 
     71            using (FileStream stream = volume.Open(FileAccess.Read, FileShare.ReadWrite, 
     72                FileOptions.None)) 
     73            using (SafeFileHandle handle = stream.SafeFileHandle) 
    7374            { 
    74                 if (volumeHandle.IsInvalid) 
    75                     return null; 
    76  
    7775                uint resultSize = 0; 
    7876                NativeMethods.NTFS_VOLUME_DATA_BUFFER volumeData = 
    7977                    new NativeMethods.NTFS_VOLUME_DATA_BUFFER(); 
    80                 if (NativeMethods.DeviceIoControl(volumeHandle, 
     78                if (NativeMethods.DeviceIoControl(handle, 
    8179                    NativeMethods.FSCTL_GET_NTFS_VOLUME_DATA, IntPtr.Zero, 0, out volumeData, 
    8280                    (uint)Marshal.SizeOf(volumeData), out resultSize, IntPtr.Zero)) 
Note: See TracChangeset for help on using the changeset viewer.