-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[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.
- Loading branch information
Showing
4 changed files
with
52 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Rufus: The Reliable USB Formatting Utility | ||
* Device detection and enumeration | ||
* Copyright © 2014-2023 Pete Batard <[email protected]> | ||
* Copyright © 2014-2024 Pete Batard <[email protected]> | ||
* | ||
* 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) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Rufus: The Reliable USB Formatting Utility | ||
* Drive access function calls | ||
* Copyright © 2011-2023 Pete Batard <[email protected]> | ||
* Copyright © 2011-2024 Pete Batard <[email protected]> | ||
* | ||
* 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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
/* | ||
* Rufus: The Reliable USB Formatting Utility | ||
* Drive access function calls | ||
* Copyright © 2011-2023 Pete Batard <[email protected]> | ||
* Copyright © 2011-2024 Pete Batard <[email protected]> | ||
* | ||
* 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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters