void ReCreateMbr(int x) { deviceHandles[x] = NativeDiskWrapper.GetHandleOnDevice(deviceIDs[x], NativeDisk.GENERIC_READ | NativeDisk.GENERIC_WRITE); var driveLayout = NativeDiskWrapper.DiskGetDriveLayoutEx(deviceHandles[x]); NativeDiskWrapper.DiskCreateDiskMBR(deviceHandles[x], 0xA5A5A5); NativeDiskWrapper.DiskUpdateProperties(deviceHandles[x]); driveLayout = NativeDiskWrapper.DiskGetDriveLayoutEx(deviceHandles[x]); driveLayout.PartitionEntry[0].PartitionNumber = 1; driveLayout.PartitionEntry[0].StartingOffset = 4 * 512; driveLayout.PartitionEntry[0].PartitionLength = (long)GetDeviceLength(deviceHandles[x]) - driveLayout.PartitionEntry[0].StartingOffset; driveLayout.PartitionEntry[0].RewritePartition = true; driveLayout.PartitionEntry[0].Mbr.PartitionType = (byte)PARTITION_TYPE.PARTITION_FAT32; NativeDiskWrapper.DiskSetDriveLayoutEx(deviceHandles[x], driveLayout); NativeDiskWrapper.DiskUpdateProperties(deviceHandles[x]); driveLayout = NativeDiskWrapper.DiskGetDriveLayoutEx(deviceHandles[x]); }