mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-14 23:57:05 +00:00
[dev] filter out Microsoft Dev Drives
* Microsoft Dev Drives are VHDs consisting of a small MSR followed by a large (50 GB or more) ReFS partition. See https://learn.microsoft.com/en-us/windows/dev-drive/. * Closes #2395.
This commit is contained in:
parent
51569d9e13
commit
ebe01cc7b6
4 changed files with 52 additions and 8 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Device detection and enumeration
|
||||
* Copyright © 2014-2023 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2014-2024 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* 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
|
||||
|
@ -933,6 +933,10 @@ BOOL GetDevices(DWORD devnum)
|
|||
uprintf("To use such a card, check 'List USB Hard Drives' under 'advanced drive properties'");
|
||||
safe_free(devint_detail_data);
|
||||
break;
|
||||
} else if (props.is_VHD && IsMsDevDrive(drive_index)) {
|
||||
uprintf("Device eliminated because it was detected as a Microsoft Dev Drive");
|
||||
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) {
|
||||
|
|
41
src/drive.c
41
src/drive.c
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Drive access function calls
|
||||
* Copyright © 2011-2023 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* 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
|
||||
|
@ -2645,3 +2645,42 @@ const char* GetGPTPartitionType(const GUID* guid)
|
|||
for (i = 0; (i < ARRAYSIZE(gpt_type)) && !CompareGUID(guid, gpt_type[i].guid); i++);
|
||||
return (i < ARRAYSIZE(gpt_type)) ? gpt_type[i].name : GuidToString(guid, TRUE);
|
||||
}
|
||||
|
||||
/*
|
||||
* Detect Microsoft Dev Drives, which are VHDs consisting of a small MSR followed by a large
|
||||
* (50 GB or more) ReFS partition. See https://learn.microsoft.com/en-us/windows/dev-drive/.
|
||||
* NB: Despite the option being proposed, I have *NOT* been able to create MBR-based Dev Drives.
|
||||
*/
|
||||
BOOL IsMsDevDrive(DWORD DriveIndex)
|
||||
{
|
||||
BOOL r, ret = FALSE;
|
||||
DWORD size = 0;
|
||||
HANDLE hPhysical = INVALID_HANDLE_VALUE;
|
||||
BYTE layout[4096] = { 0 };
|
||||
PDRIVE_LAYOUT_INFORMATION_EX DriveLayout = (PDRIVE_LAYOUT_INFORMATION_EX)(void*)layout;
|
||||
|
||||
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;
|
||||
|
||||
if (DriveLayout->PartitionStyle != PARTITION_STYLE_GPT)
|
||||
goto out;
|
||||
if (DriveLayout->PartitionCount != 2)
|
||||
goto out;
|
||||
if (!CompareGUID(&DriveLayout->PartitionEntry[0].Gpt.PartitionType, &PARTITION_MICROSOFT_RESERVED))
|
||||
goto out;
|
||||
if (!CompareGUID(&DriveLayout->PartitionEntry[1].Gpt.PartitionType, &PARTITION_MICROSOFT_DATA))
|
||||
goto out;
|
||||
if (DriveLayout->PartitionEntry[1].PartitionLength.QuadPart < 20 * GB)
|
||||
goto out;
|
||||
ret = (strcmp(GetFsName(hPhysical, DriveLayout->PartitionEntry[1].StartingOffset), "ReFS") == 0);
|
||||
|
||||
out:
|
||||
safe_closehandle(hPhysical);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
* Rufus: The Reliable USB Formatting Utility
|
||||
* Drive access function calls
|
||||
* Copyright © 2011-2023 Pete Batard <pete@akeo.ie>
|
||||
* Copyright © 2011-2024 Pete Batard <pete@akeo.ie>
|
||||
*
|
||||
* 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
|
||||
|
@ -421,3 +421,4 @@ BOOL RefreshLayout(DWORD DriveIndex);
|
|||
BOOL GetOpticalMedia(IMG_SAVE* img_save);
|
||||
uint64_t GetEspOffset(DWORD DriveIndex);
|
||||
BOOL ToggleEsp(DWORD DriveIndex, uint64_t PartitionOffset);
|
||||
BOOL IsMsDevDrive(DWORD DriveIndex);
|
||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -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.4.2096"
|
||||
CAPTION "Rufus 4.4.2097"
|
||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||
BEGIN
|
||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||
|
@ -392,8 +392,8 @@ END
|
|||
//
|
||||
|
||||
VS_VERSION_INFO VERSIONINFO
|
||||
FILEVERSION 4,4,2096,0
|
||||
PRODUCTVERSION 4,4,2096,0
|
||||
FILEVERSION 4,4,2097,0
|
||||
PRODUCTVERSION 4,4,2097,0
|
||||
FILEFLAGSMASK 0x3fL
|
||||
#ifdef _DEBUG
|
||||
FILEFLAGS 0x1L
|
||||
|
@ -411,13 +411,13 @@ BEGIN
|
|||
VALUE "Comments", "https://rufus.ie"
|
||||
VALUE "CompanyName", "Akeo Consulting"
|
||||
VALUE "FileDescription", "Rufus"
|
||||
VALUE "FileVersion", "4.4.2096"
|
||||
VALUE "FileVersion", "4.4.2097"
|
||||
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.4.exe"
|
||||
VALUE "ProductName", "Rufus"
|
||||
VALUE "ProductVersion", "4.4.2096"
|
||||
VALUE "ProductVersion", "4.4.2097"
|
||||
END
|
||||
END
|
||||
BLOCK "VarFileInfo"
|
||||
|
|
Loading…
Reference in a new issue