[ui] add option to create extra hidden partition

* Closes #77
This commit is contained in:
Pete Batard 2012-05-18 18:41:28 +01:00
parent aea60183cc
commit 8c47bac10e
2 changed files with 38 additions and 13 deletions

View File

@ -569,16 +569,24 @@ BOOL CreatePartition(HANDLE hDrive)
PDRIVE_LAYOUT_INFORMATION_EX DriveLayoutEx = (PDRIVE_LAYOUT_INFORMATION_EX)layout;
BOOL r;
DWORD size;
LONGLONG sector_size;
PrintStatus(0, TRUE, "Partitioning...");
DriveLayoutEx->PartitionStyle = PARTITION_STYLE_MBR;
DriveLayoutEx->PartitionCount = 4; // Must be multiple of 4 for MBR
DriveLayoutEx->Mbr.Signature = GetTickCount();
DriveLayoutEx->PartitionEntry[0].PartitionStyle = PARTITION_STYLE_MBR;
// TODO: CHS fixup (32 sectors/track) through a cheat mode, if requested
// NB: disk geometry is computed by BIOS & co. by finding a match between LBA and CHS value of first partition
DriveLayoutEx->PartitionEntry[0].StartingOffset.QuadPart =
SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack;
DriveLayoutEx->PartitionEntry[0].PartitionLength.QuadPart = SelectedDrive.DiskSize -
DriveLayoutEx->PartitionEntry[0].StartingOffset.QuadPart;
sector_size = (SelectedDrive.DiskSize - DriveLayoutEx->PartitionEntry[0].StartingOffset.QuadPart) / SelectedDrive.Geometry.BytesPerSector;
// Align on sector boundary if the extra part option is checked
if (IsChecked(IDC_EXTRA_PARTITION)) {
sector_size = ((sector_size / SelectedDrive.Geometry.SectorsPerTrack)-1) * SelectedDrive.Geometry.SectorsPerTrack;
if (sector_size <= 0) return FALSE;
}
DriveLayoutEx->PartitionEntry[0].PartitionLength.QuadPart = sector_size * SelectedDrive.Geometry.BytesPerSector;
DriveLayoutEx->PartitionEntry[0].PartitionNumber = 1;
DriveLayoutEx->PartitionEntry[0].RewritePartition = TRUE;
DriveLayoutEx->PartitionEntry[0].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack;
@ -590,10 +598,27 @@ BOOL CreatePartition(HANDLE hDrive)
case FS_EXFAT:
DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType = 0x07; // NTFS
break;
default:
case FS_FAT32:
DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType = 0x0c; // FAT32 LBA
break;
default:
uprintf("Unsupported file system\n");
return FALSE;
}
// Create an extra partition on request - can improve BIOS detection as HDD for older BIOSes
if (IsChecked(IDC_EXTRA_PARTITION)) {
DriveLayoutEx->PartitionEntry[1].PartitionStyle = PARTITION_STYLE_MBR;
// Should end on a sector boundary
DriveLayoutEx->PartitionEntry[1].StartingOffset.QuadPart = DriveLayoutEx->PartitionEntry[0].StartingOffset.QuadPart +
DriveLayoutEx->PartitionEntry[0].PartitionLength.QuadPart;
DriveLayoutEx->PartitionEntry[1].PartitionLength.QuadPart = SelectedDrive.Geometry.SectorsPerTrack*SelectedDrive.Geometry.BytesPerSector;
DriveLayoutEx->PartitionEntry[1].PartitionNumber = 2;
DriveLayoutEx->PartitionEntry[1].RewritePartition = TRUE;
DriveLayoutEx->PartitionEntry[1].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack*SelectedDrive.Geometry.BytesPerSector;
DriveLayoutEx->PartitionEntry[1].Mbr.PartitionType = DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType + 0x10; // Hidden whatever
}
// For the remaining partitions, PartitionStyle & PartitionType have already
// been zeroed => set to MBR/unused
@ -1007,13 +1032,13 @@ static void EnableControls(BOOL bEnable)
EnableWindow(hDOSType, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
EnableWindow(hDiskID, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
// EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
} else {
EnableWindow(hDOS, FALSE);
EnableWindow(hDOSType, FALSE);
EnableWindow(hDiskID, FALSE);
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), FALSE);
// EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), FALSE);
EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), FALSE);
}
EnableWindow(GetDlgItem(hMainDialog, IDC_BADBLOCKS), bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_ABOUT), bEnable);

View File

@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 316
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.2.0.171"
CAPTION "Rufus v1.2.0.172"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
@ -61,8 +61,8 @@ BEGIN
PUSHBUTTON "",IDC_ADVANCED,63,148,14,10,BS_TOP | BS_FLAT
GROUPBOX "Advanced Options",IDC_ADVANCED_GROUP,7,210,192,42,NOT WS_VISIBLE
COMBOBOX IDC_DISK_ID,119,220,32,30,CBS_DROPDOWNLIST | NOT WS_VISIBLE | WS_VSCROLL | WS_TABSTOP
CONTROL "Apply fixes for older BIOSes (extra partition, etc.)",IDC_EXTRA_PARTITION,
"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_DISABLED | WS_TABSTOP,13,235,177,10
CONTROL "Add fixes for old BIOSes (extra partition, align, etc.)",IDC_EXTRA_PARTITION,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,235,184,10
END
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195
@ -76,7 +76,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.2.0 (Build 171)",IDC_STATIC,46,19,78,8
LTEXT "Version 1.2.0 (Build 172)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -221,8 +221,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,0,171
PRODUCTVERSION 1,2,0,171
FILEVERSION 1,2,0,172
PRODUCTVERSION 1,2,0,172
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -239,13 +239,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.2.0.171"
VALUE "FileVersion", "1.2.0.172"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.2.0.171"
VALUE "ProductVersion", "1.2.0.172"
END
END
BLOCK "VarFileInfo"