[togo] improve Windows To Go support for Windows 10 Creators Update

* Enable the use of GPT on REMOVABLE drives, if the host is Windows 10 CU
* Don't display the message about REMOVABLE boot, if the target is Windows 10 CU
This commit is contained in:
Pete Batard 2017-04-19 11:30:24 +01:00
parent fff4465b1d
commit aec2736245
5 changed files with 38 additions and 22 deletions

View File

@ -1288,22 +1288,21 @@ out:
// to set our extraction index. Asks the user to select one if needed.
BOOL SetWinToGoIndex(void)
{
char *mounted_iso, image[128];
char *mounted_iso, *build, image[128];
char tmp_path[MAX_PATH] = "", xml_file[MAX_PATH] = "";
StrArray version_name, version_index;
int i;
int i, build_nr = 0;
// Sanity checks
wintogo_index = -1;
if ((nWindowsVersion < WINDOWS_8) || ((WimExtractCheck() & 4) == 0) ||
(ComboBox_GetItemData(hFileSystem, ComboBox_GetCurSel(hFileSystem)) != FS_NTFS)) {
wintogo_index = -1;
return FALSE;
}
// Mount the install.wim image, that resides on the ISO
mounted_iso = MountISO(image_path);
if (mounted_iso == NULL) {
uprintf("Could not mount ISO for Windows To Go selection");
wintogo_index = -1;
return FALSE;
}
static_sprintf(image, "%s%s", mounted_iso, &img_report.install_wim_path[2]);
@ -1321,13 +1320,13 @@ BOOL SetWinToGoIndex(void)
// Must use the Windows WIM API as 7z messes up the XML
if (!WimExtractFile_API(image, 0, "[1].xml", xml_file)) {
uprintf("Failed to acquire WIM index");
goto out;
}
StrArrayCreate(&version_name, 16);
StrArrayCreate(&version_index, 16);
for (i = 0; (StrArrayAdd(&version_name, get_token_data_file_indexed("DISPLAYNAME", xml_file, i + 1), FALSE) >= 0) &&
(StrArrayAdd(&version_index, get_token_data_file_indexed("IMAGE INDEX", xml_file, i + 1), FALSE) >= 0); i++);
DeleteFileU(xml_file);
UnMountISO();
if (i > 1)
i = Selection(lmprintf(MSG_291), lmprintf(MSG_292), version_name.String, i);
@ -1338,10 +1337,27 @@ BOOL SetWinToGoIndex(void)
} else {
wintogo_index = atoi(version_index.String[i - 1]);
}
if (i >= 1)
uprintf("Will use '%s' (index %s) for Windows To Go", version_name.String[i - 1], version_index.String[i - 1]);
if (i >= 0) {
// Get the build version
build = get_token_data_file_indexed("BUILD", xml_file, i);
if (build != NULL)
build_nr = atoi(build);
free(build);
uprintf("Will use '%s' (Build: %d, Index %s) for Windows To Go",
version_name.String[i - 1], build_nr, version_index.String[i - 1]);
// Need Windows 10 Creator Update or later for boot on REMOVABLE to work
if ((build_nr < 15000) && (SelectedDrive.MediaType != FixedMedia)) {
if (MessageBoxExU(hMainDialog, lmprintf(MSG_098), lmprintf(MSG_190),
MB_YESNO | MB_ICONWARNING | MB_IS_RTL, selected_langid) != IDYES)
wintogo_index = -1;
}
}
StrArrayDestroy(&version_name);
StrArrayDestroy(&version_index);
out:
DeleteFileU(xml_file);
UnMountISO();
return (wintogo_index >= 0);
}
@ -1368,7 +1384,7 @@ static BOOL SetupWinToGo(const char* drive_name, BOOL use_ms_efi)
uprintf("Windows To Go mode selected");
// Additional sanity checks
if ( (use_ms_efi) && (SelectedDrive.MediaType != FixedMedia) ) {
if ( (use_ms_efi) && (SelectedDrive.MediaType != FixedMedia) && (nWindowsBuildNumber < 15000)) {
FormatStatus = ERROR_SEVERITY_ERROR|FAC(FACILITY_STORAGE)|ERROR_NOT_SUPPORTED;
return FALSE;
}

View File

@ -1296,17 +1296,14 @@ static BOOL BootCheck(void)
// Windows To Go only works for NTFS
MessageBoxExU(hMainDialog, lmprintf(MSG_097, "Windows To Go"), lmprintf(MSG_092), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
return FALSE;
} else if (SelectedDrive.MediaType != FixedMedia) {
if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT)) {
// We're screwed since we need access to 2 partitions at the same time to set this, which
// Windows can't do. Cue in Arthur's Theme: "♫ I know it's stupid... but it's true. ♫"
}
if (SelectedDrive.MediaType != FixedMedia) {
if ((tt == TT_UEFI) && (pt == PARTITION_STYLE_GPT) && (nWindowsBuildNumber < 15000)) {
// Up to Windows 10 Creators Update, we were screwed, since we need access to 2 partitions at the same time.
// Thankfully, the newer Windows allow mounting multiple partitions on the same REMOVABLE drive.
MessageBoxExU(hMainDialog, lmprintf(MSG_198), lmprintf(MSG_190), MB_OK|MB_ICONERROR|MB_IS_RTL, selected_langid);
return FALSE;
}
// I never had any success with drives that have the REMOVABLE attribute set, no matter the
// method or tool I tried. If you manage to get this working, I'd like to hear from you!
if (MessageBoxExU(hMainDialog, lmprintf(MSG_098), lmprintf(MSG_190), MB_YESNO|MB_ICONWARNING|MB_IS_RTL, selected_langid) != IDYES)
return FALSE;
}
// If multiple versions are available, asks the user to select one before we commit to format the drive
if (!SetWinToGoIndex())

View File

@ -390,6 +390,7 @@ extern RUFUS_IMG_REPORT img_report;
extern int64_t iso_blocking_status;
extern uint16_t rufus_version[3], embedded_sl_version[2];
extern int nWindowsVersion;
extern int nWindowsBuildNumber;
extern char WindowsVersionStr[128];
extern char ubuffer[256];
extern char embedded_sl_version_str[2][12];

View File

@ -33,7 +33,7 @@ LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
IDD_DIALOG DIALOGEX 12, 12, 242, 376
STYLE DS_SETFONT | DS_MODALFRAME | DS_CENTER | WS_MINIMIZEBOX | WS_POPUP | WS_CAPTION | WS_SYSMENU
EXSTYLE WS_EX_ACCEPTFILES
CAPTION "Rufus 2.15.1089"
CAPTION "Rufus 2.15.1090"
FONT 8, "Segoe UI Symbol", 400, 0, 0x0
BEGIN
LTEXT "Device",IDS_DEVICE_TXT,9,6,200,8
@ -334,8 +334,8 @@ END
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,15,1089,0
PRODUCTVERSION 2,15,1089,0
FILEVERSION 2,15,1090,0
PRODUCTVERSION 2,15,1090,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
@ -352,13 +352,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "Akeo Consulting (http://akeo.ie)"
VALUE "FileDescription", "Rufus"
VALUE "FileVersion", "2.15.1089"
VALUE "FileVersion", "2.15.1090"
VALUE "InternalName", "Rufus"
VALUE "LegalCopyright", "© 2011-2017 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "rufus.exe"
VALUE "ProductName", "Rufus"
VALUE "ProductVersion", "2.15.1089"
VALUE "ProductVersion", "2.15.1090"
END
END
BLOCK "VarFileInfo"

View File

@ -34,6 +34,7 @@
extern BOOL usb_debug; // For uuprintf
int nWindowsVersion = WINDOWS_UNDEFINED;
int nWindowsBuildNumber = -1;
char WindowsVersionStr[128] = "Windows ";
PF_TYPE_DECL(WINAPI, int, LCIDToLocaleName, (LCID, LPWSTR, int, DWORD));
@ -328,6 +329,7 @@ void GetWindowsVersion(void)
if (nWindowsVersion >= 0x62) {
GetRegistryKeyStr(REGKEY_HKLM, "Microsoft\\Windows NT\\CurrentVersion\\CurrentBuildNumber", build_number, sizeof(build_number));
if (build_number[0] != 0) {
nWindowsBuildNumber = atoi(build_number); // Keep a global copy
safe_strcat(WindowsVersionStr, sizeof(WindowsVersionStr), " (Build ");
safe_strcat(WindowsVersionStr, sizeof(WindowsVersionStr), build_number);
safe_strcat(WindowsVersionStr, sizeof(WindowsVersionStr), ")");