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

[ui] add advanced mode

* Adds "bare" Syslinux, Rufus MBR and disabling of fake USB detection options
This commit is contained in:
Pete Batard 2012-05-16 23:38:39 +01:00
parent cbff178717
commit bf2cb0bd88
12 changed files with 263 additions and 117 deletions

BIN
res/down.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -7,7 +7,7 @@ the user for boot selection, when a second bootable device (typically bootable
fixed HDD) is reported by the BIOS at 0x81. fixed HDD) is reported by the BIOS at 0x81.
This aims at mimicking the Microsoft Windows optical installation media feature, This aims at mimicking the Microsoft Windows optical installation media feature,
which may be necessary on for WinPE 2.x or earlier based installations. which may be necessary on for WinPE based installations.
This MBR will also masquerade a bootable USB drive booted as 0x80 by the BIOS to This MBR will also masquerade a bootable USB drive booted as 0x80 by the BIOS to
a different ID according to the one found in its partition table entry. Eg. if a different ID according to the one found in its partition table entry. Eg. if

BIN
res/up.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View file

@ -191,7 +191,9 @@
<Manifest Include="..\common_controls_and_elevation.manifest" /> <Manifest Include="..\common_controls_and_elevation.manifest" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\..\res\down.ico" />
<None Include="..\..\res\rufus.ico" /> <None Include="..\..\res\rufus.ico" />
<None Include="..\..\res\up.ico" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ResourceCompile Include="..\rufus.rc" /> <ResourceCompile Include="..\rufus.rc" />

View file

@ -100,6 +100,12 @@
<None Include="..\..\res\rufus.ico"> <None Include="..\..\res\rufus.ico">
<Filter>Resource Files</Filter> <Filter>Resource Files</Filter>
</None> </None>
<None Include="..\..\res\up.ico">
<Filter>Resource Files</Filter>
</None>
<None Include="..\..\res\down.ico">
<Filter>Resource Files</Filter>
</None>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Manifest Include="..\common_controls_and_elevation.manifest"> <Manifest Include="..\common_controls_and_elevation.manifest">

View file

@ -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) if (currently_testing + tryout > last_block)
tryout = last_block - currently_testing; tryout = last_block - currently_testing;
/* Add the block number at a fixed (random) offset during each pass to if (detect_fakes) {
allow for the detection of 'fake' media (eg. 2GB USB masquerading as 16GB) */ /* Add the block number at a fixed (random) offset during each pass to
for (i=0; i<(int)blocks_at_once; i++) { allow for the detection of 'fake' media (eg. 2GB USB masquerading as 16GB) */
blk_id = (blk_t*)(intptr_t)(buffer + id_offset+ i*block_size); for (i=0; i<(int)blocks_at_once; i++) {
*blk_id = (blk_t)(currently_testing + 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); got = do_write(hDrive, buffer, tryout, block_size, currently_testing);
if (v_flag > 1) 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) if (currently_testing + tryout > last_block)
tryout = last_block - currently_testing; tryout = last_block - currently_testing;
for (i=0; i<(int)blocks_at_once; i++) { if (detect_fakes) {
blk_id = (blk_t*)(intptr_t)(buffer + id_offset+ i*block_size); for (i=0; i<(int)blocks_at_once; i++) {
*blk_id = (blk_t)(currently_testing + 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, got = do_read(hDrive, read_buffer, tryout, block_size,
currently_testing); currently_testing);

View file

@ -374,7 +374,6 @@ static BOOL AnalyzePBR(HANDLE hLogicalVolume)
fake_fd._ptr = (char*)hLogicalVolume; fake_fd._ptr = (char*)hLogicalVolume;
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
// TODO: Add/Eliminate FAT12?
if (!is_br(&fake_fd)) { if (!is_br(&fake_fd)) {
uprintf("Volume does not have an x86 partition boot record\n"); uprintf("Volume does not have an x86 partition boot record\n");
return FALSE; return FALSE;
@ -416,6 +415,7 @@ BOOL WriteRufusMBR(FILE *fp)
unsigned char aucRef[] = {0x55, 0xAA}; unsigned char aucRef[] = {0x55, 0xAA};
unsigned char* rufus_mbr; 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); res = FindResource(hMainInstance, MAKEINTRESOURCE(IDR_BR_MBR_BIN), RT_RCDATA);
if (res == NULL) { if (res == NULL) {
uprintf("Unable to locate mbr.bin resource: %s\n", WindowsErrorString()); uprintf("Unable to locate mbr.bin resource: %s\n", WindowsErrorString());
@ -482,8 +482,8 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
break; break;
} }
if (IsChecked(IDC_DOS)) { if (IsChecked(IDC_DOS)) {
// Set first partition bootable - masquerade as 0x81 for non /minint WinPE // Set first partition bootable - masquerade as per the DiskID selected
buf[0x1be] = ((!IS_WINPE(iso_report.winpe)) || ((IS_WINPE(iso_report.winpe) && iso_report.uses_minint)))?0x80:0x81; 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]); 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; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); 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); r = write_syslinux_mbr(&fake_fd);
} else { } else {
if ((IS_WINPE(iso_report.winpe) && !iso_report.uses_minint) || (IsChecked(IDC_RUFUS_MBR))) { 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* patch_str_rep[] = { "\\i386\\txtsetup.sif", "\\i386\\system32\\" };
const char *win_nt_bt_org = "$win_nt$.~bt", *win_nt_bt_rep = "i386"; const char *win_nt_bt_org = "$win_nt$.~bt", *win_nt_bt_rep = "i386";
const char *rdisk_zero = "rdisk(0)"; const char *rdisk_zero = "rdisk(0)";
// TODO: allow other values than harddisk 1, as per user choice? char setupsrcdev[64];
char* setupsrcdev = "SetupSourceDevice = \"\\device\\harddisk1\\partition1\"";
HANDLE handle = INVALID_HANDLE_VALUE; HANDLE handle = INVALID_HANDLE_VALUE;
DWORD i, j, size, rw_size, index = 0; DWORD i, j, size, rw_size, index = 0;
BOOL r = FALSE; BOOL r = FALSE;
char* buf = NULL; char* buf = NULL;
index = ((iso_report.winpe&WINPE_I386) == WINPE_I386)?0:1; 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 // Copy of ntdetect.com in root
safe_sprintf(src, sizeof(src), "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]); safe_sprintf(src, sizeof(src), "%c:\\%s\\ntdetect.com", drive_letter, basedir[index]);
safe_sprintf(dst, sizeof(dst), "%c:\\ntdetect.com", drive_letter); 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); uprintf("Patching file %s\n", dst);
// Remove CRC check for 32 bit part of setupldr.bin from Win2k3 // Remove CRC check for 32 bit part of setupldr.bin from Win2k3
if ((size > 0x2061) && (buf[0x2060] == 0x74) && (buf[0x2061] == 0x03)) { 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[0x2060] = 0xeb;
buf[0x2061] = 0x1a; buf[0x2061] = 0x1a;
uprintf(" 0x00002060: 0x74 0x03 -> 0xEB 0x1A (disable Win2k3 CRC check)\n"); 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) { if (!iso_report.uses_minint) {
// Additional setupldr.bin/bootmgr patching // Additional setupldr.bin/bootmgr patching
for (i=0; i<size-32; i++) { for (i=0; i<size-32; i++) {
// rdisk(0) -> rdisk(1) disk masquerading // rdisk(0) -> rdisk(#) disk masquerading
// TODO: only the first one seems to be needed // TODO: only the first one seems to be needed
if (safe_strnicmp(&buf[i], rdisk_zero, strlen(rdisk_zero)-1) == 0) { if (safe_strnicmp(&buf[i], rdisk_zero, strlen(rdisk_zero)-1) == 0) {
buf[i+6] = '1'; buf[i+6] = 0x20 + ComboBox_GetCurSel(hDiskID);
uprintf(" 0x%08X: '%s' -> 'rdisk(1)'\n", i, rdisk_zero); uprintf(" 0x%08X: '%s' -> 'rdisk(%c)'\n", i, rdisk_zero, buf[i+6]);
} }
// $WIN_NT$_~BT -> i386 // $WIN_NT$_~BT -> i386
if (safe_strnicmp(&buf[i], win_nt_bt_org, strlen(win_nt_bt_org)-1) == 0) { 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 // We must close and unlock the volume to write files to it
safe_unlockclose(hLogicalVolume); 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..."); PrintStatus(0, TRUE, "Installing Syslinux...");
if (!InstallSyslinux(num, drive_name)) { if (!InstallSyslinux(num, drive_name)) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;

View file

@ -9,6 +9,8 @@
#define IDD_LICENSE 105 #define IDD_LICENSE 105
#define IDD_ISO_EXTRACT 106 #define IDD_ISO_EXTRACT 106
#define IDS_VERSION 107 #define IDS_VERSION 107
#define IDI_UP 108
#define IDI_DOWN 109
#define IDR_BR_MBR_BIN 200 #define IDR_BR_MBR_BIN 200
#define IDR_FD_COMMAND_COM 300 #define IDR_FD_COMMAND_COM 300
#define IDR_FD_KERNEL_SYS 301 #define IDR_FD_KERNEL_SYS 301
@ -58,9 +60,11 @@
#define IDC_SELECT_ISO 1016 #define IDC_SELECT_ISO 1016
#define IDC_SET_ICON 1017 #define IDC_SET_ICON 1017
#define IDC_RUFUS_MBR 1018 #define IDC_RUFUS_MBR 1018
#define IDC_ISO_PROGRESS 1020 #define IDC_ISO_PROGRESS 1019
#define IDC_ISO_FILENAME 1021 #define IDC_ISO_FILENAME 1020
#define IDC_ISO_ABORT 1022 #define IDC_ISO_ABORT 1021
#define IDC_DISK_ID 1022
#define IDC_EXTRA_PARTITION 1023
#define IDC_ABOUT_LICENSE 1030 #define IDC_ABOUT_LICENSE 1030
#define IDC_ABOUT_ICON 1031 #define IDC_ABOUT_ICON 1031
#define IDC_RUFUS_BOLD 1032 #define IDC_RUFUS_BOLD 1032
@ -71,15 +75,17 @@
#define IDC_NOTIFICATION_ICON 1040 #define IDC_NOTIFICATION_ICON 1040
#define IDC_NOTIFICATION_TEXT 1041 #define IDC_NOTIFICATION_TEXT 1041
#define IDC_NOTIFICATION_LINE 1042 #define IDC_NOTIFICATION_LINE 1042
#define IDC_ADVANCED 1043
#define IDC_ADVANCED_GROUP 1044
// Next default values for new objects // Next default values for new objects
// //
#ifdef APSTUDIO_INVOKED #ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS #ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NO_MFC 1 #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_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1043 #define _APS_NEXT_CONTROL_VALUE 1045
#define _APS_NEXT_SYMED_VALUE 101 #define _APS_NEXT_SYMED_VALUE 101
#endif #endif
#endif #endif

View file

@ -52,6 +52,33 @@
#ifndef PBST_PAUSED #ifndef PBST_PAUSED
#define PBST_PAUSED 3 #define PBST_PAUSED 3
#endif #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" }; static const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "exFAT" };
// Don't ask me - just following the MS standard here // 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 existing_key = FALSE; // For LGP set/restore
static BOOL iso_size_check = TRUE; static BOOL iso_size_check = TRUE;
static int selection_default; static int selection_default;
BOOL enable_fixed_disks = FALSE; BOOL enable_fixed_disks = FALSE, advanced_mode = TRUE;
/* /*
* Globals * Globals
@ -73,15 +100,15 @@ char* iso_path = NULL;
float fScale = 1.0f; float fScale = 1.0f;
int default_fs; int default_fs;
HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses; HWND hDeviceList, hCapacity, hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses;
HWND hISOProgressDlg = NULL, hISOProgressBar, hISOFileName; HWND hISOProgressDlg = NULL, hISOProgressBar, hISOFileName, hDiskID;
BOOL use_own_vesamenu = FALSE; BOOL use_own_vesamenu = FALSE, detect_fakes = TRUE;
int rufus_version[4]; int rufus_version[4];
extern char szStatusMessage[256]; extern char szStatusMessage[256];
static HANDLE format_thid = NULL; static HANDLE format_thid = NULL;
static HWND hDeviceTooltip = NULL, hFSTooltip = NULL, hProgress = NULL; static HWND hDeviceTooltip = NULL, hFSTooltip = NULL, hProgress = NULL;
static HWND hDOS = NULL, hSelectISO = NULL, hISOToolTip = NULL, hPassesToolTip = NULL; static HWND hDOS = NULL, hSelectISO = NULL, hISOToolTip = NULL, hPassesToolTip = NULL;
static HICON hIconDisc; static HICON hIconDisc, hIconDown, hIconUp;
static StrArray DriveID, DriveLabel; static StrArray DriveID, DriveLabel;
static char szTimer[12] = "00:00:00"; static char szTimer[12] = "00:00:00";
static unsigned int timer; static unsigned int timer;
@ -132,7 +159,6 @@ static BOOL DefineClusterSizes(void)
default_fs = FS_UNKNOWN; default_fs = FS_UNKNOWN;
memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize)); memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize));
if (SelectedDrive.DiskSize < 8*MB) { 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"); uprintf("This application does not support volumes smaller than 8 MB\n");
goto out; goto out;
} }
@ -439,6 +465,24 @@ static void SetFSFromISO(void)
ComboBox_GetCurSel(hFileSystem)); 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 * Populate the UI properties
*/ */
@ -461,8 +505,8 @@ static BOOL PopulateProperties(int ComboIndex)
hFSTooltip = NULL; hFSTooltip = NULL;
memset(&SelectedDrive, 0, sizeof(SelectedDrive)); memset(&SelectedDrive, 0, sizeof(SelectedDrive));
EnableWindow(GetDlgItem(hMainDialog, IDC_DOS), FALSE); EnableWindow(hDOS, FALSE);
EnableWindow(GetDlgItem(hMainDialog, IDC_DOSTYPE), FALSE); EnableWindow(hDOSType, FALSE);
if (ComboIndex < 0) { if (ComboIndex < 0) {
return TRUE; return TRUE;
@ -473,8 +517,8 @@ static BOOL PopulateProperties(int ComboIndex)
return FALSE; return FALSE;
SetFSFromISO(); SetFSFromISO();
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
EnableWindow(GetDlgItem(hMainDialog, IDC_DOS), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); EnableWindow(hDOS, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
EnableWindow(GetDlgItem(hMainDialog, IDC_DOSTYPE), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); EnableWindow(hDOSType, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
HumanReadableSize = (double)SelectedDrive.DiskSize; HumanReadableSize = (double)SelectedDrive.DiskSize;
for (i=0; i<ARRAYSIZE(suffix); i++) { for (i=0; i<ARRAYSIZE(suffix); i++) {
@ -959,19 +1003,25 @@ static void EnableControls(BOOL bEnable)
EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), bEnable);
if (bEnable) { if (bEnable) {
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)); fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
EnableWindow(GetDlgItem(hMainDialog, IDC_DOS), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); EnableWindow(hDOS, (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS));
EnableWindow(GetDlgItem(hMainDialog, IDC_DOSTYPE), (fs == FS_FAT16) || (fs == FS_FAT32) || (fs == FS_NTFS)); 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));
} else { } else {
EnableWindow(GetDlgItem(hMainDialog, IDC_DOS), FALSE); EnableWindow(hDOS, FALSE);
EnableWindow(GetDlgItem(hMainDialog, IDC_DOSTYPE), 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_BADBLOCKS), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_BADBLOCKS), bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_ABOUT), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_ABOUT), bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_START), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_START), bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_SELECT_ISO), bEnable); EnableWindow(hSelectISO, bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_NBPASSES), bEnable); EnableWindow(hNBPasses, bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), bEnable);
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), bEnable); EnableWindow(GetDlgItem(hMainDialog, IDC_ADVANCED), bEnable);
SetDlgItemTextA(hMainDialog, IDCANCEL, bEnable?"Close":"Cancel"); SetDlgItemTextA(hMainDialog, IDCANCEL, bEnable?"Close":"Cancel");
} }
@ -1077,10 +1127,8 @@ DWORD WINAPI ISOScanThread(LPVOID param)
"based on 'bootmgr/WinPE' or 'isolinux'.\n" "based on 'bootmgr/WinPE' or 'isolinux'.\n"
"This ISO image doesn't appear to use either...", "Unsupported ISO", MB_OK|MB_ICONINFORMATION); "This ISO image doesn't appear to use either...", "Unsupported ISO", MB_OK|MB_ICONINFORMATION);
safe_free(iso_path); safe_free(iso_path);
SetMBRProps();
} else { } else {
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), (iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe)));
CheckDlgButton(hMainDialog, IDC_RUFUS_MBR,
(((iso_report.winpe&WINPE_I386)==WINPE_I386)&&(!iso_report.uses_minint))?BST_CHECKED:BST_UNCHECKED);
if (iso_report.has_old_vesamenu) { if (iso_report.has_old_vesamenu) {
fd = fopen(vesamenu_filename, "rb"); fd = fopen(vesamenu_filename, "rb");
if (fd != NULL) { if (fd != NULL) {
@ -1109,6 +1157,7 @@ DWORD WINAPI ISOScanThread(LPVOID param)
// Enable DOS, set DOS Type to ISO (last item) and set FS accordingly // Enable DOS, set DOS Type to ISO (last item) and set FS accordingly
CheckDlgButton(hMainDialog, IDC_DOS, BST_CHECKED); CheckDlgButton(hMainDialog, IDC_DOS, BST_CHECKED);
SetFSFromISO(); SetFSFromISO();
SetMBRProps();
for (i=(int)safe_strlen(iso_path); (i>0)&&(iso_path[i]!='\\'); i--); for (i=(int)safe_strlen(iso_path); (i>0)&&(iso_path[i]!='\\'); i--);
PrintStatus(0, TRUE, "Using ISO: %s\n", &iso_path[i+1]); PrintStatus(0, TRUE, "Using ISO: %s\n", &iso_path[i+1]);
// Some Linux distros, such as Arch Linux, require the USB drive to have // Some Linux distros, such as Arch Linux, require the USB drive to have
@ -1127,28 +1176,60 @@ out:
ExitThread(0); 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) 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; HINSTANCE hDllInst;
HDC hDC; HDC hDC;
int i, i16; int i, i16;
@ -1171,6 +1252,7 @@ void InitDialog(HWND hDlg)
hDOSType = GetDlgItem(hDlg, IDC_DOSTYPE); hDOSType = GetDlgItem(hDlg, IDC_DOSTYPE);
hSelectISO = GetDlgItem(hDlg, IDC_SELECT_ISO); hSelectISO = GetDlgItem(hDlg, IDC_SELECT_ISO);
hNBPasses = GetDlgItem(hDlg, IDC_NBPASSES); hNBPasses = GetDlgItem(hDlg, IDC_NBPASSES);
hDiskID = GetDlgItem(hDlg, IDC_DISK_ID);
// High DPI scaling // High DPI scaling
i16 = GetSystemMetrics(SM_CXSMICON); i16 = GetSystemMetrics(SM_CXSMICON);
@ -1209,10 +1291,17 @@ void InitDialog(HWND hDlg)
// Fill up the DOS type dropdown // Fill up the DOS type dropdown
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "MS-DOS"), DT_WINME)); IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "MS-DOS"), DT_WINME));
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 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 // Create the string array
StrArrayCreate(&DriveID, MAX_DRIVES); StrArrayCreate(&DriveID, MAX_DRIVES);
StrArrayCreate(&DriveLabel, 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_QUICKFORMAT, BST_CHECKED);
CheckDlgButton(hDlg, IDC_DOS, BST_CHECKED); CheckDlgButton(hDlg, IDC_DOS, BST_CHECKED);
CheckDlgButton(hDlg, IDC_SET_ICON, 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) // Load system icons (NB: Use the excellent http://www.nirsoft.net/utils/iconsext.html to find icon IDs)
hDllInst = LoadLibraryA("shell32.dll"); hDllInst = LoadLibraryA("shell32.dll");
hIconDisc = (HICON)LoadImage(hDllInst, MAKEINTRESOURCE(12), IMAGE_ICON, i16, i16, LR_DEFAULTCOLOR|LR_SHARED); 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_Create = (ImageList_Create_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_Create");
pImageList_ReplaceIcon = (ImageList_ReplaceIcon_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_ReplaceIcon"); pImageList_ReplaceIcon = (ImageList_ReplaceIcon_t) GetProcAddress(GetDLLHandle("Comctl32.dll"), "ImageList_ReplaceIcon");
bi.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0); bi_iso.himl = pImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
pImageList_ReplaceIcon(bi.himl, -1, hIconDisc); pImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc);
SetRect(&bi.margin, 0, 1, 0, 0); SetRect(&bi_iso.margin, 0, 1, 0, 0);
bi.uAlign = 4; // BUTTON_IMAGELIST_ALIGN_CENTER bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
SendMessage(GetDlgItem(hDlg, IDC_SELECT_ISO), 0x1602, 0, (LPARAM)&bi); // BCM_SETIMAGELIST 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); 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. " 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); "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: case IDC_TEST:
break; break;
#endif #endif
case IDC_ADVANCED:
ToggleAdvanced();
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
ComboBox_GetCurSel(hFileSystem));
break;
case IDC_DEVICE: case IDC_DEVICE:
if (HIWORD(wParam) != CBN_SELCHANGE) if (HIWORD(wParam) != CBN_SELCHANGE)
break; break;
@ -1353,7 +1465,7 @@ 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));
SetClusterSizes(fs); SetClusterSizes(fs);
if ((fs == FS_EXFAT) || (fs <0)) { if ((fs == FS_EXFAT) || (fs < 0)) {
if (IsWindowEnabled(hDOS)) { if (IsWindowEnabled(hDOS)) {
// unlikely to be supported by BIOSes => don't bother // unlikely to be supported by BIOSes => don't bother
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 0)); 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(hDOSType, FALSE);
EnableWindow(hSelectISO, FALSE); EnableWindow(hSelectISO, FALSE);
} }
SetMBRProps();
break; break;
} }
IGNORE_RETVAL(ComboBox_ResetContent(hDOSType)); 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, "FreeDOS"), DT_FREEDOS));
} }
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO)); IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO));
if (selection_default == DT_ISO) { // If needed (advanced mode) also append a Syslinux option
if (iso_path == NULL) if ( ((fs == FS_FAT16) || (fs == FS_FAT32)) && (advanced_mode) )
selection_default = DT_FREEDOS; IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "SysLinux"), DT_SYSLINUX));
else if ( ((!advanced_mode) && (selection_default == DT_SYSLINUX)) ) {
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), selection_default = DT_FREEDOS;
(iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe))); CheckDlgButton(hDlg, IDC_DISK_ID, BST_UNCHECKED);
} }
for (i=0; i<ComboBox_GetCount(hDOSType); i++) { for (i=0; i<ComboBox_GetCount(hDOSType); i++) {
if (ComboBox_GetItemData(hDOSType, i) == selection_default) { if (ComboBox_GetItemData(hDOSType, i) == selection_default) {
@ -1392,12 +1505,13 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
EnableWindow(hSelectISO, TRUE); EnableWindow(hSelectISO, TRUE);
CheckDlgButton(hDlg, IDC_DOS, uDOSChecked); CheckDlgButton(hDlg, IDC_DOS, uDOSChecked);
} }
SetMBRProps();
break; break;
case IDC_DOSTYPE: case IDC_DOSTYPE:
if (HIWORD(wParam) != CBN_SELCHANGE) if (HIWORD(wParam) != CBN_SELCHANGE)
break; break;
selection_default = ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_ISO) { if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_ISO) {
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), (iso_report.has_bootmgr) || (IS_WINPE(iso_report.winpe)));
if ((iso_path == NULL) || (iso_report.label[0] == 0)) { if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
// Set focus to the Select ISO button // Set focus to the Select ISO button
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0); SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
@ -1406,11 +1520,12 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
SetWindowTextU(hLabel, iso_report.label); SetWindowTextU(hLabel, iso_report.label);
} }
} else { } else {
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), TRUE);
// Set focus on the start button // Set focus on the start button
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0); SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDC_START), TRUE); SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hMainDialog, IDC_START), TRUE);
SetWindowTextU(hLabel, SelectedDrive.proposed_label); SetWindowTextU(hLabel, SelectedDrive.proposed_label);
// Reset disk ID to 0x80 if Rufus MBR is used
IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0));
} }
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
case IDC_SELECT_ISO: case IDC_SELECT_ISO:
@ -1558,7 +1673,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
HANDLE mutex = NULL; HANDLE mutex = NULL;
HWND hDlg = NULL; HWND hDlg = NULL;
MSG msg; MSG msg;
BOOL mbr_shown = FALSE;
uprintf("*** RUFUS INIT ***\n"); uprintf("*** RUFUS INIT ***\n");
@ -1578,6 +1692,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
// Initialize COM for folder selection // Initialize COM for folder selection
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
// Set the Windows version
DetectWindowsVersion();
// We use local group policies rather than direct registry manipulation // We use local group policies rather than direct registry manipulation
// 0x9e disables removable and fixed drive notifications // 0x9e disables removable and fixed drive notifications
SetLGP(FALSE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e); SetLGP(FALSE, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e);
@ -1613,11 +1730,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine
existing_key = FALSE; existing_key = FALSE;
continue; continue;
} }
// Alt M => make Rufus MBR choice visible // Alt K => Toggle fake drive detection during bad blocks check (enabled by default)
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'M')) { if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'K')) {
mbr_shown = !mbr_shown; detect_fakes = !detect_fakes;
ShowWindow(GetDlgItem(hDlg, IDC_RUFUS_MBR), mbr_shown?SW_SHOW:SW_HIDE); PrintStatus(0, FALSE, "Fake drive detection %s", detect_fakes?"enabled":"disabled");
existing_key = FALSE;
continue; continue;
} }
TranslateMessage(&msg); TranslateMessage(&msg);

View file

@ -125,6 +125,7 @@ enum dos_type {
DT_WINME = 0, DT_WINME = 0,
DT_FREEDOS, DT_FREEDOS,
DT_ISO, DT_ISO,
DT_SYSLINUX,
DT_MAX DT_MAX
}; };
@ -170,27 +171,41 @@ typedef enum TASKBAR_PROGRESS_FLAGS
TASKBAR_PAUSED = 0x8 TASKBAR_PAUSED = 0x8
} TASKBAR_PROGRESS_FLAGS; } 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 * Globals
*/ */
extern HINSTANCE hMainInstance; extern HINSTANCE hMainInstance;
extern HWND hMainDialog, hStatus, hDeviceList, hCapacity; extern HWND hMainDialog, hStatus, hDeviceList, hCapacity;
extern HWND hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses; extern HWND hFileSystem, hClusterSize, hLabel, hDOSType, hNBPasses;
extern HWND hISOProgressDlg, hISOProgressBar, hISOFileName; extern HWND hISOProgressDlg, hISOProgressBar, hISOFileName, hDiskID;
extern float fScale; extern float fScale;
extern char szFolderPath[MAX_PATH]; extern char szFolderPath[MAX_PATH];
extern char* iso_path; extern char* iso_path;
extern DWORD FormatStatus; extern DWORD FormatStatus;
extern RUFUS_DRIVE_INFO SelectedDrive; extern RUFUS_DRIVE_INFO SelectedDrive;
extern const int nb_steps[FS_MAX]; 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 RUFUS_ISO_REPORT iso_report;
extern int64_t iso_blocking_status; extern int64_t iso_blocking_status;
extern int rufus_version[4]; extern int rufus_version[4];
extern enum WindowsVersion nWindowsVersion;
/* /*
* Shared prototypes * Shared prototypes
*/ */
extern void DetectWindowsVersion(void);
extern const char *WindowsErrorString(void); extern const char *WindowsErrorString(void);
extern void DumpBufferHex(void *buf, size_t size); extern void DumpBufferHex(void *buf, size_t size);
extern void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...); extern void PrintStatus(unsigned int duration, BOOL debug, const char *format, ...);

View file

@ -27,14 +27,14 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
// Dialog // 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 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.169" CAPTION "Rufus v1.2.0.170"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,248,50,14 DEFPUSHBUTTON "Start",IDC_START,94,278,50,14
PUSHBUTTON "Close",IDCANCEL,148,248,50,14 PUSHBUTTON "Close",IDCANCEL,148,278,50,14
COMBOBOX IDC_DEVICE,8,17,190,33,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP 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 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 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 LTEXT "Capacity",IDC_STATIC,9,35,29,8
COMBOBOX IDC_CLUSTERSIZE,8,104,190,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP COMBOBOX IDC_CLUSTERSIZE,8,104,190,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Cluster size",IDC_STATIC,9,93,105,10 LTEXT "Cluster size",IDC_STATIC,9,93,105,10
PUSHBUTTON "About...",IDC_ABOUT,8,248,50,14 PUSHBUTTON "About...",IDC_ABOUT,8,278,50,14
GROUPBOX "Format Options",IDC_STATIC,7,149,189,64 GROUPBOX "Format Options ",IDC_STATIC,7,149,192,66
EDITTEXT IDC_LABEL,7,131,190,13,ES_AUTOHSCROLL 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 "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 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, 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 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_NBPASSES,119,159,49,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_DOSTYPE,119,183,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 "...",IDC_SELECT_ISO,171,182,22,14,BS_ICON
PUSHBUTTON "Test",IDC_TEST,62,248,20,14,NOT WS_VISIBLE PUSHBUTTON "Test",IDC_TEST,62,278,20,14,NOT WS_VISIBLE
CONTROL "Rufus MBR",IDC_RUFUS_MBR,"Button",BS_AUTOCHECKBOX | NOT WS_VISIBLE | WS_TABSTOP,71,173,44,10 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 END
IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195 IDD_ABOUTBOX DIALOGEX 0, 0, 287, 195
@ -71,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 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 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
@ -187,7 +192,7 @@ GUIDELINES DESIGNINFO
BEGIN BEGIN
IDD_DIALOG, DIALOG IDD_DIALOG, DIALOG
BEGIN BEGIN
BOTTOMMARGIN, 288 BOTTOMMARGIN, 315
END END
IDD_ABOUTBOX, DIALOG IDD_ABOUTBOX, DIALOG
@ -216,8 +221,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,0,169 FILEVERSION 1,2,0,170
PRODUCTVERSION 1,2,0,169 PRODUCTVERSION 1,2,0,170
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -234,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.169" VALUE "FileVersion", "1.2.0.170"
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.169" VALUE "ProductVersion", "1.2.0.170"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"
@ -258,6 +263,8 @@ END
// Icon with lowest ID value placed first to ensure application icon // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems. // remains consistent on all systems.
IDI_ICON ICON "../res/rufus.ico" IDI_ICON ICON "../res/rufus.ico"
IDI_UP ICON "../res/up.ico"
IDI_DOWN ICON "../res/down.ico"
#endif // English resources #endif // English resources
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View file

@ -38,18 +38,6 @@
#include "resource.h" #include "resource.h"
#include "license.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 */ /* The following is only available on Vista and later */
#if (_WIN32_WINNT >= 0x0600) #if (_WIN32_WINNT >= 0x0600)
static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR, IBindCtx*, REFIID, void **) = NULL; static HRESULT (WINAPI *pSHCreateItemFromParsingName)(PCWSTR, IBindCtx*, REFIID, void **) = NULL;