From bf2cb0bd88afa6d4584c652fdf1b3a3b7a4b8adf Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Wed, 16 May 2012 23:38:39 +0100 Subject: [PATCH] [ui] add advanced mode * Adds "bare" Syslinux, Rufus MBR and disabling of fake USB detection options --- res/down.ico | Bin 0 -> 1150 bytes res/mbr/readme.txt | 2 +- res/up.ico | Bin 0 -> 1150 bytes src/.msvc/rufus_2010.vcxproj | 2 + src/.msvc/rufus_2010.vcxproj.filters | 6 + src/badblocks.c | 20 ++- src/format.c | 24 +-- src/resource.h | 16 +- src/rufus.c | 238 ++++++++++++++++++++------- src/rufus.h | 19 ++- src/rufus.rc | 41 +++-- src/stdlg.c | 12 -- 12 files changed, 263 insertions(+), 117 deletions(-) create mode 100644 res/down.ico create mode 100644 res/up.ico diff --git a/res/down.ico b/res/down.ico new file mode 100644 index 0000000000000000000000000000000000000000..ccce932a861b7969e01e2246d14189dd69a35d47 GIT binary patch literal 1150 zcmZQzU<5(|0R|wcz>vYhz#zuJz@P!dKp~(AL>x#lH~{5F0dXO4Z?pe2ApQ@ciPM2l z1=IWG%NLM-lFUHX3(`-D8QAm^YX&~Ogv=mDFFrGX`oaE$sUbvz)FVQhfdOVeNSsJa sa-1UDH=Nl2fgy>E|I{-u{IF+W_#n@~@PMCz;Q%`WLjyAcBdZ0m0aiTvYhz#zuJz@P!dKp~(AL>x#lH~{5F0cHr?+w6Y@i2sv-uOOQO z()Z=d7osspJ(_;7{lu67bt8)XAhUqt1kJ#u7v>gxW)RYg&kSPqVl#tOz366u`~(vl pr7=U`KQJXC;|6911{glT&cN`1pMl|nJOjfIdj^I-^{8q=`T!HU4h{eS literal 0 HcmV?d00001 diff --git a/src/.msvc/rufus_2010.vcxproj b/src/.msvc/rufus_2010.vcxproj index a36dc096..8ef7be04 100644 --- a/src/.msvc/rufus_2010.vcxproj +++ b/src/.msvc/rufus_2010.vcxproj @@ -191,7 +191,9 @@ + + diff --git a/src/.msvc/rufus_2010.vcxproj.filters b/src/.msvc/rufus_2010.vcxproj.filters index 296839b3..f1c28cb2 100644 --- a/src/.msvc/rufus_2010.vcxproj.filters +++ b/src/.msvc/rufus_2010.vcxproj.filters @@ -100,6 +100,12 @@ Resource Files + + Resource Files + + + Resource Files + diff --git a/src/badblocks.c b/src/badblocks.c index 7be49e4d..0cab56e4 100644 --- a/src/badblocks.c +++ b/src/badblocks.c @@ -477,11 +477,13 @@ static unsigned int test_rw(HANDLE hDrive, blk_t last_block, size_t block_size, } if (currently_testing + tryout > last_block) tryout = last_block - currently_testing; - /* Add the block number at a fixed (random) offset during each pass to - allow for the detection of 'fake' media (eg. 2GB USB masquerading as 16GB) */ - for (i=0; i<(int)blocks_at_once; i++) { - blk_id = (blk_t*)(intptr_t)(buffer + id_offset+ i*block_size); - *blk_id = (blk_t)(currently_testing + i); + if (detect_fakes) { + /* Add the block number at a fixed (random) offset during each pass to + allow for the detection of 'fake' media (eg. 2GB USB masquerading as 16GB) */ + for (i=0; i<(int)blocks_at_once; i++) { + blk_id = (blk_t*)(intptr_t)(buffer + id_offset+ i*block_size); + *blk_id = (blk_t)(currently_testing + i); + } } got = do_write(hDrive, buffer, tryout, block_size, currently_testing); if (v_flag > 1) @@ -523,9 +525,11 @@ static unsigned int test_rw(HANDLE hDrive, blk_t last_block, size_t block_size, } if (currently_testing + tryout > last_block) tryout = last_block - currently_testing; - for (i=0; i<(int)blocks_at_once; i++) { - blk_id = (blk_t*)(intptr_t)(buffer + id_offset+ i*block_size); - *blk_id = (blk_t)(currently_testing + i); + if (detect_fakes) { + for (i=0; i<(int)blocks_at_once; i++) { + blk_id = (blk_t*)(intptr_t)(buffer + id_offset+ i*block_size); + *blk_id = (blk_t)(currently_testing + i); + } } got = do_read(hDrive, read_buffer, tryout, block_size, currently_testing); diff --git a/src/format.c b/src/format.c index 1e7652e9..b76df6b3 100644 --- a/src/format.c +++ b/src/format.c @@ -374,7 +374,6 @@ static BOOL AnalyzePBR(HANDLE hLogicalVolume) fake_fd._ptr = (char*)hLogicalVolume; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; - // TODO: Add/Eliminate FAT12? if (!is_br(&fake_fd)) { uprintf("Volume does not have an x86 partition boot record\n"); return FALSE; @@ -416,6 +415,7 @@ BOOL WriteRufusMBR(FILE *fp) unsigned char aucRef[] = {0x55, 0xAA}; unsigned char* rufus_mbr; + // TODO: will we need to edit the disk ID according to UI sel in the MBR as well? res = FindResource(hMainInstance, MAKEINTRESOURCE(IDR_BR_MBR_BIN), RT_RCDATA); if (res == NULL) { uprintf("Unable to locate mbr.bin resource: %s\n", WindowsErrorString()); @@ -482,8 +482,8 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) break; } if (IsChecked(IDC_DOS)) { - // Set first partition bootable - masquerade as 0x81 for non /minint WinPE - buf[0x1be] = ((!IS_WINPE(iso_report.winpe)) || ((IS_WINPE(iso_report.winpe) && iso_report.uses_minint)))?0x80:0x81; + // Set first partition bootable - masquerade as per the DiskID selected + buf[0x1be] = (IsChecked(IDC_RUFUS_MBR))?(BYTE)ComboBox_GetItemData(hDiskID, ComboBox_GetCurSel(hDiskID)):0x80; uprintf("Set bootable USB partition as 0x%02X\n", buf[0x1be]); } @@ -497,7 +497,7 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive) fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); - if ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) { + if ( (dt == DT_SYSLINUX) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) { r = write_syslinux_mbr(&fake_fd); } else { if ((IS_WINPE(iso_report.winpe) && !iso_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) { @@ -591,14 +591,16 @@ static BOOL SetupWinPE(char drive_letter) const char* patch_str_rep[] = { "\\i386\\txtsetup.sif", "\\i386\\system32\\" }; const char *win_nt_bt_org = "$win_nt$.~bt", *win_nt_bt_rep = "i386"; const char *rdisk_zero = "rdisk(0)"; - // TODO: allow other values than harddisk 1, as per user choice? - char* setupsrcdev = "SetupSourceDevice = \"\\device\\harddisk1\\partition1\""; + char setupsrcdev[64]; HANDLE handle = INVALID_HANDLE_VALUE; DWORD i, j, size, rw_size, index = 0; BOOL r = FALSE; char* buf = NULL; index = ((iso_report.winpe&WINPE_I386) == WINPE_I386)?0:1; + // Allow other values than harddisk 1, as per user choice for disk ID + safe_sprintf(setupsrcdev, sizeof(setupsrcdev), + "SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"", ComboBox_GetCurSel(hDiskID)); // Copy of ntdetect.com in root safe_sprintf(src, sizeof(src), "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]); safe_sprintf(dst, sizeof(dst), "%c:\\ntdetect.com", drive_letter); @@ -657,7 +659,7 @@ static BOOL SetupWinPE(char drive_letter) uprintf("Patching file %s\n", dst); // Remove CRC check for 32 bit part of setupldr.bin from Win2k3 if ((size > 0x2061) && (buf[0x2060] == 0x74) && (buf[0x2061] == 0x03)) { - // TODO: amend this is not all Win2k3 setupldr.bin use the same header + // TODO: amend this if not all Win2k3 setupldr.bin's use the same header buf[0x2060] = 0xeb; buf[0x2061] = 0x1a; uprintf(" 0x00002060: 0x74 0x03 -> 0xEB 0x1A (disable Win2k3 CRC check)\n"); @@ -675,11 +677,11 @@ static BOOL SetupWinPE(char drive_letter) if (!iso_report.uses_minint) { // Additional setupldr.bin/bootmgr patching for (i=0; i rdisk(1) disk masquerading + // rdisk(0) -> rdisk(#) disk masquerading // TODO: only the first one seems to be needed if (safe_strnicmp(&buf[i], rdisk_zero, strlen(rdisk_zero)-1) == 0) { - buf[i+6] = '1'; - uprintf(" 0x%08X: '%s' -> 'rdisk(1)'\n", i, rdisk_zero); + buf[i+6] = 0x20 + ComboBox_GetCurSel(hDiskID); + uprintf(" 0x%08X: '%s' -> 'rdisk(%c)'\n", i, rdisk_zero, buf[i+6]); } // $WIN_NT$_~BT -> i386 if (safe_strnicmp(&buf[i], win_nt_bt_org, strlen(win_nt_bt_org)-1) == 0) { @@ -888,7 +890,7 @@ DWORD WINAPI FormatThread(LPVOID param) } // We must close and unlock the volume to write files to it safe_unlockclose(hLogicalVolume); - } else if ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) { + } else if ( (dt == DT_SYSLINUX) || ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) ) { PrintStatus(0, TRUE, "Installing Syslinux..."); if (!InstallSyslinux(num, drive_name)) { FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; diff --git a/src/resource.h b/src/resource.h index a00b7821..e4f17158 100644 --- a/src/resource.h +++ b/src/resource.h @@ -9,6 +9,8 @@ #define IDD_LICENSE 105 #define IDD_ISO_EXTRACT 106 #define IDS_VERSION 107 +#define IDI_UP 108 +#define IDI_DOWN 109 #define IDR_BR_MBR_BIN 200 #define IDR_FD_COMMAND_COM 300 #define IDR_FD_KERNEL_SYS 301 @@ -58,9 +60,11 @@ #define IDC_SELECT_ISO 1016 #define IDC_SET_ICON 1017 #define IDC_RUFUS_MBR 1018 -#define IDC_ISO_PROGRESS 1020 -#define IDC_ISO_FILENAME 1021 -#define IDC_ISO_ABORT 1022 +#define IDC_ISO_PROGRESS 1019 +#define IDC_ISO_FILENAME 1020 +#define IDC_ISO_ABORT 1021 +#define IDC_DISK_ID 1022 +#define IDC_EXTRA_PARTITION 1023 #define IDC_ABOUT_LICENSE 1030 #define IDC_ABOUT_ICON 1031 #define IDC_RUFUS_BOLD 1032 @@ -71,15 +75,17 @@ #define IDC_NOTIFICATION_ICON 1040 #define IDC_NOTIFICATION_TEXT 1041 #define IDC_NOTIFICATION_LINE 1042 +#define IDC_ADVANCED 1043 +#define IDC_ADVANCED_GROUP 1044 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NO_MFC 1 -#define _APS_NEXT_RESOURCE_VALUE 108 +#define _APS_NEXT_RESOURCE_VALUE 110 #define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1043 +#define _APS_NEXT_CONTROL_VALUE 1045 #define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/src/rufus.c b/src/rufus.c index 4bc0b02b..02cc9460 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -52,6 +52,33 @@ #ifndef PBST_PAUSED #define PBST_PAUSED 3 #endif +#ifndef BUTTON_IMAGELIST_ALIGN_CENTER +#define BUTTON_IMAGELIST_ALIGN_CENTER 4 +#endif +#ifndef BCM_SETIMAGELIST +#define BCM_SETIMAGELIST 0x1602 +#endif + +// MinGW fails to link those +typedef HIMAGELIST (WINAPI *ImageList_Create_t)( + int cx, + int cy, + UINT flags, + int cInitial, + int cGrow +); +ImageList_Create_t pImageList_Create = NULL; +typedef int (WINAPI *ImageList_ReplaceIcon_t)( + HIMAGELIST himl, + int i, + HICON hicon +); +ImageList_ReplaceIcon_t pImageList_ReplaceIcon = NULL; +struct { + HIMAGELIST himl; + RECT margin; + UINT uAlign; +} bi_iso = {0}, bi_up = {0}, bi_down = {0}; // BUTTON_IMAGELIST static const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "exFAT" }; // Don't ask me - just following the MS standard here @@ -61,7 +88,7 @@ static const char* ClusterSizeLabel[] = { "512 bytes", "1024 bytes","2048 bytes" static BOOL existing_key = FALSE; // For LGP set/restore static BOOL iso_size_check = TRUE; static int selection_default; -BOOL enable_fixed_disks = FALSE; +BOOL enable_fixed_disks = FALSE, advanced_mode = TRUE; /* * Globals @@ -73,15 +100,15 @@ char* iso_path = NULL; float fScale = 1.0f; int default_fs; HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses; -HWND hISOProgressDlg = NULL, hISOProgressBar, hISOFileName; -BOOL use_own_vesamenu = FALSE; +HWND hISOProgressDlg = NULL, hISOProgressBar, hISOFileName, hDiskID; +BOOL use_own_vesamenu = FALSE, detect_fakes = TRUE; int rufus_version[4]; extern char szStatusMessage[256]; static HANDLE format_thid = NULL; static HWND hDeviceTooltip = NULL, hFSTooltip = NULL, hProgress = NULL; static HWND hDOS = NULL, hSelectISO = NULL, hISOToolTip = NULL, hPassesToolTip = NULL; -static HICON hIconDisc; +static HICON hIconDisc, hIconDown, hIconUp; static StrArray DriveID, DriveLabel; static char szTimer[12] = "00:00:00"; static unsigned int timer; @@ -132,7 +159,6 @@ static BOOL DefineClusterSizes(void) default_fs = FS_UNKNOWN; memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize)); if (SelectedDrive.DiskSize < 8*MB) { - // TODO: muck with FAT12 and Small FAT16 like Microsoft does to support small drives? uprintf("This application does not support volumes smaller than 8 MB\n"); goto out; } @@ -439,6 +465,24 @@ static void SetFSFromISO(void) ComboBox_GetCurSel(hFileSystem)); } +void SetMBRProps(void) +{ + int fs, dt; + BOOL needs_masquerading = (iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe) && (!iso_report.uses_minint)); + + fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); + dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); + + if ((iso_path == NULL) || (dt != DT_ISO) || (fs != FS_NTFS)) { + CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, BST_UNCHECKED); + IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); + return; + } + + CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, needs_masquerading?BST_CHECKED:BST_UNCHECKED); + IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, needs_masquerading?1:0)); +} + /* * Populate the UI properties */ @@ -461,8 +505,8 @@ static BOOL PopulateProperties(int ComboIndex) hFSTooltip = NULL; memset(&SelectedDrive, 0, sizeof(SelectedDrive)); - EnableWindow(GetDlgItem(hMainDialog, IDC_DOS), FALSE); - EnableWindow(GetDlgItem(hMainDialog, IDC_DOSTYPE), FALSE); + EnableWindow(hDOS, FALSE); + EnableWindow(hDOSType, FALSE); if (ComboIndex < 0) { return TRUE; @@ -473,8 +517,8 @@ static BOOL PopulateProperties(int ComboIndex) return FALSE; SetFSFromISO(); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); - EnableWindow(GetDlgItem(hMainDialog, IDC_DOS), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); - EnableWindow(GetDlgItem(hMainDialog, IDC_DOSTYPE), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); + EnableWindow(hDOS, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); + EnableWindow(hDOSType, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); HumanReadableSize = (double)SelectedDrive.DiskSize; for (i=0; i0)&&(iso_path[i]!='\\'); i--); PrintStatus(0, TRUE, "Using ISO: %s\n", &iso_path[i+1]); // Some Linux distros, such as Arch Linux, require the USB drive to have @@ -1127,28 +1176,60 @@ out: ExitThread(0); } + +void MoveControl(int nID, float vertical_shift) +{ + RECT rect; + POINT point; + HWND hControl; + + hControl = GetDlgItem(hMainDialog, nID); + GetWindowRect(hControl, &rect); + point.x = rect.left; + point.y = rect.top; + ScreenToClient(hMainDialog, &point); + GetClientRect(hControl, &rect); + MoveWindow(hControl, point.x, point.y + (int)(fScale*(advanced_mode?vertical_shift:-vertical_shift)), + (rect.right - rect.left), (rect.bottom - rect.top), TRUE); +} + +// Toggle "advanced" mode +void ToggleAdvanced(void) +{ + float dialog_shift = 60.0f; + RECT rect; + POINT point; + int toggle; + + advanced_mode = !advanced_mode; + + // Increase or decrease the Window size + GetWindowRect(hMainDialog, &rect); + point.x = (rect.right - rect.left); + point.y = (rect.bottom - rect.top); + MoveWindow(hMainDialog, rect.left, rect.top, point.x, + point.y + (int)(fScale*(advanced_mode?dialog_shift:-dialog_shift)), TRUE); + + // Move the status bar up or down + MoveControl(IDC_STATUS, dialog_shift); + MoveControl(IDC_START, dialog_shift); + MoveControl(IDC_PROGRESS, dialog_shift); + MoveControl(IDC_ABOUT, dialog_shift); + MoveControl(IDCANCEL, dialog_shift); + + // Hide or show the various advanced options + toggle = advanced_mode?SW_SHOW:SW_HIDE; + ShowWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), toggle); + ShowWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), toggle); + ShowWindow(GetDlgItem(hMainDialog, IDC_DISK_ID), toggle); + ShowWindow(GetDlgItem(hMainDialog, IDC_ADVANCED_GROUP), toggle); + + // Toggle the up/down icon + SendMessage(GetDlgItem(hMainDialog, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)(advanced_mode?&bi_up:&bi_down)); +} + void InitDialog(HWND hDlg) { - // MinGW fails to link those - typedef HIMAGELIST (WINAPI *ImageList_Create_t)( - int cx, - int cy, - UINT flags, - int cInitial, - int cGrow - ); - ImageList_Create_t pImageList_Create = NULL; - typedef int (WINAPI *ImageList_ReplaceIcon_t)( - HIMAGELIST himl, - int i, - HICON hicon - ); - ImageList_ReplaceIcon_t pImageList_ReplaceIcon = NULL; - struct { - HIMAGELIST himl; - RECT margin; - UINT uAlign; - } bi = {0}; // BUTTON_IMAGELIST HINSTANCE hDllInst; HDC hDC; int i, i16; @@ -1171,6 +1252,7 @@ void InitDialog(HWND hDlg) hDOSType = GetDlgItem(hDlg, IDC_DOSTYPE); hSelectISO = GetDlgItem(hDlg, IDC_SELECT_ISO); hNBPasses = GetDlgItem(hDlg, IDC_NBPASSES); + hDiskID = GetDlgItem(hDlg, IDC_DISK_ID); // High DPI scaling i16 = GetSystemMetrics(SM_CXSMICON); @@ -1209,10 +1291,17 @@ void InitDialog(HWND hDlg) // Fill up the DOS type dropdown IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "MS-DOS"), DT_WINME)); IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, DT_WINME)); + // Fill up the MBR disk IDs ("9 IDs should be enough for anybody") + for (i=0x80; i<=0x88; i++) { + sprintf(tmp, "0x%02x", i); + IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, tmp), i)); + } + IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0)); + // Create the string array StrArrayCreate(&DriveID, MAX_DRIVES); StrArrayCreate(&DriveLabel, MAX_DRIVES); - // Set the Quick format, Create bootable and Set icon checkboxes + // Set various checkboxes CheckDlgButton(hDlg, IDC_QUICKFORMAT, BST_CHECKED); CheckDlgButton(hDlg, IDC_DOS, BST_CHECKED); CheckDlgButton(hDlg, IDC_SET_ICON, BST_CHECKED); @@ -1220,20 +1309,38 @@ void InitDialog(HWND hDlg) // Load system icons (NB: Use the excellent http://www.nirsoft.net/utils/iconsext.html to find icon IDs) hDllInst = LoadLibraryA("shell32.dll"); hIconDisc = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(12), IMAGE_ICON, i16, i16, LR_DEFAULTCOLOR|LR_SHARED); + if (nWindowsVersion >= WINDOWS_VISTA) { + hIconDown = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(16750), IMAGE_ICON, i16, i16, LR_DEFAULTCOLOR|LR_SHARED); + hIconUp = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(16749), IMAGE_ICON, i16, i16, LR_DEFAULTCOLOR|LR_SHARED); + } else { + hIconDown = (HICON)LoadImage(hMainInstance, MAKEINTRESOURCE(IDI_DOWN), IMAGE_ICON, 16, 16, 0); + hIconUp = (HICON)LoadImage(hMainInstance, MAKEINTRESOURCE(IDI_UP), IMAGE_ICON, 16, 16, 0); + } - // Set a disc icon on the select ISO button + // Set the icons on the the buttons pImageList_Create = (ImageList_Create_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_Create"); pImageList_ReplaceIcon = (ImageList_ReplaceIcon_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_ReplaceIcon"); - bi.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); - pImageList_ReplaceIcon(bi.himl, -1, hIconDisc); - SetRect(&bi.margin, 0, 1, 0, 0); - bi.uAlign = 4; // BUTTON_IMAGELIST_ALIGN_CENTER - SendMessage(GetDlgItem(hDlg, IDC_SELECT_ISO), 0x1602, 0, (LPARAM)&bi); // BCM_SETIMAGELIST + bi_iso.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc); + SetRect(&bi_iso.margin, 0, 1, 0, 0); + bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_down.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pImageList_ReplaceIcon(bi_down.himl, -1, hIconDown); + SetRect(&bi_down.margin, 0, 0, 0, 0); + bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + bi_up.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); + pImageList_ReplaceIcon(bi_up.himl, -1, hIconUp); + SetRect(&bi_up.margin, 0, 0, 0, 0); + bi_up.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER; + SendMessage(hSelectISO, BCM_SETIMAGELIST, 0, (LPARAM)&bi_iso); + SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)&bi_down); hISOToolTip = CreateTooltip(hSelectISO, "Click to select...", -1); CreateTooltip(GetDlgItem(hDlg, IDC_SET_ICON), "Create an autorun.inf on the target drive, to set the icon. " "Also allow the display of non-English labels.", 10000); + + ToggleAdvanced(); // We start in advanced mode => go to basic mode } /* @@ -1322,6 +1429,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case IDC_TEST: break; #endif + case IDC_ADVANCED: + ToggleAdvanced(); + SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, + ComboBox_GetCurSel(hFileSystem)); + break; case IDC_DEVICE: if (HIWORD(wParam) != CBN_SELCHANGE) break; @@ -1353,7 +1465,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA break; fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); SetClusterSizes(fs); - if ((fs == FS_EXFAT) || (fs <0)) { + if ((fs == FS_EXFAT) || (fs < 0)) { if (IsWindowEnabled(hDOS)) { // unlikely to be supported by BIOSes => don't bother IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 0)); @@ -1363,6 +1475,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA EnableWindow(hDOSType, FALSE); EnableWindow(hSelectISO, FALSE); } + SetMBRProps(); break; } IGNORE_RETVAL(ComboBox_ResetContent(hDOSType)); @@ -1371,12 +1484,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "FreeDOS"), DT_FREEDOS)); } IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO)); - if (selection_default == DT_ISO) { - if (iso_path == NULL) - selection_default = DT_FREEDOS; - else - EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), - (iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe))); + // If needed (advanced mode) also append a Syslinux option + if ( ((fs == FS_FAT16) || (fs == FS_FAT32)) && (advanced_mode) ) + IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "SysLinux"), DT_SYSLINUX)); + if ( ((!advanced_mode) && (selection_default == DT_SYSLINUX)) ) { + selection_default = DT_FREEDOS; + CheckDlgButton(hDlg, IDC_DISK_ID, BST_UNCHECKED); } for (i=0; i make Rufus MBR choice visible - if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'M')) { - mbr_shown = !mbr_shown; - ShowWindow(GetDlgItem(hDlg, IDC_RUFUS_MBR), mbr_shown?SW_SHOW:SW_HIDE); - existing_key = FALSE; + // Alt K => Toggle fake drive detection during bad blocks check (enabled by default) + if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'K')) { + detect_fakes = !detect_fakes; + PrintStatus(0, FALSE, "Fake drive detection %s", detect_fakes?"enabled":"disabled"); continue; } TranslateMessage(&msg); diff --git a/src/rufus.h b/src/rufus.h index 56e45041..19219339 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -125,6 +125,7 @@ enum dos_type { DT_WINME = 0, DT_FREEDOS, DT_ISO, + DT_SYSLINUX, DT_MAX }; @@ -170,27 +171,41 @@ typedef enum TASKBAR_PROGRESS_FLAGS TASKBAR_PAUSED = 0x8 } TASKBAR_PROGRESS_FLAGS; +/* Windows versions */ +enum WindowsVersion { + WINDOWS_UNDEFINED, + WINDOWS_UNSUPPORTED, + WINDOWS_2K, + WINDOWS_XP, + WINDOWS_2003_XP64, + WINDOWS_VISTA, + WINDOWS_7, + WINDOWS_8 +}; + /* * Globals */ extern HINSTANCE hMainInstance; extern HWND hMainDialog, hStatus, hDeviceList, hCapacity; extern HWND hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses; -extern HWND hISOProgressDlg, hISOProgressBar, hISOFileName; +extern HWND hISOProgressDlg, hISOProgressBar, hISOFileName, hDiskID; extern float fScale; extern char szFolderPath[MAX_PATH]; extern char* iso_path; extern DWORD FormatStatus; extern RUFUS_DRIVE_INFO SelectedDrive; extern const int nb_steps[FS_MAX]; -extern BOOL bWithFreeDOS, use_own_vesamenu; +extern BOOL use_own_vesamenu, detect_fakes; extern RUFUS_ISO_REPORT iso_report; extern int64_t iso_blocking_status; extern int rufus_version[4]; +extern enum WindowsVersion nWindowsVersion; /* * Shared prototypes */ +extern void DetectWindowsVersion(void); extern const char *WindowsErrorString(void); extern void DumpBufferHex(void *buf, size_t size); extern void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...); diff --git a/src/rufus.rc b/src/rufus.rc index 6e5fc069..6b95d9f0 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -27,14 +27,14 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL // Dialog // -IDD_DIALOG DIALOGEX 12, 12, 206, 289 +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.169" +CAPTION "Rufus v1.2.0.170" FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN - DEFPUSHBUTTON "Start",IDC_START,94,248,50,14 - PUSHBUTTON "Close",IDCANCEL,148,248,50,14 + DEFPUSHBUTTON "Start",IDC_START,94,278,50,14 + PUSHBUTTON "Close",IDCANCEL,148,278,50,14 COMBOBOX IDC_DEVICE,8,17,190,33,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Device",IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,9,6,22,8 COMBOBOX IDC_FILESYSTEM,8,75,190,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP @@ -43,21 +43,26 @@ BEGIN LTEXT "Capacity",IDC_STATIC,9,35,29,8 COMBOBOX IDC_CLUSTERSIZE,8,104,190,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP LTEXT "Cluster size",IDC_STATIC,9,93,105,10 - PUSHBUTTON "About...",IDC_ABOUT,8,248,50,14 - GROUPBOX "Format Options",IDC_STATIC,7,149,189,64 + PUSHBUTTON "About...",IDC_ABOUT,8,278,50,14 + GROUPBOX "Format Options ",IDC_STATIC,7,149,192,66 EDITTEXT IDC_LABEL,7,131,190,13,ES_AUTOHSCROLL CONTROL "Check device for bad blocks:",IDC_BADBLOCKS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,161,101,10 - CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,173,58,10 + CONTROL "Quick Format",IDC_QUICKFORMAT,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,173,55,10 CONTROL "Create a bootable disk using:",IDC_DOS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,185,104,10 CONTROL "Create extended label and icon files",IDC_SET_ICON, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,197,131,10 + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,13,198,131,10 LTEXT "New volume label",IDC_STATIC,9,121,105,10 - CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,7,221,189,9 + CONTROL "",IDC_PROGRESS,"msctls_progress32",PBS_SMOOTH | WS_BORDER,8,259,189,9 COMBOBOX IDC_NBPASSES,119,159,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_DOSTYPE,119,183,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP PUSHBUTTON "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON - PUSHBUTTON "Test",IDC_TEST,62,248,20,14,NOT WS_VISIBLE - CONTROL "Rufus MBR",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,71,173,44,10 + PUSHBUTTON "Test",IDC_TEST,62,278,20,14,NOT WS_VISIBLE + CONTROL "Use Rufus MBR with Drive ID:",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,13,222,106,10 + 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 END IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195 @@ -71,7 +76,7 @@ BEGIN DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP CONTROL "http://rufus.akeo.ie",IDC_ABOUT_RUFUS_URL, "SysLink",WS_TABSTOP,46,47,114,9 - LTEXT "Version 1.2.0 (Build 169)",IDC_STATIC,46,19,78,8 + LTEXT "Version 1.2.0 (Build 170)",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 @@ -187,7 +192,7 @@ GUIDELINES DESIGNINFO BEGIN IDD_DIALOG, DIALOG BEGIN - BOTTOMMARGIN, 288 + BOTTOMMARGIN, 315 END IDD_ABOUTBOX, DIALOG @@ -216,8 +221,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,2,0,169 - PRODUCTVERSION 1,2,0,169 + FILEVERSION 1,2,0,170 + PRODUCTVERSION 1,2,0,170 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -234,13 +239,13 @@ BEGIN BEGIN VALUE "CompanyName", "akeo.ie" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "1.2.0.169" + VALUE "FileVersion", "1.2.0.170" 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.169" + VALUE "ProductVersion", "1.2.0.170" END END BLOCK "VarFileInfo" @@ -258,6 +263,8 @@ END // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. IDI_ICON ICON "../res/rufus.ico" +IDI_UP ICON "../res/up.ico" +IDI_DOWN ICON "../res/down.ico" #endif // English resources ///////////////////////////////////////////////////////////////////////////// diff --git a/src/stdlg.c b/src/stdlg.c index 5d9853db..74eaa8ec 100644 --- a/src/stdlg.c +++ b/src/stdlg.c @@ -38,18 +38,6 @@ #include "resource.h" #include "license.h" -/* Windows versions */ -enum WindowsVersion { - WINDOWS_UNDEFINED, - WINDOWS_UNSUPPORTED, - WINDOWS_2K, - WINDOWS_XP, - WINDOWS_2003_XP64, - WINDOWS_VISTA, - WINDOWS_7, - WINDOWS_8 -}; - /* The following is only available on Vista and later */ #if (_WIN32_WINNT >= 0x0600) static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR, IBindCtx*, REFIID, void **) = NULL;