Skip to content

Commit

Permalink
[dev] add disk exclusion by GPT Disk GUID
Browse files Browse the repository at this point in the history
* Similar to what we already do with IgnoreUSB##, except this time, users
  can add REG_SZ keys IgnoreDisk01 to IgnoreDisk08, with a string like
  "{F333EC2E-25C9-488D-A7FC-9147C2367623}" to ignore a GPT disk with this
  specific GUID.
* This may be useful for people who mount fixed virtual drives, or people
  who have enabled Hot Swap on their SATA storage, and who want to make sure
  they won't be able to inadvertently select that disk in Rufus.
* Also set rufus-next to 4.7.
  • Loading branch information
pbatard committed Nov 22, 2024
1 parent 7488e44 commit 37e383a
Show file tree
Hide file tree
Showing 6 changed files with 63 additions and 17 deletions.
20 changes: 10 additions & 10 deletions configure
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
# Generated by GNU Autoconf 2.71 for rufus 4.6.
# Generated by GNU Autoconf 2.71 for rufus 4.7.
#
# Report bugs to <https://github.com/pbatard/rufus/issues>.
#
Expand Down Expand Up @@ -611,8 +611,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='rufus'
PACKAGE_TARNAME='rufus'
PACKAGE_VERSION='4.6'
PACKAGE_STRING='rufus 4.6'
PACKAGE_VERSION='4.7'
PACKAGE_STRING='rufus 4.7'
PACKAGE_BUGREPORT='https://github.com/pbatard/rufus/issues'
PACKAGE_URL='https://rufus.ie'

Expand Down Expand Up @@ -1269,7 +1269,7 @@ if test "$ac_init_help" = "long"; then
# 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.
cat <<_ACEOF
\`configure' configures rufus 4.6 to adapt to many kinds of systems.
\`configure' configures rufus 4.7 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
Expand Down Expand Up @@ -1336,7 +1336,7 @@ fi

if test -n "$ac_init_help"; then
case $ac_init_help in
short | recursive ) echo "Configuration of rufus 4.6:";;
short | recursive ) echo "Configuration of rufus 4.7:";;
esac
cat <<\_ACEOF
Expand Down Expand Up @@ -1428,7 +1428,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
rufus configure 4.6
rufus configure 4.7
generated by GNU Autoconf 2.71
Copyright (C) 2021 Free Software Foundation, Inc.
Expand Down Expand Up @@ -1504,7 +1504,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by rufus $as_me 4.6, which was
It was created by rufus $as_me 4.7, which was
generated by GNU Autoconf 2.71. Invocation command line was
$ $0$ac_configure_args_raw
Expand Down Expand Up @@ -2767,7 +2767,7 @@ fi
# Define the identity of the package.
PACKAGE='rufus'
VERSION='4.6'
VERSION='4.7'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
Expand Down Expand Up @@ -5309,7 +5309,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
This file was extended by rufus $as_me 4.6, which was
This file was extended by rufus $as_me 4.7, which was
generated by GNU Autoconf 2.71. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
Expand Down Expand Up @@ -5365,7 +5365,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
rufus config.status 4.6
rufus config.status 4.7
configured by $0, generated by GNU Autoconf 2.71,
with options \\"\$ac_cs_config\\"
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([rufus], [4.6], [https://github.com/pbatard/rufus/issues], [rufus], [https://rufus.ie])
AC_INIT([rufus], [4.7], [https://github.com/pbatard/rufus/issues], [rufus], [https://rufus.ie])
AM_INIT_AUTOMAKE([-Wno-portability foreign no-dist no-dependencies])
AC_CONFIG_SRCDIR([src/rufus.c])
AC_CONFIG_MACRO_DIR([m4])
Expand Down
3 changes: 3 additions & 0 deletions src/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -943,6 +943,9 @@ BOOL GetDevices(DWORD devnum)
uprintf("Device eliminated because it was detected as a Microsoft Dev Drive");
safe_free(devint_detail_data);
break;
} else if (IsFilteredDrive(drive_index)) {
safe_free(devint_detail_data);
break;
}
// Windows 10 19H1 mounts a 'PortableBaseLayer' for its Windows Sandbox feature => unlist those
if (safe_strcmp(label, windows_sandbox_vhd_label) == 0) {
Expand Down
42 changes: 42 additions & 0 deletions src/drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -2647,3 +2647,45 @@ BOOL IsMsDevDrive(DWORD DriveIndex)
safe_closehandle(hPhysical);
return ret;
}

/*
* Detect filtered drives, that have been added by users through the registry
* entries IgnoreDisk01 - IgnoreDisk08. These entries must contain *decorated*
* string GUIDs that match the GPT Disk GUID of the drive to filter out, as
* reported by Rufus, such as "{F333EC2E-25C9-488D-A7FC-9147C2367623}".
*/
BOOL IsFilteredDrive(DWORD DriveIndex)
{
char setting_name[32];
DWORD i, size = 0;
BOOL r, ret = FALSE;
HANDLE hPhysical = INVALID_HANDLE_VALUE;
BYTE layout[4096] = { 0 };
PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)(void*)layout;
GUID* DiskGuid;

hPhysical = GetPhysicalHandle(DriveIndex, FALSE, FALSE, TRUE);
if (hPhysical == INVALID_HANDLE_VALUE)
goto out;

r = DeviceIoControl(hPhysical, IOCTL_DISK_GET_DRIVE_LAYOUT_EX, NULL, 0, layout, sizeof(layout), &size, NULL);
if (!r || size <= 0)
goto out;

// Only works for GPT drives
if (DriveLayout->PartitionStyle != PARTITION_STYLE_GPT)
goto out;
for (i = 1; i <= MAX_IGNORE_USB; i++) {
static_sprintf(setting_name, "IgnoreDisk%02d", i);
DiskGuid = StringToGuid(ReadSettingStr(setting_name));
if (CompareGUID(&DriveLayout->Gpt.DiskId, DiskGuid)) {
uprintf("Device eliminated because it matches Disk GUID %s", GuidToString(DiskGuid, TRUE));
ret = TRUE;
goto out;
}
}

out:
safe_closehandle(hPhysical);
return ret;
}
1 change: 1 addition & 0 deletions src/drive.h
Original file line number Diff line number Diff line change
Expand Up @@ -425,3 +425,4 @@ BOOL GetOpticalMedia(IMG_SAVE* img_save);
uint64_t GetEspOffset(DWORD DriveIndex);
BOOL ToggleEsp(DWORD DriveIndex, uint64_t PartitionOffset);
BOOL IsMsDevDrive(DWORD DriveIndex);
BOOL IsFilteredDrive(DWORD DriveIndex);
12 changes: 6 additions & 6 deletions src/rufus.rc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 232, 326
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 4.6.2208"
CAPTION "Rufus 4.7.2209"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
Expand Down Expand Up @@ -399,8 +399,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 4,6,2208,0
PRODUCTVERSION 4,6,2208,0
FILEVERSION 4,7,2209,0
PRODUCTVERSION 4,7,2209,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -418,13 +418,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "4.6.2208"
VALUE "FileVersion", "4.7.2209"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "� 2011-2024 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-4.6.exe"
VALUE "OriginalFilename", "rufus-4.7.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "4.6.2208"
VALUE "ProductVersion", "4.7.2209"
END
END
BLOCK "VarFileInfo"
Expand Down

0 comments on commit 37e383a

Please sign in to comment.