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

[core] add a cheat mode to zero the USB device

* Alt-Z to zap!
* Also set rufus-next to 2.6
This commit is contained in:
Pete Batard 2015-11-04 13:58:19 +00:00
parent 521ffc11df
commit b66401b355
6 changed files with 89 additions and 26 deletions

20
configure vendored
View file

@ -1,6 +1,6 @@
#! /bin/sh #! /bin/sh
# Guess values for system-dependent variables and create Makefiles. # Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.69 for rufus 2.5. # Generated by GNU Autoconf 2.69 for rufus 2.6.
# #
# Report bugs to <https://github.com/pbatard/rufus/issues>. # Report bugs to <https://github.com/pbatard/rufus/issues>.
# #
@ -580,8 +580,8 @@ MAKEFLAGS=
# Identity of this package. # Identity of this package.
PACKAGE_NAME='rufus' PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus' PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='2.5' PACKAGE_VERSION='2.6'
PACKAGE_STRING='rufus 2.5' PACKAGE_STRING='rufus 2.6'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues' PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='http://rufus.akeo.ie' PACKAGE_URL='http://rufus.akeo.ie'
@ -1228,7 +1228,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing. # Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh. # This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF cat <<_ACEOF
\`configure' configures rufus 2.5 to adapt to many kinds of systems. \`configure' configures rufus 2.6 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]... Usage: $0 [OPTION]... [VAR=VALUE]...
@ -1294,7 +1294,7 @@ fi
if test -n "$ac_init_help"; then if test -n "$ac_init_help"; then
case $ac_init_help in case $ac_init_help in
short | recursive ) echo "Configuration of rufus 2.5:";; short | recursive ) echo "Configuration of rufus 2.6:";;
esac esac
cat <<\_ACEOF cat <<\_ACEOF
@ -1385,7 +1385,7 @@ fi
test -n "$ac_init_help" && exit $ac_status test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then if $ac_init_version; then
cat <<\_ACEOF cat <<\_ACEOF
rufus configure 2.5 rufus configure 2.6
generated by GNU Autoconf 2.69 generated by GNU Autoconf 2.69
Copyright (C) 2012 Free Software Foundation, Inc. Copyright (C) 2012 Free Software Foundation, Inc.
@ -1440,7 +1440,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake. running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 2.5, which was It was created by rufus $as_me 2.6, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
$ $0 $@ $ $0 $@
@ -2303,7 +2303,7 @@ fi
# Define the identity of the package. # Define the identity of the package.
PACKAGE='rufus' PACKAGE='rufus'
VERSION='2.5' VERSION='2.6'
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
@ -4480,7 +4480,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their # report actual input values of CONFIG_FILES etc. instead of their
# values after options handling. # values after options handling.
ac_log=" ac_log="
This file was extended by rufus $as_me 2.5, which was This file was extended by rufus $as_me 2.6, which was
generated by GNU Autoconf 2.69. Invocation command line was generated by GNU Autoconf 2.69. Invocation command line was
CONFIG_FILES = $CONFIG_FILES CONFIG_FILES = $CONFIG_FILES
@ -4534,7 +4534,7 @@ _ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
ac_cs_version="\\ ac_cs_version="\\
rufus config.status 2.5 rufus config.status 2.6
configured by $0, generated by GNU Autoconf 2.69, configured by $0, generated by GNU Autoconf 2.69,
with options \\"\$ac_cs_config\\" with options \\"\$ac_cs_config\\"

View file

@ -1,4 +1,4 @@
AC_INIT([rufus], [2.5], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie]) AC_INIT([rufus], [2.6], [https://github.com/pbatard/rufus/issues], [rufus], [http://rufus.akeo.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies]) AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c]) AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])

View file

@ -545,6 +545,7 @@ t MSG_283 "Invalid signature"
t MSG_284 "The downloaded executable is missing a digital signature." t MSG_284 "The downloaded executable is missing a digital signature."
t MSG_285 "The downloaded executable is signed by '%s'.\nThis is not a signature we recognize and could " t MSG_285 "The downloaded executable is signed by '%s'.\nThis is not a signature we recognize and could "
"indicate some form of malicious activity...\nAre you sure you want to run this file?" "indicate some form of malicious activity...\nAre you sure you want to run this file?"
t MSG_286 "Zeroing drive: %0.1f%% completed"
################################################################################ ################################################################################
############################# TRANSLATOR END COPY ############################## ############################# TRANSLATOR END COPY ##############################

View file

@ -59,7 +59,7 @@ static int task_number = 0;
extern const int nb_steps[FS_MAX]; extern const int nb_steps[FS_MAX];
extern uint32_t dur_mins, dur_secs; extern uint32_t dur_mins, dur_secs;
static int fs_index = 0; static int fs_index = 0;
extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive; extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive;
uint8_t *grub2_buf = NULL; uint8_t *grub2_buf = NULL;
long grub2_len; long grub2_len;
static BOOL WritePBR(HANDLE hLogicalDrive); static BOOL WritePBR(HANDLE hLogicalDrive);
@ -1577,12 +1577,14 @@ DWORD WINAPI FormatThread(void* param)
} }
CHECK_FOR_USER_CANCEL; CHECK_FOR_USER_CANCEL;
if (!zero_drive) {
PrintInfoDebug(0, MSG_226); PrintInfoDebug(0, MSG_226);
AnalyzeMBR(hPhysicalDrive, "Drive"); AnalyzeMBR(hPhysicalDrive, "Drive");
if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) { if ((hLogicalVolume != NULL) && (hLogicalVolume != INVALID_HANDLE_VALUE)) {
AnalyzePBR(hLogicalVolume); AnalyzePBR(hLogicalVolume);
} }
UpdateProgress(OP_ANALYZE_MBR, -1.0f); UpdateProgress(OP_ANALYZE_MBR, -1.0f);
}
// Zap any existing partitions. This helps prevent access errors. // Zap any existing partitions. This helps prevent access errors.
// As this creates issues with FAT16 formatted MS drives, only do this for other filesystems // As this creates issues with FAT16 formatted MS drives, only do this for other filesystems
@ -1591,9 +1593,61 @@ DWORD WINAPI FormatThread(void* param)
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE; FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_PARTITION_FAILURE;
goto out; goto out;
} }
CreateThread(NULL, 0, CloseFormatPromptThread, NULL, 0, NULL); CreateThread(NULL, 0, CloseFormatPromptThread, NULL, 0, NULL);
if (IsChecked(IDC_BADBLOCKS)) {
// TODO: factorize this with DD write?
if (zero_drive) {
li.QuadPart = 0;
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
uprintf("Zeroing drive...");
// Our buffer size must be a multiple of the sector size
BufSize = ((DD_BUFFER_SIZE + SectorSize - 1) / SectorSize) * SectorSize;
buffer = (uint8_t*)calloc(BufSize + SectorSize, 1); // +1 sector for align
if (buffer == NULL) {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_NOT_ENOUGH_MEMORY;
uprintf("could not allocate zeroing buffer");
goto out;
}
// http://msdn.microsoft.com/en-us/library/windows/desktop/aa365747.aspx does buffer sector alignment
aligned_buffer = ((void *)((((uintptr_t)(buffer)) + (SectorSize)-1) & (~(((uintptr_t)(SectorSize)) - 1))));
for (wb = 0, wSize = 0; wb < (uint64_t)SelectedDrive.DiskSize; wb += wSize) {
if (GetTickCount() > LastRefresh + 25) {
LastRefresh = GetTickCount();
format_percent = (100.0f*wb) / (1.0f*SelectedDrive.DiskSize);
PrintInfo(0, MSG_286, format_percent);
UpdateProgress(OP_FORMAT, format_percent);
}
// Don't overflow our projected size
if (wb + BufSize > (uint64_t)SelectedDrive.DiskSize) {
BufSize = (DWORD)(SelectedDrive.DiskSize - wb);
}
// WriteFile fails unless the size is a multiple of sector size
if (BufSize % SectorSize != 0)
BufSize = ((BufSize + SectorSize - 1) / SectorSize) * SectorSize;
for (i = 0; i < WRITE_RETRIES; i++) {
CHECK_FOR_USER_CANCEL;
s = WriteFile(hPhysicalDrive, aligned_buffer, BufSize, &wSize, NULL);
if ((s) && (wSize == BufSize))
break;
if (s)
uprintf("write error: Wrote %d bytes, expected %d bytes\n", wSize, BufSize);
else
uprintf("write error: %s", WindowsErrorString());
if (i < WRITE_RETRIES - 1) {
li.QuadPart = wb;
SetFilePointerEx(hPhysicalDrive, li, NULL, FILE_BEGIN);
uprintf(" RETRYING...\n");
}
else {
FormatStatus = ERROR_SEVERITY_ERROR | FAC(FACILITY_STORAGE) | ERROR_WRITE_FAULT;
goto out;
}
}
if (i >= WRITE_RETRIES) goto out;
}
RefreshDriveLayout(hPhysicalDrive);
goto out;
} else if (IsChecked(IDC_BADBLOCKS)) {
do { do {
// create a log file for bad blocks report. Since %USERPROFILE% may // create a log file for bad blocks report. Since %USERPROFILE% may
// have localized characters, we use the UTF-8 API. // have localized characters, we use the UTF-8 API.
@ -1954,6 +2008,7 @@ DWORD WINAPI FormatThread(void* param)
} }
out: out:
zero_drive = FALSE;
safe_free(guid_volume); safe_free(guid_volume);
safe_free(buffer); safe_free(buffer);
safe_closehandle(hSourceImage); safe_closehandle(hSourceImage);

View file

@ -141,6 +141,7 @@ BOOL use_own_c32[NB_OLD_C32] = {FALSE, FALSE}, mbr_selected_by_user = FALSE, tog
BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE; BOOL iso_op_in_progress = FALSE, format_op_in_progress = FALSE, right_to_left_mode = FALSE;
BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE; BOOL enable_HDDs = FALSE, force_update = FALSE, enable_ntfs_compression = FALSE, no_confirmation_on_cancel = FALSE, lock_drive = TRUE;
BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps; BOOL advanced_mode, allow_dual_uefi_bios, detect_fakes, enable_vmdk, force_large_fat32, usb_debug, use_fake_units, preserve_timestamps;
BOOL zero_drive = FALSE;
int dialog_showing = 0, lang_button_id = 0; int dialog_showing = 0, lang_button_id = 0;
uint16_t rufus_version[3], embedded_sl_version[2]; uint16_t rufus_version[3], embedded_sl_version[2];
char embedded_sl_version_str[2][12] = { "?.??", "?.??" }; char embedded_sl_version_str[2][12] = { "?.??", "?.??" };
@ -2514,7 +2515,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA
// Disable all controls except cancel // Disable all controls except cancel
EnableControls(FALSE); EnableControls(FALSE);
DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex); DeviceNum = (DWORD)ComboBox_GetItemData(hDeviceList, nDeviceIndex);
InitProgress(FALSE); InitProgress(zero_drive);
format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL); format_thid = CreateThread(NULL, 0, FormatThread, (LPVOID)(uintptr_t)DeviceNum, 0, NULL);
if (format_thid == NULL) { if (format_thid == NULL) {
uprintf("Unable to start formatting thread"); uprintf("Unable to start formatting thread");
@ -3173,6 +3174,12 @@ relaunch:
SHDeleteDirectoryExU(NULL, tmp_path, FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION); SHDeleteDirectoryExU(NULL, tmp_path, FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMATION);
continue; continue;
} }
// 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);
}
// Let the system handle dialog messages (e.g. those from the tab key) // Let the system handle dialog messages (e.g. those from the tab key)
if (!IsDialogMessage(hDlg, &msg) && !IsDialogMessage(hLogDlg, &msg)) { if (!IsDialogMessage(hDlg, &msg) && !IsDialogMessage(hLogDlg, &msg)) {

View file

@ -32,7 +32,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376 IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
CAPTION "Rufus 2.5.801" CAPTION "Rufus 2.6.802"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0 FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -319,8 +319,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,5,801,0 FILEVERSION 2,6,802,0
PRODUCTVERSION 2,5,801,0 PRODUCTVERSION 2,6,802,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -337,13 +337,13 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus" VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.5.801" VALUE "FileVersion", "2.6.802"
VALUE "InternalName", "Rufus" VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2015 Pete Batard (GPL v3)" VALUE "LegalCopyright", "© 2011-2015 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", "2.5.801" VALUE "ProductVersion", "2.6.802"
END END
END END
BLOCK "VarFileInfo" BLOCK "VarFileInfo"