mirror of
https://github.com/pbatard/rufus.git
synced 2024-08-31 05:56:09 +02:00
[core] add VDS detection and print a notice if VDS is unavailable
This commit is contained in:
parent
c09ede16b3
commit
ce8aaa99f7
6 changed files with 67 additions and 17 deletions
|
@ -11,7 +11,7 @@
|
||||||
<Identity
|
<Identity
|
||||||
Name="19453.net.Rufus"
|
Name="19453.net.Rufus"
|
||||||
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
|
Publisher="CN=7AC86D13-3E5A-491A-ADD5-80095C212740"
|
||||||
Version="3.16.1828.0" />
|
Version="3.16.1829.0" />
|
||||||
|
|
||||||
<Properties>
|
<Properties>
|
||||||
<DisplayName>Rufus</DisplayName>
|
<DisplayName>Rufus</DisplayName>
|
||||||
|
|
40
src/drive.c
40
src/drive.c
|
@ -443,6 +443,46 @@ static const char* VdsErrorString(HRESULT hr) {
|
||||||
return WindowsErrorString();
|
return WindowsErrorString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Per https://docs.microsoft.com/en-us/windows/win32/api/combaseapi/nf-combaseapi-cocreateinstance
|
||||||
|
* and even though we aren't a UWP app, Windows Store prevents the ability to use of VDS when the
|
||||||
|
* Store version of Rufus is running (the call to IVdsServiceLoader_LoadService() will return
|
||||||
|
* E_ACCESSDENIED).
|
||||||
|
*/
|
||||||
|
BOOL IsVdsAvailable(BOOL bSilent)
|
||||||
|
{
|
||||||
|
HRESULT hr = S_FALSE;
|
||||||
|
IVdsService* pService = NULL;
|
||||||
|
IVdsServiceLoader* pLoader = NULL;
|
||||||
|
|
||||||
|
// Initialize COM
|
||||||
|
IGNORE_RETVAL(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE));
|
||||||
|
IGNORE_RETVAL(CoInitializeSecurity(NULL, -1, NULL, NULL, RPC_C_AUTHN_LEVEL_CONNECT,
|
||||||
|
RPC_C_IMP_LEVEL_IMPERSONATE, NULL, 0, NULL));
|
||||||
|
|
||||||
|
// Create a VDS Loader Instance
|
||||||
|
hr = CoCreateInstance(&CLSID_VdsLoader, NULL, CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER,
|
||||||
|
&IID_IVdsServiceLoader, (void**)&pLoader);
|
||||||
|
if (hr != S_OK) {
|
||||||
|
suprintf("Notice: Disabling VDS (Could not create VDS Loader Instance: %s)", VdsErrorString(hr));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
hr = IVdsServiceLoader_LoadService(pLoader, L"", &pService);
|
||||||
|
if (hr != S_OK) {
|
||||||
|
suprintf("Notice: Disabling VDS (Could not load VDS Service: %s)", VdsErrorString(hr));
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
|
out:
|
||||||
|
if (pService != NULL)
|
||||||
|
IVdsService_Release(pService);
|
||||||
|
if (pLoader != NULL)
|
||||||
|
IVdsServiceLoader_Release(pLoader);
|
||||||
|
VDS_SET_ERROR(hr);
|
||||||
|
return (hr == S_OK);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Call on VDS to refresh the drive layout
|
* Call on VDS to refresh the drive layout
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -375,6 +375,7 @@ BOOL SetAutoMount(BOOL enable);
|
||||||
BOOL GetAutoMount(BOOL* enabled);
|
BOOL GetAutoMount(BOOL* enabled);
|
||||||
char* GetPhysicalName(DWORD DriveIndex);
|
char* GetPhysicalName(DWORD DriveIndex);
|
||||||
BOOL DeletePartition(DWORD DriveIndex, ULONGLONG PartitionOffset, BOOL bSilent);
|
BOOL DeletePartition(DWORD DriveIndex, ULONGLONG PartitionOffset, BOOL bSilent);
|
||||||
|
BOOL IsVdsAvailable(BOOL bSilent);
|
||||||
BOOL ListVdsVolumes(BOOL bSilent);
|
BOOL ListVdsVolumes(BOOL bSilent);
|
||||||
BOOL VdsRescan(DWORD dwRescanType, DWORD dwSleepTime, BOOL bSilent);
|
BOOL VdsRescan(DWORD dwRescanType, DWORD dwSleepTime, BOOL bSilent);
|
||||||
HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWriteShare);
|
HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWriteShare);
|
||||||
|
|
16
src/format.c
16
src/format.c
|
@ -70,7 +70,7 @@ extern uint32_t dur_mins, dur_secs;
|
||||||
extern uint32_t wim_nb_files, wim_proc_files, wim_extra_files;
|
extern uint32_t wim_nb_files, wim_proc_files, wim_extra_files;
|
||||||
static int actual_fs_type, wintogo_index = -1, wininst_index = 0;
|
static int actual_fs_type, wintogo_index = -1, wininst_index = 0;
|
||||||
extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, fast_zeroing, enable_file_indexing, write_as_image;
|
extern BOOL force_large_fat32, enable_ntfs_compression, lock_drive, zero_drive, fast_zeroing, enable_file_indexing, write_as_image;
|
||||||
extern BOOL use_vds, write_as_esp;
|
extern BOOL use_vds, write_as_esp, is_vds_available;
|
||||||
uint8_t *grub2_buf = NULL, *sec_buf = NULL;
|
uint8_t *grub2_buf = NULL, *sec_buf = NULL;
|
||||||
long grub2_len;
|
long grub2_len;
|
||||||
|
|
||||||
|
@ -1769,7 +1769,9 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
{
|
{
|
||||||
int r;
|
int r;
|
||||||
BOOL ret, use_large_fat32, windows_to_go, actual_lock_drive = lock_drive;
|
BOOL ret, use_large_fat32, windows_to_go, actual_lock_drive = lock_drive;
|
||||||
BOOL need_logical = FALSE;
|
// Windows 11 and VDS (which I suspect is what fmifs.dll's FormatEx() is now calling behind the
|
||||||
|
// scenes) require us to unlock the physical drive to format the drive, else access denied is re
|
||||||
|
BOOL need_logical = FALSE, must_unlock_physical = (use_vds || nWindowsVersion >= WINDOWS_11);
|
||||||
DWORD cr, DriveIndex = (DWORD)(uintptr_t)param, ClusterSize, Flags;
|
DWORD cr, DriveIndex = (DWORD)(uintptr_t)param, ClusterSize, Flags;
|
||||||
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
|
HANDLE hPhysicalDrive = INVALID_HANDLE_VALUE;
|
||||||
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
|
HANDLE hLogicalVolume = INVALID_HANDLE_VALUE;
|
||||||
|
@ -1839,7 +1841,8 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
// for VDS to be able to delete the partitions that reside on it...
|
// for VDS to be able to delete the partitions that reside on it...
|
||||||
safe_unlockclose(hPhysicalDrive);
|
safe_unlockclose(hPhysicalDrive);
|
||||||
PrintInfo(0, MSG_239, lmprintf(MSG_307));
|
PrintInfo(0, MSG_239, lmprintf(MSG_307));
|
||||||
if (!DeletePartition(DriveIndex, 0, FALSE)) {
|
if (!is_vds_available || !DeletePartition(DriveIndex, 0, TRUE)) {
|
||||||
|
uprintf("Warning: Could not delete partition(s): %s", is_vds_available ? WindowsErrorString() : "VDS is not available");
|
||||||
SetLastError(FormatStatus);
|
SetLastError(FormatStatus);
|
||||||
FormatStatus = 0;
|
FormatStatus = 0;
|
||||||
// If we couldn't delete partitions, Windows give us trouble unless we
|
// If we couldn't delete partitions, Windows give us trouble unless we
|
||||||
|
@ -2011,9 +2014,10 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
}
|
}
|
||||||
hLogicalVolume = INVALID_HANDLE_VALUE;
|
hLogicalVolume = INVALID_HANDLE_VALUE;
|
||||||
|
|
||||||
// VDS wants us to unlock the phys
|
if (must_unlock_physical)
|
||||||
if (use_vds) {
|
|
||||||
safe_unlockclose(hPhysicalDrive);
|
safe_unlockclose(hPhysicalDrive);
|
||||||
|
|
||||||
|
if (use_vds) {
|
||||||
uprintf("Refreshing drive layout...");
|
uprintf("Refreshing drive layout...");
|
||||||
// Note: This may leave the device disabled on re-plug or reboot
|
// Note: This may leave the device disabled on re-plug or reboot
|
||||||
// so only do this for the experimental VDS path for now...
|
// so only do this for the experimental VDS path for now...
|
||||||
|
@ -2078,7 +2082,7 @@ DWORD WINAPI FormatThread(void* param)
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_vds) {
|
if (must_unlock_physical) {
|
||||||
// Get RW access back to the physical drive...
|
// Get RW access back to the physical drive...
|
||||||
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
|
||||||
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
|
||||||
|
|
15
src/rufus.c
15
src/rufus.c
|
@ -121,7 +121,7 @@ BOOL advanced_mode_device, advanced_mode_format, allow_dual_uefi_bios, detect_fa
|
||||||
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
|
BOOL use_fake_units, preserve_timestamps = FALSE, fast_zeroing = FALSE, app_changed_size = FALSE;
|
||||||
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE;
|
BOOL zero_drive = FALSE, list_non_usb_removable_drives = FALSE, enable_file_indexing, large_drive = FALSE;
|
||||||
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, use_vds = FALSE, ignore_boot_marker = FALSE;
|
BOOL write_as_image = FALSE, write_as_esp = FALSE, installed_uefi_ntfs = FALSE, use_vds = FALSE, ignore_boot_marker = FALSE;
|
||||||
BOOL windows_to_go_selected = FALSE, appstore_version = FALSE;
|
BOOL windows_to_go_selected = FALSE, appstore_version = FALSE, is_vds_available = TRUE;
|
||||||
float fScale = 1.0f;
|
float fScale = 1.0f;
|
||||||
int dialog_showing = 0, selection_default = BT_IMAGE, persistence_unit_selection = -1;
|
int dialog_showing = 0, selection_default = BT_IMAGE, persistence_unit_selection = -1;
|
||||||
int default_fs, fs_type, boot_type, partition_type, target_type; // file system, boot type, partition type, target type
|
int default_fs, fs_type, boot_type, partition_type, target_type; // file system, boot type, partition type, target type
|
||||||
|
@ -1839,6 +1839,8 @@ static void InitDialog(HWND hDlg)
|
||||||
"one. Because of this, some messages will only be displayed in English.", selected_locale->txt[1]);
|
"one. Because of this, some messages will only be displayed in English.", selected_locale->txt[1]);
|
||||||
uprintf("If you think you can help update this translation, please e-mail the author of this application");
|
uprintf("If you think you can help update this translation, please e-mail the author of this application");
|
||||||
}
|
}
|
||||||
|
if (!is_vds_available)
|
||||||
|
uprintf("Notice: Windows VDS is unavailable");
|
||||||
|
|
||||||
CreateTaskbarList();
|
CreateTaskbarList();
|
||||||
SetTaskbarProgressState(TASKBAR_NORMAL);
|
SetTaskbarProgressState(TASKBAR_NORMAL);
|
||||||
|
@ -3371,7 +3373,8 @@ skip_args_processing:
|
||||||
advanced_mode_format = ReadSettingBool(SETTING_ADVANCED_MODE_FORMAT);
|
advanced_mode_format = ReadSettingBool(SETTING_ADVANCED_MODE_FORMAT);
|
||||||
preserve_timestamps = ReadSettingBool(SETTING_PRESERVE_TIMESTAMPS);
|
preserve_timestamps = ReadSettingBool(SETTING_PRESERVE_TIMESTAMPS);
|
||||||
use_fake_units = !ReadSettingBool(SETTING_USE_PROPER_SIZE_UNITS);
|
use_fake_units = !ReadSettingBool(SETTING_USE_PROPER_SIZE_UNITS);
|
||||||
use_vds = ReadSettingBool(SETTING_USE_VDS);
|
is_vds_available = IsVdsAvailable(FALSE);
|
||||||
|
use_vds = ReadSettingBool(SETTING_USE_VDS) && is_vds_available;
|
||||||
usb_debug = ReadSettingBool(SETTING_ENABLE_USB_DEBUG);
|
usb_debug = ReadSettingBool(SETTING_ENABLE_USB_DEBUG);
|
||||||
cdio_loglevel_default = usb_debug ? CDIO_LOG_DEBUG : CDIO_LOG_WARN;
|
cdio_loglevel_default = usb_debug ? CDIO_LOG_DEBUG : CDIO_LOG_WARN;
|
||||||
detect_fakes = !ReadSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK);
|
detect_fakes = !ReadSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK);
|
||||||
|
@ -3801,9 +3804,11 @@ relaunch:
|
||||||
}
|
}
|
||||||
// Alt-V => Use VDS facilities for formatting
|
// Alt-V => Use VDS facilities for formatting
|
||||||
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'V')) {
|
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'V')) {
|
||||||
use_vds = !use_vds;
|
if (is_vds_available) {
|
||||||
WriteSettingBool(SETTING_USE_VDS, use_vds);
|
use_vds = !use_vds;
|
||||||
PrintStatusTimeout("VDS", use_vds);
|
WriteSettingBool(SETTING_USE_VDS, use_vds);
|
||||||
|
PrintStatusTimeout("VDS", use_vds);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Alt-W => Enable VMWare disk detection
|
// Alt-W => Enable VMWare disk detection
|
||||||
|
|
10
src/rufus.rc
10
src/rufus.rc
|
@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
|
||||||
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
IDD_DIALOG DIALOGEX 12, 12, 232, 326
|
||||||
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
|
||||||
EXSTYLE WS_EX_ACCEPTFILES
|
EXSTYLE WS_EX_ACCEPTFILES
|
||||||
CAPTION "Rufus 3.16.1828"
|
CAPTION "Rufus 3.16.1829"
|
||||||
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
|
||||||
BEGIN
|
BEGIN
|
||||||
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
|
||||||
|
@ -395,8 +395,8 @@ END
|
||||||
//
|
//
|
||||||
|
|
||||||
VS_VERSION_INFO VERSIONINFO
|
VS_VERSION_INFO VERSIONINFO
|
||||||
FILEVERSION 3,16,1828,0
|
FILEVERSION 3,16,1829,0
|
||||||
PRODUCTVERSION 3,16,1828,0
|
PRODUCTVERSION 3,16,1829,0
|
||||||
FILEFLAGSMASK 0x3fL
|
FILEFLAGSMASK 0x3fL
|
||||||
#ifdef _DEBUG
|
#ifdef _DEBUG
|
||||||
FILEFLAGS 0x1L
|
FILEFLAGS 0x1L
|
||||||
|
@ -414,13 +414,13 @@ BEGIN
|
||||||
VALUE "Comments", "https://rufus.ie"
|
VALUE "Comments", "https://rufus.ie"
|
||||||
VALUE "CompanyName", "Akeo Consulting"
|
VALUE "CompanyName", "Akeo Consulting"
|
||||||
VALUE "FileDescription", "Rufus"
|
VALUE "FileDescription", "Rufus"
|
||||||
VALUE "FileVersion", "3.16.1828"
|
VALUE "FileVersion", "3.16.1829"
|
||||||
VALUE "InternalName", "Rufus"
|
VALUE "InternalName", "Rufus"
|
||||||
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
|
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
|
||||||
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
|
||||||
VALUE "OriginalFilename", "rufus-3.16.exe"
|
VALUE "OriginalFilename", "rufus-3.16.exe"
|
||||||
VALUE "ProductName", "Rufus"
|
VALUE "ProductName", "Rufus"
|
||||||
VALUE "ProductVersion", "3.16.1828"
|
VALUE "ProductVersion", "3.16.1829"
|
||||||
END
|
END
|
||||||
END
|
END
|
||||||
BLOCK "VarFileInfo"
|
BLOCK "VarFileInfo"
|
||||||
|
|
Loading…
Reference in a new issue