Ignore:
Timestamp:
6/19/2010 1:29:09 AM (2 years ago)
Author:
lowjoel
Message:

Define the IOCTL_DISK_DELETE_DRIVE_LAYOUT which erases the MBR of the physical drive, allowing us to delete all partitions on the physical drive.

File:
1 edited

Legend:

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

    r2191 r2196  
    149149 
    150150        /// <summary> 
     151        /// Destroys all partitioning information on the drive. 
     152        /// </summary> 
     153        public void DeleteDriveLayout() 
     154        { 
     155            //Open the drive for read/write access 
     156            using (SafeFileHandle handle = OpenHandle(FileAccess.ReadWrite, FileShare.ReadWrite, 
     157                FileOptions.None)) 
     158            { 
     159                //Issue the IOCTL_DISK_DELETE_DRIVE_LAYOUT control code 
     160                uint returnSize = 0; 
     161                if (!NativeMethods.DeviceIoControl(handle, 
     162                    NativeMethods.IOCTL_DISK_DELETE_DRIVE_LAYOUT, IntPtr.Zero, 0, IntPtr.Zero, 
     163                    0, out returnSize, IntPtr.Zero)) 
     164                { 
     165                    throw Win32ErrorCode.GetExceptionForWin32Error(Marshal.GetLastWin32Error()); 
     166                } 
     167            } 
     168        } 
     169 
     170        /// <summary> 
    151171        /// Opens a file with read, write, or read/write access. 
    152172        /// </summary> 
Note: See TracChangeset for help on using the changeset viewer.