diff --git a/res/appstore/Package.appxmanifest b/res/appstore/Package.appxmanifest
index 316367a7..c6de6096 100644
--- a/res/appstore/Package.appxmanifest
+++ b/res/appstore/Package.appxmanifest
@@ -11,7 +11,7 @@
+ Version="3.16.1829.0" />
Rufus
diff --git a/src/drive.c b/src/drive.c
index c15eecc4..7621a72c 100644
--- a/src/drive.c
+++ b/src/drive.c
@@ -443,6 +443,46 @@ static const char* VdsErrorString(HRESULT hr) {
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
*/
diff --git a/src/drive.h b/src/drive.h
index 461fc097..8ad642eb 100644
--- a/src/drive.h
+++ b/src/drive.h
@@ -375,6 +375,7 @@ BOOL SetAutoMount(BOOL enable);
BOOL GetAutoMount(BOOL* enabled);
char* GetPhysicalName(DWORD DriveIndex);
BOOL DeletePartition(DWORD DriveIndex, ULONGLONG PartitionOffset, BOOL bSilent);
+BOOL IsVdsAvailable(BOOL bSilent);
BOOL ListVdsVolumes(BOOL bSilent);
BOOL VdsRescan(DWORD dwRescanType, DWORD dwSleepTime, BOOL bSilent);
HANDLE GetPhysicalHandle(DWORD DriveIndex, BOOL bLockDrive, BOOL bWriteAccess, BOOL bWriteShare);
diff --git a/src/format.c b/src/format.c
index c74f5aaa..f55eefab 100644
--- a/src/format.c
+++ b/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;
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 use_vds, write_as_esp;
+extern BOOL use_vds, write_as_esp, is_vds_available;
uint8_t *grub2_buf = NULL, *sec_buf = NULL;
long grub2_len;
@@ -1769,7 +1769,9 @@ DWORD WINAPI FormatThread(void* param)
{
int r;
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;
HANDLE hPhysicalDrive = 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...
safe_unlockclose(hPhysicalDrive);
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);
FormatStatus = 0;
// 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;
- // VDS wants us to unlock the phys
- if (use_vds) {
+ if (must_unlock_physical)
safe_unlockclose(hPhysicalDrive);
+
+ if (use_vds) {
uprintf("Refreshing drive layout...");
// Note: This may leave the device disabled on re-plug or reboot
// so only do this for the experimental VDS path for now...
@@ -2078,7 +2082,7 @@ DWORD WINAPI FormatThread(void* param)
goto out;
}
- if (use_vds) {
+ if (must_unlock_physical) {
// Get RW access back to the physical drive...
hPhysicalDrive = GetPhysicalHandle(DriveIndex, actual_lock_drive, TRUE, !actual_lock_drive);
if (hPhysicalDrive == INVALID_HANDLE_VALUE) {
diff --git a/src/rufus.c b/src/rufus.c
index 4c884e94..c42dc5df 100755
--- a/src/rufus.c
+++ b/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 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 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;
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
@@ -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]);
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();
SetTaskbarProgressState(TASKBAR_NORMAL);
@@ -3371,7 +3373,8 @@ skip_args_processing:
advanced_mode_format = ReadSettingBool(SETTING_ADVANCED_MODE_FORMAT);
preserve_timestamps = ReadSettingBool(SETTING_PRESERVE_TIMESTAMPS);
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);
cdio_loglevel_default = usb_debug ? CDIO_LOG_DEBUG : CDIO_LOG_WARN;
detect_fakes = !ReadSettingBool(SETTING_DISABLE_FAKE_DRIVES_CHECK);
@@ -3801,9 +3804,11 @@ relaunch:
}
// Alt-V => Use VDS facilities for formatting
if ((msg.message == WM_SYSKEYDOWN) && (msg.wParam == 'V')) {
- use_vds = !use_vds;
- WriteSettingBool(SETTING_USE_VDS, use_vds);
- PrintStatusTimeout("VDS", use_vds);
+ if (is_vds_available) {
+ use_vds = !use_vds;
+ WriteSettingBool(SETTING_USE_VDS, use_vds);
+ PrintStatusTimeout("VDS", use_vds);
+ }
continue;
}
// Alt-W => Enable VMWare disk detection
diff --git a/src/rufus.rc b/src/rufus.rc
index 2c4000c2..4aa48015 100644
--- a/src/rufus.rc
+++ b/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 3.16.1828"
+CAPTION "Rufus 3.16.1829"
FONT 9, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Drive Properties",IDS_DRIVE_PROPERTIES_TXT,8,6,53,12,NOT WS_GROUP
@@ -395,8 +395,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
- FILEVERSION 3,16,1828,0
- PRODUCTVERSION 3,16,1828,0
+ FILEVERSION 3,16,1829,0
+ PRODUCTVERSION 3,16,1829,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@@ -414,13 +414,13 @@ BEGIN
VALUE "Comments", "https://rufus.ie"
VALUE "CompanyName", "Akeo Consulting"
VALUE "FileDescription", "Rufus"
- VALUE "FileVersion", "3.16.1828"
+ VALUE "FileVersion", "3.16.1829"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2021 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "https://www.gnu.org/licenses/gpl-3.0.html"
VALUE "OriginalFilename", "rufus-3.16.exe"
VALUE "ProductName", "Rufus"
- VALUE "ProductVersion", "3.16.1828"
+ VALUE "ProductVersion", "3.16.1829"
END
END
BLOCK "VarFileInfo"