1
1
Fork 0
mirror of https://github.com/pbatard/rufus.git synced 2024-08-14 23:57:05 +00:00

[iso] add support for Windows XP/Server 2003 x64 ISOs

This commit is contained in:
Mattiwatti 2018-06-22 21:59:03 +02:00
parent faebe1040f
commit c8c8ac4c87
No known key found for this signature in database
GPG key ID: D40D1DBE299B83EA
3 changed files with 23 additions and 17 deletions

View file

@ -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<size-32; i++) {
for (j=0; j<ARRAYSIZE(patch_str_org); j++) {
if (safe_strnicmp(&buffer[i], patch_str_org[j], strlen(patch_str_org[j])-1) == 0) {
patch_str_rep = (img_report.winpe&WINPE_I386) == WINPE_I386?patch_str_rep_i386:patch_str_rep_amd64;
uprintf(" 0x%08X: '%s' -> '%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

View file

@ -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<ARRAYSIZE(pe_dirname); i++)
if (safe_stricmp(psz_dirname, pe_dirname[i]) == 0)
for (j=0; j<ARRAYSIZE(pe_file); j++)
@ -664,7 +664,7 @@ BOOL ExtractISO(const char* src_iso, const char* dest_dir, BOOL scan)
udf_dirent_t* p_udf_root;
char *tmp, *buf, *ext;
char path[MAX_PATH], path2[16];
const char* basedir[] = { "i386", "minint" };
const char* basedir[] = { "i386", "amd64", "minint" };
const char* tmp_sif = ".\\txtsetup.sif~";
iso_extension_mask_t iso_extension_mask = ISO_EXTENSION_ALL;
char* spacing = " ";
@ -859,7 +859,7 @@ out:
// during scan, to see if /minint was provided for OsLoadOptions, as it decides
// whether we should use 0x80 or 0x81 as the disk ID in the MBR
static_sprintf(path, "/%s/txtsetup.sif",
basedir[((img_report.winpe&WINPE_I386) == WINPE_I386)?0:1]);
basedir[((img_report.winpe&WINPE_I386) == WINPE_I386)?0:((img_report.winpe&WINPE_AMD64) == WINPE_AMD64?1:2)]);
ExtractISOFile(src_iso, path, tmp_sif, FILE_ATTRIBUTE_NORMAL);
tmp = get_token_data_file("OsLoadOptions", tmp_sif);
if (tmp != NULL) {

View file

@ -254,8 +254,9 @@ enum checksum_type {
#define OLD_C32_THRESHOLD { 53500, 148000 }
/* ISO details that the application may want */
#define WINPE_MININT 0x2A
#define WINPE_I386 0x15
#define WINPE_MININT 0x124
#define WINPE_I386 0x49
#define WINPE_AMD64 0x89
#define MAX_WIM_VERSION 0x000E0000
#define HAS_KOLIBRIOS(r) (r.has_kolibrios)
#define HAS_REACTOS(r) (r.reactos_path[0] != 0)
@ -263,7 +264,7 @@ enum checksum_type {
#define HAS_SYSLINUX(r) (r.sl_version != 0)
#define HAS_BOOTMGR(r) (r.has_bootmgr)
#define HAS_INSTALL_WIM(r) (r.install_wim_path[0] != 0)
#define HAS_WINPE(r) (((r.winpe & WINPE_MININT) == WINPE_MININT)||((r.winpe & WINPE_I386) == WINPE_I386))
#define HAS_WINPE(r) (((r.winpe & WINPE_MININT) == WINPE_MININT)||((r.winpe & WINPE_I386) == WINPE_I386)||((r.winpe & WINPE_AMD64) == WINPE_AMD64))
#define HAS_WINDOWS(r) (HAS_BOOTMGR(r) || (r.uses_minint) || HAS_WINPE(r))
#define HAS_WIN7_EFI(r) ((r.has_efi == 1) && HAS_INSTALL_WIM(r))
#define HAS_EFI_IMG(r) (r.efi_img_path[0] != 0)
@ -286,7 +287,7 @@ typedef struct {
uint32_t install_wim_version;
BOOLEAN is_iso;
BOOLEAN is_bootable_img;
uint8_t winpe;
uint16_t winpe;
uint8_t has_efi;
BOOLEAN has_4GB_file;
BOOLEAN has_long_filename;