1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[core] add Super Floppy Disk support

This commit is contained in:
Pete Batard 2017-08-12 15:12:00 +01:00
parent 65f5ccd28b
commit c82842ce2a
4 changed files with 50 additions and 20 deletions

View file

@ -703,7 +703,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)(void*)layout; PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)(void*)layout;
char* volume_name; char* volume_name;
char tmp[256]; char tmp[256];
DWORD i, j, big_floppy = FALSE; DWORD i, j, super_floppy_disk = FALSE;
if (FileSystemName == NULL) if (FileSystemName == NULL)
return FALSE; return FALSE;
@ -768,7 +768,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
if ((DriveLayout->PartitionEntry[0].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) && if ((DriveLayout->PartitionEntry[0].Mbr.PartitionType != PARTITION_ENTRY_UNUSED) &&
(DriveLayout->PartitionEntry[0].StartingOffset.QuadPart == 0LL)) { (DriveLayout->PartitionEntry[0].StartingOffset.QuadPart == 0LL)) {
suprintf("Partition type: SFD (Super Floppy Disk) or Unpartitioned"); suprintf("Partition type: SFD (Super Floppy Disk) or Unpartitioned");
big_floppy = TRUE; super_floppy_disk = TRUE;
} else { } else {
suprintf("Partition type: MBR, NB Partitions: %d\n", SelectedDrive.nPartitions); suprintf("Partition type: MBR, NB Partitions: %d\n", SelectedDrive.nPartitions);
SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER); SelectedDrive.has_mbr_uefi_marker = (DriveLayout->Mbr.Signature == MBR_UEFI_MARKER);
@ -780,7 +780,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType; part_type = DriveLayout->PartitionEntry[i].Mbr.PartitionType;
isUefiNtfs = (i == 1) && (part_type == 0xef) && isUefiNtfs = (i == 1) && (part_type == 0xef) &&
(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart <= 1*MB); (DriveLayout->PartitionEntry[i].PartitionLength.QuadPart <= 1*MB);
suprintf("Partition %d%s:\n", i+(big_floppy?0:1), isUefiNtfs?" (UEFI:NTFS)":""); suprintf("Partition %d%s:\n", i+(super_floppy_disk?0:1), isUefiNtfs?" (UEFI:NTFS)":"");
for (j=0; j<ARRAYSIZE(mbr_mountable); j++) { for (j=0; j<ARRAYSIZE(mbr_mountable); j++) {
if (part_type == mbr_mountable[j]) { if (part_type == mbr_mountable[j]) {
ret = TRUE; ret = TRUE;
@ -789,7 +789,7 @@ BOOL GetDrivePartitionData(DWORD DriveIndex, char* FileSystemName, DWORD FileSys
} }
// NB: MinGW's gcc 4.9.2 broke "%lld" printout on XP so we use the inttypes.h "PRI##" qualifiers // NB: MinGW's gcc 4.9.2 broke "%lld" printout on XP so we use the inttypes.h "PRI##" qualifiers
suprintf(" Type: %s (0x%02x)\r\n Size: %s (%" PRIi64 " bytes)\r\n Start Sector: %" PRIi64 ", Boot: %s", suprintf(" Type: %s (0x%02x)\r\n Size: %s (%" PRIi64 " bytes)\r\n Start Sector: %" PRIi64 ", Boot: %s",
((part_type==0x07||big_floppy)&&(FileSystemName[0]!=0))?FileSystemName:GetPartitionType(part_type), big_floppy?0:part_type, ((part_type==0x07||super_floppy_disk)&&(FileSystemName[0]!=0))?FileSystemName:GetPartitionType(part_type), super_floppy_disk?0:part_type,
SizeToHumanReadable(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, TRUE, FALSE), SizeToHumanReadable(DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, TRUE, FALSE),
DriveLayout->PartitionEntry[i].PartitionLength.QuadPart, DriveLayout->PartitionEntry[i].PartitionLength.QuadPart,
DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize, DriveLayout->PartitionEntry[i].StartingOffset.QuadPart / SelectedDrive.SectorSize,
@ -1078,7 +1078,7 @@ typedef struct _DRIVE_LAYOUT_INFORMATION_EX4 {
*/ */
BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL mbr_uefi_marker, uint8_t extra_partitions) BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL mbr_uefi_marker, uint8_t extra_partitions)
{ {
const char* PartitionTypeName[2] = { "MBR", "GPT" }; const char* PartitionTypeName[] = { "MBR", "GPT", "SFD" };
unsigned char* buffer; unsigned char* buffer;
size_t uefi_ntfs_size = 0; size_t uefi_ntfs_size = 0;
CREATE_DISK CreateDisk = {PARTITION_STYLE_RAW, {{0}}}; CREATE_DISK CreateDisk = {PARTITION_STYLE_RAW, {{0}}};
@ -1090,6 +1090,10 @@ BOOL CreatePartition(HANDLE hDrive, int partition_style, int file_system, BOOL m
PrintInfoDebug(0, MSG_238, PartitionTypeName[partition_style]); PrintInfoDebug(0, MSG_238, PartitionTypeName[partition_style]);
if (partition_style == PARTITION_STYLE_SFD)
// Nothing to do
return TRUE;
if (extra_partitions & XP_UEFI_NTFS) { if (extra_partitions & XP_UEFI_NTFS) {
uefi_ntfs_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_NTFS), _RT_RCDATA, "uefi-ntfs.img"); uefi_ntfs_size = GetResourceSize(hMainInstance, MAKEINTRESOURCEA(IDR_UEFI_NTFS), _RT_RCDATA, "uefi-ntfs.img");
if (uefi_ntfs_size == 0) if (uefi_ntfs_size == 0)

View file

@ -456,6 +456,10 @@ static BOOL SetDriveInfo(int ComboIndex)
lmprintf(MSG_033, PartitionTypeLabel[pt])), (TT_UEFI<<16)|pt)); lmprintf(MSG_033, PartitionTypeLabel[pt])), (TT_UEFI<<16)|pt));
} }
} }
if (advanced_mode) {
IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme,
ComboBox_AddStringU(hPartitionScheme, "Super Floppy Disk"), PARTITION_STYLE_SFD));
}
// At least one filesystem is go => enable formatting // At least one filesystem is go => enable formatting
EnableWindow(hStart, TRUE); EnableWindow(hStart, TRUE);
@ -578,13 +582,17 @@ static void SetPartitionSchemeTooltip(void)
int tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); int tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
int pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); int pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
if (tt == TT_BIOS) { if (tt == TT_BIOS) {
CreateTooltip(hPartitionScheme, lmprintf(MSG_150), 15000); if (pt != PARTITION_STYLE_SFD)
CreateTooltip(hPartitionScheme, lmprintf(MSG_150), 15000);
else
DestroyTooltip(hPartitionScheme);
} else { } else {
if (pt == PARTITION_STYLE_MBR) { if (pt == PARTITION_STYLE_MBR)
CreateTooltip(hPartitionScheme, lmprintf(MSG_151), 15000); CreateTooltip(hPartitionScheme, lmprintf(MSG_151), 15000);
} else { else if (pt == PARTITION_STYLE_GPT)
CreateTooltip(hPartitionScheme, lmprintf(MSG_152), 15000); CreateTooltip(hPartitionScheme, lmprintf(MSG_152), 15000);
} else
DestroyTooltip(hPartitionScheme);
} }
} }
@ -1122,7 +1130,8 @@ static void ToggleAdvanced(BOOL enable)
float dialog_shift = -3.22807f*fScale*fScale*fScale + 6.69173f*fScale*fScale + 15.8822f*fScale + 62.9737f; float dialog_shift = -3.22807f*fScale*fScale*fScale + 6.69173f*fScale*fScale + 15.8822f*fScale + 62.9737f;
RECT rect; RECT rect;
POINT point; POINT point;
int toggle; BOOL needs_resel = FALSE;
int i, toggle;
if (!enable) if (!enable)
dialog_shift = -dialog_shift; dialog_shift = -dialog_shift;
@ -1171,6 +1180,21 @@ static void ToggleAdvanced(BOOL enable)
ShowWindow(GetDlgItem(hMainDialog, IDC_DISK_ID), toggle); ShowWindow(GetDlgItem(hMainDialog, IDC_DISK_ID), toggle);
ShowWindow(GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), toggle); ShowWindow(GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), toggle);
if (enable) {
IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme,
ComboBox_AddStringU(hPartitionScheme, "Super Floppy Disk"), PARTITION_STYLE_SFD));
} else {
for (i = 0; i < ComboBox_GetCount(hPartitionScheme); i++) {
if (ComboBox_GetItemData(hPartitionScheme, i) == PARTITION_STYLE_SFD) {
if (ComboBox_GetCurSel(hPartitionScheme) == i)
needs_resel = TRUE;
ComboBox_DeleteString(hPartitionScheme, i);
}
}
if (needs_resel)
SetTargetSystem();
}
// Toggle the up/down icon // Toggle the up/down icon
SendMessage(GetDlgItem(hMainDialog, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)(enable?&bi_up:&bi_down)); SendMessage(GetDlgItem(hMainDialog, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)(enable?&bi_up:&bi_down));
@ -1986,7 +2010,7 @@ static void ShowLanguageMenu(RECT rcExclude)
DestroyMenu(menu); DestroyMenu(menu);
} }
static void SetBoot(int fs, int tt) static void SetBoot(int fs, int tt, int pt)
{ {
int i; int i;
char tmp[32]; char tmp[32];
@ -2026,7 +2050,7 @@ static void SetBoot(int fs, int tt)
if (i == ComboBox_GetCount(hBootType)) if (i == ComboBox_GetCount(hBootType))
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0)); IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0));
if (!IsWindowEnabled(hBoot)) { if ((pt != PARTITION_STYLE_SFD) && !IsWindowEnabled(hBoot)) {
EnableWindow(hBoot, TRUE); EnableWindow(hBoot, TRUE);
EnableWindow(hBootType, TRUE); EnableWindow(hBootType, TRUE);
EnableWindow(hSelectISO, TRUE); EnableWindow(hSelectISO, TRUE);
@ -2411,10 +2435,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break; break;
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme))); tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
if ((selection_default == BT_IMG) && IsChecked(IDC_BOOT)) { if ((selection_default == BT_IMG) && IsChecked(IDC_BOOT)) {
ToggleImage(FALSE); ToggleImage(FALSE);
EnableAdvancedBootOptions(FALSE, TRUE); EnableAdvancedBootOptions(FALSE, TRUE);
SetBoot(fs, tt); SetBoot(fs, tt, pt);
SetToGo(); SetToGo();
break; break;
} }
@ -2443,7 +2468,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
} }
break; break;
} }
if ((fs == FS_EXFAT) || (fs == FS_UDF) || (fs == FS_REFS)) { if ((fs == FS_EXFAT) || (fs == FS_UDF) || (fs == FS_REFS) || (pt == PARTITION_STYLE_SFD)) {
if (IsWindowEnabled(hBoot)) { if (IsWindowEnabled(hBoot)) {
// unlikely to be supported by BIOSes => don't bother // unlikely to be supported by BIOSes => don't bother
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0)); IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0));
@ -2458,7 +2483,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break; break;
} }
EnableAdvancedBootOptions(TRUE, TRUE); EnableAdvancedBootOptions(TRUE, TRUE);
SetBoot(fs, tt); SetBoot(fs, tt, pt);
SetMBRProps(); SetMBRProps();
SetToGo(); SetToGo();
break; break;

View file

@ -235,6 +235,7 @@ enum target_type {
TT_MAX TT_MAX
}; };
// For the partition types we'll use Microsoft's PARTITION_STYLE_### constants // For the partition types we'll use Microsoft's PARTITION_STYLE_### constants
#define PARTITION_STYLE_SFD PARTITION_STYLE_RAW
#define GETTARGETTYPE(x) (((x)>0)?(((x) >> 16) & 0xFFFF):0) #define GETTARGETTYPE(x) (((x)>0)?(((x) >> 16) & 0xFFFF):0)
#define GETPARTTYPE(x) (((x)>0)?((x) & 0xFFFF):0); #define GETPARTTYPE(x) (((x)>0)?((x) & 0xFFFF):0);

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376 IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.17.1177" CAPTION "Rufus 2.17.1178"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0 FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -366,8 +366,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,17,1177,0 FILEVERSION 2,17,1178,0
PRODUCTVERSION 2,17,1177,0 PRODUCTVERSION 2,17,1178,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -384,13 +384,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.17.1177" VALUE "FileVersion", "2.17.1178"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.17.1177" VALUE "ProductVersion", "2.17.1178"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"