2011-11-13 20:53:23 +00:00
|
|
|
/*
|
2011-12-05 11:36:02 +00:00
|
|
|
* Rufus: The Reliable USB Formatting Utility
|
2015-01-01 23:39:28 +00:00
|
|
|
* Copyright © 2011-2015 Pete Batard <pete@akeo.ie>
|
2013-12-27 16:06:59 +00:00
|
|
|
*
|
2011-11-13 20:53:23 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2011-11-21 20:12:23 +00:00
|
|
|
/* Memory leaks detection - define _CRTDBG_MAP_ALLOC as preprocessor macro */
|
|
|
|
#ifdef _CRTDBG_MAP_ALLOC
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <crtdbg.h>
|
|
|
|
#endif
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
#include <windows.h>
|
|
|
|
#include <windowsx.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2011-11-24 02:24:50 +00:00
|
|
|
#include <math.h>
|
2011-11-20 02:34:15 +00:00
|
|
|
#include <winioctl.h>
|
2013-12-20 18:32:10 +00:00
|
|
|
#include <shlobj.h>
|
2011-11-27 23:40:28 +00:00
|
|
|
#include <process.h>
|
2011-11-26 00:25:04 +00:00
|
|
|
#include <dbt.h>
|
2013-02-04 01:14:28 +00:00
|
|
|
#include <io.h>
|
|
|
|
#include <getopt.h>
|
2011-11-20 22:49:55 +00:00
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
#include "msapi_utf8.h"
|
|
|
|
#include "resource.h"
|
2011-11-19 19:08:23 +00:00
|
|
|
#include "rufus.h"
|
2014-01-05 01:39:41 +00:00
|
|
|
#include "drive.h"
|
2015-01-25 00:56:38 +00:00
|
|
|
#include "settings.h"
|
2013-10-15 21:58:27 +00:00
|
|
|
#include "localization.h"
|
2014-12-29 20:34:41 +00:00
|
|
|
#include "bled/bled.h"
|
2014-12-30 19:46:13 +00:00
|
|
|
#include "../res/grub/grub_version.h"
|
|
|
|
#include "../res/grub2/grub2_version.h"
|
2011-11-13 20:53:23 +00:00
|
|
|
|
2013-06-03 23:44:49 +00:00
|
|
|
/* Redefinitions for WDK and MinGW */
|
2014-11-18 23:49:29 +00:00
|
|
|
// TODO: these would be better in a 'missing.h' file
|
2012-03-29 17:16:06 +00:00
|
|
|
#ifndef PBM_SETSTATE
|
|
|
|
#define PBM_SETSTATE (WM_USER+16)
|
|
|
|
#endif
|
|
|
|
#ifndef PBST_NORMAL
|
|
|
|
#define PBST_NORMAL 1
|
|
|
|
#endif
|
|
|
|
#ifndef PBST_ERROR
|
|
|
|
#define PBST_ERROR 2
|
|
|
|
#endif
|
|
|
|
#ifndef PBST_PAUSED
|
|
|
|
#define PBST_PAUSED 3
|
|
|
|
#endif
|
2012-05-16 22:38:39 +00:00
|
|
|
#ifndef BUTTON_IMAGELIST_ALIGN_CENTER
|
|
|
|
#define BUTTON_IMAGELIST_ALIGN_CENTER 4
|
|
|
|
#endif
|
|
|
|
#ifndef BCM_SETIMAGELIST
|
|
|
|
#define BCM_SETIMAGELIST 0x1602
|
|
|
|
#endif
|
2013-06-03 23:44:49 +00:00
|
|
|
#ifndef DBT_CUSTOMEVENT
|
|
|
|
#define DBT_CUSTOMEVENT 0x8006
|
|
|
|
#endif
|
2015-08-05 21:36:22 +00:00
|
|
|
#ifndef ERROR_FILE_TOO_LARGE
|
|
|
|
#define ERROR_FILE_TOO_LARGE 223
|
|
|
|
#endif
|
2012-05-16 22:38:39 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
HIMAGELIST himl;
|
|
|
|
RECT margin;
|
|
|
|
UINT uAlign;
|
2015-04-18 07:04:29 +00:00
|
|
|
} bi_iso = {0}, bi_up = {0}, bi_down = {0}; // BUTTON_IMAGELIST
|
2012-03-29 17:16:06 +00:00
|
|
|
|
2013-12-20 18:32:10 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
LPCITEMIDLIST pidl;
|
2014-05-12 21:44:10 +00:00
|
|
|
BOOL fRecursive;
|
2013-12-20 18:32:10 +00:00
|
|
|
} MY_SHChangeNotifyEntry;
|
|
|
|
|
2014-05-12 21:44:10 +00:00
|
|
|
// MinGW doesn't know these
|
|
|
|
PF_TYPE(WINAPI, HIMAGELIST, ImageList_Create, (int, int, UINT, int, int));
|
2015-04-18 07:04:29 +00:00
|
|
|
PF_TYPE(WINAPI, int, ImageList_AddIcon, (HIMAGELIST, HICON));
|
2014-05-12 21:44:10 +00:00
|
|
|
PF_TYPE(WINAPI, int, ImageList_ReplaceIcon, (HIMAGELIST, int, HICON));
|
|
|
|
// WDK blows up when trying to using PF_TYPE_DECL() for the ImageList calls... so we don't.
|
|
|
|
PF_DECL(ImageList_Create);
|
2015-04-18 07:04:29 +00:00
|
|
|
PF_DECL(ImageList_AddIcon);
|
2014-05-12 21:44:10 +00:00
|
|
|
PF_DECL(ImageList_ReplaceIcon);
|
|
|
|
PF_TYPE_DECL(WINAPI, BOOL, SHChangeNotifyDeregister, (ULONG));
|
|
|
|
PF_TYPE_DECL(WINAPI, ULONG, SHChangeNotifyRegister, (HWND, int, LONG, UINT, int, const MY_SHChangeNotifyEntry*));
|
2013-12-20 18:32:10 +00:00
|
|
|
|
2015-02-22 01:14:00 +00:00
|
|
|
const char* cmdline_hogger = "rufus.com";
|
2014-03-29 00:22:54 +00:00
|
|
|
const char* FileSystemLabel[FS_MAX] = { "FAT", "FAT32", "NTFS", "UDF", "exFAT", "ReFS" };
|
2013-07-08 23:14:29 +00:00
|
|
|
// Number of steps for each FS for FCC_STRUCTURE_PROGRESS
|
|
|
|
const int nb_steps[FS_MAX] = { 5, 5, 12, 1, 10 };
|
2013-01-22 02:40:43 +00:00
|
|
|
static const char* PartitionTypeLabel[2] = { "MBR", "GPT" };
|
2012-02-07 16:17:14 +00:00
|
|
|
static BOOL existing_key = FALSE; // For LGP set/restore
|
2013-07-05 22:58:04 +00:00
|
|
|
static BOOL size_check = TRUE;
|
2012-05-30 23:32:25 +00:00
|
|
|
static BOOL log_displayed = FALSE;
|
2013-02-04 01:14:28 +00:00
|
|
|
static BOOL iso_provided = FALSE;
|
2013-12-28 01:27:09 +00:00
|
|
|
static BOOL user_notified = FALSE;
|
2013-10-24 21:57:34 +00:00
|
|
|
static BOOL relaunch = FALSE;
|
2015-08-14 22:09:45 +00:00
|
|
|
static BOOL dont_display_image_name = FALSE;
|
2015-09-16 23:20:22 +00:00
|
|
|
extern BOOL enable_iso, enable_joliet, enable_rockridge, enable_ntfs_compression;
|
2014-12-30 19:46:13 +00:00
|
|
|
extern uint8_t* grub2_buf;
|
|
|
|
extern long grub2_len;
|
2014-02-04 20:01:28 +00:00
|
|
|
extern const char* old_c32_name[NB_OLD_C32];
|
2012-03-03 23:12:48 +00:00
|
|
|
static int selection_default;
|
2013-10-15 21:58:27 +00:00
|
|
|
static loc_cmd* selected_locale = NULL;
|
2013-10-24 21:57:34 +00:00
|
|
|
static UINT_PTR UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU;
|
|
|
|
static RECT relaunch_rc = { -65536, -65536, 0, 0};
|
2014-03-14 23:13:04 +00:00
|
|
|
static UINT uBootChecked = BST_CHECKED, uQFChecked = BST_CHECKED, uMBRChecked = BST_UNCHECKED;
|
2015-05-21 22:51:48 +00:00
|
|
|
static HFONT hInfoFont;
|
|
|
|
static HBRUSH hInfoBrush;
|
2015-02-08 00:38:21 +00:00
|
|
|
static WNDPROC info_original_proc = NULL;
|
2013-10-15 21:58:27 +00:00
|
|
|
char ClusterSizeLabel[MAX_CLUSTER_SIZES][64];
|
2015-01-25 00:56:38 +00:00
|
|
|
char msgbox[1024], msgbox_title[32], *ini_file = NULL;
|
2015-02-03 23:42:27 +00:00
|
|
|
char lost_translators[][6] = LOST_TRANSLATORS;
|
2011-12-01 02:56:44 +00:00
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
/*
|
|
|
|
* Globals
|
|
|
|
*/
|
2014-05-12 21:44:10 +00:00
|
|
|
OPENED_LIBRARIES_VARS;
|
2011-11-21 17:06:17 +00:00
|
|
|
HINSTANCE hMainInstance;
|
2015-05-08 22:37:22 +00:00
|
|
|
HWND hMainDialog, hLangToolbar = NULL, hUpdatesDlg = NULL;
|
2015-08-22 22:23:08 +00:00
|
|
|
char szFolderPath[MAX_PATH], app_dir[MAX_PATH], system_dir[MAX_PATH], sysnative_dir[MAX_PATH];
|
2014-05-22 00:52:25 +00:00
|
|
|
char* image_path = NULL;
|
2011-11-21 17:06:17 +00:00
|
|
|
float fScale = 1.0f;
|
2011-12-01 15:01:10 +00:00
|
|
|
int default_fs;
|
2013-10-31 22:59:53 +00:00
|
|
|
uint32_t dur_mins, dur_secs;
|
2015-10-18 20:31:47 +00:00
|
|
|
WORD selected_langid = MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT);
|
2013-01-24 21:30:11 +00:00
|
|
|
HWND hDeviceList, hPartitionScheme, hFileSystem, hClusterSize, hLabel, hBootType, hNBPasses, hLog = NULL;
|
2015-07-06 21:04:38 +00:00
|
|
|
HWND hLogDlg = NULL, hProgress = NULL, hInfo, hDiskID, hStatusToolbar;
|
2015-09-16 23:20:22 +00:00
|
|
|
BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, togo_mode;
|
2014-01-24 02:46:06 +00:00
|
|
|
BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE;
|
2015-10-01 21:22:20 +00:00
|
|
|
BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE;
|
2015-09-16 23:20:22 +00:00
|
|
|
BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps;
|
2015-11-04 13:58:19 +00:00
|
|
|
BOOL zero_drive = FALSE;
|
2015-04-18 07:04:29 +00:00
|
|
|
int dialog_showing = 0, lang_button_id = 0;
|
2015-02-08 22:36:57 +00:00
|
|
|
uint16_t rufus_version[3], embedded_sl_version[2];
|
2014-01-24 19:59:23 +00:00
|
|
|
char embedded_sl_version_str[2][12] = { "?.??", "?.??" };
|
2014-08-05 23:57:32 +00:00
|
|
|
char embedded_sl_version_ext[2][32];
|
2015-02-08 22:36:57 +00:00
|
|
|
RUFUS_UPDATE update = { {0,0,0}, {0,0}, NULL, NULL};
|
2014-05-17 23:37:01 +00:00
|
|
|
StrArray DriveID, DriveLabel;
|
2015-01-08 00:22:56 +00:00
|
|
|
extern char* szStatusMessage;
|
2011-11-17 01:43:06 +00:00
|
|
|
|
2012-02-07 02:05:58 +00:00
|
|
|
static HANDLE format_thid = NULL;
|
2015-04-19 03:15:44 +00:00
|
|
|
static HWND hBoot = NULL, hSelectISO = NULL, hStart = NULL;
|
2013-10-24 21:57:34 +00:00
|
|
|
static HICON hIconDisc, hIconDown, hIconUp, hIconLang;
|
2012-02-07 02:05:58 +00:00
|
|
|
static char szTimer[12] = "00:00:00";
|
2011-12-08 12:14:21 +00:00
|
|
|
static unsigned int timer;
|
2012-02-07 16:17:14 +00:00
|
|
|
static int64_t last_iso_blocking_status;
|
2015-01-13 02:11:57 +00:00
|
|
|
static void ToggleToGo(void);
|
2011-11-23 12:27:51 +00:00
|
|
|
|
2011-12-09 01:39:13 +00:00
|
|
|
/*
|
|
|
|
* The following is used to allocate slots within the progress bar
|
|
|
|
* 0 means unused (no operation or no progress allocated to it)
|
2013-06-20 14:41:22 +00:00
|
|
|
* +n means allocate exactly n bars (n percent of the progress bar)
|
2011-12-09 01:39:13 +00:00
|
|
|
* -n means allocate a weighted slot of n from all remaining
|
2014-05-20 18:28:46 +00:00
|
|
|
* bars. E.g. if 80 slots remain and the sum of all negative entries
|
2011-12-09 01:39:13 +00:00
|
|
|
* is 10, -4 will allocate 4/10*80 = 32 bars (32%) for OP progress
|
|
|
|
*/
|
|
|
|
static int nb_slots[OP_MAX];
|
2014-05-20 18:28:46 +00:00
|
|
|
static float slot_end[OP_MAX+1]; // shifted +1 so that we can subtract 1 to OP indexes
|
2012-11-03 17:40:33 +00:00
|
|
|
static float previous_end;
|
2011-12-09 01:39:13 +00:00
|
|
|
|
2015-01-12 00:53:09 +00:00
|
|
|
// TODO: Remember to update copyright year in stdlg's AboutCallback() WM_INITDIALOG,
|
|
|
|
// localization_data.sh and the .rc when the year changes!
|
2011-11-18 21:46:34 +00:00
|
|
|
|
2015-08-22 14:18:25 +00:00
|
|
|
// Set the combo selection according to the data
|
|
|
|
static __inline void SetComboEntry(HWND hDlg, int data) {
|
|
|
|
int i;
|
|
|
|
for (i = 0; i < ComboBox_GetCount(hDlg); i++) {
|
|
|
|
if (ComboBox_GetItemData(hDlg, i) == data)
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hDlg, i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-01 02:56:44 +00:00
|
|
|
#define KB 1024LL
|
|
|
|
#define MB 1048576LL
|
|
|
|
#define GB 1073741824LL
|
|
|
|
#define TB 1099511627776LL
|
2013-10-15 21:58:27 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Fill in the cluster size names
|
|
|
|
*/
|
|
|
|
static void SetClusterSizeLabels(void)
|
|
|
|
{
|
|
|
|
unsigned int i, j, k;
|
|
|
|
safe_sprintf(ClusterSizeLabel[0], 64, lmprintf(MSG_029));
|
|
|
|
for (i=512, j=1, k=MSG_026; j<MAX_CLUSTER_SIZES; i<<=1, j++) {
|
|
|
|
if (i > 8192) {
|
|
|
|
i /= 1024;
|
|
|
|
k++;
|
|
|
|
}
|
|
|
|
safe_sprintf(ClusterSizeLabel[j], 64, "%d %s", i, lmprintf(k));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-27 16:06:59 +00:00
|
|
|
/*
|
2011-12-01 15:01:10 +00:00
|
|
|
* Set cluster size values according to http://support.microsoft.com/kb/140365
|
|
|
|
* this call will return FALSE if we can't find a supportable FS for the drive
|
|
|
|
*/
|
2011-12-01 02:56:44 +00:00
|
|
|
static BOOL DefineClusterSizes(void)
|
|
|
|
{
|
|
|
|
LONGLONG i;
|
2011-12-01 15:01:10 +00:00
|
|
|
int fs;
|
|
|
|
BOOL r = FALSE;
|
2014-01-24 02:46:06 +00:00
|
|
|
char tmp[128] = "", *entry;
|
2011-12-01 15:01:10 +00:00
|
|
|
|
|
|
|
default_fs = FS_UNKNOWN;
|
2011-12-01 02:56:44 +00:00
|
|
|
memset(&SelectedDrive.ClusterSize, 0, sizeof(SelectedDrive.ClusterSize));
|
|
|
|
if (SelectedDrive.DiskSize < 8*MB) {
|
2013-07-05 22:58:04 +00:00
|
|
|
uprintf("Device was eliminated because it is smaller than 8 MB\n");
|
2011-12-01 15:01:10 +00:00
|
|
|
goto out;
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-13 02:10:27 +00:00
|
|
|
/*
|
2012-11-03 17:40:33 +00:00
|
|
|
* The following are MS's allowed cluster sizes for FAT16 and FAT32:
|
2011-12-13 02:10:27 +00:00
|
|
|
*
|
|
|
|
* FAT16
|
|
|
|
* 31M : 512 - 4096
|
|
|
|
* 63M : 1024 - 8192
|
|
|
|
* 127M : 2048 - 16k
|
|
|
|
* 255M : 4096 - 32k
|
|
|
|
* 511M : 8192 - 64k
|
|
|
|
* 1023M: 16k - 64k
|
|
|
|
* 2047M: 32k - 64k
|
|
|
|
* 4095M: 64k
|
|
|
|
* 4GB+ : N/A
|
|
|
|
*
|
|
|
|
* FAT32
|
|
|
|
* 31M : N/A
|
2014-04-10 21:01:48 +00:00
|
|
|
* 63M : N/A (NB unlike MS, we're allowing 512-512 here)
|
2011-12-13 02:10:27 +00:00
|
|
|
* 127M : 512 - 1024
|
|
|
|
* 255M : 512 - 2048
|
|
|
|
* 511M : 512 - 4096
|
|
|
|
* 1023M: 512 - 8192
|
|
|
|
* 2047M: 512 - 16k
|
|
|
|
* 4095M: 1024 - 32k
|
|
|
|
* 7GB : 2048 - 64k
|
|
|
|
* 15GB : 4096 - 64k
|
2012-11-03 17:40:33 +00:00
|
|
|
* 31GB : 8192 - 64k This is as far as Microsoft's FormatEx goes...
|
|
|
|
* 63GB : 16k - 64k ...but we can go higher using fat32format from RidgeCrop.
|
|
|
|
* 2TB+ : N/A
|
2014-04-04 17:22:00 +00:00
|
|
|
*
|
2011-12-13 02:10:27 +00:00
|
|
|
*/
|
|
|
|
|
2011-12-01 02:56:44 +00:00
|
|
|
// FAT 16
|
|
|
|
if (SelectedDrive.DiskSize < 4*GB) {
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT16].Allowed = 0x00001E00;
|
2011-12-01 02:56:44 +00:00
|
|
|
for (i=32; i<=4096; i<<=1) { // 8 MB -> 4 GB
|
|
|
|
if (SelectedDrive.DiskSize < i*MB) {
|
|
|
|
SelectedDrive.ClusterSize[FS_FAT16].Default = 16*(ULONG)i;
|
|
|
|
break;
|
|
|
|
}
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT16].Allowed <<= 1;
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT16].Allowed &= 0x0001FE00;
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// FAT 32
|
2013-06-20 14:41:22 +00:00
|
|
|
// > 32GB FAT32 is not supported by MS and FormatEx but is achieved using fat32format
|
2011-12-13 02:10:27 +00:00
|
|
|
// See: http://www.ridgecrop.demon.co.uk/index.htm?fat32format.htm
|
2012-11-03 17:40:33 +00:00
|
|
|
// < 32 MB FAT32 is not allowed by FormatEx, so we don't bother
|
2013-09-22 02:28:56 +00:00
|
|
|
if ((SelectedDrive.DiskSize >= 32*MB) && (1.0f*SelectedDrive.DiskSize < 1.0f*MAX_FAT32_SIZE*TB)) {
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Allowed = 0x000001F8;
|
|
|
|
for (i=32; i<=(32*1024); i<<=1) { // 32 MB -> 32 GB
|
2014-04-13 14:20:20 +00:00
|
|
|
if (SelectedDrive.DiskSize*1.0f < i*MB*FAT32_CLUSTER_THRESHOLD) { // MS
|
2011-12-01 02:56:44 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Default = 8*(ULONG)i;
|
|
|
|
break;
|
|
|
|
}
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Allowed <<= 1;
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Allowed &= 0x0001FE00;
|
|
|
|
|
|
|
|
// Default cluster sizes in the 256MB to 32 GB range do not follow the rule above
|
2012-11-03 17:40:33 +00:00
|
|
|
if ((SelectedDrive.DiskSize >= 256*MB) && (SelectedDrive.DiskSize < 32*GB)) {
|
2011-12-13 02:10:27 +00:00
|
|
|
for (i=8; i<=32; i<<=1) { // 256 MB -> 32 GB
|
2014-04-13 14:20:20 +00:00
|
|
|
if (SelectedDrive.DiskSize*1.0f < i*GB*FAT32_CLUSTER_THRESHOLD) {
|
2011-12-13 02:10:27 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Default = ((ULONG)i/2)*1024;
|
|
|
|
break;
|
|
|
|
}
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
2012-11-03 17:40:33 +00:00
|
|
|
// More adjustments for large drives
|
|
|
|
if (SelectedDrive.DiskSize >= 32*GB) {
|
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Allowed &= 0x0001C000;
|
|
|
|
SelectedDrive.ClusterSize[FS_FAT32].Default = 0x00008000;
|
|
|
|
}
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (SelectedDrive.DiskSize < 256*TB) {
|
2013-07-08 23:14:29 +00:00
|
|
|
// NTFS
|
2011-12-01 02:56:44 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_NTFS].Allowed = 0x0001FE00;
|
|
|
|
for (i=16; i<=256; i<<=1) { // 7 MB -> 256 TB
|
|
|
|
if (SelectedDrive.DiskSize < i*TB) {
|
|
|
|
SelectedDrive.ClusterSize[FS_NTFS].Default = ((ULONG)i/4)*1024;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-08 23:14:29 +00:00
|
|
|
// exFAT (requires KB955704 installed on XP => don't bother)
|
|
|
|
if (nWindowsVersion > WINDOWS_XP) {
|
|
|
|
SelectedDrive.ClusterSize[FS_EXFAT].Allowed = 0x03FFFE00;
|
|
|
|
if (SelectedDrive.DiskSize < 256*MB) // < 256 MB
|
|
|
|
SelectedDrive.ClusterSize[FS_EXFAT].Default = 4*1024;
|
|
|
|
else if (SelectedDrive.DiskSize < 32*GB) // < 32 GB
|
|
|
|
SelectedDrive.ClusterSize[FS_EXFAT].Default = 32*1024;
|
|
|
|
else
|
|
|
|
SelectedDrive.ClusterSize[FS_EXFAT].Default = 28*1024;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UDF (only supported for Vista and later)
|
|
|
|
if (nWindowsVersion >= WINDOWS_VISTA) {
|
2014-10-28 19:16:35 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_UDF].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
2013-07-08 23:14:29 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_UDF].Default = 1;
|
|
|
|
}
|
2014-03-29 00:22:54 +00:00
|
|
|
|
|
|
|
// ReFS (only supported for Windows 8.1 and later and for fixed disks)
|
2014-04-02 21:47:35 +00:00
|
|
|
if (SelectedDrive.DiskSize >= 512*MB) {
|
2014-11-08 00:23:50 +00:00
|
|
|
if ((nWindowsVersion >= WINDOWS_8_1) && (SelectedDrive.Geometry.MediaType == FixedMedia)) {
|
2014-10-28 19:16:35 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_REFS].Allowed = SINGLE_CLUSTERSIZE_DEFAULT;
|
2014-04-02 21:47:35 +00:00
|
|
|
SelectedDrive.ClusterSize[FS_REFS].Default = 1;
|
|
|
|
}
|
2014-03-29 00:22:54 +00:00
|
|
|
}
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
out:
|
|
|
|
// Only add the filesystems we can service
|
|
|
|
for (fs=0; fs<FS_MAX; fs++) {
|
2014-10-28 19:16:35 +00:00
|
|
|
// Remove all cluster sizes that are below the sector size
|
|
|
|
if (SelectedDrive.ClusterSize[fs].Allowed != SINGLE_CLUSTERSIZE_DEFAULT) {
|
|
|
|
SelectedDrive.ClusterSize[fs].Allowed &= ~(SelectedDrive.Geometry.BytesPerSector - 1);
|
|
|
|
if ((SelectedDrive.ClusterSize[fs].Default & SelectedDrive.ClusterSize[fs].Allowed) == 0)
|
|
|
|
// We lost our default => Use rightmost bit to select the new one
|
|
|
|
SelectedDrive.ClusterSize[fs].Default =
|
|
|
|
SelectedDrive.ClusterSize[fs].Allowed & (-(LONG)SelectedDrive.ClusterSize[fs].Allowed);
|
|
|
|
}
|
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
if (SelectedDrive.ClusterSize[fs].Allowed != 0) {
|
2013-01-09 23:24:31 +00:00
|
|
|
tmp[0] = 0;
|
|
|
|
// Tell the user if we're going to use Large FAT32 or regular
|
2013-11-25 22:34:26 +00:00
|
|
|
if ((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32)))
|
2013-01-09 23:24:31 +00:00
|
|
|
safe_strcat(tmp, sizeof(tmp), "Large ");
|
|
|
|
safe_strcat(tmp, sizeof(tmp), FileSystemLabel[fs]);
|
2011-12-01 15:01:10 +00:00
|
|
|
if (default_fs == FS_UNKNOWN) {
|
2013-10-15 21:58:27 +00:00
|
|
|
entry = lmprintf(MSG_030, tmp);
|
2011-12-01 15:01:10 +00:00
|
|
|
default_fs = fs;
|
2013-10-15 21:58:27 +00:00
|
|
|
} else {
|
|
|
|
entry = tmp;
|
2011-12-01 15:01:10 +00:00
|
|
|
}
|
2013-12-27 16:06:59 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hFileSystem,
|
2013-10-15 21:58:27 +00:00
|
|
|
ComboBox_AddStringU(hFileSystem, entry), fs));
|
2011-12-01 15:01:10 +00:00
|
|
|
r = TRUE;
|
|
|
|
}
|
|
|
|
}
|
2011-12-01 02:56:44 +00:00
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
return r;
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
#undef KB
|
|
|
|
#undef MB
|
|
|
|
#undef GB
|
|
|
|
#undef TB
|
|
|
|
|
2011-12-01 17:54:35 +00:00
|
|
|
/*
|
|
|
|
* Populate the Allocation unit size field
|
|
|
|
*/
|
2011-12-01 15:01:10 +00:00
|
|
|
static BOOL SetClusterSizes(int FSType)
|
2011-11-28 20:05:34 +00:00
|
|
|
{
|
2013-10-15 21:58:27 +00:00
|
|
|
char* szClustSize;
|
2011-12-13 02:10:27 +00:00
|
|
|
int i, k, default_index = 0;
|
2011-12-01 02:56:44 +00:00
|
|
|
ULONG j;
|
|
|
|
|
2011-11-28 20:05:34 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_ResetContent(hClusterSize));
|
2011-12-01 02:56:44 +00:00
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
if ((FSType < 0) || (FSType >= FS_MAX)) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-12-01 02:56:44 +00:00
|
|
|
if ( (SelectedDrive.ClusterSize[FSType].Allowed == 0)
|
|
|
|
|| (SelectedDrive.ClusterSize[FSType].Default == 0) ) {
|
|
|
|
uprintf("The drive is incompatible with FS type #%d\n", FSType);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-07-08 23:14:29 +00:00
|
|
|
for(i=0,j=0x100,k=0;j<0x10000000;i++,j<<=1) {
|
2011-12-01 02:56:44 +00:00
|
|
|
if (j & SelectedDrive.ClusterSize[FSType].Allowed) {
|
2011-12-04 20:13:51 +00:00
|
|
|
if (j == SelectedDrive.ClusterSize[FSType].Default) {
|
2013-10-15 21:58:27 +00:00
|
|
|
szClustSize = lmprintf(MSG_030, ClusterSizeLabel[i]);
|
2011-12-13 02:10:27 +00:00
|
|
|
default_index = k;
|
2013-10-15 21:58:27 +00:00
|
|
|
} else {
|
|
|
|
szClustSize = ClusterSizeLabel[i];
|
2011-12-04 20:13:51 +00:00
|
|
|
}
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hClusterSize, ComboBox_AddStringU(hClusterSize, szClustSize), j));
|
2011-12-13 02:10:27 +00:00
|
|
|
k++;
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-04 20:13:51 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hClusterSize, default_index));
|
2011-12-01 02:56:44 +00:00
|
|
|
return TRUE;
|
2011-11-28 20:05:34 +00:00
|
|
|
}
|
|
|
|
|
2015-05-24 20:50:50 +00:00
|
|
|
// This call sets the first option for the "partition type and target system" field
|
|
|
|
// according to whether we will be running in UEFI/CSM mode or standard UEFI
|
|
|
|
static void SetMBRForUEFI(BOOL replace)
|
|
|
|
{
|
|
|
|
BOOL useCSM = FALSE;
|
|
|
|
|
2015-06-06 22:12:12 +00:00
|
|
|
if (ComboBox_GetCurSel(hDeviceList) < 0)
|
|
|
|
return;
|
|
|
|
|
2015-05-24 20:50:50 +00:00
|
|
|
if (image_path != NULL) {
|
2015-09-02 22:20:00 +00:00
|
|
|
if ( (!img_report.has_efi) || ((img_report.has_bootmgr) && (!allow_dual_uefi_bios) &&
|
2015-05-24 20:50:50 +00:00
|
|
|
(Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) != BST_CHECKED)) )
|
|
|
|
useCSM = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (replace)
|
|
|
|
ComboBox_DeleteString(hPartitionScheme, 0);
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, ComboBox_InsertStringU(hPartitionScheme, 0,
|
2015-07-01 20:26:15 +00:00
|
|
|
lmprintf(MSG_031, PartitionTypeLabel[PARTITION_STYLE_MBR], useCSM?"UEFI-CSM":"UEFI")), (TT_BIOS<<16)|PARTITION_STYLE_MBR));
|
2015-05-24 20:50:50 +00:00
|
|
|
if (replace)
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hPartitionScheme, max(ComboBox_GetCurSel(hPartitionScheme), 0)));
|
|
|
|
}
|
|
|
|
|
2011-11-18 21:46:34 +00:00
|
|
|
/*
|
2011-11-24 02:24:50 +00:00
|
|
|
* Fill the drive properties (size, FS, etc)
|
2011-11-18 21:46:34 +00:00
|
|
|
*/
|
2014-03-01 00:09:40 +00:00
|
|
|
static BOOL SetDriveInfo(int ComboIndex)
|
2011-11-18 21:46:34 +00:00
|
|
|
{
|
2013-01-24 21:30:11 +00:00
|
|
|
DWORD i;
|
2015-05-24 20:50:50 +00:00
|
|
|
int pt;
|
2013-01-24 21:30:11 +00:00
|
|
|
char fs_type[32];
|
2011-11-18 21:46:34 +00:00
|
|
|
|
2013-01-20 22:46:11 +00:00
|
|
|
memset(&SelectedDrive, 0, sizeof(SelectedDrive));
|
2013-01-22 02:40:43 +00:00
|
|
|
SelectedDrive.DeviceNumber = (DWORD)ComboBox_GetItemData(hDeviceList, ComboIndex);
|
2011-11-18 21:46:34 +00:00
|
|
|
|
2014-08-07 00:45:46 +00:00
|
|
|
GetDrivePartitionData(SelectedDrive.DeviceNumber, fs_type, sizeof(fs_type), FALSE);
|
2011-11-18 21:46:34 +00:00
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
if (!DefineClusterSizes()) {
|
2013-06-06 22:40:37 +00:00
|
|
|
uprintf("No file system is selectable for this drive\n");
|
2011-12-01 15:01:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-11-25 01:30:41 +00:00
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
// re-select existing FS if it's one we know
|
2013-01-24 21:30:11 +00:00
|
|
|
SelectedDrive.FSType = FS_UNKNOWN;
|
|
|
|
if (safe_strlen(fs_type) != 0) {
|
2011-12-01 15:01:10 +00:00
|
|
|
for (SelectedDrive.FSType=FS_MAX-1; SelectedDrive.FSType>=0; SelectedDrive.FSType--) {
|
|
|
|
if (safe_strcmp(fs_type, FileSystemLabel[SelectedDrive.FSType]) == 0) {
|
2011-11-24 23:49:42 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-12-01 15:01:10 +00:00
|
|
|
} else {
|
|
|
|
SelectedDrive.FSType = FS_UNKNOWN;
|
2011-11-19 01:30:20 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
|
|
|
|
if (ComboBox_GetItemData(hFileSystem, i) == SelectedDrive.FSType) {
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (i == ComboBox_GetCount(hFileSystem)) {
|
|
|
|
// failed to reselect => pick default
|
|
|
|
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
|
|
|
|
if (ComboBox_GetItemData(hFileSystem, i) == default_fs) {
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-01 00:09:40 +00:00
|
|
|
for (i=0; i<3; i++) {
|
|
|
|
// Populate MBR/BIOS, MBR/UEFI and GPT/UEFI targets, with an exception
|
|
|
|
// for XP, as it doesn't support GPT at all
|
|
|
|
if ((i == 2) && (nWindowsVersion <= WINDOWS_XP))
|
|
|
|
continue;
|
|
|
|
pt = (i==2)?PARTITION_STYLE_GPT:PARTITION_STYLE_MBR;
|
2015-05-24 20:50:50 +00:00
|
|
|
if (i==0) {
|
|
|
|
SetMBRForUEFI(FALSE);
|
|
|
|
} else {
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hPartitionScheme, ComboBox_AddStringU(hPartitionScheme,
|
2015-07-01 20:26:15 +00:00
|
|
|
lmprintf(MSG_033, PartitionTypeLabel[pt])), (TT_UEFI<<16)|pt));
|
2015-05-24 20:50:50 +00:00
|
|
|
}
|
2014-03-01 00:09:40 +00:00
|
|
|
}
|
|
|
|
|
2011-12-01 15:01:10 +00:00
|
|
|
// At least one filesystem is go => enable formatting
|
2015-04-19 03:15:44 +00:00
|
|
|
EnableWindow(hStart, TRUE);
|
2011-12-01 15:01:10 +00:00
|
|
|
|
|
|
|
return SetClusterSizes((int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)));
|
2011-11-18 21:46:34 +00:00
|
|
|
}
|
|
|
|
|
2012-02-16 11:37:59 +00:00
|
|
|
static void SetFSFromISO(void)
|
|
|
|
{
|
2012-03-03 23:12:48 +00:00
|
|
|
int i, fs, selected_fs = FS_UNKNOWN;
|
|
|
|
uint32_t fs_mask = 0;
|
2015-07-01 20:26:15 +00:00
|
|
|
int tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
2015-09-02 22:20:00 +00:00
|
|
|
BOOL windows_to_go = (togo_mode) && HAS_TOGO(img_report) &&
|
2015-02-03 00:28:08 +00:00
|
|
|
(Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED);
|
2012-02-16 11:37:59 +00:00
|
|
|
|
2014-05-22 00:52:25 +00:00
|
|
|
if (image_path == NULL)
|
2012-02-16 11:37:59 +00:00
|
|
|
return;
|
|
|
|
|
2012-03-03 23:12:48 +00:00
|
|
|
// Create a mask of all the FS's available
|
|
|
|
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
|
2012-02-16 23:40:31 +00:00
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, i);
|
2012-03-03 23:12:48 +00:00
|
|
|
fs_mask |= 1<<fs;
|
|
|
|
}
|
|
|
|
|
2013-01-20 22:46:11 +00:00
|
|
|
// Syslinux and EFI have precedence over bootmgr (unless the user selected BIOS as target type)
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((HAS_SYSLINUX(img_report)) || (IS_REACTOS(img_report)) || (img_report.has_kolibrios) ||
|
|
|
|
((img_report.has_efi) && (tt == TT_UEFI) && (!img_report.has_4GB_file) && (!windows_to_go))) {
|
2012-03-03 23:12:48 +00:00
|
|
|
if (fs_mask & (1<<FS_FAT32)) {
|
|
|
|
selected_fs = FS_FAT32;
|
2015-09-02 22:20:00 +00:00
|
|
|
} else if ((fs_mask & (1<<FS_FAT16)) && (!img_report.has_kolibrios)) {
|
2012-03-03 23:12:48 +00:00
|
|
|
selected_fs = FS_FAT16;
|
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
} else if ((windows_to_go) || (img_report.has_bootmgr) || (IS_WINPE(img_report.winpe))) {
|
2012-03-03 23:12:48 +00:00
|
|
|
if (fs_mask & (1<<FS_NTFS)) {
|
|
|
|
selected_fs = FS_NTFS;
|
2012-02-16 11:37:59 +00:00
|
|
|
}
|
|
|
|
}
|
2012-03-03 23:12:48 +00:00
|
|
|
|
|
|
|
// Try to select the FS
|
|
|
|
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
|
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, i);
|
|
|
|
if (fs == selected_fs)
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
|
|
|
|
}
|
|
|
|
|
2012-02-16 11:37:59 +00:00
|
|
|
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
|
|
|
|
ComboBox_GetCurSel(hFileSystem));
|
|
|
|
}
|
|
|
|
|
2013-02-04 23:15:11 +00:00
|
|
|
static void SetMBRProps(void)
|
2012-05-16 22:38:39 +00:00
|
|
|
{
|
2012-11-03 17:40:33 +00:00
|
|
|
int fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
2015-07-01 20:26:15 +00:00
|
|
|
int bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
2015-09-02 22:20:00 +00:00
|
|
|
BOOL needs_masquerading = (IS_WINPE(img_report.winpe) && (!img_report.uses_minint));
|
2012-05-16 22:38:39 +00:00
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((!mbr_selected_by_user) && ((image_path == NULL) || (bt != BT_ISO) || (fs != FS_NTFS) || IS_GRUB(img_report) ||
|
2015-01-22 22:31:34 +00:00
|
|
|
((togo_mode) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED)) )) {
|
2012-05-16 22:38:39 +00:00
|
|
|
CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, BST_UNCHECKED);
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
uMBRChecked = (needs_masquerading || img_report.has_bootmgr || mbr_selected_by_user)?BST_CHECKED:BST_UNCHECKED;
|
2014-03-14 23:13:04 +00:00
|
|
|
if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_RUFUS_MBR)))
|
|
|
|
CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, uMBRChecked);
|
2012-05-16 22:38:39 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, needs_masquerading?1:0));
|
|
|
|
}
|
|
|
|
|
2015-01-13 02:11:57 +00:00
|
|
|
static void SetToGo(void)
|
|
|
|
{
|
2015-07-01 20:26:15 +00:00
|
|
|
int bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
2015-09-02 22:20:00 +00:00
|
|
|
if ( ((bt != BT_ISO) && (togo_mode)) || ((bt == BT_ISO) && (HAS_TOGO(img_report)) && (!togo_mode)) )
|
2015-01-13 02:11:57 +00:00
|
|
|
ToggleToGo();
|
|
|
|
}
|
|
|
|
|
2014-03-15 14:14:10 +00:00
|
|
|
static void EnableAdvancedBootOptions(BOOL enable, BOOL remove_checkboxes)
|
2012-05-25 16:54:06 +00:00
|
|
|
{
|
2015-07-01 20:26:15 +00:00
|
|
|
int tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
|
|
|
BOOL actual_enable_mbr = ((tt==TT_UEFI)||(selection_default>=BT_IMG)||!IsChecked(IDC_BOOT))?FALSE:enable;
|
|
|
|
BOOL actual_enable_fix = ((tt==TT_UEFI)||(selection_default==BT_IMG)||!IsChecked(IDC_BOOT))?FALSE:enable;
|
2014-03-14 23:13:04 +00:00
|
|
|
static UINT uXPartChecked = BST_UNCHECKED;
|
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((selection_default == BT_ISO) && (img_report.has_kolibrios || IS_GRUB(img_report) || IS_REACTOS(img_report) || HAS_SYSLINUX(img_report))) {
|
2014-11-18 23:49:29 +00:00
|
|
|
actual_enable_mbr = FALSE;
|
|
|
|
mbr_selected_by_user = FALSE;
|
|
|
|
}
|
2014-03-15 14:14:10 +00:00
|
|
|
if (remove_checkboxes) {
|
|
|
|
// Store/Restore the checkbox states
|
2014-11-18 23:49:29 +00:00
|
|
|
if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_RUFUS_MBR)) && !actual_enable_mbr) {
|
2014-03-15 14:14:10 +00:00
|
|
|
uMBRChecked = IsChecked(IDC_RUFUS_MBR);
|
|
|
|
CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, BST_UNCHECKED);
|
|
|
|
uXPartChecked = IsChecked(IDC_EXTRA_PARTITION);
|
|
|
|
CheckDlgButton(hMainDialog, IDC_EXTRA_PARTITION, BST_UNCHECKED);
|
2014-11-18 23:49:29 +00:00
|
|
|
} else if (!IsWindowEnabled(GetDlgItem(hMainDialog, IDC_RUFUS_MBR)) && actual_enable_mbr) {
|
2014-03-15 14:14:10 +00:00
|
|
|
CheckDlgButton(hMainDialog, IDC_RUFUS_MBR, uMBRChecked);
|
|
|
|
CheckDlgButton(hMainDialog, IDC_EXTRA_PARTITION, uXPartChecked);
|
|
|
|
}
|
2014-03-14 23:13:04 +00:00
|
|
|
}
|
2013-02-04 23:15:11 +00:00
|
|
|
|
2014-11-18 23:49:29 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), actual_enable_fix);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), actual_enable_mbr);
|
|
|
|
EnableWindow(hDiskID, actual_enable_mbr);
|
2013-02-04 23:15:11 +00:00
|
|
|
}
|
|
|
|
|
2014-03-15 14:14:10 +00:00
|
|
|
static void EnableBootOptions(BOOL enable, BOOL remove_checkboxes)
|
2013-02-04 23:15:11 +00:00
|
|
|
{
|
|
|
|
int fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
2015-07-01 20:26:15 +00:00
|
|
|
BOOL actual_enable = ((!IS_FAT(fs)) && (fs != FS_NTFS) && (selection_default == BT_IMG))?FALSE:enable;
|
2013-02-04 23:15:11 +00:00
|
|
|
|
|
|
|
EnableWindow(hBoot, actual_enable);
|
|
|
|
EnableWindow(hBootType, actual_enable);
|
|
|
|
EnableWindow(hSelectISO, actual_enable);
|
2015-01-13 02:11:57 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_INSTALL), actual_enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO), actual_enable);
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableAdvancedBootOptions(actual_enable, remove_checkboxes);
|
2012-05-25 16:54:06 +00:00
|
|
|
}
|
|
|
|
|
2013-01-27 01:40:09 +00:00
|
|
|
static void SetPartitionSchemeTooltip(void)
|
|
|
|
{
|
2015-07-01 20:26:15 +00:00
|
|
|
int tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
2014-03-14 23:13:04 +00:00
|
|
|
int pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
2015-07-01 20:26:15 +00:00
|
|
|
if (tt == TT_BIOS) {
|
2013-10-15 21:58:27 +00:00
|
|
|
CreateTooltip(hPartitionScheme, lmprintf(MSG_150), 15000);
|
2013-01-27 01:40:09 +00:00
|
|
|
} else {
|
|
|
|
if (pt == PARTITION_STYLE_MBR) {
|
2013-10-15 21:58:27 +00:00
|
|
|
CreateTooltip(hPartitionScheme, lmprintf(MSG_151), 15000);
|
2013-01-27 01:40:09 +00:00
|
|
|
} else {
|
2013-10-15 21:58:27 +00:00
|
|
|
CreateTooltip(hPartitionScheme, lmprintf(MSG_152), 15000);
|
2013-01-27 01:40:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-22 20:48:57 +00:00
|
|
|
static void SetTargetSystem(void)
|
|
|
|
{
|
|
|
|
int ts;
|
|
|
|
|
2015-05-24 20:50:50 +00:00
|
|
|
SetMBRForUEFI(TRUE);
|
2013-12-22 20:48:57 +00:00
|
|
|
if (SelectedDrive.PartitionType == PARTITION_STYLE_GPT) {
|
|
|
|
ts = 2; // GPT/UEFI
|
2015-09-02 22:20:00 +00:00
|
|
|
} else if (SelectedDrive.has_protective_mbr || SelectedDrive.has_mbr_uefi_marker || ((img_report.has_efi) &&
|
2015-10-18 20:31:47 +00:00
|
|
|
(!HAS_SYSLINUX(img_report)) && (!img_report.has_bootmgr) && (!IS_REACTOS(img_report)) &&
|
2015-09-02 22:20:00 +00:00
|
|
|
(!img_report.has_kolibrios) && (!IS_GRUB(img_report)) && (!IS_WINPE(img_report.winpe))) ) {
|
2013-12-22 20:48:57 +00:00
|
|
|
ts = 1; // MBR/UEFI
|
|
|
|
} else {
|
|
|
|
ts = 0; // MBR/BIOS|UEFI
|
|
|
|
}
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hPartitionScheme, ts));
|
|
|
|
SetPartitionSchemeTooltip();
|
|
|
|
}
|
|
|
|
|
2011-11-21 17:06:17 +00:00
|
|
|
/*
|
|
|
|
* Populate the UI properties
|
|
|
|
*/
|
2011-11-24 02:24:50 +00:00
|
|
|
static BOOL PopulateProperties(int ComboIndex)
|
2011-11-18 21:46:34 +00:00
|
|
|
{
|
2014-03-01 00:09:40 +00:00
|
|
|
const char no_label[] = STR_NO_LABEL;
|
2013-11-30 17:39:38 +00:00
|
|
|
char* device_tooltip;
|
2011-11-18 21:46:34 +00:00
|
|
|
|
2013-01-18 01:39:24 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_ResetContent(hPartitionScheme));
|
2011-11-19 01:30:20 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_ResetContent(hFileSystem));
|
2011-11-28 20:05:34 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_ResetContent(hClusterSize));
|
2015-04-19 03:15:44 +00:00
|
|
|
EnableWindow(hStart, FALSE);
|
2011-11-24 02:24:50 +00:00
|
|
|
SetWindowTextA(hLabel, "");
|
|
|
|
memset(&SelectedDrive, 0, sizeof(SelectedDrive));
|
|
|
|
|
2012-05-25 16:54:06 +00:00
|
|
|
if (ComboIndex < 0)
|
2011-11-18 23:41:28 +00:00
|
|
|
return TRUE;
|
|
|
|
|
2014-03-01 00:09:40 +00:00
|
|
|
if (!SetDriveInfo(ComboIndex)) // This also populates FS
|
2011-11-18 21:46:34 +00:00
|
|
|
return FALSE;
|
2013-12-22 20:48:57 +00:00
|
|
|
SetTargetSystem();
|
|
|
|
SetFSFromISO();
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableBootOptions(TRUE, TRUE);
|
2011-11-24 20:02:14 +00:00
|
|
|
|
2012-02-21 19:46:28 +00:00
|
|
|
// Set a proposed label according to the size (eg: "256MB", "8GB")
|
2014-03-01 00:09:40 +00:00
|
|
|
safe_sprintf(SelectedDrive.proposed_label, sizeof(SelectedDrive.proposed_label),
|
2014-04-02 21:47:35 +00:00
|
|
|
SizeToHumanReadable(SelectedDrive.DiskSize, FALSE, use_fake_units));
|
2012-02-21 19:46:28 +00:00
|
|
|
|
2013-11-30 17:39:38 +00:00
|
|
|
// Add a tooltip (with the size of the device in parenthesis)
|
2014-03-01 00:09:40 +00:00
|
|
|
device_tooltip = (char*) malloc(safe_strlen(DriveID.String[ComboIndex]) + 16);
|
|
|
|
if (device_tooltip != NULL) {
|
|
|
|
safe_sprintf(device_tooltip, safe_strlen(DriveID.String[ComboIndex]) + 16, "%s (%s)",
|
|
|
|
DriveID.String[ComboIndex], SizeToHumanReadable(SelectedDrive.DiskSize, FALSE, FALSE));
|
2013-11-30 17:39:38 +00:00
|
|
|
CreateTooltip(hDeviceList, device_tooltip, -1);
|
2014-03-01 00:09:40 +00:00
|
|
|
free(device_tooltip);
|
|
|
|
}
|
2013-11-30 17:39:38 +00:00
|
|
|
|
2012-02-16 11:37:59 +00:00
|
|
|
// If no existing label is available and no ISO is selected, propose one according to the size (eg: "256MB", "8GB")
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((image_path == NULL) || (img_report.label[0] == 0)) {
|
2014-01-22 01:28:25 +00:00
|
|
|
if ( (safe_stricmp(no_label, DriveLabel.String[ComboIndex]) == 0)
|
|
|
|
|| (safe_stricmp(lmprintf(MSG_207), DriveLabel.String[ComboIndex]) == 0) ) {
|
2012-02-21 19:46:28 +00:00
|
|
|
SetWindowTextU(hLabel, SelectedDrive.proposed_label);
|
2011-11-24 20:02:14 +00:00
|
|
|
} else {
|
2014-01-22 01:28:25 +00:00
|
|
|
SetWindowTextU(hLabel, DriveLabel.String[ComboIndex]);
|
2011-11-24 02:24:50 +00:00
|
|
|
}
|
|
|
|
} else {
|
2015-09-02 22:20:00 +00:00
|
|
|
SetWindowTextU(hLabel, img_report.label);
|
2011-11-24 02:24:50 +00:00
|
|
|
}
|
|
|
|
|
2011-11-18 21:46:34 +00:00
|
|
|
return TRUE;
|
2011-11-17 01:43:06 +00:00
|
|
|
}
|
2011-11-13 20:53:23 +00:00
|
|
|
|
2011-12-09 01:39:13 +00:00
|
|
|
/*
|
|
|
|
* Set up progress bar real estate allocation
|
|
|
|
*/
|
2014-05-23 00:03:01 +00:00
|
|
|
static void InitProgress(BOOL bOnlyFormat)
|
2011-12-09 01:39:13 +00:00
|
|
|
{
|
2014-02-09 02:54:07 +00:00
|
|
|
int i, fs;
|
2011-12-09 01:39:13 +00:00
|
|
|
float last_end = 0.0f, slots_discrete = 0.0f, slots_analog = 0.0f;
|
|
|
|
|
2012-03-29 19:27:53 +00:00
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
2011-12-09 01:39:13 +00:00
|
|
|
|
2012-11-03 17:40:33 +00:00
|
|
|
memset(nb_slots, 0, sizeof(nb_slots));
|
|
|
|
memset(slot_end, 0, sizeof(slot_end));
|
|
|
|
previous_end = 0.0f;
|
|
|
|
|
2014-05-23 00:03:01 +00:00
|
|
|
if (bOnlyFormat) {
|
2011-12-09 12:57:32 +00:00
|
|
|
nb_slots[OP_FORMAT] = -1;
|
2014-02-09 02:54:07 +00:00
|
|
|
} else {
|
2014-05-23 00:03:01 +00:00
|
|
|
nb_slots[OP_ANALYZE_MBR] = 1;
|
|
|
|
if (IsChecked(IDC_BADBLOCKS)) {
|
|
|
|
nb_slots[OP_BADBLOCKS] = -1;
|
|
|
|
}
|
|
|
|
if (IsChecked(IDC_BOOT)) {
|
|
|
|
// 1 extra slot for PBR writing
|
|
|
|
switch (selection_default) {
|
2015-07-01 20:26:15 +00:00
|
|
|
case BT_MSDOS:
|
2014-05-23 00:03:01 +00:00
|
|
|
nb_slots[OP_DOS] = 3+1;
|
|
|
|
break;
|
2015-07-01 20:26:15 +00:00
|
|
|
case BT_FREEDOS:
|
2014-05-23 00:03:01 +00:00
|
|
|
nb_slots[OP_DOS] = 5+1;
|
|
|
|
break;
|
2015-07-01 20:26:15 +00:00
|
|
|
case BT_IMG:
|
2014-05-23 00:03:01 +00:00
|
|
|
nb_slots[OP_DOS] = 0;
|
|
|
|
break;
|
2015-07-01 20:26:15 +00:00
|
|
|
case BT_ISO:
|
2014-05-23 00:03:01 +00:00
|
|
|
nb_slots[OP_DOS] = -1;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
nb_slots[OP_DOS] = 2+1;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
if (selection_default == BT_IMG) {
|
2014-02-09 02:54:07 +00:00
|
|
|
nb_slots[OP_FORMAT] = -1;
|
2014-05-23 00:03:01 +00:00
|
|
|
} else {
|
|
|
|
nb_slots[OP_ZERO_MBR] = 1;
|
|
|
|
nb_slots[OP_PARTITION] = 1;
|
|
|
|
nb_slots[OP_FIX_MBR] = 1;
|
|
|
|
nb_slots[OP_CREATE_FS] =
|
|
|
|
nb_steps[ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem))];
|
|
|
|
if ( (!IsChecked(IDC_QUICKFORMAT))
|
|
|
|
|| ((fs == FS_FAT32) && ((SelectedDrive.DiskSize >= LARGE_FAT32_SIZE) || (force_large_fat32))) ) {
|
|
|
|
nb_slots[OP_FORMAT] = -1;
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
nb_slots[OP_FINALIZE] = ((selection_default == BT_ISO) && (fs == FS_NTFS))?3:2;
|
2014-02-09 02:54:07 +00:00
|
|
|
}
|
2011-12-09 01:39:13 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<OP_MAX; i++) {
|
|
|
|
if (nb_slots[i] > 0) {
|
|
|
|
slots_discrete += nb_slots[i]*1.0f;
|
|
|
|
}
|
|
|
|
if (nb_slots[i] < 0) {
|
|
|
|
slots_analog += nb_slots[i]*1.0f;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i=0; i<OP_MAX; i++) {
|
|
|
|
if (nb_slots[i] == 0) {
|
|
|
|
slot_end[i+1] = last_end;
|
|
|
|
} else if (nb_slots[i] > 0) {
|
|
|
|
slot_end[i+1] = last_end + (1.0f * nb_slots[i]);
|
|
|
|
} else if (nb_slots[i] < 0) {
|
|
|
|
slot_end[i+1] = last_end + (( (100.0f-slots_discrete) * nb_slots[i]) / slots_analog);
|
|
|
|
}
|
|
|
|
last_end = slot_end[i+1];
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Is there's no analog, adjust our discrete ends to fill the whole bar */
|
|
|
|
if (slots_analog == 0.0f) {
|
|
|
|
for (i=0; i<OP_MAX; i++) {
|
|
|
|
slot_end[i+1] *= 100.0f / slots_discrete;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Position the progress bar within each operation range
|
|
|
|
*/
|
|
|
|
void UpdateProgress(int op, float percent)
|
|
|
|
{
|
|
|
|
int pos;
|
|
|
|
|
2014-05-09 21:05:25 +00:00
|
|
|
if ((op < 0) || (op >= OP_MAX)) {
|
2013-01-27 20:56:57 +00:00
|
|
|
duprintf("UpdateProgress: invalid op %d\n", op);
|
2011-12-09 01:39:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (percent > 100.1f) {
|
2014-11-18 23:49:29 +00:00
|
|
|
// duprintf("UpdateProgress(%d): invalid percentage %0.2f\n", op, percent);
|
2011-12-09 01:39:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ((percent < 0.0f) && (nb_slots[op] <= 0)) {
|
2013-01-27 20:56:57 +00:00
|
|
|
duprintf("UpdateProgress(%d): error negative percentage sent for negative slot value\n", op);
|
2011-12-09 01:39:13 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (nb_slots[op] == 0)
|
|
|
|
return;
|
|
|
|
if (previous_end < slot_end[op]) {
|
|
|
|
previous_end = slot_end[op];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (percent < 0.0f) {
|
|
|
|
// Negative means advance one slot (1.0%) - requires a positive slot allocation
|
|
|
|
previous_end += (slot_end[op+1] - slot_end[op]) / (1.0f * nb_slots[op]);
|
|
|
|
pos = (int)(previous_end / 100.0f * MAX_PROGRESS);
|
|
|
|
} else {
|
|
|
|
pos = (int)((previous_end + ((slot_end[op+1] - previous_end) * (percent / 100.0f))) / 100.0f * MAX_PROGRESS);
|
|
|
|
}
|
|
|
|
if (pos > MAX_PROGRESS) {
|
2013-01-27 20:56:57 +00:00
|
|
|
duprintf("UpdateProgress(%d): rounding error - pos %d is greater than %d\n", op, pos, MAX_PROGRESS);
|
2011-12-09 01:39:13 +00:00
|
|
|
pos = MAX_PROGRESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, (WPARAM)pos, 0);
|
2012-03-29 17:16:06 +00:00
|
|
|
SetTaskbarProgressValue(pos, MAX_PROGRESS);
|
2011-12-09 01:39:13 +00:00
|
|
|
}
|
|
|
|
|
2013-12-27 16:06:59 +00:00
|
|
|
/*
|
2011-12-01 17:54:35 +00:00
|
|
|
* Toggle controls according to operation
|
|
|
|
*/
|
2011-11-28 01:32:18 +00:00
|
|
|
static void EnableControls(BOOL bEnable)
|
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_DEVICE), bEnable);
|
2015-04-19 03:15:44 +00:00
|
|
|
EnableWindow(hStart, (ComboBox_GetCurSel(hDeviceList)<0)?FALSE:bEnable);
|
2014-02-09 02:54:07 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_ABOUT), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_BADBLOCKS), bEnable);
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableBootOptions(bEnable, FALSE);
|
2012-05-16 22:38:39 +00:00
|
|
|
EnableWindow(hSelectISO, bEnable);
|
|
|
|
EnableWindow(hNBPasses, bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_ADVANCED), bEnable);
|
2015-04-18 07:04:29 +00:00
|
|
|
EnableWindow(hLangToolbar, bEnable);
|
2015-07-06 21:04:38 +00:00
|
|
|
EnableWindow(hStatusToolbar, bEnable);
|
2014-02-09 02:54:07 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_ENABLE_FIXED_DISKS), bEnable);
|
2013-10-15 21:58:27 +00:00
|
|
|
SetDlgItemTextU(hMainDialog, IDCANCEL, lmprintf(bEnable?MSG_006:MSG_007));
|
2015-07-01 20:26:15 +00:00
|
|
|
if (selection_default == BT_IMG)
|
2014-02-09 02:54:07 +00:00
|
|
|
return;
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_PARTITION_TYPE), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_FILESYSTEM), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_CLUSTERSIZE), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), bEnable);
|
2015-01-13 02:11:57 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_INSTALL), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO), bEnable);
|
2011-11-28 01:32:18 +00:00
|
|
|
}
|
|
|
|
|
2012-05-30 23:32:25 +00:00
|
|
|
/* Callback for the log window */
|
2013-12-27 16:06:59 +00:00
|
|
|
BOOL CALLBACK LogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
2012-05-30 23:32:25 +00:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
HFONT hf;
|
|
|
|
long lfHeight;
|
|
|
|
DWORD log_size;
|
2012-11-30 00:18:28 +00:00
|
|
|
char *log_buffer = NULL, *filepath;
|
2014-05-22 21:46:36 +00:00
|
|
|
EXT_DECL(log_ext, "rufus.log", __VA_GROUP__("*.log"), __VA_GROUP__("Rufus log"));
|
2012-05-30 23:32:25 +00:00
|
|
|
switch (message) {
|
|
|
|
case WM_INITDIALOG:
|
2013-10-15 21:58:27 +00:00
|
|
|
apply_localization(IDD_LOG, hDlg);
|
2012-05-30 23:32:25 +00:00
|
|
|
hLog = GetDlgItem(hDlg, IDC_LOG_EDIT);
|
|
|
|
// Increase the size of our log textbox to MAX_LOG_SIZE (unsigned word)
|
|
|
|
PostMessage(hLog, EM_LIMITTEXT, MAX_LOG_SIZE , 0);
|
|
|
|
// Set the font to Unicode so that we can display anything
|
|
|
|
hdc = GetDC(NULL);
|
|
|
|
lfHeight = -MulDiv(8, GetDeviceCaps(hdc, LOGPIXELSY), 72);
|
2015-07-06 21:04:38 +00:00
|
|
|
if (hdc != NULL)
|
|
|
|
ReleaseDC(NULL, hdc);
|
2012-05-30 23:32:25 +00:00
|
|
|
hf = CreateFontA(lfHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
|
|
|
|
DEFAULT_CHARSET, 0, 0, PROOF_QUALITY, 0, "Arial Unicode MS");
|
|
|
|
SendDlgItemMessageA(hDlg, IDC_LOG_EDIT, WM_SETFONT, (WPARAM)hf, TRUE);
|
2015-04-19 03:15:44 +00:00
|
|
|
// Set 'Close Log' as the selected button
|
|
|
|
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hDlg, IDCANCEL), TRUE);
|
|
|
|
break;
|
2013-12-27 16:06:59 +00:00
|
|
|
case WM_COMMAND:
|
2012-05-30 23:32:25 +00:00
|
|
|
switch (LOWORD(wParam)) {
|
|
|
|
case IDCANCEL:
|
|
|
|
ShowWindow(hDlg, SW_HIDE);
|
|
|
|
log_displayed = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
case IDC_LOG_CLEAR:
|
|
|
|
SetWindowTextA(hLog, "");
|
|
|
|
return TRUE;
|
|
|
|
case IDC_LOG_SAVE:
|
|
|
|
log_size = GetWindowTextLengthU(hLog);
|
2013-06-30 01:31:52 +00:00
|
|
|
if (log_size <= 0)
|
|
|
|
break;
|
|
|
|
log_buffer = (char*)malloc(log_size);
|
2012-05-30 23:32:25 +00:00
|
|
|
if (log_buffer != NULL) {
|
|
|
|
log_size = GetDlgItemTextU(hDlg, IDC_LOG_EDIT, log_buffer, log_size);
|
2013-06-06 22:40:37 +00:00
|
|
|
if (log_size != 0) {
|
|
|
|
log_size--; // remove NUL terminator
|
2014-05-22 00:52:25 +00:00
|
|
|
filepath = FileDialog(TRUE, app_dir, &log_ext, 0);
|
2012-05-30 23:32:25 +00:00
|
|
|
if (filepath != NULL) {
|
|
|
|
FileIO(TRUE, filepath, &log_buffer, &log_size);
|
|
|
|
}
|
|
|
|
safe_free(filepath);
|
|
|
|
}
|
|
|
|
safe_free(log_buffer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case WM_CLOSE:
|
|
|
|
ShowWindow(hDlg, SW_HIDE);
|
2013-10-15 21:58:27 +00:00
|
|
|
reset_localization(IDD_LOG);
|
2012-05-30 23:32:25 +00:00
|
|
|
log_displayed = FALSE;
|
|
|
|
return TRUE;
|
|
|
|
}
|
2013-12-27 16:06:59 +00:00
|
|
|
return FALSE;
|
2012-05-30 23:32:25 +00:00
|
|
|
}
|
|
|
|
|
2011-12-08 12:14:21 +00:00
|
|
|
/*
|
|
|
|
* Timer in the right part of the status area
|
|
|
|
*/
|
|
|
|
static void CALLBACK ClockTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
|
|
|
{
|
|
|
|
timer++;
|
|
|
|
safe_sprintf(szTimer, sizeof(szTimer), "%02d:%02d:%02d",
|
|
|
|
timer/3600, (timer%3600)/60, timer%60);
|
2015-06-30 22:22:10 +00:00
|
|
|
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
|
2011-12-08 12:14:21 +00:00
|
|
|
}
|
|
|
|
|
2013-02-10 21:54:47 +00:00
|
|
|
/*
|
|
|
|
* Device Refresh Timer
|
|
|
|
*/
|
|
|
|
static void CALLBACK RefreshTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
|
|
|
{
|
2014-02-09 02:54:07 +00:00
|
|
|
// DO NOT USE WM_DEVICECHANGE - IT MAY BE FILTERED OUT BY WINDOWS!
|
|
|
|
SendMessage(hWnd, UM_MEDIA_CHANGE, 0, 0);
|
2013-02-10 21:54:47 +00:00
|
|
|
}
|
|
|
|
|
2012-02-07 16:17:14 +00:00
|
|
|
/*
|
|
|
|
* Detect and notify about a blocking operation during ISO extraction cancellation
|
|
|
|
*/
|
|
|
|
static void CALLBACK BlockingTimer(HWND hWnd, UINT uMsg, UINT_PTR idEvent, DWORD dwTime)
|
|
|
|
{
|
|
|
|
if (iso_blocking_status < 0) {
|
|
|
|
KillTimer(hMainDialog, TID_BLOCKING_TIMER);
|
|
|
|
user_notified = FALSE;
|
|
|
|
uprintf("Killed blocking I/O timer\n");
|
|
|
|
} else if(!user_notified) {
|
|
|
|
if (last_iso_blocking_status == iso_blocking_status) {
|
2014-01-24 02:46:06 +00:00
|
|
|
// A write or close operation hasn't made any progress since our last check
|
|
|
|
user_notified = TRUE;
|
|
|
|
uprintf("Blocking I/O operation detected\n");
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_080), lmprintf(MSG_048),
|
|
|
|
MB_OK|MB_ICONINFORMATION|MB_IS_RTL, selected_langid);
|
2012-02-07 16:17:14 +00:00
|
|
|
} else {
|
|
|
|
last_iso_blocking_status = iso_blocking_status;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-02-03 23:42:27 +00:00
|
|
|
// Randomly nag users about translations that have been left behind
|
|
|
|
void LostTranslatorCheck(void)
|
|
|
|
{
|
|
|
|
char *p;
|
|
|
|
char* lang = safe_strdup(selected_locale->txt[1]);
|
|
|
|
int i, r = rand() * LOST_TRANSLATOR_PROBABILITY / RAND_MAX;
|
|
|
|
for (i=0; i<ARRAYSIZE(lost_translators); i++)
|
|
|
|
if (strcmp(selected_locale->txt[0], lost_translators[i]) == 0)
|
|
|
|
break;
|
|
|
|
if ((r == 0) && (i != ARRAYSIZE(lost_translators)) && (lang != NULL) && ((p = strchr(lang, '(')) != NULL)) {
|
|
|
|
p[-1] = 0;
|
|
|
|
safe_sprintf(msgbox, sizeof(msgbox), "Note: The %s translation requires an update, but the original "
|
|
|
|
"translator is no longer contributing to it...\nIf you can read English and want to help complete "
|
|
|
|
"this translation, please visit: http://rufus.akeo.ie/translate.", lang);
|
|
|
|
MessageBoxU(hMainDialog, msgbox, "Translation help needed", MB_OK|MB_ICONINFORMATION);
|
|
|
|
}
|
|
|
|
safe_free(lang);
|
|
|
|
}
|
|
|
|
|
2014-11-14 23:40:00 +00:00
|
|
|
// Report the features of the selected ISO images
|
|
|
|
static const char* YesNo(BOOL b) {
|
|
|
|
return (b) ? "Yes" : "No";
|
|
|
|
}
|
|
|
|
static void DisplayISOProps(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
char isolinux_str[16] = "No";
|
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
if (HAS_SYSLINUX(img_report)) {
|
|
|
|
safe_sprintf(isolinux_str, sizeof(isolinux_str), "Yes (%s)", img_report.sl_version_str);
|
2014-11-14 23:40:00 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Only report features that are present
|
2015-09-02 22:20:00 +00:00
|
|
|
uprintf("ISO label: '%s'", img_report.label);
|
|
|
|
uprintf(" Size: %" PRIu64 " bytes", img_report.projected_size);
|
|
|
|
uprintf(" Has a >64 chars filename: %s", YesNo(img_report.has_long_filename));
|
|
|
|
uprintf(" Has Symlinks: %s", YesNo(img_report.has_symlinks));
|
|
|
|
uprintf(" Has a >4GB file: %s", YesNo(img_report.has_4GB_file));
|
|
|
|
uprintf(" Uses Bootmgr: %s", YesNo(img_report.has_bootmgr));
|
|
|
|
uprintf(" Uses EFI: %s%s", YesNo(img_report.has_efi), IS_WIN7_EFI(img_report) ? " (win7_x64)" : "");
|
|
|
|
uprintf(" Uses Grub 2: %s", YesNo(img_report.has_grub2));
|
|
|
|
uprintf(" Uses Grub4DOS: %s", YesNo(img_report.has_grub4dos));
|
2014-11-14 23:40:00 +00:00
|
|
|
uprintf(" Uses isolinux: %s", isolinux_str);
|
2015-09-02 22:20:00 +00:00
|
|
|
if (HAS_SYSLINUX(img_report) && (SL_MAJOR(img_report.sl_version) < 5)) {
|
2014-11-14 23:40:00 +00:00
|
|
|
for (i = 0; i<NB_OLD_C32; i++) {
|
2015-09-02 22:20:00 +00:00
|
|
|
uprintf(" With an old %s: %s\n", old_c32_name[i], img_report.has_old_c32[i] ? "Yes" : "No");
|
2014-11-14 23:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
uprintf(" Uses KolibriOS: %s", YesNo(img_report.has_kolibrios));
|
|
|
|
uprintf(" Uses ReactOS: %s", YesNo(IS_REACTOS(img_report)));
|
|
|
|
uprintf(" Uses WinPE: %s%s", YesNo(IS_WINPE(img_report.winpe)), (img_report.uses_minint) ? " (with /minint)" : "");
|
|
|
|
if (HAS_INSTALL_WIM(img_report)) {
|
|
|
|
uprintf(" Uses Install.wim: Yes (version %d.%d.%d)", (img_report.install_wim_version >> 24) & 0xff,
|
|
|
|
(img_report.install_wim_version >> 16) & 0xff, (img_report.install_wim_version >> 8) & 0xff);
|
2015-08-27 17:22:27 +00:00
|
|
|
// Microsoft somehow managed to make their ESD WIMs incompatible with their own APIs
|
|
|
|
// (yes, EVEN the Windows 10 APIs), so we must filter them out...
|
2015-09-02 22:20:00 +00:00
|
|
|
if (img_report.install_wim_version >= MAX_WIM_VERSION)
|
2015-08-27 17:22:27 +00:00
|
|
|
uprintf(" Note: This WIM version is NOT compatible with Windows To Go");
|
|
|
|
}
|
2015-01-13 02:11:57 +00:00
|
|
|
|
2015-01-16 01:51:24 +00:00
|
|
|
// We don't support ToGo on Windows 7 or earlier, for lack of ISO mount capabilities
|
|
|
|
// TODO: add install.wim extraction workaround for Windows 7
|
|
|
|
if (nWindowsVersion >= WINDOWS_8)
|
2015-09-02 22:20:00 +00:00
|
|
|
if ( ((!togo_mode) && (HAS_TOGO(img_report))) || ((togo_mode) && (!HAS_TOGO(img_report))) )
|
2015-01-16 01:51:24 +00:00
|
|
|
ToggleToGo();
|
2014-11-14 23:40:00 +00:00
|
|
|
}
|
|
|
|
|
2012-02-01 14:26:36 +00:00
|
|
|
// The scanning process can be blocking for message processing => use a thread
|
2012-02-07 02:05:58 +00:00
|
|
|
DWORD WINAPI ISOScanThread(LPVOID param)
|
2012-02-01 14:26:36 +00:00
|
|
|
{
|
2012-02-07 16:17:14 +00:00
|
|
|
int i;
|
|
|
|
|
2014-05-22 00:52:25 +00:00
|
|
|
if (image_path == NULL)
|
2012-02-07 16:17:14 +00:00
|
|
|
goto out;
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfoDebug(0, MSG_202);
|
2013-12-28 01:27:09 +00:00
|
|
|
user_notified = FALSE;
|
2013-12-27 16:06:59 +00:00
|
|
|
EnableControls(FALSE);
|
2015-09-04 12:53:35 +00:00
|
|
|
img_report.is_iso = (BOOLEAN)ExtractISO(image_path, "", TRUE);
|
|
|
|
img_report.is_bootable_img = (BOOLEAN)IsBootableImage(image_path);
|
2015-09-02 22:20:00 +00:00
|
|
|
if (!img_report.is_iso && !img_report.is_bootable_img) {
|
2015-01-01 23:39:28 +00:00
|
|
|
SendMessage(hMainDialog, UM_PROGRESS_EXIT, 0, 0);
|
|
|
|
PrintInfoDebug(0, MSG_203);
|
2014-05-22 00:52:25 +00:00
|
|
|
safe_free(image_path);
|
2015-08-14 22:09:45 +00:00
|
|
|
EnableControls(TRUE);
|
2015-07-06 21:04:38 +00:00
|
|
|
EnableWindow(hStatusToolbar, FALSE);
|
2015-02-11 23:22:18 +00:00
|
|
|
PrintStatus(0, MSG_086);
|
|
|
|
SetMBRProps();
|
2012-02-07 02:05:58 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2014-02-09 02:54:07 +00:00
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
if (img_report.is_bootable_img) {
|
2015-08-22 14:18:25 +00:00
|
|
|
uprintf(" Image is a %sbootable %s image",
|
2015-09-02 22:20:00 +00:00
|
|
|
(img_report.compression_type != BLED_COMPRESSION_NONE) ? "compressed " : "", img_report.is_vhd ? "VHD" : "disk");
|
2015-07-01 20:26:15 +00:00
|
|
|
selection_default = BT_IMG;
|
2015-08-22 14:18:25 +00:00
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
if (img_report.is_iso) {
|
2015-08-22 14:18:25 +00:00
|
|
|
// Will override BT_IMG above for ISOHybrid
|
2015-07-01 20:26:15 +00:00
|
|
|
selection_default = BT_ISO;
|
2014-11-14 23:40:00 +00:00
|
|
|
DisplayISOProps();
|
2012-12-15 03:27:14 +00:00
|
|
|
}
|
2015-08-14 22:09:45 +00:00
|
|
|
// Only enable AFTER we have determined the image type
|
|
|
|
EnableControls(TRUE);
|
2015-09-02 22:20:00 +00:00
|
|
|
if ( (!img_report.has_bootmgr) && (!HAS_SYSLINUX(img_report)) && (!IS_WINPE(img_report.winpe)) && (!IS_GRUB(img_report))
|
|
|
|
&& (!img_report.has_efi) && (!IS_REACTOS(img_report) && (!img_report.has_kolibrios) && (!img_report.is_bootable_img)) ) {
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_081);
|
2014-05-22 00:52:25 +00:00
|
|
|
safe_free(image_path);
|
2015-07-06 21:04:38 +00:00
|
|
|
EnableWindow(hStatusToolbar, FALSE);
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_082), lmprintf(MSG_081), MB_OK|MB_ICONINFORMATION|MB_IS_RTL, selected_langid);
|
2015-01-08 00:22:56 +00:00
|
|
|
PrintStatus(0, MSG_086);
|
2012-05-16 22:38:39 +00:00
|
|
|
SetMBRProps();
|
2014-02-09 02:54:07 +00:00
|
|
|
} else {
|
2013-12-22 20:48:57 +00:00
|
|
|
// Enable bootable and set Target System and FS accordingly
|
2013-01-24 21:30:11 +00:00
|
|
|
CheckDlgButton(hMainDialog, IDC_BOOT, BST_CHECKED);
|
2015-09-02 22:34:20 +00:00
|
|
|
if (img_report.is_iso) {
|
2014-02-09 02:54:07 +00:00
|
|
|
SetTargetSystem();
|
|
|
|
SetFSFromISO();
|
|
|
|
SetMBRProps();
|
|
|
|
// Some Linux distros, such as Arch Linux, require the USB drive to have
|
|
|
|
// a specific label => copy the one we got from the ISO image
|
2015-09-02 22:20:00 +00:00
|
|
|
if (img_report.label[0] != 0) {
|
|
|
|
SetWindowTextU(hLabel, img_report.label);
|
2014-02-09 02:54:07 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
|
|
|
|
ComboBox_GetCurSel(hFileSystem));
|
|
|
|
}
|
2015-08-14 22:09:45 +00:00
|
|
|
if (!dont_display_image_name) {
|
|
|
|
for (i = (int)safe_strlen(image_path); (i > 0) && (image_path[i] != '\\'); i--);
|
|
|
|
PrintStatusDebug(0, MSG_205, &image_path[i + 1]);
|
|
|
|
}
|
2012-02-16 11:37:59 +00:00
|
|
|
// Lose the focus on the select ISO (but place it on Close)
|
2015-04-19 03:15:44 +00:00
|
|
|
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
|
2012-02-16 11:37:59 +00:00
|
|
|
// Lose the focus from Close and set it back to Start
|
2015-04-19 03:15:44 +00:00
|
|
|
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)hStart, TRUE);
|
2012-02-07 02:05:58 +00:00
|
|
|
}
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2015-01-13 02:11:57 +00:00
|
|
|
// Need to invalidate as we may have changed the UI and may get artifacts if we don't
|
2015-02-10 22:45:48 +00:00
|
|
|
// Oh and we need to invoke BOTH RedrawWindow() and InvalidateRect() because UI refresh
|
|
|
|
// in the Microsoft worlds SUCKS!!!! (we may lose the disabled "Start" button otherwise)
|
|
|
|
RedrawWindow(hMainDialog, NULL, NULL, RDW_ALLCHILDREN | RDW_UPDATENOW);
|
2015-01-13 02:11:57 +00:00
|
|
|
InvalidateRect(hMainDialog, NULL, TRUE);
|
2012-02-07 02:05:58 +00:00
|
|
|
|
|
|
|
out:
|
2015-08-14 22:09:45 +00:00
|
|
|
dont_display_image_name = FALSE;
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_210);
|
2012-02-07 02:05:58 +00:00
|
|
|
ExitThread(0);
|
2012-02-01 14:26:36 +00:00
|
|
|
}
|
|
|
|
|
2013-10-15 21:58:27 +00:00
|
|
|
// Move a control along the Y axis according to the advanced mode setting
|
2015-01-12 00:34:09 +00:00
|
|
|
static __inline void MoveCtrlY(HWND hDlg, int nID, float vertical_shift) {
|
2015-08-22 14:18:25 +00:00
|
|
|
ResizeMoveCtrl(hDlg, GetDlgItem(hDlg, nID), 0, (int)vertical_shift, 0, 0, fScale);
|
2012-05-16 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2015-01-12 00:34:09 +00:00
|
|
|
static void SetPassesTooltip(void)
|
2013-01-25 01:38:10 +00:00
|
|
|
{
|
2013-10-15 21:58:27 +00:00
|
|
|
const unsigned char pattern[] = BADBLOCK_PATTERNS;
|
|
|
|
CreateTooltip(hNBPasses, lmprintf(MSG_153 + ComboBox_GetCurSel(hNBPasses),
|
|
|
|
pattern[0], pattern[1], pattern[2], pattern[3]), -1);
|
2013-01-25 01:38:10 +00:00
|
|
|
}
|
|
|
|
|
2012-05-16 22:38:39 +00:00
|
|
|
// Toggle "advanced" mode
|
2015-09-16 23:20:22 +00:00
|
|
|
static void ToggleAdvanced(BOOL enable)
|
2012-05-16 22:38:39 +00:00
|
|
|
{
|
2015-05-14 23:36:42 +00:00
|
|
|
// Compute the shift according to the weird values we measured at different scales:
|
|
|
|
// {1.0, 82}, {1.25, 88}, {1.5, 90}, {2.0, 96}, {2.5, 94} (Seriously, WTF is wrong with your scaling Microsoft?!?!)
|
|
|
|
// https://www.wolframalpha.com/input/?i=cubic+fit+{1%2C82}%2C{1.25%2C88}%2C{1.5%2C90}%2C{2%2C96}%2C{2.5%2C94}
|
|
|
|
float dialog_shift = -3.22807f*fScale*fScale*fScale + 6.69173f*fScale*fScale + 15.8822f*fScale + 62.9737f;
|
2012-05-16 22:38:39 +00:00
|
|
|
RECT rect;
|
|
|
|
POINT point;
|
|
|
|
int toggle;
|
|
|
|
|
2015-09-16 23:20:22 +00:00
|
|
|
if (!enable)
|
2015-01-12 00:34:09 +00:00
|
|
|
dialog_shift = -dialog_shift;
|
2012-05-16 22:38:39 +00:00
|
|
|
|
|
|
|
// 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,
|
2015-01-12 00:34:09 +00:00
|
|
|
point.y + (int)(fScale*dialog_shift), TRUE);
|
2012-05-16 22:38:39 +00:00
|
|
|
|
2015-07-02 21:46:26 +00:00
|
|
|
// Move the controls up or down
|
2013-10-15 21:58:27 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_STATUS, dialog_shift);
|
2015-07-06 21:04:38 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_STATUS_TOOLBAR, dialog_shift);
|
2013-10-15 21:58:27 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_START, dialog_shift);
|
2015-01-01 23:39:28 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_INFO, dialog_shift);
|
2013-10-15 21:58:27 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_PROGRESS, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_ABOUT, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_LOG, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDCANCEL, dialog_shift);
|
2012-05-30 23:32:25 +00:00
|
|
|
#ifdef RUFUS_TEST
|
2013-10-15 21:58:27 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_TEST, dialog_shift);
|
2012-05-30 23:32:25 +00:00
|
|
|
#endif
|
2012-05-16 22:38:39 +00:00
|
|
|
|
2013-06-03 20:32:22 +00:00
|
|
|
// And do the same for the log dialog while we're at it
|
|
|
|
GetWindowRect(hLogDlg, &rect);
|
|
|
|
point.x = (rect.right - rect.left);
|
|
|
|
point.y = (rect.bottom - rect.top);
|
|
|
|
MoveWindow(hLogDlg, rect.left, rect.top, point.x,
|
2015-01-12 00:34:09 +00:00
|
|
|
point.y + (int)(fScale*dialog_shift), TRUE);
|
2013-10-15 21:58:27 +00:00
|
|
|
MoveCtrlY(hLogDlg, IDC_LOG_CLEAR, dialog_shift);
|
|
|
|
MoveCtrlY(hLogDlg, IDC_LOG_SAVE, dialog_shift);
|
|
|
|
MoveCtrlY(hLogDlg, IDCANCEL, dialog_shift);
|
2013-06-03 20:32:22 +00:00
|
|
|
GetWindowRect(hLog, &rect);
|
|
|
|
point.x = (rect.right - rect.left);
|
2015-01-12 00:34:09 +00:00
|
|
|
point.y = (rect.bottom - rect.top) + (int)(fScale*dialog_shift);
|
2015-07-06 21:04:38 +00:00
|
|
|
SetWindowPos(hLog, NULL, 0, 0, point.x, point.y, SWP_NOZORDER);
|
2013-06-03 20:32:22 +00:00
|
|
|
// Don't forget to scroll the edit to the bottom after resize
|
|
|
|
SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0));
|
|
|
|
|
2012-05-16 22:38:39 +00:00
|
|
|
// Hide or show the various advanced options
|
2015-09-16 23:20:22 +00:00
|
|
|
toggle = enable?SW_SHOW:SW_HIDE;
|
2013-06-03 20:32:22 +00:00
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDC_ENABLE_FIXED_DISKS), toggle);
|
2012-05-16 22:38:39 +00:00
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDC_EXTRA_PARTITION), toggle);
|
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDC_RUFUS_MBR), toggle);
|
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDC_DISK_ID), toggle);
|
2013-10-15 21:58:27 +00:00
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), toggle);
|
2012-05-16 22:38:39 +00:00
|
|
|
|
|
|
|
// Toggle the up/down icon
|
2015-09-16 23:20:22 +00:00
|
|
|
SendMessage(GetDlgItem(hMainDialog, IDC_ADVANCED), BCM_SETIMAGELIST, 0, (LPARAM)(enable?&bi_up:&bi_down));
|
2015-02-16 23:05:27 +00:00
|
|
|
|
|
|
|
// Never hurts to force Windows' hand
|
|
|
|
InvalidateRect(hMainDialog, NULL, TRUE);
|
2012-05-16 22:38:39 +00:00
|
|
|
}
|
|
|
|
|
2014-02-09 02:54:07 +00:00
|
|
|
// Toggle DD Image mode
|
2015-01-12 00:34:09 +00:00
|
|
|
static void ToggleImage(BOOL enable)
|
2014-02-09 02:54:07 +00:00
|
|
|
{
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_PARTITION_TYPE), enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_FILESYSTEM), enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_CLUSTERSIZE), enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_LABEL), enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), enable);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_SET_ICON), enable);
|
|
|
|
}
|
|
|
|
|
2015-01-12 00:34:09 +00:00
|
|
|
// Toggle the Windows To Go radio choice
|
|
|
|
static void ToggleToGo(void)
|
|
|
|
{
|
2015-05-14 23:36:42 +00:00
|
|
|
// {1.0, 38}, {1.25, 40}, {1.5, 40}, {2.0, 44}, {2.5, 44}
|
|
|
|
float dialog_shift = (fScale >= 1.9f)?44.0f:((fScale >= 1.2f)?40.0f:38.0f);
|
2015-01-12 00:34:09 +00:00
|
|
|
RECT rect;
|
|
|
|
POINT point;
|
|
|
|
int toggle;
|
|
|
|
|
2015-02-08 00:38:21 +00:00
|
|
|
// Windows To Go mode is only available for Windows 8 or later due to the lack
|
|
|
|
// of an ISO mounting API on previous versions.
|
|
|
|
// But we still need to be able to hide the Windows To Go option on startup.
|
|
|
|
if ((nWindowsVersion < WINDOWS_8) && (!togo_mode))
|
|
|
|
return;
|
|
|
|
|
2015-01-12 00:34:09 +00:00
|
|
|
togo_mode = !togo_mode;
|
|
|
|
if (!togo_mode)
|
|
|
|
dialog_shift = -dialog_shift;
|
|
|
|
|
|
|
|
// 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*dialog_shift), TRUE);
|
|
|
|
|
|
|
|
// Move the controls up or down
|
|
|
|
MoveCtrlY(hMainDialog, IDC_STATUS, dialog_shift);
|
2015-07-06 21:04:38 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_STATUS_TOOLBAR, dialog_shift);
|
2015-01-12 00:34:09 +00:00
|
|
|
MoveCtrlY(hMainDialog, IDC_START, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_INFO, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_PROGRESS, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_ABOUT, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_LOG, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDCANCEL, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_SET_ICON, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDS_ADVANCED_OPTIONS_GRP, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_ENABLE_FIXED_DISKS, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_EXTRA_PARTITION, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_RUFUS_MBR, dialog_shift);
|
|
|
|
MoveCtrlY(hMainDialog, IDC_DISK_ID, dialog_shift);
|
2015-08-22 14:18:25 +00:00
|
|
|
ResizeMoveCtrl(hMainDialog, GetDlgItem(hMainDialog, IDS_FORMAT_OPTIONS_GRP), 0, 0, 0, (int)dialog_shift, fScale);
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2015-01-12 00:34:09 +00:00
|
|
|
#ifdef RUFUS_TEST
|
|
|
|
MoveCtrlY(hMainDialog, IDC_TEST, dialog_shift);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// And do the same for the log dialog while we're at it
|
|
|
|
GetWindowRect(hLogDlg, &rect);
|
|
|
|
point.x = (rect.right - rect.left);
|
|
|
|
point.y = (rect.bottom - rect.top);
|
|
|
|
MoveWindow(hLogDlg, rect.left, rect.top, point.x,
|
|
|
|
point.y + (int)(fScale*dialog_shift), TRUE);
|
|
|
|
MoveCtrlY(hLogDlg, IDC_LOG_CLEAR, dialog_shift);
|
|
|
|
MoveCtrlY(hLogDlg, IDC_LOG_SAVE, dialog_shift);
|
|
|
|
MoveCtrlY(hLogDlg, IDCANCEL, dialog_shift);
|
|
|
|
GetWindowRect(hLog, &rect);
|
|
|
|
point.x = (rect.right - rect.left);
|
|
|
|
point.y = (rect.bottom - rect.top) + (int)(fScale*dialog_shift);
|
2015-07-06 21:04:38 +00:00
|
|
|
SetWindowPos(hLog, NULL, 0, 0, point.x, point.y, SWP_NOZORDER);
|
2015-01-12 00:34:09 +00:00
|
|
|
// Don't forget to scroll the edit to the bottom after resize
|
|
|
|
SendMessage(hLog, EM_LINESCROLL, 0, SendMessage(hLog, EM_GETLINECOUNT, 0, 0));
|
|
|
|
|
|
|
|
// Hide or show the various advanced options
|
|
|
|
toggle = togo_mode?SW_SHOW:SW_HIDE;
|
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_INSTALL), toggle);
|
|
|
|
ShowWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO), toggle);
|
|
|
|
|
|
|
|
// Reset the radio button choice
|
|
|
|
Button_SetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_INSTALL), BST_CHECKED);
|
|
|
|
Button_SetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO), BST_UNCHECKED);
|
2015-02-16 23:05:27 +00:00
|
|
|
|
|
|
|
// If you don't force a redraw here, all kind of bad UI artifacts happen...
|
|
|
|
InvalidateRect(hMainDialog, NULL, TRUE);
|
2015-01-12 00:34:09 +00:00
|
|
|
}
|
|
|
|
|
2013-01-25 01:38:10 +00:00
|
|
|
static BOOL BootCheck(void)
|
|
|
|
{
|
2015-07-01 20:26:15 +00:00
|
|
|
int i, fs, tt, bt, pt, r;
|
2014-08-05 23:57:32 +00:00
|
|
|
FILE *fd;
|
2014-02-04 20:01:28 +00:00
|
|
|
DWORD len;
|
2014-03-13 22:13:46 +00:00
|
|
|
BOOL in_files_dir = FALSE;
|
2014-12-30 19:46:13 +00:00
|
|
|
const char* grub = "grub";
|
|
|
|
const char* core_img = "core.img";
|
2014-01-21 17:08:41 +00:00
|
|
|
const char* ldlinux = "ldlinux";
|
|
|
|
const char* syslinux = "syslinux";
|
|
|
|
const char* ldlinux_ext[3] = { "sys", "bss", "c32" };
|
2014-08-05 23:57:32 +00:00
|
|
|
char tmp[MAX_PATH], tmp2[MAX_PATH];
|
2013-01-25 01:38:10 +00:00
|
|
|
|
2014-01-21 17:08:41 +00:00
|
|
|
syslinux_ldlinux_len[0] = 0; syslinux_ldlinux_len[1] = 0;
|
2014-12-30 19:46:13 +00:00
|
|
|
safe_free(grub2_buf);
|
2015-07-01 20:26:15 +00:00
|
|
|
bt = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
2015-01-20 21:50:24 +00:00
|
|
|
pt = GETPARTTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
2015-07-01 20:26:15 +00:00
|
|
|
if ((bt == BT_ISO) || (bt == BT_IMG)) {
|
2014-05-22 00:52:25 +00:00
|
|
|
if (image_path == NULL) {
|
2013-10-31 22:59:53 +00:00
|
|
|
// Please click on the disc button to select a bootable ISO
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_087), lmprintf(MSG_086), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2013-01-25 01:38:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((size_check) && (img_report.projected_size > (uint64_t)SelectedDrive.DiskSize)) {
|
2013-10-31 22:59:53 +00:00
|
|
|
// This ISO image is too big for the selected target
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_089), lmprintf(MSG_088), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2013-01-25 01:38:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
if (bt == BT_IMG) {
|
2015-09-02 22:20:00 +00:00
|
|
|
if (!img_report.is_bootable_img)
|
2014-02-09 02:54:07 +00:00
|
|
|
// The selected image doesn't match the boot option selected.
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_188), lmprintf(MSG_187), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2015-09-02 22:20:00 +00:00
|
|
|
return (img_report.is_bootable_img);
|
2014-02-09 02:54:07 +00:00
|
|
|
}
|
2013-01-25 01:38:10 +00:00
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
2015-07-01 20:26:15 +00:00
|
|
|
tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
2015-01-16 01:51:24 +00:00
|
|
|
if ((togo_mode) && (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED)) {
|
|
|
|
if (fs != FS_NTFS) {
|
|
|
|
// Windows To Go only works for NTFS
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_097, "Windows To Go"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2015-01-16 01:51:24 +00:00
|
|
|
return FALSE;
|
|
|
|
} else if (SelectedDrive.Geometry.MediaType != FixedMedia) {
|
2015-07-01 20:26:15 +00:00
|
|
|
if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) {
|
2015-01-20 21:50:24 +00:00
|
|
|
// We're screwed since we need access to 2 partitions at the same time to set this, which
|
|
|
|
// Windows can't do. Cue in Arthur's Theme: "♫ I know it's stupid... but it's true. ♫"
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2015-01-20 21:50:24 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-01-16 01:51:24 +00:00
|
|
|
// I never had any success with drives that have the REMOVABLE attribute set, no matter the
|
|
|
|
// method or tool I tried. If you manage to get this working, I'd like to hear from you!
|
2015-10-18 20:31:47 +00:00
|
|
|
if (MessageBoxExU(hMainDialog, lmprintf(MSG_098), lmprintf(MSG_190), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) != IDYES)
|
2015-01-16 01:51:24 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
} else if (tt == TT_UEFI) {
|
2015-09-02 22:20:00 +00:00
|
|
|
if (!img_report.has_efi) {
|
2013-10-31 22:59:53 +00:00
|
|
|
// Unsupported ISO
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_091), lmprintf(MSG_090), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2013-01-25 01:38:10 +00:00
|
|
|
return FALSE;
|
2013-12-11 19:00:57 +00:00
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
if (IS_WIN7_EFI(img_report) && (!WimExtractCheck())) {
|
2013-12-11 19:00:57 +00:00
|
|
|
// Your platform cannot extract files from WIM archives => download 7-zip?
|
2015-10-18 20:31:47 +00:00
|
|
|
if (MessageBoxExU(hMainDialog, lmprintf(MSG_102), lmprintf(MSG_101), MB_YESNO|MB_ICONERROR|MB_IS_RTL, selected_langid) == IDYES)
|
2013-12-11 19:00:57 +00:00
|
|
|
ShellExecuteA(hMainDialog, "open", SEVENZIP_URL, NULL, NULL, SW_SHOWNORMAL);
|
2013-01-25 01:38:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
} else if ( ((fs == FS_NTFS) && (!img_report.has_bootmgr) && (!IS_WINPE(img_report.winpe)) && (!IS_GRUB(img_report)))
|
2015-09-02 22:34:20 +00:00
|
|
|
|| ((IS_FAT(fs)) && (!HAS_SYSLINUX(img_report)) && (!allow_dual_uefi_bios) && (!img_report.has_efi) &&
|
2015-09-02 22:20:00 +00:00
|
|
|
(!IS_REACTOS(img_report)) && (!img_report.has_kolibrios) && (!IS_GRUB(img_report))) ) {
|
2015-01-16 01:51:24 +00:00
|
|
|
// Incompatible FS and ISO
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_096), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2013-01-25 01:38:10 +00:00
|
|
|
return FALSE;
|
2015-09-02 22:20:00 +00:00
|
|
|
} else if ((fs == FS_FAT16) && (img_report.has_kolibrios)) {
|
2014-05-15 20:17:12 +00:00
|
|
|
// KolibriOS doesn't support FAT16
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_189), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2014-05-15 20:17:12 +00:00
|
|
|
return FALSE;
|
2013-12-11 19:00:57 +00:00
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((IS_FAT(fs)) && (img_report.has_4GB_file)) {
|
2013-10-31 22:59:53 +00:00
|
|
|
// This ISO image contains a file larger than 4GB file (FAT32)
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_100), lmprintf(MSG_099), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2013-01-25 01:38:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-02-04 20:01:28 +00:00
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((img_report.has_grub2) && (img_report.grub2_version[0] != 0) &&
|
|
|
|
(strcmp(img_report.grub2_version, GRUB2_PACKAGE_VERSION) != 0)) {
|
2014-12-30 19:46:13 +00:00
|
|
|
// We may have to download a different Grub2 version if we can find one
|
|
|
|
IGNORE_RETVAL(_chdirU(app_dir));
|
|
|
|
IGNORE_RETVAL(_mkdir(FILES_DIR));
|
|
|
|
IGNORE_RETVAL(_chdir(FILES_DIR));
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s-%s/%s", grub, img_report.grub2_version, core_img);
|
2014-12-30 19:46:13 +00:00
|
|
|
fd = fopen(tmp, "rb");
|
|
|
|
if (fd != NULL) {
|
|
|
|
// If a file already exists in the current directory, use that one
|
|
|
|
uprintf("Will reuse '%s' from './" FILES_DIR "/%s-%s/' for Grub 2.x installation\n",
|
2015-09-02 22:20:00 +00:00
|
|
|
core_img, grub, img_report.grub2_version);
|
2014-12-30 19:46:13 +00:00
|
|
|
fseek(fd, 0, SEEK_END);
|
|
|
|
grub2_len = ftell(fd);
|
|
|
|
fseek(fd, 0, SEEK_SET);
|
|
|
|
if (grub2_len > 0)
|
|
|
|
grub2_buf = malloc(grub2_len);
|
|
|
|
|
|
|
|
// grub2_buf was set to NULL at the beginning of this call
|
|
|
|
if ((grub2_buf == NULL) || (fread(grub2_buf, 1, (size_t)grub2_len, fd) != (size_t)grub2_len)) {
|
|
|
|
uprintf("Failed to read existing '%s' data - will use embedded version", core_img);
|
|
|
|
safe_free(grub2_buf);
|
|
|
|
}
|
|
|
|
fclose(fd);
|
|
|
|
} else {
|
2015-10-18 20:31:47 +00:00
|
|
|
r = MessageBoxExU(hMainDialog, lmprintf(MSG_116, img_report.grub2_version, GRUB2_PACKAGE_VERSION),
|
|
|
|
lmprintf(MSG_115), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid);
|
2014-12-30 19:46:13 +00:00
|
|
|
if (r == IDCANCEL)
|
|
|
|
return FALSE;
|
|
|
|
else if (r == IDYES) {
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s-%s", grub, img_report.grub2_version);
|
2014-12-30 19:46:13 +00:00
|
|
|
IGNORE_RETVAL(_mkdir(tmp));
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, grub, img_report.grub2_version, core_img);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfoDebug(0, MSG_085, tmp);
|
2014-12-30 19:46:13 +00:00
|
|
|
PromptOnError = FALSE;
|
2015-01-01 23:39:28 +00:00
|
|
|
grub2_len = (long)DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog);
|
2014-12-30 19:46:13 +00:00
|
|
|
PromptOnError = TRUE;
|
2015-01-08 00:22:56 +00:00
|
|
|
if (grub2_len <= 0) {
|
|
|
|
PrintInfo(0, MSG_195, "Grub2");
|
2014-12-30 19:46:13 +00:00
|
|
|
uprintf("%s was not found - will use embedded version\n", tmp);
|
2015-01-08 00:22:56 +00:00
|
|
|
} else {
|
|
|
|
PrintInfo(0, MSG_193, tmp);
|
2014-12-30 19:46:13 +00:00
|
|
|
fd = fopen(&tmp[sizeof(FILES_URL)], "rb");
|
|
|
|
grub2_buf = malloc(grub2_len);
|
|
|
|
if ((fd == NULL) || (grub2_buf == NULL) || (fread(grub2_buf, 1, (size_t)grub2_len, fd) != (size_t)grub2_len)) {
|
|
|
|
uprintf("Failed to read '%s' data - will use embedded version", core_img);
|
|
|
|
safe_free(grub2_buf);
|
|
|
|
}
|
|
|
|
if (fd != NULL)
|
|
|
|
fclose(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-09-02 22:20:00 +00:00
|
|
|
if (HAS_SYSLINUX(img_report)) {
|
|
|
|
if (SL_MAJOR(img_report.sl_version) < 5) {
|
2014-02-04 20:01:28 +00:00
|
|
|
IGNORE_RETVAL(_chdirU(app_dir));
|
|
|
|
for (i=0; i<NB_OLD_C32; i++) {
|
2015-09-02 22:20:00 +00:00
|
|
|
if (img_report.has_old_c32[i]) {
|
2014-03-13 22:13:46 +00:00
|
|
|
if (!in_files_dir) {
|
2014-02-04 20:01:28 +00:00
|
|
|
IGNORE_RETVAL(_mkdir(FILES_DIR));
|
|
|
|
IGNORE_RETVAL(_chdir(FILES_DIR));
|
2014-03-13 22:13:46 +00:00
|
|
|
in_files_dir = TRUE;
|
2014-02-04 20:01:28 +00:00
|
|
|
}
|
|
|
|
static_sprintf(tmp, "%s-%s/%s", syslinux, embedded_sl_version_str[0], old_c32_name[i]);
|
|
|
|
fd = fopen(tmp, "rb");
|
|
|
|
if (fd != NULL) {
|
|
|
|
// If a file already exists in the current directory, use that one
|
2014-03-13 22:13:46 +00:00
|
|
|
uprintf("Will replace obsolete '%s' from ISO with the one found in './" FILES_DIR "/%s'\n", old_c32_name[i], tmp);
|
2014-02-04 20:01:28 +00:00
|
|
|
fclose(fd);
|
|
|
|
use_own_c32[i] = TRUE;
|
|
|
|
} else {
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_204, old_c32_name[i]);
|
2015-10-18 20:31:47 +00:00
|
|
|
if (MessageBoxExU(hMainDialog, lmprintf(MSG_084, old_c32_name[i], old_c32_name[i]),
|
|
|
|
lmprintf(MSG_083, old_c32_name[i]), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDYES) {
|
2014-02-04 20:01:28 +00:00
|
|
|
static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[0]);
|
|
|
|
IGNORE_RETVAL(_mkdir(tmp));
|
|
|
|
static_sprintf(tmp, "%s/%s-%s/%s", FILES_URL, syslinux, embedded_sl_version_str[0], old_c32_name[i]);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_085, old_c32_name[i]);
|
|
|
|
len = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog);
|
2014-02-04 20:01:28 +00:00
|
|
|
if (len == 0) {
|
2015-01-01 23:39:28 +00:00
|
|
|
uprintf("Could not download file - cancelling\n");
|
2014-02-04 20:01:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
use_own_c32[i] = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2014-01-21 17:08:41 +00:00
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
} else if ((img_report.sl_version != embedded_sl_version[1]) ||
|
|
|
|
(safe_strcmp(img_report.sl_version_ext, embedded_sl_version_ext[1]) != 0)) {
|
2014-02-04 20:01:28 +00:00
|
|
|
// Unlike what was the case for v4 and earlier, Syslinux v5+ versions are INCOMPATIBLE with one another!
|
|
|
|
IGNORE_RETVAL(_chdirU(app_dir));
|
|
|
|
IGNORE_RETVAL(_mkdir(FILES_DIR));
|
|
|
|
IGNORE_RETVAL(_chdir(FILES_DIR));
|
2014-01-21 17:08:41 +00:00
|
|
|
for (i=0; i<2; i++) {
|
2014-02-04 20:01:28 +00:00
|
|
|
// Check if we already have the relevant ldlinux_v#.##.sys & ldlinux_v#.##.bss files
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s-%s%s/%s.%s", syslinux, img_report.sl_version_str,
|
|
|
|
img_report.sl_version_ext, ldlinux, ldlinux_ext[i]);
|
2014-02-04 20:01:28 +00:00
|
|
|
fd = fopen(tmp, "rb");
|
|
|
|
if (fd != NULL) {
|
|
|
|
fseek(fd, 0, SEEK_END);
|
|
|
|
syslinux_ldlinux_len[i] = (DWORD)ftell(fd);
|
|
|
|
fclose(fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ((syslinux_ldlinux_len[0] != 0) && (syslinux_ldlinux_len[1] != 0)) {
|
2014-08-05 23:57:32 +00:00
|
|
|
uprintf("Will reuse '%s.%s' and '%s.%s' from './" FILES_DIR "/%s/%s-%s%s/' for Syslinux installation\n",
|
|
|
|
ldlinux, ldlinux_ext[0], ldlinux, ldlinux_ext[1], FILES_DIR, syslinux,
|
2015-09-02 22:20:00 +00:00
|
|
|
img_report.sl_version_str, img_report.sl_version_ext);
|
2014-02-04 20:01:28 +00:00
|
|
|
} else {
|
2015-10-18 20:31:47 +00:00
|
|
|
r = MessageBoxExU(hMainDialog, lmprintf(MSG_114, img_report.sl_version_str, img_report.sl_version_ext,
|
2014-11-11 19:53:39 +00:00
|
|
|
embedded_sl_version_str[1], embedded_sl_version_ext[1]),
|
2015-10-18 20:31:47 +00:00
|
|
|
lmprintf(MSG_115), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid);
|
2014-02-04 20:01:28 +00:00
|
|
|
if (r != IDYES)
|
2014-01-21 17:08:41 +00:00
|
|
|
return FALSE;
|
2014-02-04 20:01:28 +00:00
|
|
|
for (i=0; i<2; i++) {
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s-%s", syslinux, img_report.sl_version_str);
|
2014-02-04 20:01:28 +00:00
|
|
|
IGNORE_RETVAL(_mkdir(tmp));
|
2015-09-02 22:20:00 +00:00
|
|
|
if (*img_report.sl_version_ext != 0) {
|
2014-08-05 23:57:32 +00:00
|
|
|
IGNORE_RETVAL(_chdir(tmp));
|
2015-09-02 22:20:00 +00:00
|
|
|
IGNORE_RETVAL(_mkdir(&img_report.sl_version_ext[1]));
|
2014-08-05 23:57:32 +00:00
|
|
|
IGNORE_RETVAL(_chdir(".."));
|
|
|
|
}
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s/%s-%s%s/%s.%s", FILES_URL, syslinux, img_report.sl_version_str,
|
|
|
|
img_report.sl_version_ext, ldlinux, ldlinux_ext[i]);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_085, tmp);
|
2015-09-02 22:20:00 +00:00
|
|
|
PromptOnError = (*img_report.sl_version_ext == 0);
|
2015-01-01 23:39:28 +00:00
|
|
|
syslinux_ldlinux_len[i] = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog);
|
2014-08-05 23:57:32 +00:00
|
|
|
PromptOnError = TRUE;
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((syslinux_ldlinux_len[i] == 0) && (DownloadStatus == 404) && (*img_report.sl_version_ext != 0)) {
|
2014-08-05 23:57:32 +00:00
|
|
|
// Couldn't locate the file on the server => try to download without the version extra
|
|
|
|
uprintf("Extended version was not found, trying main version\n");
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, img_report.sl_version_str,
|
2014-08-05 23:57:32 +00:00
|
|
|
ldlinux, ldlinux_ext[i]);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_085, tmp);
|
|
|
|
syslinux_ldlinux_len[i] = DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog);
|
2014-08-05 23:57:32 +00:00
|
|
|
if (syslinux_ldlinux_len[i] != 0) {
|
|
|
|
// Duplicate the file so that the user won't be prompted to download again
|
2015-09-02 22:20:00 +00:00
|
|
|
static_sprintf(tmp, "%s-%s\\%s.%s", syslinux, img_report.sl_version_str, ldlinux, ldlinux_ext[i]);
|
2015-10-18 20:31:47 +00:00
|
|
|
static_sprintf(tmp2, "%s-%s\\%s\\%s.%s", syslinux, img_report.sl_version_str,
|
2015-09-02 22:20:00 +00:00
|
|
|
&img_report.sl_version_ext[1], ldlinux, ldlinux_ext[i]);
|
2014-08-05 23:57:32 +00:00
|
|
|
CopyFileA(tmp, tmp2, FALSE);
|
|
|
|
}
|
|
|
|
}
|
2014-02-04 20:01:28 +00:00
|
|
|
if (syslinux_ldlinux_len[i] == 0) {
|
2015-01-01 23:39:28 +00:00
|
|
|
uprintf("Could not download the file - cancelling\n");
|
2014-02-04 20:01:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2014-01-21 17:08:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
} else if (bt == BT_SYSLINUX_V6) {
|
2014-01-14 20:17:07 +00:00
|
|
|
IGNORE_RETVAL(_chdirU(app_dir));
|
|
|
|
IGNORE_RETVAL(_mkdir(FILES_DIR));
|
|
|
|
IGNORE_RETVAL(_chdir(FILES_DIR));
|
2014-01-24 19:59:23 +00:00
|
|
|
static_sprintf(tmp, "%s-%s/%s.%s", syslinux, embedded_sl_version_str[1], ldlinux, ldlinux_ext[2]);
|
2014-01-21 17:08:41 +00:00
|
|
|
fd = fopenU(tmp, "rb");
|
2013-06-15 16:31:55 +00:00
|
|
|
if (fd != NULL) {
|
2014-01-21 17:08:41 +00:00
|
|
|
uprintf("Will reuse './%s/%s' for Syslinux installation\n", FILES_DIR, tmp);
|
2013-06-15 16:31:55 +00:00
|
|
|
fclose(fd);
|
|
|
|
} else {
|
2014-01-21 17:08:41 +00:00
|
|
|
static_sprintf(tmp, "%s.%s", ldlinux, ldlinux_ext[2]);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_206, tmp);
|
2014-01-21 17:08:41 +00:00
|
|
|
// MSG_104: "Syslinux v5.0 or later requires a '%s' file to be installed"
|
2015-10-18 20:31:47 +00:00
|
|
|
r = MessageBoxExU(hMainDialog, lmprintf(MSG_104, "Syslinux v5.0", tmp, "Syslinux v5+", tmp),
|
|
|
|
lmprintf(MSG_103, tmp), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid);
|
2013-12-27 16:06:59 +00:00
|
|
|
if (r == IDCANCEL)
|
2013-06-15 16:31:55 +00:00
|
|
|
return FALSE;
|
|
|
|
if (r == IDYES) {
|
2014-01-24 19:59:23 +00:00
|
|
|
static_sprintf(tmp, "%s-%s", syslinux, embedded_sl_version_str[1]);
|
2014-01-14 20:17:07 +00:00
|
|
|
IGNORE_RETVAL(_mkdir(tmp));
|
2014-01-24 19:59:23 +00:00
|
|
|
static_sprintf(tmp, "%s/%s-%s/%s.%s", FILES_URL, syslinux, embedded_sl_version_str[1], ldlinux, ldlinux_ext[2]);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_085, tmp);
|
2015-02-26 00:15:13 +00:00
|
|
|
if (DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog) == 0)
|
2015-02-16 22:29:23 +00:00
|
|
|
return FALSE;
|
2013-06-15 16:31:55 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
} else if (bt == BT_MSDOS) {
|
2013-10-31 22:59:53 +00:00
|
|
|
if ((size_check) && (ComboBox_GetItemData(hClusterSize, ComboBox_GetCurSel(hClusterSize)) >= 65536)) {
|
|
|
|
// MS-DOS cannot boot from a drive using a 64 kilobytes Cluster size
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_110), lmprintf(MSG_111), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2013-10-31 22:59:53 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
} else if (bt == BT_GRUB4DOS) {
|
2014-11-14 23:40:00 +00:00
|
|
|
IGNORE_RETVAL(_chdirU(app_dir));
|
|
|
|
IGNORE_RETVAL(_mkdir(FILES_DIR));
|
|
|
|
IGNORE_RETVAL(_chdir(FILES_DIR));
|
2015-02-16 22:29:23 +00:00
|
|
|
static_sprintf(tmp, "grub4dos-%s/grldr", GRUB4DOS_VERSION);
|
2014-11-14 23:40:00 +00:00
|
|
|
fd = fopenU(tmp, "rb");
|
|
|
|
if (fd != NULL) {
|
|
|
|
uprintf("Will reuse './%s/%s' for Grub4DOS installation\n", FILES_DIR, tmp);
|
|
|
|
fclose(fd);
|
|
|
|
} else {
|
|
|
|
static_sprintf(tmp, "grldr");
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_206, tmp);
|
2015-10-18 20:31:47 +00:00
|
|
|
r = MessageBoxExU(hMainDialog, lmprintf(MSG_104, "Grub4DOS 0.4", tmp, "Grub4DOS", tmp),
|
|
|
|
lmprintf(MSG_103, tmp), MB_YESNOCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid);
|
2014-11-14 23:40:00 +00:00
|
|
|
if (r == IDCANCEL)
|
|
|
|
return FALSE;
|
|
|
|
if (r == IDYES) {
|
2015-02-16 22:29:23 +00:00
|
|
|
static_sprintf(tmp, "grub4dos-%s", GRUB4DOS_VERSION);
|
|
|
|
IGNORE_RETVAL(_mkdir(tmp));
|
|
|
|
static_sprintf(tmp, "%s/grub4dos-%s/grldr", FILES_URL, GRUB4DOS_VERSION);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_085, tmp);
|
2015-02-16 22:29:23 +00:00
|
|
|
uprintf("URL = %s", tmp);
|
|
|
|
if (DownloadFile(tmp, &tmp[sizeof(FILES_URL)], hMainDialog) == 0)
|
|
|
|
return FALSE;
|
2014-11-14 23:40:00 +00:00
|
|
|
}
|
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
} else if (bt == BT_UEFI_NTFS) {
|
2015-03-18 21:34:28 +00:00
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
|
|
|
if (fs != FS_NTFS) {
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_097, "UEFI:NTFS"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
|
2015-03-18 21:34:28 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2013-01-25 01:38:10 +00:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2014-11-20 22:57:22 +00:00
|
|
|
static __inline const char* IsAlphaOrBeta(void)
|
|
|
|
{
|
2014-11-28 00:00:59 +00:00
|
|
|
#if defined(ALPHA)
|
2014-11-20 22:57:22 +00:00
|
|
|
return " (Alpha) ";
|
2014-11-28 00:00:59 +00:00
|
|
|
#elif defined(BETA)
|
2014-11-20 22:57:22 +00:00
|
|
|
return " (Beta) ";
|
2015-06-26 21:49:32 +00:00
|
|
|
#elif defined(TEST)
|
2015-10-21 23:40:24 +00:00
|
|
|
# define TEST_STR(x) " (Test" STRINGIFY(x) ") "
|
2015-06-26 21:49:32 +00:00
|
|
|
return TEST_STR(TEST);
|
2014-11-20 22:57:22 +00:00
|
|
|
#else
|
|
|
|
return " ";
|
|
|
|
#endif
|
|
|
|
}
|
2013-01-25 01:38:10 +00:00
|
|
|
|
2015-02-08 22:36:57 +00:00
|
|
|
static INT_PTR CALLBACK InfoCallback(HWND hCtrl, UINT message, WPARAM wParam, LPARAM lParam)
|
2015-02-08 00:38:21 +00:00
|
|
|
{
|
|
|
|
HDC hdc;
|
|
|
|
RECT rect;
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
wchar_t winfo[128];
|
|
|
|
|
2015-06-17 17:32:19 +00:00
|
|
|
// Prevent the cursor (caret) from appearing within the edit control
|
|
|
|
HideCaret(hCtrl);
|
|
|
|
|
2015-02-08 00:38:21 +00:00
|
|
|
switch (message) {
|
|
|
|
|
|
|
|
// Prevent select (which screws up our display as it redraws the font using different settings)
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
return (INT_PTR)FALSE;
|
|
|
|
|
2015-06-17 17:32:19 +00:00
|
|
|
// Prevent the text selection pointer from appearing on hover
|
2015-02-08 00:38:21 +00:00
|
|
|
case WM_SETCURSOR:
|
|
|
|
SetCursor(LoadCursor(NULL, IDC_ARROW));
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
|
|
|
|
// The things one needs to do to vertically center text in an edit control...
|
|
|
|
case WM_PAINT:
|
|
|
|
GetWindowTextW(hInfo, winfo, ARRAYSIZE(winfo));
|
|
|
|
hdc = BeginPaint(hCtrl , &ps);
|
2015-05-21 22:51:48 +00:00
|
|
|
SelectObject(hdc, hInfoFont);
|
2015-06-21 16:59:59 +00:00
|
|
|
SetTextColor(hdc, GetSysColor(COLOR_BTNTEXT));
|
2015-02-08 00:38:21 +00:00
|
|
|
SetBkColor(hdc, GetSysColor(COLOR_BTNFACE));
|
|
|
|
SetTextAlign(hdc , TA_CENTER | TA_BASELINE);
|
|
|
|
GetClientRect(hCtrl , &rect);
|
2015-02-09 13:36:03 +00:00
|
|
|
// If you don't fill the client area, you get leftover text artifacts
|
2015-05-21 22:51:48 +00:00
|
|
|
FillRect(hdc, &rect, hInfoBrush);
|
2015-10-22 17:25:40 +00:00
|
|
|
ExtTextOutW(hdc, rect.right/2, rect.bottom/2 + (int)(5.0f * fScale),
|
|
|
|
ETO_CLIPPED | ETO_NUMERICSLOCAL | (right_to_left_mode?ETO_RTLREADING:0),
|
|
|
|
&rect, winfo, (int)wcslen(winfo), NULL);
|
2015-02-08 00:38:21 +00:00
|
|
|
EndPaint(hCtrl, &ps);
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return CallWindowProc(info_original_proc, hCtrl, message, wParam, lParam);
|
|
|
|
}
|
|
|
|
|
2012-02-02 13:16:49 +00:00
|
|
|
void InitDialog(HWND hDlg)
|
|
|
|
{
|
2015-04-18 07:04:29 +00:00
|
|
|
HINSTANCE hShell32DllInst, hUserLanguagesCplDllInst, hINetCplDllInst;
|
|
|
|
HIMAGELIST hLangToolbarImageList;
|
|
|
|
TBBUTTON tbLangToolbarButtons[1];
|
2015-05-14 23:36:42 +00:00
|
|
|
RECT rcDeviceList, rcToolbarButton, rcFormatGroup, rcAdvancedOptions, rcBootType, rcSelectImage;
|
2014-01-21 17:08:41 +00:00
|
|
|
DWORD len;
|
2014-11-28 22:42:22 +00:00
|
|
|
SIZE sz;
|
|
|
|
HWND hCtrl;
|
2012-02-02 13:16:49 +00:00
|
|
|
HDC hDC;
|
2015-01-01 23:39:28 +00:00
|
|
|
int i, i16, s16, lfHeight;
|
2014-08-05 23:57:32 +00:00
|
|
|
char tmp[128], *token, *buf, *ext;
|
2014-11-28 22:42:22 +00:00
|
|
|
wchar_t wtmp[128] = {0};
|
2014-11-11 19:53:39 +00:00
|
|
|
static char* resource[2] = { MAKEINTRESOURCEA(IDR_SL_LDLINUX_V4_SYS), MAKEINTRESOURCEA(IDR_SL_LDLINUX_V6_SYS) };
|
2012-02-02 13:16:49 +00:00
|
|
|
|
2012-02-07 02:05:58 +00:00
|
|
|
#ifdef RUFUS_TEST
|
|
|
|
ShowWindow(GetDlgItem(hDlg, IDC_TEST), SW_SHOW);
|
|
|
|
#endif
|
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
PF_INIT(ImageList_Create, Comctl32);
|
|
|
|
PF_INIT(ImageList_AddIcon, Comctl32);
|
|
|
|
PF_INIT(ImageList_ReplaceIcon, Comctl32);
|
|
|
|
|
2012-02-02 13:16:49 +00:00
|
|
|
// Quite a burden to carry around as parameters
|
|
|
|
hMainDialog = hDlg;
|
|
|
|
hDeviceList = GetDlgItem(hDlg, IDC_DEVICE);
|
2013-10-15 21:58:27 +00:00
|
|
|
hPartitionScheme = GetDlgItem(hDlg, IDC_PARTITION_TYPE);
|
2012-02-02 13:16:49 +00:00
|
|
|
hFileSystem = GetDlgItem(hDlg, IDC_FILESYSTEM);
|
|
|
|
hClusterSize = GetDlgItem(hDlg, IDC_CLUSTERSIZE);
|
|
|
|
hLabel = GetDlgItem(hDlg, IDC_LABEL);
|
|
|
|
hProgress = GetDlgItem(hDlg, IDC_PROGRESS);
|
2015-01-01 23:39:28 +00:00
|
|
|
hInfo = GetDlgItem(hDlg, IDC_INFO);
|
2013-01-24 21:30:11 +00:00
|
|
|
hBoot = GetDlgItem(hDlg, IDC_BOOT);
|
|
|
|
hBootType = GetDlgItem(hDlg, IDC_BOOTTYPE);
|
2012-02-02 13:16:49 +00:00
|
|
|
hSelectISO = GetDlgItem(hDlg, IDC_SELECT_ISO);
|
|
|
|
hNBPasses = GetDlgItem(hDlg, IDC_NBPASSES);
|
2012-05-16 22:38:39 +00:00
|
|
|
hDiskID = GetDlgItem(hDlg, IDC_DISK_ID);
|
2015-04-19 03:15:44 +00:00
|
|
|
hStart = GetDlgItem(hDlg, IDC_START);
|
2012-02-02 13:16:49 +00:00
|
|
|
|
|
|
|
// High DPI scaling
|
|
|
|
i16 = GetSystemMetrics(SM_CXSMICON);
|
|
|
|
hDC = GetDC(hDlg);
|
2015-02-08 00:38:21 +00:00
|
|
|
lfHeight = -MulDiv(9, GetDeviceCaps(hDC, LOGPIXELSY), 72);
|
2015-07-06 21:04:38 +00:00
|
|
|
if (hDC != NULL)
|
|
|
|
ReleaseDC(hDlg, hDC);
|
2012-06-04 16:35:32 +00:00
|
|
|
// Adjust icon size lookup
|
|
|
|
s16 = i16;
|
|
|
|
if (s16 >= 54)
|
|
|
|
s16 = 64;
|
|
|
|
else if (s16 >= 40)
|
|
|
|
s16 = 48;
|
|
|
|
else if (s16 >= 28)
|
|
|
|
s16 = 32;
|
|
|
|
else if (s16 >= 20)
|
|
|
|
s16 = 24;
|
2012-02-02 13:16:49 +00:00
|
|
|
|
2015-05-21 22:51:48 +00:00
|
|
|
// Create the font and brush for the Info edit box
|
|
|
|
hInfoFont = CreateFontA(lfHeight, 0, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE, DEFAULT_CHARSET,
|
2015-02-08 00:38:21 +00:00
|
|
|
0, 0, PROOF_QUALITY, 0, (nWindowsVersion >= WINDOWS_VISTA)?"Segoe UI":"Arial Unicode MS");
|
2015-05-21 22:51:48 +00:00
|
|
|
SendDlgItemMessageA(hDlg, IDC_INFO, WM_SETFONT, (WPARAM)hInfoFont, TRUE);
|
|
|
|
hInfoBrush = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
|
2015-01-01 23:39:28 +00:00
|
|
|
|
2012-02-02 13:16:49 +00:00
|
|
|
// Create the title bar icon
|
2012-12-05 01:53:10 +00:00
|
|
|
SetTitleBarIcon(hDlg);
|
2012-03-11 01:55:25 +00:00
|
|
|
GetWindowTextA(hDlg, tmp, sizeof(tmp));
|
|
|
|
// Count of Microsoft for making it more attractive to read a
|
|
|
|
// version using strtok() than using GetFileVersionInfo()
|
2014-01-24 19:59:23 +00:00
|
|
|
token = strtok(tmp, " ");
|
2015-02-08 22:36:57 +00:00
|
|
|
for (i=0; (i<3) && ((token = strtok(NULL, ".")) != NULL); i++)
|
2012-12-07 00:54:40 +00:00
|
|
|
rufus_version[i] = (uint16_t)atoi(token);
|
2014-11-20 22:57:22 +00:00
|
|
|
|
|
|
|
// Redefine the title to be able to add "Alpha" or "Beta" and get the version in the right order for RTL
|
|
|
|
if (!right_to_left_mode) {
|
2015-02-08 22:36:57 +00:00
|
|
|
static_sprintf(tmp, APPLICATION_NAME " %d.%d.%d%s", rufus_version[0], rufus_version[1], rufus_version[2], IsAlphaOrBeta());
|
2014-11-20 22:57:22 +00:00
|
|
|
} else {
|
2015-02-08 22:36:57 +00:00
|
|
|
static_sprintf(tmp, "%s%d.%d.%d " APPLICATION_NAME, IsAlphaOrBeta(), rufus_version[0], rufus_version[1], rufus_version[2]);
|
2014-01-24 19:59:23 +00:00
|
|
|
}
|
2014-11-20 22:57:22 +00:00
|
|
|
SetWindowTextU(hDlg, tmp);
|
2015-02-08 22:36:57 +00:00
|
|
|
uprintf(APPLICATION_NAME " version: %d.%d.%d%s", rufus_version[0], rufus_version[1], rufus_version[2], IsAlphaOrBeta());
|
2014-01-21 17:08:41 +00:00
|
|
|
for (i=0; i<ARRAYSIZE(resource); i++) {
|
2014-10-29 19:16:29 +00:00
|
|
|
buf = (char*)GetResource(hMainInstance, resource[i], _RT_RCDATA, "ldlinux_sys", &len, TRUE);
|
2014-08-05 23:57:32 +00:00
|
|
|
if (buf == NULL) {
|
2014-01-21 17:08:41 +00:00
|
|
|
uprintf("Warning: could not read embedded Syslinux v%d version", i+4);
|
|
|
|
} else {
|
2014-08-05 23:57:32 +00:00
|
|
|
embedded_sl_version[i] = GetSyslinuxVersion(buf, len, &ext);
|
2014-01-24 19:59:23 +00:00
|
|
|
static_sprintf(embedded_sl_version_str[i], "%d.%02d", SL_MAJOR(embedded_sl_version[i]), SL_MINOR(embedded_sl_version[i]));
|
2014-08-05 23:57:32 +00:00
|
|
|
safe_strcpy(embedded_sl_version_ext[i], sizeof(embedded_sl_version_ext[i]), ext);
|
2014-10-29 19:16:29 +00:00
|
|
|
free(buf);
|
2014-01-21 17:08:41 +00:00
|
|
|
}
|
|
|
|
}
|
2015-01-25 00:56:38 +00:00
|
|
|
uprintf("Windows version: %s", WindowsVersionStr);
|
2014-08-05 23:57:32 +00:00
|
|
|
uprintf("Syslinux versions: %s%s, %s%s", embedded_sl_version_str[0], embedded_sl_version_ext[0],
|
|
|
|
embedded_sl_version_str[1], embedded_sl_version_ext[1]);
|
2015-02-16 22:29:23 +00:00
|
|
|
uprintf("Grub versions: %s, %s", GRUB4DOS_VERSION, GRUB2_PACKAGE_VERSION);
|
2015-01-25 00:56:38 +00:00
|
|
|
uprintf("Locale ID: 0x%04X", GetUserDefaultUILanguage());
|
2013-10-15 21:58:27 +00:00
|
|
|
|
|
|
|
SetClusterSizeLabels();
|
|
|
|
|
2012-03-28 18:50:21 +00:00
|
|
|
// Prefer FreeDOS to MS-DOS
|
2015-07-01 20:26:15 +00:00
|
|
|
selection_default = BT_FREEDOS;
|
2012-03-29 17:16:06 +00:00
|
|
|
// Create the status line and initialize the taskbar icon for progress overlay
|
2012-02-02 13:16:49 +00:00
|
|
|
CreateStatusBar();
|
2012-03-29 17:16:06 +00:00
|
|
|
CreateTaskbarList();
|
|
|
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
|
|
|
|
2012-02-02 13:16:49 +00:00
|
|
|
// Use maximum granularity for the progress bar
|
2013-01-09 21:54:28 +00:00
|
|
|
SendMessage(hProgress, PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
|
2012-02-02 13:16:49 +00:00
|
|
|
// Fill up the passes
|
2013-01-25 01:38:10 +00:00
|
|
|
for (i=0; i<4; i++) {
|
2013-10-15 21:58:27 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_AddStringU(hNBPasses, lmprintf((i==0)?MSG_034:MSG_035, i+1)));
|
2013-01-25 01:38:10 +00:00
|
|
|
}
|
2015-04-18 22:14:55 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hNBPasses, 0));
|
2013-01-25 01:38:10 +00:00
|
|
|
SetPassesTooltip();
|
2014-08-08 23:10:12 +00:00
|
|
|
// Fill up the boot type dropdown
|
2015-07-01 20:26:15 +00:00
|
|
|
if (nWindowsVersion < WINDOWS_10) // The diskcopy.dll with the MS-DOS floppy image was removed in Windows 10
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), BT_MSDOS));
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), BT_FREEDOS));
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), BT_ISO));
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_095)), BT_IMG));
|
2015-08-22 14:18:25 +00:00
|
|
|
SetComboEntry(hBootType, selection_default);
|
2012-05-22 11:30:22 +00:00
|
|
|
// Fill up the MBR masqueraded disk IDs ("8 disks should be enough for anybody")
|
2015-10-18 20:31:47 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_030, LEFT_TO_RIGHT_EMBEDDING "0x80" POP_DIRECTIONAL_FORMATTING)), 0x80));
|
2012-05-25 16:54:06 +00:00
|
|
|
for (i=1; i<=7; i++) {
|
2013-10-15 21:58:27 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hDiskID, ComboBox_AddStringU(hDiskID, lmprintf(MSG_109, 0x80+i, i+1)), 0x80+i));
|
2012-05-16 22:38:39 +00:00
|
|
|
}
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0));
|
|
|
|
|
2012-02-02 13:16:49 +00:00
|
|
|
// Create the string array
|
|
|
|
StrArrayCreate(&DriveID, MAX_DRIVES);
|
|
|
|
StrArrayCreate(&DriveLabel, MAX_DRIVES);
|
2012-05-16 22:38:39 +00:00
|
|
|
// Set various checkboxes
|
2012-02-02 13:16:49 +00:00
|
|
|
CheckDlgButton(hDlg, IDC_QUICKFORMAT, BST_CHECKED);
|
2013-01-24 21:30:11 +00:00
|
|
|
CheckDlgButton(hDlg, IDC_BOOT, BST_CHECKED);
|
2012-02-21 19:46:28 +00:00
|
|
|
CheckDlgButton(hDlg, IDC_SET_ICON, BST_CHECKED);
|
2012-02-02 13:16:49 +00:00
|
|
|
|
|
|
|
// Load system icons (NB: Use the excellent http://www.nirsoft.net/utils/iconsext.html to find icon IDs)
|
2015-04-18 07:04:29 +00:00
|
|
|
hShell32DllInst = GetLibraryHandle("Shell32");
|
|
|
|
hIconDisc = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(12), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED);
|
|
|
|
|
|
|
|
if (nWindowsVersion >= WINDOWS_8) {
|
|
|
|
// Use the icon from the Windows 8+ 'Language' Control Panel
|
|
|
|
hUserLanguagesCplDllInst = GetLibraryHandle("UserLanguagesCpl");
|
|
|
|
hIconLang = (HICON)LoadImage(hUserLanguagesCplDllInst, MAKEINTRESOURCE(1), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED);
|
|
|
|
} else {
|
|
|
|
// Otherwise use the globe icon, from the Internet Options Control Panel
|
|
|
|
hINetCplDllInst = GetLibraryHandle("inetcpl.cpl");
|
|
|
|
hIconLang = (HICON)LoadImage(hINetCplDllInst, MAKEINTRESOURCE(1313), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED);
|
|
|
|
}
|
|
|
|
|
2012-05-16 22:38:39 +00:00
|
|
|
if (nWindowsVersion >= WINDOWS_VISTA) {
|
2015-04-18 07:04:29 +00:00
|
|
|
hIconDown = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(16750), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED);
|
|
|
|
hIconUp = (HICON)LoadImage(hShell32DllInst, MAKEINTRESOURCE(16749), IMAGE_ICON, s16, s16, LR_DEFAULTCOLOR | LR_SHARED);
|
2012-05-16 22:38:39 +00:00
|
|
|
} 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);
|
|
|
|
}
|
2012-02-02 13:16:49 +00:00
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
// Create the language toolbar
|
2015-04-19 03:15:44 +00:00
|
|
|
hLangToolbar = CreateWindowEx(0, TOOLBARCLASSNAME, NULL, WS_CHILD | WS_TABSTOP | TBSTYLE_TRANSPARENT | CCS_NOPARENTALIGN |
|
2015-04-18 07:04:29 +00:00
|
|
|
CCS_NORESIZE | CCS_NODIVIDER, 0, 0, 0, 0, hMainDialog, NULL, hMainInstance, NULL);
|
|
|
|
if ((pfImageList_Create != NULL) && (pfImageList_AddIcon != NULL)) {
|
|
|
|
hLangToolbarImageList = pfImageList_Create(i16, i16, ILC_COLOR32, 1, 0);
|
|
|
|
pfImageList_AddIcon(hLangToolbarImageList, hIconLang);
|
|
|
|
SendMessage(hLangToolbar, TB_SETIMAGELIST, (WPARAM)0, (LPARAM)hLangToolbarImageList);
|
|
|
|
}
|
|
|
|
SendMessage(hLangToolbar, TB_BUTTONSTRUCTSIZE, (WPARAM)sizeof(TBBUTTON), 0);
|
|
|
|
memset(tbLangToolbarButtons, 0, sizeof(TBBUTTON));
|
|
|
|
tbLangToolbarButtons[0].idCommand = lang_button_id;
|
|
|
|
tbLangToolbarButtons[0].fsStyle = BTNS_WHOLEDROPDOWN;
|
|
|
|
tbLangToolbarButtons[0].fsState = TBSTATE_ENABLED;
|
|
|
|
SendMessage(hLangToolbar, TB_ADDBUTTONS, (WPARAM)1, (LPARAM)&tbLangToolbarButtons); // Add just the 1 button
|
|
|
|
SendMessage(hLangToolbar, TB_GETRECT, lang_button_id, (LPARAM)&rcToolbarButton);
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
// Make the toolbar window just big enough to hold the button
|
|
|
|
// Set the top margin to 4 DIPs and the right margin so that it's aligned with the Device List Combobox
|
|
|
|
GetWindowRect(hDeviceList, &rcDeviceList);
|
|
|
|
MapWindowPoints(NULL, hDlg, (POINT*)&rcDeviceList, 2);
|
2015-07-06 21:04:38 +00:00
|
|
|
SetWindowPos(hLangToolbar, HWND_TOP, rcDeviceList.right - rcToolbarButton.right,
|
2015-04-18 07:04:29 +00:00
|
|
|
(int)(4.0f * fScale), rcToolbarButton.right, rcToolbarButton.bottom, 0);
|
|
|
|
ShowWindow(hLangToolbar, SW_SHOWNORMAL);
|
|
|
|
|
2015-05-14 23:36:42 +00:00
|
|
|
// Add trailing space to the "Format Options" text
|
2014-11-28 22:42:22 +00:00
|
|
|
hCtrl = GetDlgItem(hDlg, IDS_FORMAT_OPTIONS_GRP);
|
|
|
|
GetWindowTextW(hCtrl, wtmp, ARRAYSIZE(wtmp));
|
|
|
|
wtmp[wcslen(wtmp)] = ' ';
|
|
|
|
SetWindowTextW(hCtrl, wtmp);
|
2015-05-14 23:36:42 +00:00
|
|
|
|
|
|
|
// Reposition and resize the Advanced button
|
|
|
|
GetWindowRect(hCtrl, &rcFormatGroup);
|
|
|
|
MapWindowPoints(NULL, hDlg, (POINT*)&rcFormatGroup, 2);
|
|
|
|
sz = GetTextSize(hCtrl);
|
|
|
|
GetWindowRect(GetDlgItem(hDlg, IDC_ADVANCED), &rcAdvancedOptions);
|
|
|
|
// The label of a group box is always 8 pixels to the right, *regardless* of the zoom level
|
|
|
|
SetWindowPos(GetDlgItem(hDlg, IDC_ADVANCED), hCtrl, rcFormatGroup.left + 8 + sz.cx,
|
|
|
|
rcFormatGroup.top, i16 + (int)(4.0f * fScale), i16/2 + (int)(8.0f * fScale), 0);
|
|
|
|
|
|
|
|
// Reposition and resize the Select Image button
|
|
|
|
GetWindowRect(hBootType, &rcBootType);
|
|
|
|
MapWindowPoints(NULL, hDlg, (POINT*)&rcBootType, 2);
|
|
|
|
GetWindowRect(hSelectISO, &rcSelectImage);
|
|
|
|
MapWindowPoints(NULL, hDlg, (POINT*)&rcSelectImage, 2);
|
|
|
|
SetWindowPos(hSelectISO, NULL, rcSelectImage.left, rcBootType.top - 1,
|
2015-07-06 21:04:38 +00:00
|
|
|
rcSelectImage.right - rcSelectImage.left, rcBootType.bottom - rcBootType.top + 2, SWP_NOZORDER);
|
2015-05-14 23:36:42 +00:00
|
|
|
|
2014-11-28 22:42:22 +00:00
|
|
|
// The things one needs to do to keep things looking good...
|
|
|
|
if (nWindowsVersion == WINDOWS_7) {
|
2015-08-22 14:18:25 +00:00
|
|
|
ResizeMoveCtrl(hDlg, GetDlgItem(hMainDialog, IDS_ADVANCED_OPTIONS_GRP), 0, -1, 0, 2, fScale);
|
|
|
|
ResizeMoveCtrl(hDlg, hProgress, 0, 1, 0, 0, fScale);
|
2014-11-28 22:42:22 +00:00
|
|
|
}
|
|
|
|
|
2015-02-08 00:38:21 +00:00
|
|
|
// Subclass the Info box so that we can align its text vertically
|
|
|
|
info_original_proc = (WNDPROC)SetWindowLongPtr(hInfo, GWLP_WNDPROC, (LONG_PTR)InfoCallback);
|
|
|
|
|
2012-05-16 22:38:39 +00:00
|
|
|
// Set the icons on the the buttons
|
2014-05-12 21:44:10 +00:00
|
|
|
if ((pfImageList_Create != NULL) && (pfImageList_ReplaceIcon != NULL)) {
|
|
|
|
|
|
|
|
bi_iso.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
|
|
|
|
pfImageList_ReplaceIcon(bi_iso.himl, -1, hIconDisc);
|
|
|
|
SetRect(&bi_iso.margin, 0, 1, 0, 0);
|
|
|
|
bi_iso.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
|
|
|
|
bi_down.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
|
|
|
|
pfImageList_ReplaceIcon(bi_down.himl, -1, hIconDown);
|
|
|
|
SetRect(&bi_down.margin, 0, 0, 0, 0);
|
|
|
|
bi_down.uAlign = BUTTON_IMAGELIST_ALIGN_CENTER;
|
|
|
|
bi_up.himl = pfImageList_Create(i16, i16, ILC_COLOR32 | ILC_MASK, 1, 0);
|
|
|
|
pfImageList_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);
|
2015-09-16 23:20:22 +00:00
|
|
|
SendMessage(GetDlgItem(hDlg, IDC_ADVANCED), BCM_SETIMAGELIST, 0,
|
|
|
|
(LPARAM)(advanced_mode?&bi_up:&bi_down));
|
2014-05-12 21:44:10 +00:00
|
|
|
}
|
2012-05-22 11:30:22 +00:00
|
|
|
|
|
|
|
// Set the various tooltips
|
2013-10-15 21:58:27 +00:00
|
|
|
CreateTooltip(hFileSystem, lmprintf(MSG_157), -1);
|
|
|
|
CreateTooltip(hClusterSize, lmprintf(MSG_158), -1);
|
|
|
|
CreateTooltip(hLabel, lmprintf(MSG_159), -1);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_ADVANCED), lmprintf(MSG_160), -1);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_BADBLOCKS), lmprintf(MSG_161), -1);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_QUICKFORMAT), lmprintf(MSG_162), -1);
|
|
|
|
CreateTooltip(hBoot, lmprintf(MSG_163), -1);
|
|
|
|
CreateTooltip(hBootType, lmprintf(MSG_164), -1);
|
|
|
|
CreateTooltip(hSelectISO, lmprintf(MSG_165), -1);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_SET_ICON), lmprintf(MSG_166), 10000);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_RUFUS_MBR), lmprintf(MSG_167), 10000);
|
|
|
|
CreateTooltip(hDiskID, lmprintf(MSG_168), 10000);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_EXTRA_PARTITION), lmprintf(MSG_169), -1);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_ENABLE_FIXED_DISKS), lmprintf(MSG_170), -1);
|
2015-04-19 03:15:44 +00:00
|
|
|
CreateTooltip(hStart, lmprintf(MSG_171), -1);
|
2013-10-15 21:58:27 +00:00
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_ABOUT), lmprintf(MSG_172), -1);
|
2015-01-22 22:31:34 +00:00
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_WINDOWS_INSTALL), lmprintf(MSG_199), -1);
|
|
|
|
CreateTooltip(GetDlgItem(hDlg, IDC_WINDOWS_TO_GO), lmprintf(MSG_200), -1);
|
2015-07-06 21:04:38 +00:00
|
|
|
CreateTooltip(hStatusToolbar, lmprintf(MSG_272), -1);
|
2015-07-02 21:46:26 +00:00
|
|
|
CreateTooltip(hLangToolbar, lmprintf(MSG_273), -1);
|
2012-05-16 22:38:39 +00:00
|
|
|
|
2015-05-08 22:37:22 +00:00
|
|
|
// Set a label for the Advanced Mode and Select Image button for screen readers
|
2015-05-31 19:10:26 +00:00
|
|
|
if (nWindowsVersion > WINDOWS_XP) {
|
|
|
|
SetWindowTextU(GetDlgItem(hDlg, IDC_ADVANCED), lmprintf(MSG_160));
|
|
|
|
SetWindowTextU(hSelectISO, lmprintf(MSG_165));
|
|
|
|
}
|
2015-05-08 22:37:22 +00:00
|
|
|
|
2015-09-16 23:20:22 +00:00
|
|
|
if (!advanced_mode) // Hide as needed, since we display the advanced controls by default
|
|
|
|
ToggleAdvanced(FALSE);
|
2015-01-12 00:34:09 +00:00
|
|
|
ToggleToGo();
|
2013-02-04 01:14:28 +00:00
|
|
|
|
|
|
|
// Process commandline parameters
|
|
|
|
if (iso_provided) {
|
|
|
|
// Simulate a button click for ISO selection
|
|
|
|
PostMessage(hDlg, WM_COMMAND, IDC_SELECT_ISO, 0);
|
|
|
|
}
|
2015-01-01 23:39:28 +00:00
|
|
|
|
|
|
|
PrintInfo(0, MSG_210);
|
2012-02-02 13:16:49 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 20:32:22 +00:00
|
|
|
static void PrintStatus2000(const char* str, BOOL val)
|
|
|
|
{
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintStatus(2000, (val)?MSG_250:MSG_251, str);
|
2013-06-03 20:32:22 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
void ShowLanguageMenu(RECT rcExclude)
|
2013-10-24 21:57:34 +00:00
|
|
|
{
|
2015-04-18 07:04:29 +00:00
|
|
|
TPMPARAMS tpm;
|
2013-10-24 21:57:34 +00:00
|
|
|
HMENU menu;
|
|
|
|
loc_cmd* lcmd = NULL;
|
2014-01-24 02:46:06 +00:00
|
|
|
char lang[256];
|
|
|
|
char *search = "()";
|
2015-01-28 23:22:11 +00:00
|
|
|
char *l, *r, *str;
|
2013-10-24 21:57:34 +00:00
|
|
|
|
2014-01-24 02:46:06 +00:00
|
|
|
UM_LANGUAGE_MENU_MAX = UM_LANGUAGE_MENU;
|
2013-10-24 21:57:34 +00:00
|
|
|
menu = CreatePopupMenu();
|
|
|
|
list_for_each_entry(lcmd, &locale_list, loc_cmd, list) {
|
2014-01-24 02:46:06 +00:00
|
|
|
// The appearance of LTR languages must be fixed for RTL menus
|
|
|
|
if ((right_to_left_mode) && (!(lcmd->ctrl_id & LOC_RIGHT_TO_LEFT))) {
|
2015-01-28 23:22:11 +00:00
|
|
|
str = safe_strdup(lcmd->txt[1]);
|
|
|
|
l = strtok(str, search);
|
2014-01-24 02:46:06 +00:00
|
|
|
r = strtok(NULL, search);
|
2015-10-18 20:31:47 +00:00
|
|
|
static_sprintf(lang, LEFT_TO_RIGHT_EMBEDDING "(%s) " POP_DIRECTIONAL_FORMATTING "%s", r, l);
|
2015-01-28 23:22:11 +00:00
|
|
|
safe_free(str);
|
2014-01-24 02:46:06 +00:00
|
|
|
} else {
|
|
|
|
safe_strcpy(lang, sizeof(lang), lcmd->txt[1]);
|
|
|
|
}
|
|
|
|
InsertMenuU(menu, -1, MF_BYPOSITION|((selected_locale == lcmd)?MF_CHECKED:0), UM_LANGUAGE_MENU_MAX++, lang);
|
2013-10-24 21:57:34 +00:00
|
|
|
}
|
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
// Open the menu such that it doesn't overlap the specified rect
|
|
|
|
tpm.cbSize = sizeof(TPMPARAMS);
|
|
|
|
tpm.rcExclude = rcExclude;
|
|
|
|
TrackPopupMenuEx(menu, 0,
|
|
|
|
right_to_left_mode ? rcExclude.right : rcExclude.left, // In RTL languages, the menu should be placed at the bottom-right of the rect
|
|
|
|
rcExclude.bottom, hMainDialog, &tpm);
|
|
|
|
|
2013-10-24 21:57:34 +00:00
|
|
|
DestroyMenu(menu);
|
|
|
|
}
|
2013-10-15 21:58:27 +00:00
|
|
|
|
2015-07-01 20:26:15 +00:00
|
|
|
void SetBoot(int fs, int tt)
|
2014-02-09 02:54:07 +00:00
|
|
|
{
|
|
|
|
int i;
|
2014-11-12 02:38:13 +00:00
|
|
|
char tmp[32];
|
2014-02-09 02:54:07 +00:00
|
|
|
|
|
|
|
IGNORE_RETVAL(ComboBox_ResetContent(hBootType));
|
2015-07-01 20:26:15 +00:00
|
|
|
if ((tt == TT_BIOS) && (IS_FAT(fs))) {
|
|
|
|
if (nWindowsVersion < WINDOWS_10) // The diskcopy.dll with the MS-DOS floppy image was removed in Windows 10
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "MS-DOS"), BT_MSDOS));
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "FreeDOS"), BT_FREEDOS));
|
2014-02-09 02:54:07 +00:00
|
|
|
}
|
2015-07-01 20:26:15 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_036)), BT_ISO));
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, lmprintf(MSG_095)), BT_IMG));
|
2014-11-14 23:40:00 +00:00
|
|
|
// If needed (advanced mode) also append "bare" Syslinux and other options
|
2015-07-01 20:26:15 +00:00
|
|
|
if ( (tt == TT_BIOS) && ((IS_FAT(fs) || (fs == FS_NTFS)) && (advanced_mode)) ) {
|
2014-11-12 02:38:13 +00:00
|
|
|
static_sprintf(tmp, "Syslinux %s", embedded_sl_version_str[0]);
|
2015-07-01 20:26:15 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, tmp), BT_SYSLINUX_V4));
|
2014-11-12 02:38:13 +00:00
|
|
|
static_sprintf(tmp, "Syslinux %s", embedded_sl_version_str[1]);
|
2015-07-01 20:26:15 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, tmp), BT_SYSLINUX_V6));
|
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "ReactOS"), BT_REACTOS));
|
2015-02-16 22:29:23 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType,
|
2015-07-01 20:26:15 +00:00
|
|
|
"Grub " GRUB2_PACKAGE_VERSION), BT_GRUB2));
|
2015-02-16 22:29:23 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType,
|
2015-07-01 20:26:15 +00:00
|
|
|
"Grub4DOS " GRUB4DOS_VERSION), BT_GRUB4DOS));
|
2014-02-09 02:54:07 +00:00
|
|
|
}
|
2015-03-18 21:34:28 +00:00
|
|
|
if (advanced_mode)
|
2015-07-01 20:26:15 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetItemData(hBootType, ComboBox_AddStringU(hBootType, "UEFI:NTFS"), BT_UEFI_NTFS));
|
|
|
|
if ((!advanced_mode) && (selection_default >= BT_SYSLINUX_V4)) {
|
|
|
|
selection_default = BT_FREEDOS;
|
2014-02-09 02:54:07 +00:00
|
|
|
CheckDlgButton(hMainDialog, IDC_DISK_ID, BST_UNCHECKED);
|
|
|
|
}
|
|
|
|
for (i=0; i<ComboBox_GetCount(hBootType); i++) {
|
|
|
|
if (ComboBox_GetItemData(hBootType, i) == selection_default) {
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, i));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i == ComboBox_GetCount(hBootType))
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0));
|
|
|
|
|
|
|
|
if (!IsWindowEnabled(hBoot)) {
|
|
|
|
EnableWindow(hBoot, TRUE);
|
|
|
|
EnableWindow(hBootType, TRUE);
|
|
|
|
EnableWindow(hSelectISO, TRUE);
|
2015-01-13 02:11:57 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_INSTALL), TRUE);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO), TRUE);
|
2014-03-14 23:13:04 +00:00
|
|
|
CheckDlgButton(hMainDialog, IDC_BOOT, uBootChecked);
|
2014-02-09 02:54:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-14 22:09:45 +00:00
|
|
|
void SaveVHD(void)
|
|
|
|
{
|
2015-09-04 13:15:22 +00:00
|
|
|
static VHD_SAVE vhd_save;
|
2015-08-14 22:09:45 +00:00
|
|
|
char filename[128];
|
|
|
|
char path[MAX_PATH];
|
|
|
|
int DriveIndex = ComboBox_GetCurSel(hDeviceList);
|
2015-09-04 13:15:22 +00:00
|
|
|
EXT_DECL(vhd_ext, filename, __VA_GROUP__("*.vhd"), __VA_GROUP__("VHD File"));
|
|
|
|
ULARGE_INTEGER free_space;
|
|
|
|
|
2015-08-14 22:09:45 +00:00
|
|
|
if (DriveIndex >= 0)
|
|
|
|
safe_sprintf(filename, sizeof(filename), "%s.vhd", DriveLabel.String[DriveIndex]);
|
|
|
|
if ((DriveIndex != CB_ERR) && (!format_op_in_progress) && (format_thid == NULL)) {
|
2015-09-04 13:15:22 +00:00
|
|
|
vhd_save.DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, DriveIndex);
|
|
|
|
vhd_save.path = FileDialog(TRUE, NULL, &vhd_ext, 0);
|
2015-08-14 22:09:45 +00:00
|
|
|
if (vhd_save.path != NULL) {
|
|
|
|
// Reset all progress bars
|
|
|
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0);
|
|
|
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
|
|
|
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, 0, 0);
|
|
|
|
FormatStatus = 0;
|
|
|
|
format_op_in_progress = TRUE;
|
|
|
|
free_space.QuadPart = 0;
|
|
|
|
if ((GetVolumePathNameA(vhd_save.path, path, sizeof(path)))
|
|
|
|
&& (GetDiskFreeSpaceExA(path, &free_space, NULL, NULL))
|
|
|
|
&& ((LONGLONG)free_space.QuadPart > (SelectedDrive.DiskSize + 512))) {
|
|
|
|
// Disable all controls except cancel
|
|
|
|
EnableControls(FALSE);
|
|
|
|
FormatStatus = 0;
|
|
|
|
InitProgress(TRUE);
|
|
|
|
format_thid = CreateThread(NULL, 0, SaveImageThread, &vhd_save, 0, NULL);
|
|
|
|
if (format_thid != NULL) {
|
|
|
|
uprintf("\r\nSave to VHD operation started");
|
|
|
|
PrintInfo(0, -1);
|
|
|
|
timer = 0;
|
|
|
|
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00");
|
|
|
|
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
|
|
|
|
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uprintf("Unable to start VHD save thread");
|
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
|
|
|
safe_free(vhd_save.path);
|
|
|
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (free_space.QuadPart == 0) {
|
|
|
|
uprintf("Unable to isolate drive name for VHD save");
|
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_PATH_NOT_FOUND;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
uprintf("The VHD size is too large for the target drive");
|
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_FILE_TOO_LARGE;
|
|
|
|
}
|
|
|
|
safe_free(vhd_save.path);
|
|
|
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2011-11-17 01:43:06 +00:00
|
|
|
/*
|
2011-11-21 17:06:17 +00:00
|
|
|
* Main dialog callback
|
|
|
|
*/
|
2011-11-18 01:58:08 +00:00
|
|
|
static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
|
2011-11-13 20:53:23 +00:00
|
|
|
{
|
2015-07-03 22:42:45 +00:00
|
|
|
static DWORD DeviceNum = 0, LastRefresh = 0;
|
2015-02-02 21:16:53 +00:00
|
|
|
static BOOL first_log_display = TRUE, user_changed_label = FALSE, isMarquee = FALSE;
|
2013-12-20 18:32:10 +00:00
|
|
|
static ULONG ulRegister = 0;
|
|
|
|
static LPITEMIDLIST pidlDesktop = NULL;
|
|
|
|
static MY_SHChangeNotifyEntry NotifyEntry;
|
2015-01-01 23:39:28 +00:00
|
|
|
DRAWITEMSTRUCT* pDI;
|
|
|
|
POINT Point;
|
2015-04-18 07:04:29 +00:00
|
|
|
RECT DialogRect, DesktopRect, LangToolbarRect;
|
2015-01-01 23:39:28 +00:00
|
|
|
LONG progress_style;
|
2015-09-24 22:59:10 +00:00
|
|
|
HDC hDC;
|
2015-07-01 20:26:15 +00:00
|
|
|
int nDeviceIndex, fs, tt, i, nWidth, nHeight, nb_devices, selected_language, offset;
|
2015-01-01 23:39:28 +00:00
|
|
|
char tmp[128];
|
2013-10-24 21:57:34 +00:00
|
|
|
loc_cmd* lcmd = NULL;
|
2015-06-20 17:40:55 +00:00
|
|
|
EXT_DECL(img_ext, NULL, __VA_GROUP__("*.img;*.vhd;*.gz;*.bzip2;*.xz;*.lzma;*.Z;*.zip"), __VA_GROUP__(lmprintf(MSG_095)));
|
2014-05-22 21:46:36 +00:00
|
|
|
EXT_DECL(iso_ext, NULL, __VA_GROUP__("*.iso"), __VA_GROUP__(lmprintf(MSG_036)));
|
2015-04-18 07:04:29 +00:00
|
|
|
LPNMTOOLBAR lpnmtb;
|
2011-11-21 17:06:17 +00:00
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
switch (message) {
|
|
|
|
|
2013-12-20 18:32:10 +00:00
|
|
|
case UM_MEDIA_CHANGE:
|
|
|
|
wParam = DBT_CUSTOMEVENT;
|
|
|
|
// Fall through
|
2011-11-13 20:53:23 +00:00
|
|
|
case WM_DEVICECHANGE:
|
2013-02-10 21:54:47 +00:00
|
|
|
// The Windows hotplug subsystem sucks. Among other things, if you insert a GPT partitioned
|
|
|
|
// USB drive with zero partitions, the only device messages you will get are a stream of
|
|
|
|
// DBT_DEVNODES_CHANGED and that's it. But those messages are also issued when you get a
|
|
|
|
// DBT_DEVICEARRIVAL and DBT_DEVICEREMOVECOMPLETE, and there's a whole slew of them so we
|
|
|
|
// can't really issue a refresh for each one we receive
|
|
|
|
// What we do then is arm a timer on DBT_DEVNODES_CHANGED, if it's been more than 1 second
|
|
|
|
// since last refresh/arm timer, and have that timer send DBT_CUSTOMEVENT when it expires.
|
2014-02-09 02:54:07 +00:00
|
|
|
// DO *NOT* USE WM_DEVICECHANGE AS THE MESSAGE FROM THE TIMER PROC, as it may be filtered!
|
|
|
|
// For instance filtering will occur when (un)plugging in a FreeBSD UFD on Windows 8.
|
2014-05-20 18:28:46 +00:00
|
|
|
// Instead, use a custom user message, such as UM_MEDIA_CHANGE, to set DBT_CUSTOMEVENT.
|
2013-02-10 21:54:47 +00:00
|
|
|
if (format_thid == NULL) {
|
|
|
|
switch (wParam) {
|
|
|
|
case DBT_DEVICEARRIVAL:
|
|
|
|
case DBT_DEVICEREMOVECOMPLETE:
|
2013-12-20 18:32:10 +00:00
|
|
|
case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change
|
2013-02-10 21:54:47 +00:00
|
|
|
LastRefresh = GetTickCount(); // Don't care about 49.7 days rollback of GetTickCount()
|
|
|
|
KillTimer(hMainDialog, TID_REFRESH_TIMER);
|
|
|
|
GetUSBDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList)));
|
|
|
|
user_changed_label = FALSE;
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
case DBT_DEVNODES_CHANGED:
|
|
|
|
// If it's been more than a second since last device refresh, arm a refresh timer
|
|
|
|
if (GetTickCount() > LastRefresh + 1000) {
|
|
|
|
LastRefresh = GetTickCount();
|
|
|
|
SetTimer(hMainDialog, TID_REFRESH_TIMER, 1000, RefreshTimer);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2011-11-26 00:25:04 +00:00
|
|
|
}
|
|
|
|
break;
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
|
|
case WM_INITDIALOG:
|
2013-12-20 18:32:10 +00:00
|
|
|
PF_INIT(SHChangeNotifyRegister, shell32);
|
2015-09-24 22:59:10 +00:00
|
|
|
// Make sure fScale is set before the first call to apply localization, so that move/resize scale appropriately
|
|
|
|
hDC = GetDC(hDlg);
|
|
|
|
fScale = GetDeviceCaps(hDC, LOGPIXELSX) / 96.0f;
|
|
|
|
if (hDC != NULL)
|
|
|
|
ReleaseDC(hDlg, hDC);
|
2013-10-15 21:58:27 +00:00
|
|
|
apply_localization(IDD_DIALOG, hDlg);
|
2012-12-02 03:50:08 +00:00
|
|
|
SetUpdateCheck();
|
2015-09-16 23:20:22 +00:00
|
|
|
togo_mode = TRUE; // We display the ToGo controls by default and need to hide them
|
2012-05-30 23:32:25 +00:00
|
|
|
// Create the log window (hidden)
|
2013-10-24 21:57:34 +00:00
|
|
|
first_log_display = TRUE;
|
|
|
|
log_displayed = FALSE;
|
2015-07-03 22:42:45 +00:00
|
|
|
hLogDlg = MyCreateDialog(hMainInstance, IDD_LOG, hDlg, (DLGPROC)LogProc);
|
2012-02-02 13:16:49 +00:00
|
|
|
InitDialog(hDlg);
|
2012-02-16 23:40:31 +00:00
|
|
|
GetUSBDevices(0);
|
2012-12-06 01:40:44 +00:00
|
|
|
CheckForUpdates(FALSE);
|
2013-12-20 18:32:10 +00:00
|
|
|
// Register MEDIA_INSERTED/MEDIA_REMOVED notifications for card readers
|
|
|
|
if ((pfSHChangeNotifyRegister != NULL) && (SUCCEEDED(SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidlDesktop)))) {
|
|
|
|
NotifyEntry.pidl = pidlDesktop;
|
|
|
|
NotifyEntry.fRecursive = TRUE;
|
|
|
|
// NB: The following only works if the media is already formatted.
|
|
|
|
// If you insert a blank card, notifications will not be sent... :(
|
|
|
|
ulRegister = pfSHChangeNotifyRegister(hDlg, 0x0001|0x0002|0x8000,
|
|
|
|
SHCNE_MEDIAINSERTED|SHCNE_MEDIAREMOVED, UM_MEDIA_CHANGE, 1, &NotifyEntry);
|
|
|
|
}
|
2014-05-27 01:02:50 +00:00
|
|
|
// Bring our Window on top. We have to go through all *THREE* of these, or Far Manager hides our window :(
|
|
|
|
SetWindowPos(hMainDialog, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
SetWindowPos(hMainDialog, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
|
|
|
SetWindowPos(hMainDialog, HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE);
|
2014-11-20 22:57:22 +00:00
|
|
|
|
2015-04-19 03:15:44 +00:00
|
|
|
// Set 'Start' as the selected button if it's enabled, otherwise use 'Select ISO', instead
|
|
|
|
SendMessage(hDlg, WM_NEXTDLGCTL, (WPARAM)(IsWindowEnabled(hStart) ? hStart : hSelectISO), TRUE);
|
|
|
|
|
2014-11-28 00:00:59 +00:00
|
|
|
#if defined(ALPHA)
|
2014-11-20 22:57:22 +00:00
|
|
|
// Add a VERY ANNOYING popup for Alpha releases, so that people don't start redistributing them
|
2015-10-21 23:40:24 +00:00
|
|
|
MessageBoxA(NULL, "This is an Alpha version of " APPLICATION_NAME " - It is meant to be used for "
|
|
|
|
"testing ONLY and should NOT be distributed as a release.", "ALPHA VERSION", MSG_INFO);
|
2015-06-26 21:49:32 +00:00
|
|
|
#elif defined(TEST)
|
|
|
|
// Same thing for Test releases
|
2015-10-21 23:40:24 +00:00
|
|
|
MessageBoxA(NULL, "This is a Test version of " APPLICATION_NAME " - It is meant to be used for "
|
|
|
|
"testing ONLY and should NOT be distributed as a release.", "TEST VERSION", MSG_INFO);
|
2014-11-20 22:57:22 +00:00
|
|
|
#endif
|
2015-04-19 03:15:44 +00:00
|
|
|
return (INT_PTR)FALSE;
|
2011-11-13 20:53:23 +00:00
|
|
|
|
2015-07-02 21:46:26 +00:00
|
|
|
// The things one must do to get an ellipsis and text alignment on the status bar...
|
2011-12-08 12:14:21 +00:00
|
|
|
case WM_DRAWITEM:
|
|
|
|
if (wParam == IDC_STATUS) {
|
|
|
|
pDI = (DRAWITEMSTRUCT*)lParam;
|
2015-05-14 23:36:42 +00:00
|
|
|
pDI->rcItem.top -= (int)((4.0f * fScale) - 6.0f);
|
2015-07-02 21:46:26 +00:00
|
|
|
pDI->rcItem.left += (int)(((pDI->itemID == SB_SECTION_MIDDLE)?-2.0f:4.0f) * fScale);
|
2012-02-15 00:52:40 +00:00
|
|
|
SetBkMode(pDI->hDC, TRANSPARENT);
|
|
|
|
switch(pDI->itemID) {
|
2015-06-30 22:22:10 +00:00
|
|
|
case SB_SECTION_LEFT:
|
2015-06-21 16:59:59 +00:00
|
|
|
SetTextColor(pDI->hDC, GetSysColor(COLOR_BTNTEXT));
|
2012-02-15 00:52:40 +00:00
|
|
|
DrawTextExU(pDI->hDC, szStatusMessage, -1, &pDI->rcItem,
|
2012-05-30 23:32:25 +00:00
|
|
|
DT_LEFT|DT_END_ELLIPSIS|DT_PATH_ELLIPSIS, NULL);
|
2012-02-15 00:52:40 +00:00
|
|
|
return (INT_PTR)TRUE;
|
2015-06-30 22:22:10 +00:00
|
|
|
case SB_SECTION_RIGHT:
|
2012-02-15 00:52:40 +00:00
|
|
|
SetTextColor(pDI->hDC, GetSysColor(COLOR_3DSHADOW));
|
|
|
|
DrawTextExA(pDI->hDC, szTimer, -1, &pDI->rcItem, DT_LEFT, NULL);
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
}
|
2011-12-08 12:14:21 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
case WM_COMMAND:
|
2013-10-24 21:57:34 +00:00
|
|
|
if ((LOWORD(wParam) >= UM_LANGUAGE_MENU) && (LOWORD(wParam) < UM_LANGUAGE_MENU_MAX)) {
|
|
|
|
selected_language = LOWORD(wParam) - UM_LANGUAGE_MENU;
|
|
|
|
i = 0;
|
|
|
|
list_for_each_entry(lcmd, &locale_list, loc_cmd, list) {
|
|
|
|
if (i++ == selected_language) {
|
|
|
|
if (selected_locale != lcmd) {
|
|
|
|
selected_locale = lcmd;
|
2015-10-18 20:31:47 +00:00
|
|
|
selected_langid = get_language_id(lcmd);
|
2013-10-24 21:57:34 +00:00
|
|
|
relaunch = TRUE;
|
|
|
|
PostMessage(hDlg, WM_COMMAND, IDCANCEL, 0);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-11-13 20:53:23 +00:00
|
|
|
switch(LOWORD(wParam)) {
|
2011-11-21 20:12:23 +00:00
|
|
|
case IDOK: // close application
|
|
|
|
case IDCANCEL:
|
2014-05-12 21:44:10 +00:00
|
|
|
PF_INIT(SHChangeNotifyDeregister, Shell32);
|
2012-02-07 16:17:14 +00:00
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCANCEL), FALSE);
|
2012-02-07 02:05:58 +00:00
|
|
|
if (format_thid != NULL) {
|
2015-10-18 20:31:47 +00:00
|
|
|
if ((no_confirmation_on_cancel) || (MessageBoxExU(hMainDialog, lmprintf(MSG_105), lmprintf(MSG_049),
|
|
|
|
MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDYES)) {
|
2011-11-28 12:37:58 +00:00
|
|
|
// Operation may have completed in the meantime
|
2012-02-07 02:05:58 +00:00
|
|
|
if (format_thid != NULL) {
|
2011-11-28 12:37:58 +00:00
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANCELLED;
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_201);
|
|
|
|
uprintf("Cancelling");
|
2012-02-07 16:17:14 +00:00
|
|
|
// Start a timer to detect blocking operations during ISO file extraction
|
|
|
|
if (iso_blocking_status >= 0) {
|
|
|
|
last_iso_blocking_status = iso_blocking_status;
|
|
|
|
SetTimer(hMainDialog, TID_BLOCKING_TIMER, 3000, BlockingTimer);
|
|
|
|
}
|
2011-11-28 01:32:18 +00:00
|
|
|
}
|
2012-02-07 16:17:14 +00:00
|
|
|
} else {
|
|
|
|
EnableWindow(GetDlgItem(hDlg, IDCANCEL), TRUE);
|
2011-11-28 01:32:18 +00:00
|
|
|
}
|
2015-06-29 22:43:49 +00:00
|
|
|
no_confirmation_on_cancel = FALSE;
|
2011-11-28 01:32:18 +00:00
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
}
|
2013-12-20 18:32:10 +00:00
|
|
|
if ((pfSHChangeNotifyDeregister != NULL) && (ulRegister != 0))
|
|
|
|
pfSHChangeNotifyDeregister(ulRegister);
|
2011-11-21 20:12:23 +00:00
|
|
|
PostQuitMessage(0);
|
|
|
|
StrArrayDestroy(&DriveID);
|
2011-11-24 02:24:50 +00:00
|
|
|
StrArrayDestroy(&DriveLabel);
|
2011-11-21 20:25:32 +00:00
|
|
|
DestroyAllTooltips();
|
2013-10-24 21:57:34 +00:00
|
|
|
DestroyWindow(hLogDlg);
|
|
|
|
GetWindowRect(hDlg, &relaunch_rc);
|
2011-11-21 20:12:23 +00:00
|
|
|
EndDialog(hDlg, 0);
|
|
|
|
break;
|
2011-11-21 17:06:17 +00:00
|
|
|
case IDC_ABOUT:
|
|
|
|
CreateAboutBox();
|
|
|
|
break;
|
2012-05-30 23:32:25 +00:00
|
|
|
case IDC_LOG:
|
2014-01-24 02:46:06 +00:00
|
|
|
// Place the log Window to the right (or left for RTL) of our dialog on first display
|
2012-05-30 23:32:25 +00:00
|
|
|
if (first_log_display) {
|
|
|
|
GetClientRect(GetDesktopWindow(), &DesktopRect);
|
|
|
|
GetWindowRect(hLogDlg, &DialogRect);
|
|
|
|
nWidth = DialogRect.right - DialogRect.left;
|
|
|
|
nHeight = DialogRect.bottom - DialogRect.top;
|
|
|
|
GetWindowRect(hDlg, &DialogRect);
|
2015-02-08 00:38:21 +00:00
|
|
|
offset = GetSystemMetrics(SM_CXSIZEFRAME) + (int)(2.0f * fScale);
|
|
|
|
if (nWindowsVersion >= WINDOWS_10)
|
|
|
|
offset += (int)(-14.0f * fScale);
|
2014-01-24 02:46:06 +00:00
|
|
|
if (right_to_left_mode)
|
2015-02-08 00:38:21 +00:00
|
|
|
Point.x = max(DialogRect.left - offset - nWidth, 0);
|
2014-01-24 02:46:06 +00:00
|
|
|
else
|
2015-02-08 00:38:21 +00:00
|
|
|
Point.x = min(DialogRect.right + offset, DesktopRect.right - nWidth);
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2012-05-30 23:32:25 +00:00
|
|
|
Point.y = max(DialogRect.top, DesktopRect.top - nHeight);
|
|
|
|
MoveWindow(hLogDlg, Point.x, Point.y, nWidth, nHeight, FALSE);
|
2014-01-24 02:46:06 +00:00
|
|
|
// The log may have been recentered to fit the screen, in which case, try to shift our main dialog left (or right for RTL)
|
2013-06-25 21:50:22 +00:00
|
|
|
nWidth = DialogRect.right - DialogRect.left;
|
|
|
|
nHeight = DialogRect.bottom - DialogRect.top;
|
2014-01-24 02:46:06 +00:00
|
|
|
if (right_to_left_mode) {
|
|
|
|
Point.x = DialogRect.left;
|
|
|
|
GetWindowRect(hLogDlg, &DialogRect);
|
2015-02-08 00:38:21 +00:00
|
|
|
Point.x = max(Point.x, DialogRect.right - DialogRect.left + offset);
|
2014-01-24 02:46:06 +00:00
|
|
|
} else {
|
2015-02-08 00:38:21 +00:00
|
|
|
Point.x = max((DialogRect.left<0)?DialogRect.left:0, Point.x - offset - nWidth);
|
2014-01-24 02:46:06 +00:00
|
|
|
}
|
|
|
|
MoveWindow(hDlg, Point.x, Point.y, nWidth, nHeight, TRUE);
|
2012-05-30 23:32:25 +00:00
|
|
|
first_log_display = FALSE;
|
|
|
|
}
|
|
|
|
// Display the log Window
|
|
|
|
log_displayed = !log_displayed;
|
|
|
|
// Set focus on the start button
|
|
|
|
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
|
2015-04-19 03:15:44 +00:00
|
|
|
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)hStart, TRUE);
|
2013-06-25 21:50:22 +00:00
|
|
|
// Must come last for the log window to get focus
|
|
|
|
ShowWindow(hLogDlg, log_displayed?SW_SHOW:SW_HIDE);
|
2012-05-30 23:32:25 +00:00
|
|
|
break;
|
2012-02-01 14:26:36 +00:00
|
|
|
#ifdef RUFUS_TEST
|
2015-01-14 00:51:41 +00:00
|
|
|
case IDC_TEST:
|
2012-01-31 01:40:22 +00:00
|
|
|
break;
|
2012-02-01 14:26:36 +00:00
|
|
|
#endif
|
2012-05-16 22:38:39 +00:00
|
|
|
case IDC_ADVANCED:
|
2015-09-16 23:20:22 +00:00
|
|
|
advanced_mode = !advanced_mode;
|
|
|
|
WriteSettingBool(SETTING_ADVANCED_MODE, advanced_mode);
|
|
|
|
ToggleAdvanced(advanced_mode);
|
2012-05-16 22:38:39 +00:00
|
|
|
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
|
|
|
|
ComboBox_GetCurSel(hFileSystem));
|
|
|
|
break;
|
2012-11-04 21:39:25 +00:00
|
|
|
case IDC_LABEL:
|
|
|
|
if (HIWORD(wParam) == EN_CHANGE)
|
|
|
|
user_changed_label = TRUE;
|
|
|
|
break;
|
2011-11-24 02:24:50 +00:00
|
|
|
case IDC_DEVICE:
|
2012-03-03 23:12:48 +00:00
|
|
|
if (HIWORD(wParam) != CBN_SELCHANGE)
|
2011-11-18 23:41:28 +00:00
|
|
|
break;
|
2013-10-15 21:58:27 +00:00
|
|
|
nb_devices = ComboBox_GetCount(hDeviceList);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintStatusDebug(0, (nb_devices==1)?MSG_208:MSG_209, nb_devices);
|
2012-03-03 23:12:48 +00:00
|
|
|
PopulateProperties(ComboBox_GetCurSel(hDeviceList));
|
2012-11-03 17:40:33 +00:00
|
|
|
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
|
|
|
|
ComboBox_GetCurSel(hFileSystem));
|
2011-11-27 23:40:28 +00:00
|
|
|
break;
|
2012-02-07 23:16:15 +00:00
|
|
|
case IDC_NBPASSES:
|
2012-03-03 23:12:48 +00:00
|
|
|
if (HIWORD(wParam) != CBN_SELCHANGE)
|
|
|
|
break;
|
2013-01-25 01:38:10 +00:00
|
|
|
SetPassesTooltip();
|
2012-02-07 23:16:15 +00:00
|
|
|
break;
|
2013-10-15 21:58:27 +00:00
|
|
|
case IDC_PARTITION_TYPE:
|
2013-01-27 01:40:09 +00:00
|
|
|
if (HIWORD(wParam) != CBN_SELCHANGE)
|
|
|
|
break;
|
|
|
|
SetPartitionSchemeTooltip();
|
|
|
|
SetFSFromISO();
|
|
|
|
// fall-through
|
2011-12-01 02:56:44 +00:00
|
|
|
case IDC_FILESYSTEM:
|
2012-02-02 13:16:49 +00:00
|
|
|
if (HIWORD(wParam) != CBN_SELCHANGE)
|
|
|
|
break;
|
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
2015-07-01 20:26:15 +00:00
|
|
|
tt = GETTARGETTYPE((int)ComboBox_GetItemData(hPartitionScheme, ComboBox_GetCurSel(hPartitionScheme)));
|
|
|
|
if ((selection_default == BT_IMG) && IsChecked(IDC_BOOT)) {
|
2014-02-09 02:54:07 +00:00
|
|
|
ToggleImage(FALSE);
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableAdvancedBootOptions(FALSE, TRUE);
|
2015-07-01 20:26:15 +00:00
|
|
|
SetBoot(fs, tt);
|
2015-01-13 02:11:57 +00:00
|
|
|
SetToGo();
|
2014-02-09 02:54:07 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-02-02 13:16:49 +00:00
|
|
|
SetClusterSizes(fs);
|
2014-03-29 00:22:54 +00:00
|
|
|
// Disable/restore the quick format control depending on large FAT32 or ReFS
|
|
|
|
if ( ((fs == FS_FAT32) && ((SelectedDrive.DiskSize > LARGE_FAT32_SIZE) || (force_large_fat32))) || (fs == FS_REFS) ) {
|
2014-03-14 23:13:04 +00:00
|
|
|
if (IsWindowEnabled(GetDlgItem(hMainDialog, IDC_QUICKFORMAT))) {
|
2014-03-15 14:14:10 +00:00
|
|
|
uQFChecked = IsChecked(IDC_QUICKFORMAT);
|
2014-03-14 23:13:04 +00:00
|
|
|
CheckDlgButton(hMainDialog, IDC_QUICKFORMAT, BST_CHECKED);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), FALSE);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!IsWindowEnabled(GetDlgItem(hMainDialog, IDC_QUICKFORMAT))) {
|
|
|
|
CheckDlgButton(hMainDialog, IDC_QUICKFORMAT, uQFChecked);
|
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDC_QUICKFORMAT), TRUE);
|
|
|
|
}
|
|
|
|
}
|
2012-05-25 16:54:06 +00:00
|
|
|
if (fs < 0) {
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableBootOptions(TRUE, TRUE);
|
2012-05-25 16:54:06 +00:00
|
|
|
SetMBRProps();
|
2014-01-05 01:39:41 +00:00
|
|
|
// Remove the SysLinux and ReactOS options if they exists
|
2015-07-01 20:26:15 +00:00
|
|
|
if (ComboBox_GetItemData(hBootType, ComboBox_GetCount(hBootType)-1) == (BT_MAX-1)) {
|
|
|
|
for (i=BT_SYSLINUX_V4; i<BT_MAX; i++)
|
2014-01-05 01:39:41 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_DeleteString(hBootType, ComboBox_GetCount(hBootType)-1));
|
2013-01-24 21:30:11 +00:00
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 1));
|
2012-05-25 16:54:06 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2014-03-29 00:22:54 +00:00
|
|
|
if ((fs == FS_EXFAT) || (fs == FS_UDF) || (fs == FS_REFS)) {
|
2014-03-14 23:13:04 +00:00
|
|
|
if (IsWindowEnabled(hBoot)) {
|
|
|
|
// unlikely to be supported by BIOSes => don't bother
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hBootType, 0));
|
2014-03-15 14:14:10 +00:00
|
|
|
uBootChecked = IsChecked(IDC_BOOT);
|
2014-03-14 23:13:04 +00:00
|
|
|
CheckDlgButton(hDlg, IDC_BOOT, BST_UNCHECKED);
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableBootOptions(FALSE, TRUE);
|
|
|
|
} else if (IsChecked(IDC_BOOT)) {
|
2014-03-14 23:13:04 +00:00
|
|
|
uBootChecked = TRUE;
|
|
|
|
CheckDlgButton(hDlg, IDC_BOOT, BST_UNCHECKED);
|
|
|
|
}
|
2012-05-16 22:38:39 +00:00
|
|
|
SetMBRProps();
|
2012-02-02 13:16:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableAdvancedBootOptions(TRUE, TRUE);
|
2015-07-01 20:26:15 +00:00
|
|
|
SetBoot(fs, tt);
|
2012-05-16 22:38:39 +00:00
|
|
|
SetMBRProps();
|
2015-01-13 02:11:57 +00:00
|
|
|
SetToGo();
|
2012-02-16 11:37:59 +00:00
|
|
|
break;
|
2014-03-14 23:13:04 +00:00
|
|
|
case IDC_BOOT:
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableAdvancedBootOptions(TRUE, TRUE);
|
2015-07-01 20:26:15 +00:00
|
|
|
if (selection_default == BT_IMG)
|
2014-03-15 14:14:10 +00:00
|
|
|
ToggleImage(!IsChecked(IDC_BOOT));
|
2014-03-14 23:13:04 +00:00
|
|
|
break;
|
2013-01-24 21:30:11 +00:00
|
|
|
case IDC_BOOTTYPE:
|
2012-02-07 23:16:15 +00:00
|
|
|
if (HIWORD(wParam) != CBN_SELCHANGE)
|
|
|
|
break;
|
2013-01-24 21:30:11 +00:00
|
|
|
selection_default = (int) ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
2014-03-15 14:14:10 +00:00
|
|
|
EnableAdvancedBootOptions(TRUE, TRUE);
|
2015-07-01 20:26:15 +00:00
|
|
|
ToggleImage(!IsChecked(IDC_BOOT) || (selection_default != BT_IMG));
|
2015-01-13 02:11:57 +00:00
|
|
|
SetToGo();
|
2015-07-01 20:26:15 +00:00
|
|
|
if ((selection_default == BT_ISO) || (selection_default == BT_IMG)) {
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((image_path != NULL) && (img_report.label[0] != 0)) {
|
2012-11-04 21:39:25 +00:00
|
|
|
// Some distros (eg. Arch Linux) want to see a specific label => ignore user one
|
2015-09-02 22:20:00 +00:00
|
|
|
SetWindowTextU(hLabel, img_report.label);
|
2012-02-22 00:23:17 +00:00
|
|
|
}
|
2012-02-16 23:40:31 +00:00
|
|
|
} else {
|
2015-07-01 20:26:15 +00:00
|
|
|
if (selection_default == BT_UEFI_NTFS) {
|
2015-03-18 21:34:28 +00:00
|
|
|
// Try to select NTFS as default
|
|
|
|
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
|
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, i);
|
|
|
|
if (fs == FS_NTFS)
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
|
|
|
|
}
|
|
|
|
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
|
|
|
|
ComboBox_GetCurSel(hFileSystem));
|
|
|
|
}
|
2012-11-04 21:39:25 +00:00
|
|
|
// For non ISO, if the user manually set a label, try to preserve it
|
|
|
|
if (!user_changed_label)
|
|
|
|
SetWindowTextU(hLabel, SelectedDrive.proposed_label);
|
2012-05-16 22:38:39 +00:00
|
|
|
// Reset disk ID to 0x80 if Rufus MBR is used
|
|
|
|
IGNORE_RETVAL(ComboBox_SetCurSel(hDiskID, 0));
|
2011-12-01 02:56:44 +00:00
|
|
|
}
|
2012-02-16 11:37:59 +00:00
|
|
|
return (INT_PTR)TRUE;
|
2012-02-02 13:16:49 +00:00
|
|
|
case IDC_SELECT_ISO:
|
2013-02-04 01:14:28 +00:00
|
|
|
if (iso_provided) {
|
2014-05-22 00:52:25 +00:00
|
|
|
uprintf("Image provided: '%s'\n", image_path);
|
2013-02-04 01:14:28 +00:00
|
|
|
iso_provided = FALSE; // One off thing...
|
|
|
|
} else {
|
2014-05-22 00:52:25 +00:00
|
|
|
safe_free(image_path);
|
2015-07-06 21:04:38 +00:00
|
|
|
EnableWindow(hStatusToolbar, FALSE);
|
2015-07-01 20:26:15 +00:00
|
|
|
image_path = FileDialog(FALSE, NULL, (selection_default == BT_IMG)?&img_ext:&iso_ext, 0);
|
2014-05-22 00:52:25 +00:00
|
|
|
if (image_path == NULL) {
|
2013-10-15 21:58:27 +00:00
|
|
|
CreateTooltip(hSelectISO, lmprintf(MSG_173), -1);
|
2015-01-08 00:22:56 +00:00
|
|
|
PrintStatus(0, MSG_086);
|
2013-02-04 01:14:28 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-02-02 13:16:49 +00:00
|
|
|
}
|
|
|
|
FormatStatus = 0;
|
2012-12-06 01:40:44 +00:00
|
|
|
if (CreateThread(NULL, 0, ISOScanThread, NULL, 0, NULL) == NULL) {
|
2012-02-02 13:16:49 +00:00
|
|
|
uprintf("Unable to start ISO scanning thread");
|
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_START_THREAD);
|
|
|
|
}
|
|
|
|
break;
|
2015-01-22 22:31:34 +00:00
|
|
|
case IDC_WINDOWS_INSTALL:
|
2015-01-16 01:51:24 +00:00
|
|
|
case IDC_WINDOWS_TO_GO:
|
2015-02-03 00:28:08 +00:00
|
|
|
if ( (Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_INSTALL)) == BST_CHECKED) ||
|
|
|
|
(Button_GetCheck(GetDlgItem(hMainDialog, IDC_WINDOWS_TO_GO)) == BST_CHECKED) ) {
|
|
|
|
SetFSFromISO();
|
2015-01-22 22:31:34 +00:00
|
|
|
SetMBRProps();
|
2015-05-24 20:50:50 +00:00
|
|
|
SetMBRForUEFI(TRUE);
|
2015-01-16 01:51:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2012-05-25 16:54:06 +00:00
|
|
|
case IDC_RUFUS_MBR:
|
|
|
|
if ((HIWORD(wParam)) == BN_CLICKED)
|
|
|
|
mbr_selected_by_user = IsChecked(IDC_RUFUS_MBR);
|
|
|
|
break;
|
2013-06-03 20:32:22 +00:00
|
|
|
case IDC_ENABLE_FIXED_DISKS:
|
|
|
|
if ((HIWORD(wParam)) == BN_CLICKED) {
|
2013-11-14 01:21:50 +00:00
|
|
|
enable_HDDs = !enable_HDDs;
|
|
|
|
PrintStatus2000(lmprintf(MSG_253), enable_HDDs);
|
2013-06-03 20:32:22 +00:00
|
|
|
GetUSBDevices(0);
|
|
|
|
}
|
|
|
|
break;
|
2011-11-23 12:27:51 +00:00
|
|
|
case IDC_START:
|
2012-02-07 02:05:58 +00:00
|
|
|
if (format_thid != NULL) {
|
2011-11-27 23:40:28 +00:00
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
}
|
2012-02-01 14:26:36 +00:00
|
|
|
FormatStatus = 0;
|
2012-12-04 01:47:45 +00:00
|
|
|
format_op_in_progress = TRUE;
|
2015-06-29 22:43:49 +00:00
|
|
|
no_confirmation_on_cancel = FALSE;
|
2012-03-29 19:27:53 +00:00
|
|
|
// Reset all progress bars
|
|
|
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0);
|
|
|
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
|
|
|
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, 0, 0);
|
2014-02-09 02:54:07 +00:00
|
|
|
selection_default = (int)ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType));
|
2011-11-23 12:27:51 +00:00
|
|
|
nDeviceIndex = ComboBox_GetCurSel(hDeviceList);
|
|
|
|
if (nDeviceIndex != CB_ERR) {
|
2013-06-15 16:31:55 +00:00
|
|
|
if ((IsChecked(IDC_BOOT)) && (!BootCheck())) {
|
|
|
|
format_op_in_progress = FALSE;
|
2013-01-25 01:38:10 +00:00
|
|
|
break;
|
2013-06-15 16:31:55 +00:00
|
|
|
}
|
2013-10-31 22:59:53 +00:00
|
|
|
|
|
|
|
// Display a warning about UDF formatting times
|
|
|
|
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
|
|
|
|
if (fs == FS_UDF) {
|
|
|
|
dur_secs = (uint32_t)(((double)SelectedDrive.DiskSize)/1073741824.0f/UDF_FORMAT_SPEED);
|
|
|
|
if (dur_secs > UDF_FORMAT_WARN) {
|
|
|
|
dur_mins = dur_secs/60;
|
|
|
|
dur_secs -= dur_mins*60;
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(hMainDialog, lmprintf(MSG_112, dur_mins, dur_secs), lmprintf(MSG_113),
|
|
|
|
MB_OK|MB_ICONASTERISK|MB_IS_RTL, selected_langid);
|
2013-10-31 22:59:53 +00:00
|
|
|
} else {
|
|
|
|
dur_secs = 0;
|
|
|
|
dur_mins = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-08-22 14:18:25 +00:00
|
|
|
// Ask users how they want to write ISOHybrid images
|
2015-09-02 22:20:00 +00:00
|
|
|
if ((IsChecked(IDC_BOOT)) && (img_report.is_bootable_img) &&
|
2015-08-22 14:18:25 +00:00
|
|
|
(ComboBox_GetItemData(hBootType, ComboBox_GetCurSel(hBootType)) == BT_ISO)) {
|
|
|
|
char* iso_image = lmprintf(MSG_036);
|
|
|
|
char* dd_image = lmprintf(MSG_095);
|
|
|
|
i = Selection(lmprintf(MSG_274), lmprintf(MSG_275, iso_image, dd_image, iso_image, dd_image),
|
|
|
|
lmprintf(MSG_276, iso_image), lmprintf(MSG_277, dd_image));
|
|
|
|
if (i < 0) { // Cancel
|
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
break;
|
|
|
|
} else if (i == 2) {
|
|
|
|
selection_default = BT_IMG;
|
|
|
|
SetComboEntry(hBootType, selection_default);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-08 00:59:34 +00:00
|
|
|
GetWindowTextU(hDeviceList, tmp, ARRAYSIZE(tmp));
|
2015-10-18 20:31:47 +00:00
|
|
|
if (MessageBoxExU(hMainDialog, lmprintf(MSG_003, tmp),
|
|
|
|
APPLICATION_NAME, MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL) {
|
2013-06-15 16:31:55 +00:00
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2015-10-18 20:31:47 +00:00
|
|
|
if ((SelectedDrive.nPartitions > 1) && (MessageBoxExU(hMainDialog, lmprintf(MSG_093),
|
|
|
|
lmprintf(MSG_094), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) {
|
2014-01-14 20:17:07 +00:00
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2015-10-18 20:31:47 +00:00
|
|
|
if ((IsChecked(IDC_BOOT)) && (SelectedDrive.Geometry.BytesPerSector != 512) &&
|
|
|
|
(MessageBoxExU(hMainDialog, lmprintf(MSG_196, SelectedDrive.Geometry.BytesPerSector),
|
|
|
|
lmprintf(MSG_197), MB_OKCANCEL|MB_ICONWARNING|MB_IS_RTL, selected_langid) == IDCANCEL)) {
|
2015-01-08 23:21:08 +00:00
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
break;
|
|
|
|
}
|
2013-06-15 16:31:55 +00:00
|
|
|
|
|
|
|
// Disable all controls except cancel
|
|
|
|
EnableControls(FALSE);
|
|
|
|
DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex);
|
2015-11-04 13:58:19 +00:00
|
|
|
InitProgress(zero_drive);
|
2013-06-15 16:31:55 +00:00
|
|
|
format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL);
|
|
|
|
if (format_thid == NULL) {
|
|
|
|
uprintf("Unable to start formatting thread");
|
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|APPERR(ERROR_CANT_START_THREAD);
|
2015-06-29 22:43:49 +00:00
|
|
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
2011-11-24 02:24:50 +00:00
|
|
|
}
|
2013-06-15 16:31:55 +00:00
|
|
|
uprintf("\r\nFormat operation started");
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, -1);
|
2013-06-15 16:31:55 +00:00
|
|
|
timer = 0;
|
|
|
|
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00");
|
2015-06-30 22:22:10 +00:00
|
|
|
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
|
2013-06-15 16:31:55 +00:00
|
|
|
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
|
2011-11-23 12:27:51 +00:00
|
|
|
}
|
2012-12-04 01:47:45 +00:00
|
|
|
if (format_thid == NULL)
|
|
|
|
format_op_in_progress = FALSE;
|
2011-11-27 23:40:28 +00:00
|
|
|
break;
|
2015-07-02 21:46:26 +00:00
|
|
|
case IDC_HASH:
|
2015-07-06 21:04:38 +00:00
|
|
|
if ((format_thid == NULL) && (image_path != NULL)) {
|
2015-07-02 21:46:26 +00:00
|
|
|
FormatStatus = 0;
|
|
|
|
format_op_in_progress = TRUE;
|
|
|
|
no_confirmation_on_cancel = TRUE;
|
|
|
|
// Reset all progress bars
|
|
|
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0);
|
|
|
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
|
|
|
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, 0, 0);
|
|
|
|
// Disable all controls except cancel
|
|
|
|
EnableControls(FALSE);
|
|
|
|
InitProgress(FALSE);
|
|
|
|
format_thid = CreateThread(NULL, 0, SumThread, NULL, 0, NULL);
|
|
|
|
if (format_thid != NULL) {
|
|
|
|
PrintInfo(0, -1);
|
|
|
|
timer = 0;
|
|
|
|
safe_sprintf(szTimer, sizeof(szTimer), "00:00:00");
|
|
|
|
SendMessageA(hStatus, SB_SETTEXTA, SBT_OWNERDRAW | SB_SECTION_RIGHT, (LPARAM)szTimer);
|
|
|
|
SetTimer(hMainDialog, TID_APP_TIMER, 1000, ClockTimer);
|
|
|
|
} else {
|
|
|
|
uprintf("Unable to start checksum thread");
|
|
|
|
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | APPERR(ERROR_CANT_START_THREAD);
|
|
|
|
PostMessage(hMainDialog, UM_FORMAT_COMPLETED, (WPARAM)FALSE, 0);
|
|
|
|
format_op_in_progress = FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2011-11-13 20:53:23 +00:00
|
|
|
default:
|
|
|
|
return (INT_PTR)FALSE;
|
|
|
|
}
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (((LPNMHDR)lParam)->code) {
|
|
|
|
case TBN_DROPDOWN:
|
|
|
|
lpnmtb = (LPNMTOOLBAR)lParam;
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2015-04-18 07:04:29 +00:00
|
|
|
// We only care about the language button on the language toolbar
|
|
|
|
if (lpnmtb->hdr.hwndFrom == hLangToolbar
|
|
|
|
&& lpnmtb->iItem == lang_button_id) {
|
|
|
|
// Get toolbar button rect and map it to actual screen pixels
|
|
|
|
SendMessage(lpnmtb->hdr.hwndFrom, TB_GETRECT, (WPARAM)lpnmtb->iItem, (LPARAM)&LangToolbarRect);
|
|
|
|
MapWindowPoints(lpnmtb->hdr.hwndFrom, NULL, (POINT*)&LangToolbarRect, 2);
|
|
|
|
|
|
|
|
// Show the language menu such that it doesn't overlap the button
|
|
|
|
ShowLanguageMenu(LangToolbarRect);
|
|
|
|
return (INT_PTR)TBDDRET_DEFAULT;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
case WM_CLOSE:
|
2015-05-21 23:01:42 +00:00
|
|
|
case WM_ENDSESSION:
|
2012-02-07 02:05:58 +00:00
|
|
|
if (format_thid != NULL) {
|
2011-11-28 01:32:18 +00:00
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
}
|
2011-11-13 20:53:23 +00:00
|
|
|
PostQuitMessage(0);
|
|
|
|
break;
|
|
|
|
|
2015-01-01 23:39:28 +00:00
|
|
|
case UM_PROGRESS_INIT:
|
2015-02-02 21:16:53 +00:00
|
|
|
isMarquee = (wParam == PBS_MARQUEE);
|
|
|
|
if (isMarquee) {
|
2015-01-01 23:39:28 +00:00
|
|
|
progress_style = GetWindowLong(hProgress, GWL_STYLE);
|
|
|
|
SetWindowLong(hProgress, GWL_STYLE, progress_style | PBS_MARQUEE);
|
|
|
|
SendMessage(hProgress, PBM_SETMARQUEE, TRUE, 0);
|
|
|
|
} else {
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, 0, 0);
|
2013-12-27 16:06:59 +00:00
|
|
|
}
|
2015-01-01 23:39:28 +00:00
|
|
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
|
|
|
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2015-01-01 23:39:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case UM_PROGRESS_EXIT:
|
2015-02-02 21:16:53 +00:00
|
|
|
if (isMarquee) {
|
|
|
|
// Remove marquee style if previously set
|
|
|
|
progress_style = GetWindowLong(hProgress, GWL_STYLE);
|
|
|
|
SetWindowLong(hProgress, GWL_STYLE, progress_style & (~PBS_MARQUEE));
|
|
|
|
SetTaskbarProgressValue(0, MAX_PROGRESS);
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, 0, 0);
|
|
|
|
} else if (!IS_ERROR(FormatStatus)) {
|
|
|
|
SetTaskbarProgressValue(MAX_PROGRESS, MAX_PROGRESS);
|
|
|
|
// This is the only way to achieve instantaneous progress transition to 100%
|
|
|
|
SendMessage(hProgress, PBM_SETRANGE, 0, ((MAX_PROGRESS+1)<<16) & 0xFFFF0000);
|
|
|
|
SendMessage(hProgress, PBM_SETPOS, (MAX_PROGRESS+1), 0);
|
|
|
|
SendMessage(hProgress, PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
|
|
|
|
}
|
2015-01-01 23:39:28 +00:00
|
|
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_NORMAL, 0);
|
|
|
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
|
|
|
break;
|
2012-12-04 01:47:45 +00:00
|
|
|
|
2015-03-09 02:49:11 +00:00
|
|
|
case UM_NO_UPDATE:
|
|
|
|
Notification(MSG_INFO, NULL, lmprintf(MSG_243), lmprintf(MSG_247));
|
2015-05-08 22:37:22 +00:00
|
|
|
// Need to manually set focus back to "Check Now" for tabbing to work
|
|
|
|
SendMessage(hUpdatesDlg, WM_NEXTDLGCTL, (WPARAM)GetDlgItem(hUpdatesDlg, IDC_CHECK_NOW), TRUE);
|
2015-03-09 02:49:11 +00:00
|
|
|
break;
|
|
|
|
|
2011-11-27 23:40:28 +00:00
|
|
|
case UM_FORMAT_COMPLETED:
|
2012-02-07 02:05:58 +00:00
|
|
|
format_thid = NULL;
|
2011-12-08 12:14:21 +00:00
|
|
|
// Stop the timer
|
2011-12-09 01:39:13 +00:00
|
|
|
KillTimer(hMainDialog, TID_APP_TIMER);
|
2012-02-07 16:17:14 +00:00
|
|
|
// Close the cancel MessageBox and Blocking notification if active
|
2013-10-15 21:58:27 +00:00
|
|
|
SendMessage(FindWindowA(MAKEINTRESOURCEA(32770), lmprintf(MSG_049)), WM_COMMAND, IDNO, 0);
|
|
|
|
SendMessage(FindWindowA(MAKEINTRESOURCEA(32770), lmprintf(MSG_049)), WM_COMMAND, IDYES, 0);
|
2012-02-07 16:17:14 +00:00
|
|
|
EnableWindow(GetDlgItem(hMainDialog, IDCANCEL), TRUE);
|
2011-11-28 01:32:18 +00:00
|
|
|
EnableControls(TRUE);
|
2015-06-29 22:43:49 +00:00
|
|
|
if (wParam) {
|
|
|
|
uprintf("\r\n");
|
|
|
|
GetUSBDevices(DeviceNum);
|
|
|
|
}
|
2011-12-04 19:47:27 +00:00
|
|
|
if (!IS_ERROR(FormatStatus)) {
|
2013-07-05 22:58:04 +00:00
|
|
|
// This is the only way to achieve instantaneous progress transition to 100%
|
2013-01-09 21:54:28 +00:00
|
|
|
SendMessage(hProgress, PBM_SETRANGE, 0, ((MAX_PROGRESS+1)<<16) & 0xFFFF0000);
|
2012-03-29 17:16:06 +00:00
|
|
|
SendMessage(hProgress, PBM_SETPOS, (MAX_PROGRESS+1), 0);
|
2013-01-09 21:54:28 +00:00
|
|
|
SendMessage(hProgress, PBM_SETRANGE, 0, (MAX_PROGRESS<<16) & 0xFFFF0000);
|
2012-03-29 17:16:06 +00:00
|
|
|
SetTaskbarProgressState(TASKBAR_NOPROGRESS);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_210);
|
2011-12-04 19:47:27 +00:00
|
|
|
} else if (SCODE_CODE(FormatStatus) == ERROR_CANCELLED) {
|
2012-03-29 17:16:06 +00:00
|
|
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_PAUSED, 0);
|
|
|
|
SetTaskbarProgressState(TASKBAR_PAUSED);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_211);
|
2013-10-15 21:58:27 +00:00
|
|
|
Notification(MSG_INFO, NULL, lmprintf(MSG_211), lmprintf(MSG_041));
|
2011-12-04 19:47:27 +00:00
|
|
|
} else {
|
2012-03-29 17:16:06 +00:00
|
|
|
SendMessage(hProgress, PBM_SETSTATE, (WPARAM)PBST_ERROR, 0);
|
|
|
|
SetTaskbarProgressState(TASKBAR_ERROR);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintInfo(0, MSG_212);
|
2014-08-08 23:10:12 +00:00
|
|
|
Notification(MSG_ERROR, NULL, lmprintf(MSG_042), lmprintf(MSG_043, StrError(FormatStatus, FALSE)));
|
2011-12-04 19:47:27 +00:00
|
|
|
}
|
2012-12-04 01:47:45 +00:00
|
|
|
FormatStatus = 0;
|
|
|
|
format_op_in_progress = FALSE;
|
2011-11-27 23:40:28 +00:00
|
|
|
return (INT_PTR)TRUE;
|
2011-11-13 20:53:23 +00:00
|
|
|
}
|
|
|
|
return (INT_PTR)FALSE;
|
|
|
|
}
|
|
|
|
|
2013-02-04 01:14:28 +00:00
|
|
|
static void PrintUsage(char* appname)
|
|
|
|
{
|
|
|
|
char fname[_MAX_FNAME];
|
|
|
|
|
|
|
|
_splitpath(appname, NULL, NULL, fname, NULL);
|
2015-02-22 01:14:00 +00:00
|
|
|
printf("\nUsage: %s [-f] [-g] [-h] [-i PATH] [-l LOCALE] [-w TIMEOUT]\n", fname);
|
|
|
|
printf(" -f, --fixed\n");
|
|
|
|
printf(" Enable the listing of fixed/HDD USB drives\n");
|
|
|
|
printf(" -g, --gui\n");
|
|
|
|
printf(" Start in GUI mode (disable the 'rufus.com' commandline hogger)\n");
|
2013-02-04 23:15:11 +00:00
|
|
|
printf(" -i PATH, --iso=PATH\n");
|
|
|
|
printf(" Select the ISO image pointed by PATH to be used on startup\n");
|
2015-02-22 01:14:00 +00:00
|
|
|
printf(" -l LOCALE, --locale=LOCALE\n");
|
|
|
|
printf(" Select the locale to be used on startup\n");
|
2013-02-04 23:15:11 +00:00
|
|
|
printf(" -w TIMEOUT, --wait=TIMEOUT\n");
|
2015-02-22 01:14:00 +00:00
|
|
|
printf(" Wait TIMEOUT tens of seconds for the global application mutex to be released.\n");
|
2013-02-04 23:15:11 +00:00
|
|
|
printf(" Used when launching a newer version of " APPLICATION_NAME " from a running application.\n");
|
|
|
|
printf(" -h, --help\n");
|
|
|
|
printf(" This usage guide.\n");
|
2013-02-04 01:14:28 +00:00
|
|
|
}
|
|
|
|
|
2015-02-22 01:14:00 +00:00
|
|
|
static HANDLE SetHogger(BOOL attached_console, BOOL disable_hogger)
|
|
|
|
{
|
|
|
|
INPUT* input;
|
|
|
|
BYTE* hog_data;
|
|
|
|
DWORD hog_size, Size;
|
|
|
|
HANDLE hogmutex = NULL, hFile = NULL;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (!attached_console)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
hog_data = GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_XT_HOGGER),
|
|
|
|
_RT_RCDATA, cmdline_hogger, &hog_size, FALSE);
|
|
|
|
if ((hog_data != NULL) && (!disable_hogger)) {
|
|
|
|
// Create our synchronisation mutex
|
|
|
|
hogmutex = CreateMutexA(NULL, TRUE, "Global/Rufus_CmdLine");
|
|
|
|
|
|
|
|
// Extract the hogger resource
|
|
|
|
hFile = CreateFileA(cmdline_hogger, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
|
|
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
|
|
|
if (hFile != INVALID_HANDLE_VALUE) {
|
|
|
|
// coverity[check_return]
|
|
|
|
WriteFile(hFile, hog_data, hog_size, &Size, NULL);
|
|
|
|
}
|
|
|
|
safe_closehandle(hFile);
|
|
|
|
|
|
|
|
// Now launch the file from the commandline, by simulating keypresses
|
|
|
|
input = (INPUT*)calloc(strlen(cmdline_hogger)+1, sizeof(INPUT));
|
|
|
|
for (i=0; i<(int)strlen(cmdline_hogger); i++) {
|
|
|
|
input[i].type = INPUT_KEYBOARD;
|
|
|
|
input[i].ki.dwFlags = KEYEVENTF_UNICODE;
|
|
|
|
input[i].ki.wScan = (wchar_t)cmdline_hogger[i];
|
|
|
|
}
|
|
|
|
input[i].type = INPUT_KEYBOARD;
|
|
|
|
input[i].ki.wVk = VK_RETURN;
|
|
|
|
SendInput(i+1, input, sizeof(INPUT));
|
|
|
|
safe_free(input);
|
|
|
|
}
|
|
|
|
if (hogmutex != NULL)
|
|
|
|
Sleep(200); // Need to add a delay, otherwise we may get some printout before the hogger
|
|
|
|
return hogmutex;
|
|
|
|
}
|
|
|
|
|
2015-07-03 22:42:45 +00:00
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
/*
|
|
|
|
* Application Entrypoint
|
|
|
|
*/
|
2013-01-09 21:54:28 +00:00
|
|
|
#if defined(_MSC_VER) && (_MSC_VER >= 1600)
|
|
|
|
int WINAPI WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd)
|
|
|
|
#else
|
2011-11-13 20:53:23 +00:00
|
|
|
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
|
2013-01-09 21:54:28 +00:00
|
|
|
#endif
|
2011-11-13 20:53:23 +00:00
|
|
|
{
|
2014-01-05 01:39:41 +00:00
|
|
|
const char* rufus_loc = "rufus.loc";
|
2013-12-20 02:59:44 +00:00
|
|
|
int i, opt, option_index = 0, argc = 0, si = 0, lcid = GetUserDefaultUILanguage();
|
2015-07-03 22:42:45 +00:00
|
|
|
int wait_for_mutex = 0;
|
2015-01-25 00:56:38 +00:00
|
|
|
FILE* fd;
|
2015-02-22 01:14:00 +00:00
|
|
|
BOOL attached_console = FALSE, external_loc_file = FALSE, lgp_set = FALSE, automount, disable_hogger = FALSE;
|
|
|
|
BYTE *loc_data;
|
2015-07-03 22:42:45 +00:00
|
|
|
DWORD loc_size, size;
|
2015-01-25 00:56:38 +00:00
|
|
|
char tmp_path[MAX_PATH] = "", loc_file[MAX_PATH] = "", ini_path[MAX_PATH], ini_flags[] = "rb";
|
|
|
|
char *tmp, *locale_name = NULL, **argv = NULL;
|
2013-02-04 01:14:28 +00:00
|
|
|
wchar_t **wenv, **wargv;
|
2015-07-03 22:42:45 +00:00
|
|
|
PF_TYPE_DECL(CDECL, int, __wgetmainargs, (int*, wchar_t***, wchar_t***, int, int*));
|
2014-05-27 01:02:50 +00:00
|
|
|
HANDLE mutex = NULL, hogmutex = NULL, hFile = NULL;
|
2011-11-13 20:53:23 +00:00
|
|
|
HWND hDlg = NULL;
|
2015-09-27 18:59:28 +00:00
|
|
|
HDC hDC;
|
2011-11-13 20:53:23 +00:00
|
|
|
MSG msg;
|
2013-02-04 01:14:28 +00:00
|
|
|
struct option long_options[] = {
|
2015-02-22 01:14:00 +00:00
|
|
|
{"fixed", no_argument, NULL, 'f'},
|
|
|
|
{"gui", no_argument, NULL, 'g'},
|
2013-02-04 01:14:28 +00:00
|
|
|
{"help", no_argument, NULL, 'h'},
|
|
|
|
{"iso", required_argument, NULL, 'i'},
|
2015-02-22 01:14:00 +00:00
|
|
|
{"locale", required_argument, NULL, 'l'},
|
2013-02-04 01:14:28 +00:00
|
|
|
{"wait", required_argument, NULL, 'w'},
|
|
|
|
{0, 0, NULL, 0}
|
|
|
|
};
|
2011-11-13 20:53:23 +00:00
|
|
|
|
2013-06-06 22:40:37 +00:00
|
|
|
uprintf("*** " APPLICATION_NAME " init ***\n");
|
|
|
|
|
2013-02-04 01:14:28 +00:00
|
|
|
// Reattach the console, if we were started from commandline
|
|
|
|
if (AttachConsole(ATTACH_PARENT_PROCESS) != 0) {
|
|
|
|
attached_console = TRUE;
|
2013-02-04 23:15:11 +00:00
|
|
|
IGNORE_RETVAL(freopen("CONIN$", "r", stdin));
|
|
|
|
IGNORE_RETVAL(freopen("CONOUT$", "w", stdout));
|
|
|
|
IGNORE_RETVAL(freopen("CONOUT$", "w", stderr));
|
2013-02-04 01:14:28 +00:00
|
|
|
_flushall();
|
|
|
|
}
|
|
|
|
|
2013-10-15 21:58:27 +00:00
|
|
|
// We have to process the arguments before we acquire the lock and process the locale
|
2014-05-12 21:44:10 +00:00
|
|
|
PF_INIT(__wgetmainargs, Msvcrt);
|
2013-02-04 01:14:28 +00:00
|
|
|
if (pf__wgetmainargs != NULL) {
|
|
|
|
pf__wgetmainargs(&argc, &wargv, &wenv, 1, &si);
|
|
|
|
argv = (char**)calloc(argc, sizeof(char*));
|
2015-02-22 01:14:00 +00:00
|
|
|
|
|
|
|
// Non getopt parameter check
|
2013-02-04 01:14:28 +00:00
|
|
|
for (i=0; i<argc; i++) {
|
|
|
|
argv[i] = wchar_to_utf8(wargv[i]);
|
2015-02-22 01:14:00 +00:00
|
|
|
// Check for " /W" (wait for mutex release for pre 1.3.3 versions)
|
|
|
|
if (strcmp(argv[i], "/W") == 0)
|
2013-02-04 01:14:28 +00:00
|
|
|
wait_for_mutex = 150; // Try to acquire the mutex for 15 seconds
|
2015-02-22 01:14:00 +00:00
|
|
|
// We need to find if we need to disable the hogger BEFORE we start
|
|
|
|
// processing arguments with getopt, as we may want to print messages
|
|
|
|
// on the commandline then, which the hogger makes more intuitive.
|
|
|
|
if ((strcmp(argv[i], "-g") == 0) || (strcmp(argv[i], "--gui") == 0))
|
|
|
|
disable_hogger = TRUE;
|
2013-02-04 01:14:28 +00:00
|
|
|
}
|
|
|
|
|
2015-01-25 00:56:38 +00:00
|
|
|
// If our application name contains a 'p' (for "portable") create a 'rufus.ini'
|
2015-02-22 01:14:00 +00:00
|
|
|
// NB: argv[0] is populated in the previous loop
|
2015-01-25 00:56:38 +00:00
|
|
|
tmp = &argv[0][strlen(argv[0]) -1];
|
|
|
|
while ((((uintptr_t)tmp)>((uintptr_t)argv[0])) && (*tmp != '\\'))
|
|
|
|
tmp--;
|
2015-08-04 21:31:37 +00:00
|
|
|
if ((strchr(tmp, 'p') != NULL) || (strchr(tmp, 'P') != NULL))
|
2015-01-25 00:56:38 +00:00
|
|
|
ini_flags[0] = 'a';
|
|
|
|
|
2015-02-22 01:14:00 +00:00
|
|
|
// Now enable the hogger before processing the rest of the arguments
|
|
|
|
hogmutex = SetHogger(attached_console, disable_hogger);
|
|
|
|
|
|
|
|
while ((opt = getopt_long(argc, argv, "?fghi:w:l:", long_options, &option_index)) != EOF)
|
2013-02-04 01:14:28 +00:00
|
|
|
switch (opt) {
|
2013-06-25 01:55:25 +00:00
|
|
|
case 'f':
|
2013-11-14 01:21:50 +00:00
|
|
|
enable_HDDs = TRUE;
|
2013-06-25 01:55:25 +00:00
|
|
|
break;
|
2015-02-22 01:14:00 +00:00
|
|
|
case 'g':
|
|
|
|
// No need to reprocess that option
|
|
|
|
break;
|
2013-02-04 01:14:28 +00:00
|
|
|
case 'i':
|
|
|
|
if (_access(optarg, 0) != -1) {
|
2014-05-22 00:52:25 +00:00
|
|
|
image_path = safe_strdup(optarg);
|
2013-02-04 01:14:28 +00:00
|
|
|
iso_provided = TRUE;
|
|
|
|
} else {
|
|
|
|
printf("Could not find ISO image '%s'\n", optarg);
|
|
|
|
}
|
|
|
|
break;
|
2013-10-15 21:58:27 +00:00
|
|
|
case 'l':
|
2013-10-16 19:45:34 +00:00
|
|
|
if (isdigitU(optarg[0])) {
|
|
|
|
lcid = (int)strtol(optarg, NULL, 0);
|
|
|
|
} else {
|
2013-12-15 21:27:25 +00:00
|
|
|
safe_free(locale_name);
|
|
|
|
locale_name =safe_strdup(optarg);
|
2013-10-16 19:45:34 +00:00
|
|
|
}
|
2013-10-15 21:58:27 +00:00
|
|
|
break;
|
2013-02-04 01:14:28 +00:00
|
|
|
case 'w':
|
|
|
|
wait_for_mutex = atoi(optarg);
|
|
|
|
break;
|
|
|
|
case '?':
|
|
|
|
case 'h':
|
|
|
|
default:
|
|
|
|
PrintUsage(argv[0]);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
} else {
|
2015-06-27 21:12:30 +00:00
|
|
|
uprintf("Could not access UTF-16 args");
|
2013-02-04 01:14:28 +00:00
|
|
|
}
|
2012-12-06 01:40:44 +00:00
|
|
|
|
2015-08-22 22:23:08 +00:00
|
|
|
// Retrieve the current application directory as well as the system & sysnative dirs
|
2015-06-27 21:12:30 +00:00
|
|
|
if (GetCurrentDirectoryU(sizeof(app_dir), app_dir) == 0) {
|
|
|
|
uprintf("Could not get current directory: %s", WindowsErrorString());
|
|
|
|
app_dir[0] = 0;
|
|
|
|
}
|
|
|
|
if (GetSystemDirectoryU(system_dir, sizeof(system_dir)) == 0) {
|
|
|
|
uprintf("Could not get system directory: %s", WindowsErrorString());
|
|
|
|
safe_strcpy(system_dir, sizeof(system_dir), "C:\\Windows\\System32");
|
|
|
|
}
|
2015-08-22 22:23:08 +00:00
|
|
|
// Construct Sysnative ourselves as there is no GetSysnativeDirectory() call
|
|
|
|
// By default (64bit app running on 64 bit OS or 32 bit app running on 32 bit OS)
|
|
|
|
// Sysnative and System32 are the same
|
|
|
|
safe_strcpy(sysnative_dir, sizeof(sysnative_dir), system_dir);
|
|
|
|
// But if the app is 32 bit and the OS is 64 bit, Sysnative must differ from System32
|
2015-10-18 20:31:47 +00:00
|
|
|
#if (!defined(_WIN64) && !defined(BUILD64))
|
2015-08-22 22:23:08 +00:00
|
|
|
if (is_x64()) {
|
|
|
|
if (GetSystemWindowsDirectoryU(sysnative_dir, sizeof(sysnative_dir)) == 0) {
|
|
|
|
uprintf("Could not get Windows directory: %s", WindowsErrorString());
|
|
|
|
safe_strcpy(sysnative_dir, sizeof(sysnative_dir), "C:\\Windows");
|
|
|
|
}
|
|
|
|
safe_strcat(sysnative_dir, sizeof(sysnative_dir), "\\Sysnative");
|
|
|
|
}
|
|
|
|
#endif
|
2013-10-15 21:58:27 +00:00
|
|
|
|
2015-01-25 00:56:38 +00:00
|
|
|
// Look for a .ini file in the current app directory
|
|
|
|
static_sprintf(ini_path, "%s\\rufus.ini", app_dir);
|
|
|
|
fd = fopenU(ini_path, ini_flags); // Will create the file if portable mode is requested
|
|
|
|
if (fd != NULL) {
|
|
|
|
ini_file = ini_path;
|
|
|
|
fclose(fd);
|
|
|
|
}
|
|
|
|
uprintf("Will use settings from %s", (ini_file != NULL)?"INI file":"registry");
|
|
|
|
|
|
|
|
// Use the locale specified by the settings, if any
|
|
|
|
tmp = ReadSettingStr(SETTING_LOCALE);
|
|
|
|
if (tmp[0] != 0) {
|
|
|
|
locale_name = safe_strdup(tmp);
|
|
|
|
uprintf("found locale '%s'", locale_name);
|
|
|
|
}
|
|
|
|
|
2015-09-16 23:20:22 +00:00
|
|
|
// Restore user-saved settings
|
|
|
|
advanced_mode = ReadSettingBool(SETTING_ADVANCED_MODE);
|
|
|
|
preserve_timestamps = ReadSettingBool(SETTING_PRESERVE_TIMESTAMPS);
|
|
|
|
use_fake_units = !ReadSettingBool(SETTING_USE_PROPER_SIZE_UNITS);
|
|
|
|
usb_debug = ReadSettingBool(SETTING_ENABLE_USB_DEBUG);
|
|
|
|
detect_fakes = !ReadSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK);
|
|
|
|
allow_dual_uefi_bios = ReadSettingBool(SETTING_ENABLE_WIN_DUAL_EFI_BIOS);
|
|
|
|
force_large_fat32 = ReadSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT);
|
|
|
|
enable_vmdk = ReadSettingBool(SETTING_ENABLE_VMDK_DETECTION);
|
|
|
|
|
2015-09-27 18:59:28 +00:00
|
|
|
// Initialize the global scaling, in case we need it before we initialize the dialog
|
|
|
|
hDC = GetDC(NULL);
|
|
|
|
fScale = GetDeviceCaps(hDC, LOGPIXELSX) / 96.0f;
|
|
|
|
if (hDC != NULL)
|
|
|
|
ReleaseDC(NULL, hDC);
|
|
|
|
|
2013-10-15 21:58:27 +00:00
|
|
|
// Init localization
|
|
|
|
init_localization();
|
2015-10-18 20:31:47 +00:00
|
|
|
|
2013-10-15 21:58:27 +00:00
|
|
|
// Seek for a loc file in the current directory
|
2014-01-05 01:39:41 +00:00
|
|
|
if (GetFileAttributesU(rufus_loc) == INVALID_FILE_ATTRIBUTES) {
|
2013-10-15 21:58:27 +00:00
|
|
|
uprintf("loc file not found in current directory - embedded one will be used");
|
|
|
|
|
2013-11-01 19:17:46 +00:00
|
|
|
loc_data = (BYTE*)GetResource(hMainInstance, MAKEINTRESOURCEA(IDR_LC_RUFUS_LOC), _RT_RCDATA, "embedded.loc", &loc_size, FALSE);
|
2014-01-05 01:39:41 +00:00
|
|
|
if ( (GetTempPathU(sizeof(tmp_path), tmp_path) == 0)
|
|
|
|
|| (GetTempFileNameU(tmp_path, APPLICATION_NAME, 0, loc_file) == 0)
|
|
|
|
|| (loc_file[0] == 0) ) {
|
|
|
|
// Last ditch effort to get a loc file - just extract it to the current directory
|
|
|
|
safe_strcpy(loc_file, sizeof(loc_file), rufus_loc);
|
|
|
|
}
|
2013-10-15 21:58:27 +00:00
|
|
|
|
|
|
|
hFile = CreateFileU(loc_file, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE,
|
2014-11-11 19:17:39 +00:00
|
|
|
NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
|
2015-07-03 22:42:45 +00:00
|
|
|
if ((hFile == INVALID_HANDLE_VALUE) || (!WriteFile(hFile, loc_data, loc_size, &size, 0)) || (loc_size != size)) {
|
2013-10-15 21:58:27 +00:00
|
|
|
uprintf("localization: unable to extract '%s': %s.\n", loc_file, WindowsErrorString());
|
|
|
|
safe_closehandle(hFile);
|
2014-01-05 01:39:41 +00:00
|
|
|
goto out;
|
2013-10-15 21:58:27 +00:00
|
|
|
}
|
2014-01-05 01:39:41 +00:00
|
|
|
uprintf("localization: extracted data to '%s'\n", loc_file);
|
|
|
|
safe_closehandle(hFile);
|
2013-10-15 21:58:27 +00:00
|
|
|
} else {
|
2014-01-05 01:39:41 +00:00
|
|
|
safe_sprintf(loc_file, sizeof(loc_file), "%s\\%s", app_dir, rufus_loc);
|
2013-10-16 19:45:34 +00:00
|
|
|
external_loc_file = TRUE;
|
2013-10-15 21:58:27 +00:00
|
|
|
uprintf("using external loc file '%s'", loc_file);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( (!get_supported_locales(loc_file))
|
2013-10-18 22:08:49 +00:00
|
|
|
|| ((selected_locale = ((locale_name == NULL)?get_locale_from_lcid(lcid, TRUE):get_locale_from_name(locale_name, TRUE))) == NULL) ) {
|
2013-10-15 21:58:27 +00:00
|
|
|
uprintf("FATAL: Could not access locale!\n");
|
2014-05-27 01:02:50 +00:00
|
|
|
MessageBoxU(NULL, "The locale data is missing or invalid. This application will now exit.",
|
2015-10-18 20:31:47 +00:00
|
|
|
"Fatal error", MB_ICONSTOP|MB_SYSTEMMODAL);
|
2013-10-15 21:58:27 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2015-10-18 20:31:47 +00:00
|
|
|
selected_langid = get_language_id(selected_locale);
|
2013-10-15 21:58:27 +00:00
|
|
|
|
2012-12-06 01:40:44 +00:00
|
|
|
// Prevent 2 applications from running at the same time, unless "/W" is passed as an option
|
|
|
|
// in which case we wait for the mutex to be relinquished
|
|
|
|
if ((safe_strlen(lpCmdLine)==2) && (lpCmdLine[0] == '/') && (lpCmdLine[1] == 'W'))
|
|
|
|
wait_for_mutex = 150; // Try to acquire the mutex for 15 seconds
|
2013-06-06 22:40:37 +00:00
|
|
|
mutex = CreateMutexA(NULL, TRUE, "Global/" APPLICATION_NAME);
|
2012-12-06 01:40:44 +00:00
|
|
|
for (;(wait_for_mutex>0) && (mutex != NULL) && (GetLastError() == ERROR_ALREADY_EXISTS); wait_for_mutex--) {
|
|
|
|
CloseHandle(mutex);
|
|
|
|
Sleep(100);
|
2013-06-06 22:40:37 +00:00
|
|
|
mutex = CreateMutexA(NULL, TRUE, "Global/" APPLICATION_NAME);
|
2012-12-06 01:40:44 +00:00
|
|
|
}
|
|
|
|
if ((mutex == NULL) || (GetLastError() == ERROR_ALREADY_EXISTS)) {
|
2013-10-29 01:40:00 +00:00
|
|
|
// Load the translation before we print the error
|
2013-12-19 23:56:40 +00:00
|
|
|
get_loc_data_file(loc_file, selected_locale);
|
2015-10-18 20:31:47 +00:00
|
|
|
right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT);
|
2014-05-27 01:02:50 +00:00
|
|
|
// Set MB_SYSTEMMODAL to prevent Far Manager from stealing focus...
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(NULL, lmprintf(MSG_002), lmprintf(MSG_001), MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid);
|
2013-02-04 23:15:11 +00:00
|
|
|
goto out;
|
2011-11-13 20:53:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Save instance of the application for further reference
|
2011-11-18 23:41:28 +00:00
|
|
|
hMainInstance = hInstance;
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
|
|
// Initialize COM for folder selection
|
2013-01-09 21:54:28 +00:00
|
|
|
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED));
|
2011-11-13 20:53:23 +00:00
|
|
|
|
2012-11-29 02:59:52 +00:00
|
|
|
// Some dialogs have Rich Edit controls and won't display without this
|
2014-05-12 21:44:10 +00:00
|
|
|
if (GetLibraryHandle("Riched20") == NULL) {
|
2012-11-29 02:59:52 +00:00
|
|
|
uprintf("Could not load RichEdit library - some dialogs may not display: %s\n", WindowsErrorString());
|
|
|
|
}
|
|
|
|
|
2012-12-02 03:50:08 +00:00
|
|
|
// Set the Windows version
|
2013-11-05 02:16:49 +00:00
|
|
|
GetWindowsVersion();
|
2012-12-02 03:50:08 +00:00
|
|
|
|
2011-12-11 23:38:16 +00:00
|
|
|
// We use local group policies rather than direct registry manipulation
|
|
|
|
// 0x9e disables removable and fixed drive notifications
|
2013-12-28 16:48:02 +00:00
|
|
|
lgp_set = SetLGP(FALSE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0x9e);
|
2013-12-19 23:56:40 +00:00
|
|
|
|
2014-11-11 19:17:39 +00:00
|
|
|
if (nWindowsVersion > WINDOWS_XP) {
|
|
|
|
// Re-enable AutoMount if needed
|
|
|
|
if (!GetAutoMount(&automount)) {
|
|
|
|
uprintf("Could not get AutoMount status");
|
|
|
|
automount = TRUE; // So that we don't try to change its status on exit
|
|
|
|
} else if (!automount) {
|
|
|
|
uprintf("AutoMount was detected as disabled - temporary re-enabling it");
|
|
|
|
if (!SetAutoMount(TRUE))
|
|
|
|
uprintf("Failed to enable AutoMount");
|
|
|
|
}
|
|
|
|
}
|
2015-02-03 23:42:27 +00:00
|
|
|
srand((unsigned int)GetTickCount());
|
2014-11-11 19:17:39 +00:00
|
|
|
|
2013-10-24 21:57:34 +00:00
|
|
|
relaunch:
|
|
|
|
uprintf("localization: using locale '%s'\n", selected_locale->txt[0]);
|
2014-01-24 02:46:06 +00:00
|
|
|
right_to_left_mode = ((selected_locale->ctrl_id) & LOC_RIGHT_TO_LEFT);
|
|
|
|
SetProcessDefaultLayout(right_to_left_mode?LAYOUT_RTL:0);
|
2013-12-22 18:28:38 +00:00
|
|
|
if (get_loc_data_file(loc_file, selected_locale))
|
2015-01-25 00:56:38 +00:00
|
|
|
WriteSettingStr(SETTING_LOCALE, selected_locale->txt[0]);
|
2013-10-24 21:57:34 +00:00
|
|
|
|
2014-01-24 02:46:06 +00:00
|
|
|
/*
|
|
|
|
* Create the main Window
|
|
|
|
*/
|
2015-07-03 22:42:45 +00:00
|
|
|
hDlg = MyCreateDialog(hInstance, IDD_DIALOG, NULL, MainCallback);
|
2013-10-15 21:58:27 +00:00
|
|
|
if (hDlg == NULL) {
|
2015-10-18 20:31:47 +00:00
|
|
|
MessageBoxExU(NULL, "Could not create Window", "DialogBox failure",
|
|
|
|
MB_ICONSTOP|MB_IS_RTL|MB_SYSTEMMODAL, selected_langid);
|
2011-11-13 20:53:23 +00:00
|
|
|
goto out;
|
|
|
|
}
|
2013-10-24 21:57:34 +00:00
|
|
|
if ((relaunch_rc.left > -65536) && (relaunch_rc.top > -65536))
|
|
|
|
SetWindowPos(hDlg, HWND_TOP, relaunch_rc.left, relaunch_rc.top, 0, 0, SWP_NOSIZE);
|
2011-11-13 20:53:23 +00:00
|
|
|
ShowWindow(hDlg, SW_SHOWNORMAL);
|
|
|
|
UpdateWindow(hDlg);
|
|
|
|
|
2011-12-30 17:58:18 +00:00
|
|
|
// Do our own event processing and process "magic" commands
|
2011-11-13 20:53:23 +00:00
|
|
|
while(GetMessage(&msg, NULL, 0, 0)) {
|
2015-01-01 23:39:28 +00:00
|
|
|
|
|
|
|
// Ctrl-A => Select the log data
|
2015-10-18 20:31:47 +00:00
|
|
|
if ( (IsWindowVisible(hLogDlg)) && (GetKeyState(VK_CONTROL) & 0x8000) &&
|
2015-01-01 23:39:28 +00:00
|
|
|
(msg.message == WM_KEYDOWN) && (msg.wParam == 'A') ) {
|
|
|
|
// Might also need ES_NOHIDESEL property if you want to select when not active
|
|
|
|
SendMessage(hLog, EM_SETSEL, 0, -1);
|
|
|
|
}
|
2015-06-26 21:49:32 +00:00
|
|
|
// Alt-. => Enable USB enumeration debug
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_PERIOD)) {
|
|
|
|
usb_debug = !usb_debug;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_ENABLE_USB_DEBUG, usb_debug);
|
2015-06-26 21:49:32 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_270), usb_debug);
|
|
|
|
GetUSBDevices(0);
|
|
|
|
continue;
|
|
|
|
}
|
2015-10-01 21:22:20 +00:00
|
|
|
// Alt-, => Disable physical drive locking
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == VK_OEM_COMMA)) {
|
|
|
|
lock_drive = !lock_drive;
|
|
|
|
PrintStatus2000(lmprintf(MSG_282), lock_drive);
|
|
|
|
continue;
|
|
|
|
}
|
2015-01-01 23:39:28 +00:00
|
|
|
// Alt-B => Toggle fake drive detection during bad blocks check
|
|
|
|
// By default, Rufus will check for fake USB flash drives that mistakenly present
|
|
|
|
// more capacity than they already have by looping over the flash. This check which
|
|
|
|
// is enabled by default is performed by writing the block number sequence and reading
|
|
|
|
// it back during the bad block check.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'B')) {
|
|
|
|
detect_fakes = !detect_fakes;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK, !detect_fakes);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_256), detect_fakes);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt C => Force the update check to be successful
|
|
|
|
// This will set the reported current version of Rufus to 0.0.0.0 when performing an update
|
|
|
|
// check, so that it always succeeds. This is useful for translators.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'C')) {
|
|
|
|
force_update = !force_update;
|
|
|
|
PrintStatus2000(lmprintf(MSG_259), force_update);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-D => Delete the NoDriveTypeAutorun key on exit (useful if the app crashed)
|
|
|
|
// This key is used to disable Windows popup messages when an USB drive is plugged in.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'D')) {
|
|
|
|
PrintStatus(2000, MSG_255);
|
|
|
|
existing_key = FALSE;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-E => Enhanced installation mode (allow dual UEFI/BIOS mode and FAT32 for Windows)
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'E')) {
|
|
|
|
allow_dual_uefi_bios = !allow_dual_uefi_bios;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_ENABLE_WIN_DUAL_EFI_BIOS, !allow_dual_uefi_bios);
|
2015-01-12 00:53:09 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_266), allow_dual_uefi_bios);
|
2015-05-24 20:50:50 +00:00
|
|
|
SetMBRForUEFI(TRUE);
|
2015-01-01 23:39:28 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-F => Toggle detection of USB HDDs
|
|
|
|
// By default Rufus does not list USB HDDs. This is a safety feature aimed at avoiding
|
|
|
|
// unintentional formatting of backup drives instead of USB keys.
|
|
|
|
// When enabled, Rufus will list and allow the formatting of USB HDDs.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'F')) {
|
|
|
|
enable_HDDs = !enable_HDDs;
|
|
|
|
PrintStatus2000(lmprintf(MSG_253), enable_HDDs);
|
|
|
|
GetUSBDevices(0);
|
|
|
|
CheckDlgButton(hMainDialog, IDC_ENABLE_FIXED_DISKS, enable_HDDs?BST_CHECKED:BST_UNCHECKED);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-I => Toggle ISO support
|
2015-08-10 22:19:57 +00:00
|
|
|
// This is useful if you have an ISOHybrid image and you want to force Rufus to use
|
2015-01-01 23:39:28 +00:00
|
|
|
// DD-mode when writing the data.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'I')) {
|
|
|
|
enable_iso = !enable_iso;
|
|
|
|
PrintStatus2000(lmprintf(MSG_262), enable_iso);
|
|
|
|
if (image_path != NULL) {
|
|
|
|
iso_provided = TRUE;
|
2015-08-14 22:09:45 +00:00
|
|
|
dont_display_image_name = TRUE;
|
2015-08-10 22:19:57 +00:00
|
|
|
SendMessage(hDlg, WM_COMMAND, IDC_SELECT_ISO, 0);
|
2013-10-22 21:46:59 +00:00
|
|
|
}
|
2015-01-01 23:39:28 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt J => Toggle Joliet support for ISO9660 images
|
|
|
|
// Some ISOs (Ubuntu) have Joliet extensions but expect applications not to use them,
|
|
|
|
// due to their reliance on filenames that are > 64 chars (the Joliet max length for
|
|
|
|
// a file name). This option allows users to ignore Joliet when using such images.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'J')) {
|
|
|
|
enable_joliet = !enable_joliet;
|
|
|
|
PrintStatus2000(lmprintf(MSG_257), enable_joliet);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt K => Toggle Rock Ridge support for ISO9660 images
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'K')) {
|
|
|
|
enable_rockridge = !enable_rockridge;
|
|
|
|
PrintStatus2000(lmprintf(MSG_258), enable_rockridge);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-L => Force Large FAT32 format to be used on < 32 GB drives
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'L')) {
|
|
|
|
force_large_fat32 = !force_large_fat32;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT, force_large_fat32);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_254), force_large_fat32);
|
|
|
|
GetUSBDevices(0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt N => Enable NTFS compression
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'N')) {
|
|
|
|
enable_ntfs_compression = !enable_ntfs_compression;
|
|
|
|
PrintStatus2000(lmprintf(MSG_260), enable_ntfs_compression);
|
|
|
|
continue;
|
|
|
|
}
|
2015-01-25 00:56:38 +00:00
|
|
|
// Alt-R => Remove all the registry keys that may have been created by Rufus
|
2015-01-01 23:39:28 +00:00
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'R')) {
|
|
|
|
PrintStatus(2000, DeleteRegistryKey(REGKEY_HKCU, COMPANY_NAME "\\" APPLICATION_NAME)?MSG_248:MSG_249);
|
|
|
|
// Also try to delete the upper key (company name) if it's empty (don't care about the result)
|
|
|
|
DeleteRegistryKey(REGKEY_HKCU, COMPANY_NAME);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-S => Disable size limit for ISOs
|
|
|
|
// By default, Rufus will not copy ISOs that are larger than in size than
|
|
|
|
// the target USB drive. If this is enabled, the size check is disabled.
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'S')) {
|
|
|
|
size_check = !size_check;
|
|
|
|
PrintStatus2000(lmprintf(MSG_252), size_check);
|
|
|
|
GetUSBDevices(0);
|
|
|
|
continue;
|
|
|
|
}
|
2015-06-25 18:48:37 +00:00
|
|
|
// Alt-T => Preserve timestamps when extracting ISO files
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'T')) {
|
|
|
|
preserve_timestamps = !preserve_timestamps;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_PRESERVE_TIMESTAMPS, preserve_timestamps);
|
2015-06-25 18:48:37 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_269), preserve_timestamps);
|
|
|
|
continue;
|
|
|
|
}
|
2015-01-01 23:39:28 +00:00
|
|
|
// Alt-U => Use PROPER size units, instead of this whole Kibi/Gibi nonsense
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'U')) {
|
|
|
|
use_fake_units = !use_fake_units;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_USE_PROPER_SIZE_UNITS, !use_fake_units);
|
2015-01-01 23:39:28 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_263), !use_fake_units);
|
|
|
|
GetUSBDevices(0);
|
|
|
|
continue;
|
2012-02-01 14:26:36 +00:00
|
|
|
}
|
2015-06-07 21:51:54 +00:00
|
|
|
// Alt-V => Save selected device to *UNCOMPRESSED* VHD
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'V')) {
|
2015-08-14 22:09:45 +00:00
|
|
|
SaveVHD();
|
|
|
|
continue;
|
2015-06-07 21:51:54 +00:00
|
|
|
}
|
2015-01-08 00:22:56 +00:00
|
|
|
// Alt-W => Enable VMWare disk detection
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'W')) {
|
|
|
|
enable_vmdk = !enable_vmdk;
|
2015-09-16 23:20:22 +00:00
|
|
|
WriteSettingBool(SETTING_ENABLE_VMDK_DETECTION, enable_vmdk);
|
2015-02-16 22:29:23 +00:00
|
|
|
PrintStatus2000(lmprintf(MSG_265), enable_vmdk);
|
2015-01-08 00:22:56 +00:00
|
|
|
GetUSBDevices(0);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Alt-X => Delete the 'rufus_files' subdirectory
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'X')) {
|
|
|
|
static_sprintf(tmp_path, "%s\\%s", app_dir, FILES_DIR);
|
|
|
|
PrintStatus(2000, MSG_264, tmp_path);
|
|
|
|
SHDeleteDirectoryExU(NULL, tmp_path, FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION);
|
|
|
|
continue;
|
|
|
|
}
|
2015-11-04 13:58:19 +00:00
|
|
|
// Alt-Z => Zero the drive
|
|
|
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'Z')) {
|
|
|
|
zero_drive = TRUE;
|
|
|
|
// Simulate a button click for Start
|
|
|
|
PostMessage(hDlg, WM_COMMAND, (WPARAM)IDC_START, 0);
|
|
|
|
}
|
2015-04-19 03:15:44 +00:00
|
|
|
|
|
|
|
// Let the system handle dialog messages (e.g. those from the tab key)
|
|
|
|
if (!IsDialogMessage(hDlg, &msg) && !IsDialogMessage(hLogDlg, &msg)) {
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
2011-11-13 20:53:23 +00:00
|
|
|
}
|
2013-10-24 21:57:34 +00:00
|
|
|
if (relaunch) {
|
|
|
|
relaunch = FALSE;
|
|
|
|
reinit_localization();
|
|
|
|
goto relaunch;
|
|
|
|
}
|
2011-11-13 20:53:23 +00:00
|
|
|
|
|
|
|
out:
|
2014-06-01 23:51:35 +00:00
|
|
|
// Destroy the hogger mutex first, so that the cmdline app can exit and we can delete it
|
2015-02-22 01:14:00 +00:00
|
|
|
if (attached_console && !disable_hogger) {
|
2014-06-01 23:51:35 +00:00
|
|
|
ReleaseMutex(hogmutex);
|
|
|
|
safe_closehandle(hogmutex);
|
|
|
|
}
|
2013-10-16 19:45:34 +00:00
|
|
|
if ((!external_loc_file) && (loc_file[0] != 0))
|
2013-10-15 21:58:27 +00:00
|
|
|
DeleteFileU(loc_file);
|
2012-02-07 02:05:58 +00:00
|
|
|
DestroyAllTooltips();
|
2013-10-15 21:58:27 +00:00
|
|
|
exit_localization();
|
2014-05-22 00:52:25 +00:00
|
|
|
safe_free(image_path);
|
2013-12-15 21:27:25 +00:00
|
|
|
safe_free(locale_name);
|
2012-12-07 00:54:40 +00:00
|
|
|
safe_free(update.download_url);
|
|
|
|
safe_free(update.release_notes);
|
2015-02-02 21:16:53 +00:00
|
|
|
safe_free(grub2_buf);
|
2013-02-04 01:14:28 +00:00
|
|
|
if (argv != NULL) {
|
|
|
|
for (i=0; i<argc; i++) safe_free(argv[i]);
|
|
|
|
safe_free(argv);
|
|
|
|
}
|
2013-12-28 16:48:02 +00:00
|
|
|
if (lgp_set)
|
|
|
|
SetLGP(TRUE, &existing_key, "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", "NoDriveTypeAutorun", 0);
|
2014-11-11 19:17:39 +00:00
|
|
|
if ((nWindowsVersion > WINDOWS_XP) && (!automount) && (!SetAutoMount(FALSE)))
|
|
|
|
uprintf("Failed to restore AutoMount to disabled");
|
2014-05-27 01:02:50 +00:00
|
|
|
if (attached_console) {
|
|
|
|
SetWindowPos(GetConsoleWindow(), HWND_TOP, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
|
|
|
|
FreeConsole();
|
|
|
|
}
|
2014-06-03 21:16:40 +00:00
|
|
|
// Unconditional delete, just in case...
|
2014-05-27 01:02:50 +00:00
|
|
|
DeleteFileA(cmdline_hogger);
|
2011-11-13 20:53:23 +00:00
|
|
|
CloseHandle(mutex);
|
2014-05-12 21:44:10 +00:00
|
|
|
CLOSE_OPENED_LIBRARIES;
|
2013-06-06 22:40:37 +00:00
|
|
|
uprintf("*** " APPLICATION_NAME " exit ***\n");
|
2011-11-21 20:12:23 +00:00
|
|
|
#ifdef _CRTDBG_MAP_ALLOC
|
|
|
|
_CrtDumpMemoryLeaks();
|
|
|
|
#endif
|
|
|
|
|
2011-11-13 20:53:23 +00:00
|
|
|
return 0;
|
|
|
|
}
|