From c8c8ac4c877f5cbe505d057dcaa55abfedde2421 Mon Sep 17 00:00:00 2001 From: Mattiwatti Date: Fri, 22 Jun 2018 21:59:03 +0200 Subject: [PATCH] [iso] add support for Windows XP/Server 2003 x64 ISOs --- src/format.c | 23 ++++++++++++++--------- src/iso.c | 8 ++++---- src/rufus.h | 9 +++++---- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/format.c b/src/format.c index 7e637528..64880906 100644 --- a/src/format.c +++ b/src/format.c @@ -1167,19 +1167,22 @@ static BOOL WritePBR(HANDLE hLogicalVolume) static BOOL SetupWinPE(char drive_letter) { char src[64], dst[32]; - const char* basedir[] = { "i386", "minint" }; + const char* basedir[] = { "i386", "amd64", "minint" }; const char* patch_str_org[] = { "\\minint\\txtsetup.sif", "\\minint\\system32\\" }; - const char* patch_str_rep[] = { "\\i386\\txtsetup.sif", "\\i386\\system32\\" }; - const char *win_nt_bt_org = "$win_nt$.~bt", *win_nt_bt_rep = "i386"; + const char* patch_str_rep_i386[] = { "\\i386\\txtsetup.sif", "\\i386\\system32\\" }; + const char* patch_str_rep_amd64[] = { "\\amd64\\txtsetup.sif", "\\amd64\\system32\\" }; + const char **patch_str_rep; + const char *win_nt_bt_org = "$win_nt$.~bt", *win_nt_bt_rep_i386 = "i386", *win_nt_bt_rep_amd64 = "amd64", *win_nt_bt_rep; const char *rdisk_zero = "rdisk(0)"; const LARGE_INTEGER liZero = { {0, 0} }; char setupsrcdev[64]; HANDLE handle = INVALID_HANDLE_VALUE; - DWORD i, j, size, rw_size, index = 0; + DWORD i, j, size, rw_size, index = 0, lst_index = 0; BOOL r = FALSE; char* buffer = NULL; - index = ((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1; + index = (img_report.winpe&(WINPE_I386|WINPE_AMD64))?0:2; + lst_index = ((img_report.winpe&WINPE_I386) == WINPE_I386)?0:((img_report.winpe&WINPE_AMD64) == WINPE_AMD64)?1:2; // Allow other values than harddisk 1, as per user choice for disk ID static_sprintf(setupsrcdev, "SetupSourceDevice = \"\\device\\harddisk%d\\partition1\"", ComboBox_GetCurSel(hDiskID)); @@ -1188,8 +1191,8 @@ static BOOL SetupWinPE(char drive_letter) static_sprintf(dst, "%c:\\ntdetect.com", drive_letter); CopyFileA(src, dst, TRUE); if (!img_report.uses_minint) { - // Create a copy of txtsetup.sif, as we want to keep the i386 files unmodified - static_sprintf(src, "%c:\\%s\\txtsetup.sif", drive_letter, basedir[index]); + // Create a copy of txtsetup.sif, as we want to keep the i386/amd64 files unmodified + static_sprintf(src, "%c:\\%s\\txtsetup.sif", drive_letter, basedir[lst_index]); static_sprintf(dst, "%c:\\txtsetup.sif", drive_letter); if (!CopyFileA(src, dst, TRUE)) { uprintf("Did not copy %s as %s: %s\n", src, dst, WindowsErrorString()); @@ -1213,7 +1216,7 @@ static BOOL SetupWinPE(char drive_letter) if (img_report.uses_minint) { uprintf("Detected \\minint directory with /minint option: nothing to patch\n"); r = TRUE; - } else if (!(img_report.winpe&WINPE_I386)) { + } else if (!(img_report.winpe&(WINPE_I386|WINPE_AMD64))) { uprintf("Detected \\minint directory only but no /minint option: not sure what to do\n"); } goto out; @@ -1254,6 +1257,7 @@ static BOOL SetupWinPE(char drive_letter) for (i=1; i '%s'\n", i, &buffer[i], patch_str_rep[j]); strcpy(&buffer[i], patch_str_rep[j]); i += (DWORD)max(strlen(patch_str_org[j]), strlen(patch_str_rep[j])); // in case org is a substring of rep @@ -1270,8 +1274,9 @@ static BOOL SetupWinPE(char drive_letter) buffer[i+6] = 0x30 + ComboBox_GetCurSel(hDiskID); uprintf(" 0x%08X: '%s' -> 'rdisk(%c)'\n", i, rdisk_zero, buffer[i+6]); } - // $WIN_NT$_~BT -> i386 + // $WIN_NT$_~BT -> i386/amd64 if (safe_strnicmp(&buffer[i], win_nt_bt_org, strlen(win_nt_bt_org)-1) == 0) { + win_nt_bt_rep = (img_report.winpe&WINPE_I386) == WINPE_I386?win_nt_bt_rep_i386:win_nt_bt_rep_amd64; uprintf(" 0x%08X: '%s' -> '%s%s'\n", i, &buffer[i], win_nt_bt_rep, &buffer[i+strlen(win_nt_bt_org)]); strcpy(&buffer[i], win_nt_bt_rep); // This ensures that we keep the terminator backslash diff --git a/src/iso.c b/src/iso.c index 4e9c6bb0..872fcf46 100644 --- a/src/iso.c +++ b/src/iso.c @@ -84,7 +84,7 @@ static const char* grub_dirname = "/boot/grub/i386-pc"; static const char* grub_cfg = "grub.cfg"; static const char* syslinux_cfg[] = { "isolinux.cfg", "syslinux.cfg", "extlinux.conf" }; static const char* isolinux_bin[] = { "isolinux.bin", "boot.bin" }; -static const char* pe_dirname[] = { "/i386", "/minint" }; +static const char* pe_dirname[] = { "/i386", "/amd64", "/minint" }; static const char* pe_file[] = { "ntdetect.com", "setupldr.bin", "txtsetup.sif" }; static const char* reactos_name = "setupldr.sys"; // TODO: freeldr.sys doesn't seem to work static const char* kolibri_name = "kolibri.img"; @@ -222,7 +222,7 @@ static BOOL check_iso_props(const char* psz_dirname, int64_t file_length, const static_sprintf(img_report.install_wim_path, "?:\\%s\\%s", &install_wim_path[1], install_wim_name[i]); } - // Check for PE (XP) specific files in "/i386" or "/minint" + // Check for PE (XP) specific files in "/i386", "/amd64" or "/minint" for (i=0; i