mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[ui] add a reference to DebugView on error messages
* Closes #83 * Also fix MinGW warning of 'array subscript out of bounds' due to previous commit
This commit is contained in:
parent
8c47bac10e
commit
3fde2a5472
2 changed files with 42 additions and 31 deletions
61
src/rufus.c
61
src/rufus.c
|
@ -560,46 +560,56 @@ static BOOL PopulateProperties(int ComboIndex)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* MinGW is unhappy about accessing partitions beside the first unless we redef */
|
||||||
|
typedef struct _DRIVE_LAYOUT_INFORMATION_EX4 {
|
||||||
|
DWORD PartitionStyle;
|
||||||
|
DWORD PartitionCount;
|
||||||
|
union {
|
||||||
|
DRIVE_LAYOUT_INFORMATION_MBR Mbr;
|
||||||
|
DRIVE_LAYOUT_INFORMATION_GPT Gpt;
|
||||||
|
} Type;
|
||||||
|
PARTITION_INFORMATION_EX PartitionEntry[4];
|
||||||
|
} DRIVE_LAYOUT_INFORMATION_EX4,*PDRIVE_LAYOUT_INFORMATION_EX4;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a partition table
|
* Create a partition table
|
||||||
*/
|
*/
|
||||||
BOOL CreatePartition(HANDLE hDrive)
|
BOOL CreatePartition(HANDLE hDrive)
|
||||||
{
|
{
|
||||||
BYTE layout[sizeof(DRIVE_LAYOUT_INFORMATION_EX) + 3*sizeof(PARTITION_INFORMATION_EX)] = {0};
|
DRIVE_LAYOUT_INFORMATION_EX4 DriveLayoutEx = {0};
|
||||||
PDRIVE_LAYOUT_INFORMATION_EX DriveLayoutEx = (PDRIVE_LAYOUT_INFORMATION_EX)layout;
|
|
||||||
BOOL r;
|
BOOL r;
|
||||||
DWORD size;
|
DWORD size;
|
||||||
LONGLONG sector_size;
|
LONGLONG sector_size;
|
||||||
|
|
||||||
PrintStatus(0, TRUE, "Partitioning...");
|
PrintStatus(0, TRUE, "Partitioning...");
|
||||||
DriveLayoutEx->PartitionStyle = PARTITION_STYLE_MBR;
|
DriveLayoutEx.PartitionStyle = PARTITION_STYLE_MBR;
|
||||||
DriveLayoutEx->PartitionCount = 4; // Must be multiple of 4 for MBR
|
DriveLayoutEx.PartitionCount = 4; // Must be multiple of 4 for MBR
|
||||||
DriveLayoutEx->Mbr.Signature = GetTickCount();
|
DriveLayoutEx.Type.Mbr.Signature = GetTickCount();
|
||||||
DriveLayoutEx->PartitionEntry[0].PartitionStyle = PARTITION_STYLE_MBR;
|
DriveLayoutEx.PartitionEntry[0].PartitionStyle = PARTITION_STYLE_MBR;
|
||||||
// TODO: CHS fixup (32 sectors/track) through a cheat mode, if requested
|
// 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
|
// 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 =
|
DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart =
|
||||||
SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack;
|
SelectedDrive.Geometry.BytesPerSector * SelectedDrive.Geometry.SectorsPerTrack;
|
||||||
sector_size = (SelectedDrive.DiskSize - DriveLayoutEx->PartitionEntry[0].StartingOffset.QuadPart) / SelectedDrive.Geometry.BytesPerSector;
|
sector_size = (SelectedDrive.DiskSize - DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart) / SelectedDrive.Geometry.BytesPerSector;
|
||||||
// Align on sector boundary if the extra part option is checked
|
// Align on sector boundary if the extra part option is checked
|
||||||
if (IsChecked(IDC_EXTRA_PARTITION)) {
|
if (IsChecked(IDC_EXTRA_PARTITION)) {
|
||||||
sector_size = ((sector_size / SelectedDrive.Geometry.SectorsPerTrack)-1) * SelectedDrive.Geometry.SectorsPerTrack;
|
sector_size = ((sector_size / SelectedDrive.Geometry.SectorsPerTrack)-1) * SelectedDrive.Geometry.SectorsPerTrack;
|
||||||
if (sector_size <= 0) return FALSE;
|
if (sector_size <= 0) return FALSE;
|
||||||
}
|
}
|
||||||
DriveLayoutEx->PartitionEntry[0].PartitionLength.QuadPart = sector_size * SelectedDrive.Geometry.BytesPerSector;
|
DriveLayoutEx.PartitionEntry[0].PartitionLength.QuadPart = sector_size * SelectedDrive.Geometry.BytesPerSector;
|
||||||
DriveLayoutEx->PartitionEntry[0].PartitionNumber = 1;
|
DriveLayoutEx.PartitionEntry[0].PartitionNumber = 1;
|
||||||
DriveLayoutEx->PartitionEntry[0].RewritePartition = TRUE;
|
DriveLayoutEx.PartitionEntry[0].RewritePartition = TRUE;
|
||||||
DriveLayoutEx->PartitionEntry[0].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack;
|
DriveLayoutEx.PartitionEntry[0].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack;
|
||||||
switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) {
|
switch (ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))) {
|
||||||
case FS_FAT16:
|
case FS_FAT16:
|
||||||
DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType = 0x0e; // FAT16 LBA
|
DriveLayoutEx.PartitionEntry[0].Mbr.PartitionType = 0x0e; // FAT16 LBA
|
||||||
break;
|
break;
|
||||||
case FS_NTFS:
|
case FS_NTFS:
|
||||||
case FS_EXFAT:
|
case FS_EXFAT:
|
||||||
DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType = 0x07; // NTFS
|
DriveLayoutEx.PartitionEntry[0].Mbr.PartitionType = 0x07; // NTFS
|
||||||
break;
|
break;
|
||||||
case FS_FAT32:
|
case FS_FAT32:
|
||||||
DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType = 0x0c; // FAT32 LBA
|
DriveLayoutEx.PartitionEntry[0].Mbr.PartitionType = 0x0c; // FAT32 LBA
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
uprintf("Unsupported file system\n");
|
uprintf("Unsupported file system\n");
|
||||||
|
@ -608,22 +618,22 @@ BOOL CreatePartition(HANDLE hDrive)
|
||||||
|
|
||||||
// Create an extra partition on request - can improve BIOS detection as HDD for older BIOSes
|
// Create an extra partition on request - can improve BIOS detection as HDD for older BIOSes
|
||||||
if (IsChecked(IDC_EXTRA_PARTITION)) {
|
if (IsChecked(IDC_EXTRA_PARTITION)) {
|
||||||
DriveLayoutEx->PartitionEntry[1].PartitionStyle = PARTITION_STYLE_MBR;
|
DriveLayoutEx.PartitionEntry[1].PartitionStyle = PARTITION_STYLE_MBR;
|
||||||
// Should end on a sector boundary
|
// Should end on a sector boundary
|
||||||
DriveLayoutEx->PartitionEntry[1].StartingOffset.QuadPart = DriveLayoutEx->PartitionEntry[0].StartingOffset.QuadPart +
|
DriveLayoutEx.PartitionEntry[1].StartingOffset.QuadPart = DriveLayoutEx.PartitionEntry[0].StartingOffset.QuadPart +
|
||||||
DriveLayoutEx->PartitionEntry[0].PartitionLength.QuadPart;
|
DriveLayoutEx.PartitionEntry[0].PartitionLength.QuadPart;
|
||||||
DriveLayoutEx->PartitionEntry[1].PartitionLength.QuadPart = SelectedDrive.Geometry.SectorsPerTrack*SelectedDrive.Geometry.BytesPerSector;
|
DriveLayoutEx.PartitionEntry[1].PartitionLength.QuadPart = SelectedDrive.Geometry.SectorsPerTrack*SelectedDrive.Geometry.BytesPerSector;
|
||||||
DriveLayoutEx->PartitionEntry[1].PartitionNumber = 2;
|
DriveLayoutEx.PartitionEntry[1].PartitionNumber = 2;
|
||||||
DriveLayoutEx->PartitionEntry[1].RewritePartition = TRUE;
|
DriveLayoutEx.PartitionEntry[1].RewritePartition = TRUE;
|
||||||
DriveLayoutEx->PartitionEntry[1].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack*SelectedDrive.Geometry.BytesPerSector;
|
DriveLayoutEx.PartitionEntry[1].Mbr.HiddenSectors = SelectedDrive.Geometry.SectorsPerTrack*SelectedDrive.Geometry.BytesPerSector;
|
||||||
DriveLayoutEx->PartitionEntry[1].Mbr.PartitionType = DriveLayoutEx->PartitionEntry[0].Mbr.PartitionType + 0x10; // Hidden whatever
|
DriveLayoutEx.PartitionEntry[1].Mbr.PartitionType = DriveLayoutEx.PartitionEntry[0].Mbr.PartitionType + 0x10; // Hidden whatever
|
||||||
}
|
}
|
||||||
|
|
||||||
// For the remaining partitions, PartitionStyle & PartitionType have already
|
// For the remaining partitions, PartitionStyle & PartitionType have already
|
||||||
// been zeroed => set to MBR/unused
|
// been zeroed => set to MBR/unused
|
||||||
|
|
||||||
r = DeviceIoControl(hDrive, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
|
r = DeviceIoControl(hDrive, IOCTL_DISK_SET_DRIVE_LAYOUT_EX,
|
||||||
layout, sizeof(layout), NULL, 0, &size, NULL );
|
(BYTE*)&DriveLayoutEx, sizeof(DriveLayoutEx), NULL, 0, &size, NULL );
|
||||||
if (!r) {
|
if (!r) {
|
||||||
uprintf("IOCTL_DISK_SET_DRIVE_LAYOUT_EX failed: %s\n", WindowsErrorString());
|
uprintf("IOCTL_DISK_SET_DRIVE_LAYOUT_EX failed: %s\n", WindowsErrorString());
|
||||||
safe_closehandle(hDrive);
|
safe_closehandle(hDrive);
|
||||||
|
@ -1683,7 +1693,8 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
|
||||||
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
||||||
SetTaskbarProgressState(TASKBAR_ERROR);
|
SetTaskbarProgressState(TASKBAR_ERROR);
|
||||||
PrintStatus(0, FALSE, "FAILED");
|
PrintStatus(0, FALSE, "FAILED");
|
||||||
Notification(MSG_ERROR, "Error", "Error: %s", StrError(FormatStatus));
|
Notification(MSG_ERROR, "Error", "Error: %s.%s", StrError(FormatStatus),
|
||||||
|
(strchr(StrError(FormatStatus), '\n') != NULL)?"":"\nFor more information, please try DebugView.");
|
||||||
}
|
}
|
||||||
return (INT_PTR)TRUE;
|
return (INT_PTR)TRUE;
|
||||||
}
|
}
|
||||||
|
|
12
src/rufus.rc
12
src/rufus.rc
|
@ -30,7 +30,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 206, 316
|
IDD_DIALOG DIALOGEX 12, 12, 206, 316
|
||||||
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||||
EXSTYLE WS_EX_APPWINDOW
|
EXSTYLE WS_EX_APPWINDOW
|
||||||
CAPTION "Rufus v1.2.0.172"
|
CAPTION "Rufus v1.2.0.173"
|
||||||
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
FONT 8, "MS Shell Dlg", 400, 0, 0x1
|
||||||
BEGIN
|
BEGIN
|
||||||
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
|
DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
|
||||||
|
@ -76,7 +76,7 @@ BEGIN
|
||||||
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
|
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,
|
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
|
||||||
"SysLink",WS_TABSTOP,46,47,114,9
|
"SysLink",WS_TABSTOP,46,47,114,9
|
||||||
LTEXT "Version 1.2.0 (Build 172)",IDC_STATIC,46,19,78,8
|
LTEXT "Version 1.2.0 (Build 173)",IDC_STATIC,46,19,78,8
|
||||||
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
|
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
|
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
|
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
|
||||||
|
@ -221,8 +221,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 1,2,0,172
|
FILEVERSION 1,2,0,173
|
||||||
PRODUCTVERSION 1,2,0,172
|
PRODUCTVERSION 1,2,0,173
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -239,13 +239,13 @@ BEGIN
|
||||||
BEGIN
|
BEGIN
|
||||||
VALUE "CompanyName", "akeo.ie"
|
VALUE "CompanyName", "akeo.ie"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "1.2.0.172"
|
VALUE "FileVersion", "1.2.0.173"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011 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", "1.2.0.172"
|
VALUE "ProductVersion", "1.2.0.173"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue