1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00
* closes #49
* closes #60
* closes #64
* should address #59
* set default doe ISOs with bot bootmgr and isolinux to syslinux
* other improvements
This commit is contained in:
Pete Batard 2012-03-03 23:12:48 +00:00
parent a9c47a4922
commit 7ee5b35551
11 changed files with 233 additions and 149 deletions

View file

@ -314,6 +314,7 @@ static BOOL ClearMBR(HANDLE hPhysicalDrive)
static BOOL WriteMBR(HANDLE hPhysicalDrive) static BOOL WriteMBR(HANDLE hPhysicalDrive)
{ {
BOOL r = FALSE; BOOL r = FALSE;
int dt, fs;
unsigned char* buf = NULL; unsigned char* buf = NULL;
size_t SecSize = SelectedDrive.Geometry.BytesPerSector; size_t SecSize = SelectedDrive.Geometry.BytesPerSector;
size_t nSecs = (0x200 + SecSize -1) / SecSize; size_t nSecs = (0x200 + SecSize -1) / SecSize;
@ -367,7 +368,9 @@ static BOOL WriteMBR(HANDLE hPhysicalDrive)
fake_fd._ptr = (char*)hPhysicalDrive; fake_fd._ptr = (char*)hPhysicalDrive;
fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector; fake_fd._bufsiz = SelectedDrive.Geometry.BytesPerSector;
if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_ISO_FAT) { fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
if ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) {
r = write_syslinux_mbr(&fake_fd); r = write_syslinux_mbr(&fake_fd);
} else { } else {
r = write_95b_mbr(&fake_fd); r = write_95b_mbr(&fake_fd);
@ -484,7 +487,7 @@ DWORD WINAPI FormatThread(LPVOID param)
char bb_msg[512]; char bb_msg[512];
char logfile[MAX_PATH], *userdir; char logfile[MAX_PATH], *userdir;
FILE* log_fd; FILE* log_fd;
int r; int r, fs, dt;
hPhysicalDrive = GetDriveHandle(num, NULL, TRUE, TRUE); hPhysicalDrive = GetDriveHandle(num, NULL, TRUE, TRUE);
if (hPhysicalDrive == INVALID_HANDLE_VALUE) { if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
@ -601,11 +604,10 @@ DWORD WINAPI FormatThread(LPVOID param)
} }
UpdateProgress(OP_FIX_MBR, -1.0f); UpdateProgress(OP_FIX_MBR, -1.0f);
fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
if (IsChecked(IDC_DOS)) { if (IsChecked(IDC_DOS)) {
switch(ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType))) { if ((dt == DT_WINME) || (dt == DT_FREEDOS) || ((dt == DT_ISO) && (fs == FS_NTFS))) {
case DT_WINME:
case DT_FREEDOS:
case DT_ISO_NTFS:
// We still have a lock, which we need to modify the volume boot record // We still have a lock, which we need to modify the volume boot record
// => no need to reacquire the lock... // => no need to reacquire the lock...
hLogicalVolume = GetDriveHandle(num, drive_name, TRUE, FALSE); hLogicalVolume = GetDriveHandle(num, drive_name, TRUE, FALSE);
@ -624,13 +626,11 @@ DWORD WINAPI FormatThread(LPVOID param)
} }
// We must close and unlock the volume to write files to it // We must close and unlock the volume to write files to it
safe_unlockclose(hLogicalVolume); safe_unlockclose(hLogicalVolume);
break; } else if ((dt == DT_ISO) && ((fs == FS_FAT16) || (fs == FS_FAT32))) {
case DT_ISO_FAT:
PrintStatus(0, TRUE, "Installing Syslinux..."); PrintStatus(0, TRUE, "Installing Syslinux...");
if (!InstallSyslinux(num, drive_name)) { if (!InstallSyslinux(num, drive_name)) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_INSTALL_FAILURE;
} }
break;
} }
} else { } else {
if (IsChecked(IDC_SET_ICON)) if (IsChecked(IDC_SET_ICON))
@ -645,18 +645,14 @@ DWORD WINAPI FormatThread(LPVOID param)
if (IsChecked(IDC_DOS)) { if (IsChecked(IDC_DOS)) {
UpdateProgress(OP_DOS, -1.0f); UpdateProgress(OP_DOS, -1.0f);
switch(ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType))) { if ((dt == DT_WINME) || (dt == DT_FREEDOS)) {
case DT_WINME:
case DT_FREEDOS:
PrintStatus(0, TRUE, "Copying DOS files..."); PrintStatus(0, TRUE, "Copying DOS files...");
if (!ExtractDOS(drive_name)) { if (!ExtractDOS(drive_name)) {
if (!FormatStatus) if (!FormatStatus)
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_CANNOT_COPY;
goto out; goto out;
} }
break; } else if (dt == DT_ISO) {
case DT_ISO_NTFS:
case DT_ISO_FAT:
if (iso_path != NULL) { if (iso_path != NULL) {
PrintStatus(0, TRUE, "Copying ISO files..."); PrintStatus(0, TRUE, "Copying ISO files...");
drive_name[2] = 0; drive_name[2] = 0;
@ -666,7 +662,6 @@ DWORD WINAPI FormatThread(LPVOID param)
goto out; goto out;
} }
} }
break;
} }
if (IsChecked(IDC_SET_ICON)) if (IsChecked(IDC_SET_ICON))
SetAutorun(drive_name); SetAutorun(drive_name);

View file

@ -177,7 +177,7 @@ static int udf_extract_files(udf_t *p_udf, udf_dirent_t *p_udf_dirent, const cha
goto out; goto out;
} }
if (udf_is_dir(p_udf_dirent)) { if (udf_is_dir(p_udf_dirent)) {
if (!scan_only) _mkdir(psz_fullpath); if (!scan_only) _mkdirU(psz_fullpath);
p_udf_dirent2 = udf_opendir(p_udf_dirent); p_udf_dirent2 = udf_opendir(p_udf_dirent);
if (p_udf_dirent2 != NULL) { if (p_udf_dirent2 != NULL) {
if (udf_extract_files(p_udf, p_udf_dirent2, &psz_fullpath[strlen(psz_extract_dir)])) if (udf_extract_files(p_udf, p_udf_dirent2, &psz_fullpath[strlen(psz_extract_dir)]))
@ -287,7 +287,7 @@ static int iso_extract_files(iso9660_t* p_iso, const char *psz_path)
continue; continue;
iso9660_name_translate_ext(p_statbuf->filename, psz_basename, i_joliet_level); iso9660_name_translate_ext(p_statbuf->filename, psz_basename, i_joliet_level);
if (p_statbuf->type == _STAT_DIR) { if (p_statbuf->type == _STAT_DIR) {
if (!scan_only) _mkdir(psz_fullpath); if (!scan_only) _mkdirU(psz_fullpath);
if (iso_extract_files(p_iso, psz_iso_name)) if (iso_extract_files(p_iso, psz_iso_name))
goto out; goto out;
} else { } else {

View file

@ -98,6 +98,12 @@ _cdio_memdup (const void *mem, size_t count);
char * char *
_cdio_strdup_upper (const char str[]); _cdio_strdup_upper (const char str[]);
/* Duplicate path and make it platform compliant. Typically needed for
MinGW/MSYS where a "/c/..." path must be translated to "c:/..." for
use with fopen(), etc. Returned string must be freed by the caller. */
char *
_cdio_strdup_fixpath (const char path[]);
void void
_cdio_strfreev(char **strv); _cdio_strfreev(char **strv);

View file

@ -56,11 +56,43 @@
#define CDIO_FSEEK fseek #define CDIO_FSEEK fseek
#endif #endif
/* Windows'd fopen is not UTF-8 compliant - make it so */
#if !defined(_WIN32)
#define CDIO_FOPEN fopen
#else
#define CDIO_FOPEN fopenU
extern wchar_t* cdio_utf8_to_wchar(const char* str);
static inline FILE* fopenU(const char* filename, const char* mode)
{
FILE* ret = NULL;
wchar_t* wfilename = cdio_utf8_to_wchar(filename);
wchar_t* wmode = cdio_utf8_to_wchar(mode);
ret = _wfopen(wfilename, wmode);
free(wfilename);
free(wmode);
return ret;
}
#endif
/* Use _stati64 if needed, on platforms that don't have transparent LFS support */ /* Use _stati64 if needed, on platforms that don't have transparent LFS support */
#if defined(HAVE__STATI64) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64) #if defined(HAVE__STATI64) && defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
#define CDIO_STAT _stati64 #define CDIO_STAT_STRUCT _stati64
#if !defined(_WIN32)
#define CDIO_STAT_CALL _stati64
#else #else
#define CDIO_STAT stat #define CDIO_STAT_CALL _stati64U
/* Once more, we have to provide an UTF-8 compliant version on Windows */
static inline int _stati64U(const char *path, struct _stati64 *buffer) {
int ret;
wchar_t* wpath = cdio_utf8_to_wchar(path);
ret = _wstati64(wpath, buffer);
free(wpath);
return ret;
}
#endif
#else
#define CDIO_STAT_STRUCT stat
#define CDIO_STAT_CALL stat
#endif #endif
#define _STRINGIFY(a) #a #define _STRINGIFY(a) #a
@ -82,7 +114,7 @@ _stdio_open (void *user_data)
{ {
_UserData *const ud = user_data; _UserData *const ud = user_data;
if ((ud->fd = fopen (ud->pathname, "rb"))) if ((ud->fd = CDIO_FOPEN (ud->pathname, "rb")))
{ {
ud->fd_buf = calloc (1, CDIO_STDIO_BUFSIZE); ud->fd_buf = calloc (1, CDIO_STDIO_BUFSIZE);
setvbuf (ud->fd, ud->fd_buf, _IOFBF, CDIO_STDIO_BUFSIZE); setvbuf (ud->fd, ud->fd_buf, _IOFBF, CDIO_STDIO_BUFSIZE);
@ -225,25 +257,18 @@ cdio_stdio_new(const char pathname[])
CdioDataSource_t *new_obj = NULL; CdioDataSource_t *new_obj = NULL;
cdio_stream_io_functions funcs = { NULL, NULL, NULL, NULL, NULL, NULL }; cdio_stream_io_functions funcs = { NULL, NULL, NULL, NULL, NULL, NULL };
_UserData *ud = NULL; _UserData *ud = NULL;
struct CDIO_STAT statbuf; struct CDIO_STAT_STRUCT statbuf;
char* pathdup; char* pathdup;
if (pathname == NULL) if (pathname == NULL)
return NULL; return NULL;
pathdup = strdup(pathname); /* MinGW may require a translated path */
pathdup = _cdio_strdup_fixpath(pathname);
if (pathdup == NULL) if (pathdup == NULL)
return NULL; return NULL;
#ifdef __MINGW32__ if (CDIO_STAT_CALL (pathdup, &statbuf) == -1)
/* _stati64 requires using native Windows paths => convert "/c/..." to "c:/..." */
if ((strlen(pathdup) > 3) && (pathdup[0] == '/') && (pathdup[2] == '/') && (isalpha(pathdup[1])))
{
pathdup[0] = pathdup[1];
pathdup[1] = ':';
}
#endif
if (CDIO_STAT (pathdup, &statbuf) == -1)
{ {
cdio_warn ("could not retrieve file info for `%s': %s", cdio_warn ("could not retrieve file info for `%s': %s",
pathdup, strerror (errno)); pathdup, strerror (errno));

View file

@ -23,7 +23,6 @@
# include "config.h" # include "config.h"
#endif #endif
#ifdef HAVE_JOLIET
#ifdef HAVE_STRING_H #ifdef HAVE_STRING_H
# include <string.h> # include <string.h>
#endif #endif
@ -43,7 +42,66 @@
#include <stdio.h> #include <stdio.h>
#endif #endif
// TODO: also remove the need for iconv on MinGW /* Windows requires some basic UTF-8 support outside of Joliet */
#if defined(_WIN32)
#include <windows.h>
#define wchar_to_utf8_no_alloc(wsrc, dest, dest_size) \
WideCharToMultiByte(CP_UTF8, 0, wsrc, -1, dest, dest_size, NULL, NULL)
#define utf8_to_wchar_no_alloc(src, wdest, wdest_size) \
MultiByteToWideChar(CP_UTF8, 0, src, -1, wdest, wdest_size)
/*
* Converts an UTF-16 string to UTF8 (allocate returned string)
* Returns NULL on error
*/
char* cdio_wchar_to_utf8(const wchar_t* wstr)
{
int size = 0;
char* str = NULL;
/* Find out the size we need to allocate for our converted string */
size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
if (size <= 1) /* An empty string would be size 1 */
return NULL;
if ((str = (char*)calloc(size, 1)) == NULL)
return NULL;
if (wchar_to_utf8_no_alloc(wstr, str, size) != size) {
free(str);
return NULL;
}
return str;
}
/*
* Converts an UTF8 string to UTF-16 (allocate returned string)
* Returns NULL on error
*/
wchar_t* cdio_utf8_to_wchar(const char* str)
{
int size = 0;
wchar_t* wstr = NULL;
/* Find out the size we need to allocate for our converted string */
size = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
if (size <= 1) /* An empty string would be size 1 */
return NULL;
if ((wstr = (wchar_t*)calloc(size, sizeof(wchar_t))) == NULL)
return NULL;
if (utf8_to_wchar_no_alloc(str, wstr, size) != size) {
free(wstr);
return NULL;
}
return wstr;
}
#endif
#ifdef HAVE_JOLIET
#ifdef HAVE_ICONV #ifdef HAVE_ICONV
#include <iconv.h> #include <iconv.h>
struct cdio_charset_coverter_s struct cdio_charset_coverter_s
@ -210,61 +268,6 @@ bool cdio_charset_to_utf8(char *src, size_t src_len, cdio_utf8_t **dst,
return result; return result;
} }
#elif defined(_WIN32) #elif defined(_WIN32)
#include <windows.h>
#define wchar_to_utf8_no_alloc(wsrc, dest, dest_size) \
WideCharToMultiByte(CP_UTF8, 0, wsrc, -1, dest, dest_size, NULL, NULL)
#define utf8_to_wchar_no_alloc(src, wdest, wdest_size) \
MultiByteToWideChar(CP_UTF8, 0, src, -1, wdest, wdest_size)
/*
* Converts an UTF-16 string to UTF8 (allocate returned string)
* Returns NULL on error
*/
static inline char* wchar_to_utf8(const wchar_t* wstr)
{
int size = 0;
char* str = NULL;
/* Find out the size we need to allocate for our converted string */
size = WideCharToMultiByte(CP_UTF8, 0, wstr, -1, NULL, 0, NULL, NULL);
if (size <= 1) /* An empty string would be size 1 */
return NULL;
if ((str = (char*)calloc(size, 1)) == NULL)
return NULL;
if (wchar_to_utf8_no_alloc(wstr, str, size) != size) {
free(str);
return NULL;
}
return str;
}
/*
* Converts an UTF8 string to UTF-16 (allocate returned string)
* Returns NULL on error
*/
static inline wchar_t* utf8_to_wchar(const char* str)
{
int size = 0;
wchar_t* wstr = NULL;
/* Find out the size we need to allocate for our converted string */
size = MultiByteToWideChar(CP_UTF8, 0, str, -1, NULL, 0);
if (size <= 1) /* An empty string would be size 1 */
return NULL;
if ((wstr = (wchar_t*)calloc(size, sizeof(wchar_t))) == NULL)
return NULL;
if (utf8_to_wchar_no_alloc(str, wstr, size) != size) {
free(wstr);
return NULL;
}
return wstr;
}
bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst, bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
int * dst_len, const char * dst_charset) int * dst_len, const char * dst_charset)
@ -276,7 +279,7 @@ bool cdio_charset_from_utf8(cdio_utf8_t * src, char ** dst,
return false; return false;
/* Eliminate empty strings */ /* Eliminate empty strings */
le_dst = utf8_to_wchar(src); le_dst = cdio_utf8_to_wchar(src);
if ((le_dst == NULL) || (le_dst[0] == 0)) { if ((le_dst == NULL) || (le_dst[0] == 0)) {
free(le_dst); free(le_dst);
return false; return false;
@ -323,7 +326,7 @@ bool cdio_charset_to_utf8(char *src, size_t src_len, cdio_utf8_t **dst,
((char*)le_src)[2*i+1] = src[2*i]; ((char*)le_src)[2*i+1] = src[2*i];
} }
le_src[src_len] = 0; le_src[src_len] = 0;
*dst = wchar_to_utf8(le_src); *dst = cdio_wchar_to_utf8(le_src);
free(le_src); free(le_src);
return (*dst != NULL); return (*dst != NULL);

View file

@ -38,6 +38,8 @@
#include "inttypes.h" #include "inttypes.h"
#endif #endif
#include <ctype.h>
#include "cdio_assert.h" #include "cdio_assert.h"
#include <cdio/types.h> #include <cdio/types.h>
#include <cdio/util.h> #include <cdio/util.h>
@ -136,6 +138,29 @@ _cdio_strdup_upper (const char str[])
return new_str; return new_str;
} }
/* Convert MinGW/MSYS paths that start in "/c/..." to "c:/..."
so that they can be used with fopen(), stat(), etc. */
char *
_cdio_strdup_fixpath (const char path[])
{
char *new_path = NULL;
if (path)
{
new_path = strdup (path);
#if defined(_WIN32)
if (new_path && (strlen (new_path) >= 3) && (new_path[0] == '/') &&
(new_path[2] == '/') && (isalpha (new_path[1])))
{
new_path[0] = new_path[1];
new_path[1] = ':';
}
#endif
}
return new_path;
}
uint8_t uint8_t
cdio_to_bcd8 (uint8_t n) cdio_to_bcd8 (uint8_t n)
{ {

View file

@ -24,6 +24,7 @@
#include <commdlg.h> #include <commdlg.h>
#include <shellapi.h> #include <shellapi.h>
#include <setupapi.h> #include <setupapi.h>
#include <direct.h>
#pragma once #pragma once
@ -618,6 +619,15 @@ static __inline char* getenvU(const char* varname)
return ret; return ret;
} }
static __inline int _mkdirU(const char* dirname)
{
wconvert(dirname);
int ret;
ret = _wmkdir(wdirname);
wfree(dirname);
return ret;
}
#ifdef __cplusplus #ifdef __cplusplus
} }
#endif #endif

View file

@ -63,10 +63,7 @@ char* get_token_data(const char* filename, const char* token)
goto out; goto out;
} }
fd = _wfopen(wfilename, L"r, ccs=UNICODE"); fd = _wfopen(wfilename, L"r, ccs=UNICODE");
if (fd == NULL) { if (fd == NULL) goto out;
uprintf("Could not open file '%s'\n", filename);
goto out;
}
// Process individual lines. NUL is always appended. // Process individual lines. NUL is always appended.
// Ideally, we'd check that our buffer fits the line // Ideally, we'd check that our buffer fits the line

View file

@ -46,6 +46,7 @@ static const char* ClusterSizeLabel[] = { "512 bytes", "1024 bytes","2048 bytes"
"1024 kilobytes","2048 kilobytes","4096 kilobytes","8192 kilobytes","16 megabytes","32 megabytes" }; "1024 kilobytes","2048 kilobytes","4096 kilobytes","8192 kilobytes","16 megabytes","32 megabytes" };
static BOOL existing_key = FALSE; // For LGP set/restore static BOOL existing_key = FALSE; // For LGP set/restore
static BOOL iso_size_check = TRUE; static BOOL iso_size_check = TRUE;
static int selection_default;
BOOL enable_fixed_disks = FALSE; BOOL enable_fixed_disks = FALSE;
/* /*
@ -387,19 +388,38 @@ static BOOL GetDriveInfo(void)
static void SetFSFromISO(void) static void SetFSFromISO(void)
{ {
int i, fs; int i, fs, selected_fs = FS_UNKNOWN;
uint32_t fs_mask = 0;
if (iso_path == NULL) if (iso_path == NULL)
return; return;
for (i=ComboBox_GetCount(hFileSystem)-1; i>=0; i--) { // Create a mask of all the FS's available
for (i=0; i<ComboBox_GetCount(hFileSystem); i++) {
fs = (int)ComboBox_GetItemData(hFileSystem, i); fs = (int)ComboBox_GetItemData(hFileSystem, i);
if ( ((iso_report.has_bootmgr) && (fs == FS_NTFS)) fs_mask |= 1<<fs;
|| ((iso_report.has_isolinux) && ((fs == FS_FAT32) || (fs == FS_FAT16))) ) { }
// Syslinux has precedence over bootmgr
if (iso_report.has_isolinux) {
if (fs_mask & (1<<FS_FAT32)) {
selected_fs = FS_FAT32;
} else if (fs_mask & (1<<FS_FAT16)) {
selected_fs = FS_FAT16;
}
} else if (iso_report.has_bootmgr) {
if (fs_mask & (1<<FS_NTFS)) {
selected_fs = FS_NTFS;
}
}
// 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)); IGNORE_RETVAL(ComboBox_SetCurSel(hFileSystem, i));
break;
}
} }
SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM, SendMessage(hMainDialog, WM_COMMAND, (CBN_SELCHANGE<<16) | IDC_FILESYSTEM,
ComboBox_GetCurSel(hFileSystem)); ComboBox_GetCurSel(hFileSystem));
} }
@ -1113,6 +1133,9 @@ void InitDialog(HWND hDlg)
safe_sprintf(tmp, sizeof(tmp), "Rufus (with FreeDOS)"); safe_sprintf(tmp, sizeof(tmp), "Rufus (with FreeDOS)");
tmp[20] = ' '; tmp[20] = ' ';
SetWindowTextA(hDlg, tmp); SetWindowTextA(hDlg, tmp);
selection_default = DT_FREEDOS;
} else {
selection_default = DT_WINME;
} }
// Create the status line // Create the status line
@ -1162,7 +1185,7 @@ void InitDialog(HWND hDlg)
static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam) static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{ {
DRAWITEMSTRUCT* pDI; DRAWITEMSTRUCT* pDI;
int nDeviceIndex, fs, dt; int nDeviceIndex, fs, i;
static DWORD DeviceNum = 0; static DWORD DeviceNum = 0;
wchar_t wtmp[128], wstr[MAX_PATH]; wchar_t wtmp[128], wstr[MAX_PATH];
static UINT uDOSChecked = BST_CHECKED; static UINT uDOSChecked = BST_CHECKED;
@ -1243,17 +1266,15 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
break; break;
#endif #endif
case IDC_DEVICE: case IDC_DEVICE:
switch (HIWORD(wParam)) { if (HIWORD(wParam) != CBN_SELCHANGE)
case CBN_SELCHANGE: break;
PrintStatus(0, TRUE, "%d device%s found.", ComboBox_GetCount(hDeviceList), PrintStatus(0, TRUE, "%d device%s found.", ComboBox_GetCount(hDeviceList),
(ComboBox_GetCount(hDeviceList)!=1)?"s":""); (ComboBox_GetCount(hDeviceList)!=1)?"s":"");
PopulateProperties(ComboBox_GetCurSel(hDeviceList)); PopulateProperties(ComboBox_GetCurSel(hDeviceList));
break; break;
}
break;
case IDC_NBPASSES: case IDC_NBPASSES:
switch (HIWORD(wParam)) { if (HIWORD(wParam) != CBN_SELCHANGE)
case CBN_SELCHANGE: break;
DestroyTooltip(hPassesToolTip); DestroyTooltip(hPassesToolTip);
switch(ComboBox_GetCurSel(hNBPasses)) { switch(ComboBox_GetCurSel(hNBPasses)) {
case 0: case 0:
@ -1269,7 +1290,6 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
hPassesToolTip = CreateTooltip(hNBPasses, "Pattern: 0x55, 0xAA, 0xFF, 0x00", -1); hPassesToolTip = CreateTooltip(hNBPasses, "Pattern: 0x55, 0xAA, 0xFF, 0x00", -1);
break; break;
} }
}
break; break;
case IDC_FILESYSTEM: case IDC_FILESYSTEM:
if (HIWORD(wParam) != CBN_SELCHANGE) if (HIWORD(wParam) != CBN_SELCHANGE)
@ -1293,15 +1313,18 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "MS-DOS"), DT_WINME)); IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "MS-DOS"), DT_WINME));
if (bWithFreeDOS) if (bWithFreeDOS)
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "FreeDOS"), DT_FREEDOS)); IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "FreeDOS"), DT_FREEDOS));
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO_FAT));
} }
if (fs == FS_NTFS) { IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO));
IGNORE_RETVAL(ComboBox_SetItemData(hDOSType, ComboBox_AddStringU(hDOSType, "ISO Image"), DT_ISO_NTFS)); if ((selection_default == DT_ISO) && (iso_path == NULL))
selection_default = (bWithFreeDOS)?DT_FREEDOS:DT_WINME;
for (i=0; i<ComboBox_GetCount(hDOSType); i++) {
if (ComboBox_GetItemData(hDOSType, i) == selection_default) {
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, i));
break;
} }
if (iso_path != NULL) }
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, ComboBox_GetCount(hDOSType) - 1)); if (i == ComboBox_GetCount(hDOSType))
else IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, 0));
IGNORE_RETVAL(ComboBox_SetCurSel(hDOSType, (bWithFreeDOS && (fs != FS_NTFS))?1:0));
if (!IsWindowEnabled(hDOS)) { if (!IsWindowEnabled(hDOS)) {
EnableWindow(hDOS, TRUE); EnableWindow(hDOS, TRUE);
EnableWindow(hDOSType, TRUE); EnableWindow(hDOSType, TRUE);
@ -1312,8 +1335,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
case IDC_DOSTYPE: case IDC_DOSTYPE:
if (HIWORD(wParam) != CBN_SELCHANGE) if (HIWORD(wParam) != CBN_SELCHANGE)
break; break;
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_ISO) {
if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) {
if ((iso_path == NULL) || (iso_report.label[0] == 0)) { if ((iso_path == NULL) || (iso_report.label[0] == 0)) {
// Set focus to the Select ISO button // Set focus to the Select ISO button
SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0); SendMessage(hMainDialog, WM_NEXTDLGCTL, (WPARAM)FALSE, 0);
@ -1336,6 +1358,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
hISOToolTip = CreateTooltip(hSelectISO, "Click to select...", -1); hISOToolTip = CreateTooltip(hSelectISO, "Click to select...", -1);
break; break;
} }
selection_default = DT_ISO;
hISOToolTip = CreateTooltip(hSelectISO, iso_path, -1); hISOToolTip = CreateTooltip(hSelectISO, iso_path, -1);
FormatStatus = 0; FormatStatus = 0;
// You'd think that Windows would let you instantiate a modeless dialog wherever // You'd think that Windows would let you instantiate a modeless dialog wherever
@ -1356,11 +1379,11 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
return (INT_PTR)TRUE; return (INT_PTR)TRUE;
} }
FormatStatus = 0; FormatStatus = 0;
selection_default = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType));
nDeviceIndex = ComboBox_GetCurSel(hDeviceList); nDeviceIndex = ComboBox_GetCurSel(hDeviceList);
if (nDeviceIndex != CB_ERR) { if (nDeviceIndex != CB_ERR) {
if (IsChecked(IDC_DOS)) { if (IsChecked(IDC_DOS)) {
dt = (int)ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)); if (ComboBox_GetItemData(hDOSType, ComboBox_GetCurSel(hDOSType)) == DT_ISO) {
if ((dt == DT_ISO_NTFS) || (dt == DT_ISO_FAT)) {
if (iso_path == NULL) { if (iso_path == NULL) {
MessageBoxA(hMainDialog, "Please click on the disc button to select a bootable ISO,\n" MessageBoxA(hMainDialog, "Please click on the disc button to select a bootable ISO,\n"
"or uncheck the \"Create a bootable disk...\" checkbox.", "or uncheck the \"Create a bootable disk...\" checkbox.",
@ -1372,13 +1395,14 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
"for the selected target.", "ISO image too big...", MB_OK|MB_ICONERROR); "for the selected target.", "ISO image too big...", MB_OK|MB_ICONERROR);
break; break;
} }
if ((dt == DT_ISO_NTFS) && (!iso_report.has_bootmgr)) { fs = (int)ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem));
if ((fs == FS_NTFS) && (!iso_report.has_bootmgr)) {
MessageBoxA(hMainDialog, "Only 'bootmgr' based ISO " MessageBoxA(hMainDialog, "Only 'bootmgr' based ISO "
"images can be used with NTFS.", "Unsupported ISO...", MB_OK|MB_ICONERROR); "images can currently be used with NTFS.", "Unsupported ISO...", MB_OK|MB_ICONERROR);
break; break;
} else if ((dt == DT_ISO_FAT) && (!iso_report.has_isolinux)) { } else if (((fs == FS_FAT16)||(fs == FS_FAT32)) && (!iso_report.has_isolinux)) {
MessageBoxA(hMainDialog, "Only 'isolinux' based ISO " MessageBoxA(hMainDialog, "Only 'isolinux' based ISO "
"images can be used with FAT.", "Unsupported ISO...", MB_OK|MB_ICONERROR); "images can currently be used with FAT.", "Unsupported ISO...", MB_OK|MB_ICONERROR);
break; break;
} }
} }

View file

@ -122,8 +122,7 @@ enum {
enum dos_type { enum dos_type {
DT_WINME = 0, DT_WINME = 0,
DT_FREEDOS, DT_FREEDOS,
DT_ISO_FAT, DT_ISO,
DT_ISO_NTFS,
DT_MAX DT_MAX
}; };

View file

@ -33,7 +33,7 @@ LANGUAGE LANG_ENGLISH, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 206, 289 IDD_DIALOG DIALOGEX 12, 12, 206, 289
STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_FIXEDSYS | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_APPWINDOW EXSTYLE WS_EX_APPWINDOW
CAPTION "Rufus v1.1.4.149" CAPTION "Rufus v1.1.4.150"
FONT 8, "MS Shell Dlg", 400, 0, 0x1 FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN BEGIN
DEFPUSHBUTTON "Start",IDC_START,94,248,50,14 DEFPUSHBUTTON "Start",IDC_START,94,248,50,14
@ -73,7 +73,7 @@ BEGIN
DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP DEFPUSHBUTTON "OK",IDOK,231,175,50,14,WS_GROUP
CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL, CONTROL "<a href=""http://rufus.akeo.ie"">http://rufus.akeo.ie</a>",IDC_ABOUT_RUFUS_URL,
"SysLink",WS_TABSTOP,46,47,114,9 "SysLink",WS_TABSTOP,46,47,114,9
LTEXT "Version 1.1.4 (Build 149)",IDC_STATIC,46,19,78,8 LTEXT "Version 1.1.4 (Build 150)",IDC_STATIC,46,19,78,8
PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP PUSHBUTTON "License...",IDC_ABOUT_LICENSE,46,175,50,14,WS_GROUP
EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL EDITTEXT IDC_ABOUT_COPYRIGHTS,46,107,235,63,ES_MULTILINE | ES_READONLY | WS_VSCROLL
LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8 LTEXT "Report bugs or request enhancements at:",IDC_STATIC,46,66,187,8
@ -223,8 +223,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,1,4,149 FILEVERSION 1,1,4,150
PRODUCTVERSION 1,1,4,149 PRODUCTVERSION 1,1,4,150
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -241,13 +241,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "akeo.ie" VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "1.1.4.149" VALUE "FileVersion", "1.1.4.150"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe" VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus" VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "1.1.4.149" VALUE "ProductVersion", "1.1.4.150"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"