From 43d9ac046b376d4b9c7612d4395234e108b1d177 Mon Sep 17 00:00:00 2001 From: Pete Batard Date: Tue, 26 Apr 2016 14:57:07 +0200 Subject: [PATCH] [core] don't list non-USB removable devices by default * Unless specifically requested with Ctrl-Alt-H * Closes #727 * Also rename usb.c to dev.c, since we may be listing more than USB devices --- src/.msvc/rufus.vcxproj | 4 ++-- src/.msvc/rufus.vcxproj.filters | 12 ++++++------ src/.msvc/rufus_sources | 2 +- src/Makefile.am | 4 ++-- src/Makefile.in | 28 ++++++++++++++-------------- src/{usb.c => dev.c} | 16 ++++++++++------ src/{usb.h => dev.h} | 2 +- src/rufus.c | 22 +++++++++++----------- src/rufus.h | 2 +- src/rufus.rc | 10 +++++----- 10 files changed, 53 insertions(+), 49 deletions(-) rename src/{usb.c => dev.c} (98%) rename src/{usb.h => dev.h} (99%) diff --git a/src/.msvc/rufus.vcxproj b/src/.msvc/rufus.vcxproj index 82fc4a9c..6d337200 100644 --- a/src/.msvc/rufus.vcxproj +++ b/src/.msvc/rufus.vcxproj @@ -200,7 +200,7 @@ - + @@ -224,7 +224,7 @@ - + diff --git a/src/.msvc/rufus.vcxproj.filters b/src/.msvc/rufus.vcxproj.filters index 41f2ae8a..2ccf6621 100644 --- a/src/.msvc/rufus.vcxproj.filters +++ b/src/.msvc/rufus.vcxproj.filters @@ -66,15 +66,15 @@ Source Files - - Source Files - Source Files Source Files + + Source Files + @@ -128,9 +128,6 @@ Header Files - - Header Files - Header Files @@ -140,6 +137,9 @@ Header Files + + Header Files + diff --git a/src/.msvc/rufus_sources b/src/.msvc/rufus_sources index 46ab8b7f..86409c87 100644 --- a/src/.msvc/rufus_sources +++ b/src/.msvc/rufus_sources @@ -36,6 +36,7 @@ SXS_APPLICATION_MANIFEST=..\rufus.manifest SOURCES=badblocks.c \ checksum.c \ + dev.c \ dos.c \ dos_locale.c \ drive.c \ @@ -52,6 +53,5 @@ SOURCES=badblocks.c \ stdio.c \ stdlg.c \ syslinux.c \ - usb.c \ vhd.c \ rufus.rc diff --git a/src/Makefile.am b/src/Makefile.am index da1937ce..a46a084c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -10,8 +10,8 @@ AM_V_WINDRES = $(AM_V_WINDRES_$(V)) %_rc.o: %.rc ../res/localization/embedded.loc $(AM_V_WINDRES) $(AM_RCFLAGS) -i $< -o $@ -rufus_SOURCES = badblocks.c checksum.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c net.c parser.c \ - pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c usb.c vhd.c +rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c \ + net.c parser.c pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c vhd.c rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows rufus_LDADD = rufus_rc.o bled/libbled.a ms-sys/libmssys.a syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a syslinux/win/libwin.a \ diff --git a/src/Makefile.in b/src/Makefile.in index 401d576f..c306667e 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -88,15 +88,15 @@ CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = PROGRAMS = $(noinst_PROGRAMS) am_rufus_OBJECTS = rufus-badblocks.$(OBJEXT) rufus-checksum.$(OBJEXT) \ - rufus-dos.$(OBJEXT) rufus-dos_locale.$(OBJEXT) \ - rufus-drive.$(OBJEXT) rufus-format.$(OBJEXT) \ - rufus-icon.$(OBJEXT) rufus-iso.$(OBJEXT) \ - rufus-localization.$(OBJEXT) rufus-net.$(OBJEXT) \ - rufus-parser.$(OBJEXT) rufus-pki.$(OBJEXT) \ + rufus-dev.$(OBJEXT) rufus-dos.$(OBJEXT) \ + rufus-dos_locale.$(OBJEXT) rufus-drive.$(OBJEXT) \ + rufus-format.$(OBJEXT) rufus-icon.$(OBJEXT) \ + rufus-iso.$(OBJEXT) rufus-localization.$(OBJEXT) \ + rufus-net.$(OBJEXT) rufus-parser.$(OBJEXT) rufus-pki.$(OBJEXT) \ rufus-rufus.$(OBJEXT) rufus-smart.$(OBJEXT) \ rufus-stdfn.$(OBJEXT) rufus-stdio.$(OBJEXT) \ rufus-stdlg.$(OBJEXT) rufus-syslinux.$(OBJEXT) \ - rufus-usb.$(OBJEXT) rufus-vhd.$(OBJEXT) + rufus-vhd.$(OBJEXT) rufus_OBJECTS = $(am_rufus_OBJECTS) rufus_DEPENDENCIES = rufus_rc.o bled/libbled.a ms-sys/libmssys.a \ syslinux/libfat/libfat.a syslinux/libinstaller/libinstaller.a \ @@ -270,8 +270,8 @@ AM_V_WINDRES_0 = @echo " RC $@";$(WINDRES) AM_V_WINDRES_1 = $(WINDRES) AM_V_WINDRES_ = $(AM_V_WINDRES_$(AM_DEFAULT_VERBOSITY)) AM_V_WINDRES = $(AM_V_WINDRES_$(V)) -rufus_SOURCES = badblocks.c checksum.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c net.c parser.c \ - pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c usb.c vhd.c +rufus_SOURCES = badblocks.c checksum.c dev.c dos.c dos_locale.c drive.c format.c icon.c iso.c localization.c \ + net.c parser.c pki.c rufus.c smart.c stdfn.c stdio.c stdlg.c syslinux.c vhd.c rufus_CFLAGS = -I./ms-sys/inc -I./syslinux/libfat -I./syslinux/libinstaller -I./syslinux/win -I./libcdio $(AM_CFLAGS) rufus_LDFLAGS = $(AM_LDFLAGS) -mwindows @@ -344,6 +344,12 @@ rufus-checksum.o: checksum.c rufus-checksum.obj: checksum.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-checksum.obj `if test -f 'checksum.c'; then $(CYGPATH_W) 'checksum.c'; else $(CYGPATH_W) '$(srcdir)/checksum.c'; fi` +rufus-dev.o: dev.c + $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dev.o `test -f 'dev.c' || echo '$(srcdir)/'`dev.c + +rufus-dev.obj: dev.c + $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dev.obj `if test -f 'dev.c'; then $(CYGPATH_W) 'dev.c'; else $(CYGPATH_W) '$(srcdir)/dev.c'; fi` + rufus-dos.o: dos.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-dos.o `test -f 'dos.c' || echo '$(srcdir)/'`dos.c @@ -440,12 +446,6 @@ rufus-syslinux.o: syslinux.c rufus-syslinux.obj: syslinux.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-syslinux.obj `if test -f 'syslinux.c'; then $(CYGPATH_W) 'syslinux.c'; else $(CYGPATH_W) '$(srcdir)/syslinux.c'; fi` -rufus-usb.o: usb.c - $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-usb.o `test -f 'usb.c' || echo '$(srcdir)/'`usb.c - -rufus-usb.obj: usb.c - $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-usb.obj `if test -f 'usb.c'; then $(CYGPATH_W) 'usb.c'; else $(CYGPATH_W) '$(srcdir)/usb.c'; fi` - rufus-vhd.o: vhd.c $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(rufus_CFLAGS) $(CFLAGS) -c -o rufus-vhd.o `test -f 'vhd.c' || echo '$(srcdir)/'`vhd.c diff --git a/src/usb.c b/src/dev.c similarity index 98% rename from src/usb.c rename to src/dev.c index 05fa769a..0ae8cd31 100644 --- a/src/usb.c +++ b/src/dev.c @@ -1,6 +1,6 @@ /* * Rufus: The Reliable USB Formatting Utility - * USB device listing + * Device detection and enumeration * Copyright © 2014-2016 Pete Batard * * This program is free software: you can redistribute it and/or modify @@ -40,7 +40,7 @@ #include "localization.h" #include "drive.h" -#include "usb.h" +#include "dev.h" extern StrArray DriveID, DriveLabel; extern BOOL enable_HDDs, use_fake_units, enable_vmdk, usb_debug, list_non_usb_removable_drives; @@ -157,7 +157,7 @@ static __inline BOOL IsRemovable(const char* buffer) /* * Refresh the list of USB devices */ -BOOL GetUSBDevices(DWORD devnum) +BOOL GetDevices(DWORD devnum) { // List of USB storage drivers we know - list may be incomplete! const char* usbstor_name[] = { @@ -461,14 +461,18 @@ BOOL GetUSBDevices(DWORD devnum) uprintf("Found VHD device '%s'", buffer); } else if ((props.is_CARD) && ((!props.is_USB) || ((props.vid == 0) && (props.pid == 0)))) { uprintf("Found card reader device '%s'", buffer); - } else if ((!props.is_USB) && (props.is_Removable) && (!props.is_UASP)) { - uprintf("Found non-USB removable device '%s'", buffer); + } else if ((!props.is_USB) && (!props.is_UASP) && (props.is_Removable)) { + uprintf("Found non-USB removable device '%s' => Eliminated", buffer); + if (!list_non_usb_removable_drives) { + uuprintf("If you *REALLY* need, you can enable listing of this device with "); + continue; + } } else { if ((props.vid == 0) && (props.pid == 0)) { if (!props.is_USB) { // If we have a non removable SCSI drive and couldn't get a VID:PID, // we are most likely dealing with a system drive => eliminate it! - uuprintf(" Non-USB or non-removable => Eliminated"); + uuprintf("Found non-USB non-removable device '%s' => Eliminated", buffer); continue; } safe_strcpy(str, sizeof(str), "????:????"); // Couldn't figure VID:PID diff --git a/src/usb.h b/src/dev.h similarity index 99% rename from src/usb.h rename to src/dev.h index d67e018c..a3787cb1 100644 --- a/src/usb.h +++ b/src/dev.h @@ -1,6 +1,6 @@ /* * Rufus: The Reliable USB Formatting Utility - * USB device listing + * Device listing * Copyright © 2014-2016 Pete Batard * * This program is free software: you can redistribute it and/or modify diff --git a/src/rufus.c b/src/rufus.c index e2af2f71..aea4a480 100644 --- a/src/rufus.c +++ b/src/rufus.c @@ -2093,7 +2093,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA case DBT_CUSTOMEVENT: // Sent by our timer refresh function or for card reader media change LastRefresh = _GetTickCount64(); KillTimer(hMainDialog, TID_REFRESH_TIMER); - GetUSBDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList))); + GetDevices((DWORD)ComboBox_GetItemData(hDeviceList, ComboBox_GetCurSel(hDeviceList))); user_changed_label = FALSE; return (INT_PTR)TRUE; case DBT_DEVNODES_CHANGED: @@ -2124,7 +2124,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA log_displayed = FALSE; hLogDlg = MyCreateDialog(hMainInstance, IDD_LOG, hDlg, (DLGPROC)LogProc); InitDialog(hDlg); - GetUSBDevices(0); + GetDevices(0); CheckForUpdates(FALSE); // Register MEDIA_INSERTED/MEDIA_REMOVED notifications for card readers if ((pfSHChangeNotifyRegister != NULL) && (SUCCEEDED(SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidlDesktop)))) { @@ -2429,7 +2429,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA if ((HIWORD(wParam)) == BN_CLICKED) { enable_HDDs = !enable_HDDs; PrintStatus2000(lmprintf(MSG_253), enable_HDDs); - GetUSBDevices(0); + GetDevices(0); } break; case IDC_START: @@ -2669,7 +2669,7 @@ static INT_PTR CALLBACK MainCallback(HWND hDlg, UINT message, WPARAM wParam, LPA EnableControls(TRUE); if (wParam) { uprintf("\r\n"); - GetUSBDevices(DeviceNum); + GetDevices(DeviceNum); } if (!IS_ERROR(FormatStatus)) { // This is the only way to achieve instantaneous progress transition to 100% @@ -3073,7 +3073,7 @@ relaunch: usb_debug = !usb_debug; WriteSettingBool(SETTING_ENABLE_USB_DEBUG, usb_debug); PrintStatus2000(lmprintf(MSG_270), usb_debug); - GetUSBDevices(0); + GetDevices(0); continue; } // Alt-, => Disable physical drive locking @@ -3123,7 +3123,7 @@ relaunch: if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'F')) { enable_HDDs = !enable_HDDs; PrintStatus2000(lmprintf(MSG_253), enable_HDDs); - GetUSBDevices(0); + GetDevices(0); CheckDlgButton(hMainDialog, IDC_ENABLE_FIXED_DISKS, enable_HDDs?BST_CHECKED:BST_UNCHECKED); continue; } @@ -3160,7 +3160,7 @@ relaunch: force_large_fat32 = !force_large_fat32; WriteSettingBool(SETTING_FORCE_LARGE_FAT32_FORMAT, force_large_fat32); PrintStatus2000(lmprintf(MSG_254), force_large_fat32); - GetUSBDevices(0); + GetDevices(0); continue; } // Alt N => Enable NTFS compression @@ -3182,7 +3182,7 @@ relaunch: if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'S')) { size_check = !size_check; PrintStatus2000(lmprintf(MSG_252), size_check); - GetUSBDevices(0); + GetDevices(0); continue; } // Alt-T => Preserve timestamps when extracting ISO files @@ -3197,7 +3197,7 @@ relaunch: use_fake_units = !use_fake_units; WriteSettingBool(SETTING_USE_PROPER_SIZE_UNITS, !use_fake_units); PrintStatus2000(lmprintf(MSG_263), !use_fake_units); - GetUSBDevices(0); + GetDevices(0); continue; } // Alt-V => Save selected device to *UNCOMPRESSED* VHD @@ -3210,7 +3210,7 @@ relaunch: enable_vmdk = !enable_vmdk; WriteSettingBool(SETTING_ENABLE_VMDK_DETECTION, enable_vmdk); PrintStatus2000(lmprintf(MSG_265), enable_vmdk); - GetUSBDevices(0); + GetDevices(0); continue; } // Alt-X => Delete the 'rufus_files' subdirectory @@ -3243,7 +3243,7 @@ relaunch: uprintf("NOTE: Listing of non-USB removable drives has been %s.", (list_non_usb_removable_drives)?"enabled (CAUTION!)":"disabled"); if (list_non_usb_removable_drives) uprintf("By using this unofficial cheat mode you forfeit ANY RIGHT to complain if you lose valuable data!"); - GetUSBDevices(0); + GetDevices(0); continue; } diff --git a/src/rufus.h b/src/rufus.h index 8c149470..18ac48a7 100644 --- a/src/rufus.h +++ b/src/rufus.h @@ -421,7 +421,7 @@ extern unsigned char* GetResource(HMODULE module, char* name, char* type, const extern DWORD GetResourceSize(HMODULE module, char* name, char* type, const char* desc); extern DWORD RunCommand(const char* cmdline, const char* dir, BOOL log); extern BOOL CompareGUID(const GUID *guid1, const GUID *guid2); -extern BOOL GetUSBDevices(DWORD devnum); +extern BOOL GetDevices(DWORD devnum); extern BOOL SetLGP(BOOL bRestore, BOOL* bExistingKey, const char* szPath, const char* szPolicy, DWORD dwValue); extern LONG GetEntryWidth(HWND hDropDown, const char* entry); extern DWORD DownloadFile(const char* url, const char* file, HWND hProgressDialog); diff --git a/src/rufus.rc b/src/rufus.rc index 4f04b228..f3526e25 100644 --- a/src/rufus.rc +++ b/src/rufus.rc @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL IDD_DIALOG DIALOGEX 12, 12, 242, 376 STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU EXSTYLE WS_EX_ACCEPTFILES -CAPTION "Rufus 2.9.891" +CAPTION "Rufus 2.9.892" FONT 8, "Segoe UI Symbol", 400, 0, 0x0 BEGIN LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8 @@ -320,8 +320,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 2,9,891,0 - PRODUCTVERSION 2,9,891,0 + FILEVERSION 2,9,892,0 + PRODUCTVERSION 2,9,892,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -338,13 +338,13 @@ BEGIN BEGIN VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)" VALUE "FileDescription", "Rufus" - VALUE "FileVersion", "2.9.891" + VALUE "FileVersion", "2.9.892" VALUE "InternalName", "Rufus" VALUE "LegalCopyright", "© 2011-2016 Pete Batard (GPL v3)" VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html" VALUE "OriginalFilename", "rufus.exe" VALUE "ProductName", "Rufus" - VALUE "ProductVersion", "2.9.891" + VALUE "ProductVersion", "2.9.892" END END BLOCK "VarFileInfo"