Changeset 2207 for trunk/eraser
- Timestamp:
- 06/19/10 10:34:05 (3 years ago)
- Location:
- trunk/eraser/Eraser.Util
- Files:
-
- 2 edited
-
PhysicalDriveInfo.cs (modified) (1 diff)
-
VolumeInfo.cs (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/eraser/Eraser.Util/PhysicalDriveInfo.cs
r2206 r2207 88 88 List<VolumeInfo> result = new List<VolumeInfo>(); 89 89 90 //Check every partition index on this drive. 91 for (int i = 1; ; ++i) 92 { 93 string path = GetPartitionPath(i); 94 using (SafeFileHandle handle = OpenWin32Device(path, 95 NativeMethods.FILE_READ_ATTRIBUTES, FileShare.ReadWrite, FileOptions.None)) 96 { 97 if (handle.IsInvalid) 98 break; 99 } 100 101 //This partition index is valid. Check which VolumeInfo this maps to. 102 foreach (VolumeInfo info in VolumeInfo.Volumes) 103 { 104 //Only check local drives 105 if (info.VolumeId.Substring(0, 4) == "\\\\?\\") 106 { 107 //Check whether the DOS Device maps to the target of the symbolic link 108 if (NativeMethods.NtQuerySymbolicLink(path) == 109 NativeMethods.QueryDosDevice(info.VolumeId.Substring( 110 4, info.VolumeId.Length - 5))) 111 { 112 //Yes, this volume belongs to this disk 113 result.Add(info); 114 break; 115 } 116 } 117 } 90 //Check every volume for which disk it is on. 91 foreach (VolumeInfo info in VolumeInfo.Volumes) 92 { 93 if (Equals(info.PhysicalDrive)) 94 result.Add(info); 118 95 } 119 96 -
trunk/eraser/Eraser.Util/VolumeInfo.cs
r2206 r2207 599 599 { 600 600 int error = Marshal.GetLastWin32Error(); 601 if (error != Win32ErrorCode.InsufficientBuffer) 601 if (error == Win32ErrorCode.InvalidFunction) 602 return null; 603 else if (error != Win32ErrorCode.MoreData) 602 604 throw Win32ErrorCode.GetExceptionForWin32Error(error); 603 605 … … 629 631 ++i, offset += Marshal.SizeOf(typeof(NativeMethods.DISK_EXTENT))) 630 632 { 631 NativeMethods.DISK_EXTENT extent = new NativeMethods.DISK_EXTENT(); 632 Marshal.PtrToStructure(new IntPtr(buffer.ToInt64() + offset), extent); 633 NativeMethods.DISK_EXTENT extent = (NativeMethods.DISK_EXTENT) 634 Marshal.PtrToStructure(new IntPtr(buffer.ToInt64() + offset), 635 typeof(NativeMethods.DISK_EXTENT)); 633 636 extents.Add(extent); 634 637 }
Note: See TracChangeset
for help on using the changeset viewer.
