From ee513d7d0c1526e56b4f807ffa7a0e2d1b28e843 Mon Sep 17 00:00:00 2001 From: kernelpanic <> Date: Sun, 24 Sep 2023 23:42:32 -0400 Subject: [PATCH] Support custom bootloader *and* installer disk number. For weird systems where NTLDR sees a different order of disks than the installer. I think the Windows XP RTM (original release/service pack 0) installer tends to do this. --- src/main.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index b8a1133..9cb5d92 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,17 +7,20 @@ fn main() { let args: Vec = env::args().collect(); let iso_mount_dir = Path::new(args.get(1) - .expect("Arguments: rsfus (path to XP ISO mount) [disk number]")) + .expect("Arguments: rsfus (path to XP ISO mount) [bootloader disk number] [installer disk number]")) .canonicalize().expect("Can't canonicalize path to XP ISO mount."); if !iso_mount_dir.exists() || !iso_mount_dir.is_dir() { panic!("XP ISO mount is not a directory."); } - let disk_number = if let Some(i) = args.get(2) { + let bootloader_disk_number = if let Some(i) = args.get(2) { i.parse::().expect("Not a valid number for disk number!") } else { 1 }; - let setup_source_line = format!("SetupSourceDevice = \"\\device\\harddisk{disk_number}\\partition1\""); + let installer_disk_number = if let Some(i) = args.get(3) { + i.parse::().expect("Not a valid number for disk number!") + } else { 1 }; + let setup_source_line = format!("SetupSourceDevice = \"\\device\\harddisk{installer_disk_number}\\partition1\""); let amd64_basedir = iso_mount_dir.join("amd64"); let i386_basedir = iso_mount_dir.join("i386"); @@ -88,8 +91,8 @@ fn main() { for index in 0..(bootmgr_contents.len() - win_nt_bt.len()) { if &bootmgr_contents[index..index + rdisk0.len()] == rdisk0 { - println!("BOOTMGR: {index:#010x} Patching rdisk(0) --> rdisk({disk_number})"); - bootmgr_contents[index + 6] = 0x30 + disk_number; + println!("BOOTMGR: {index:#010x} Patching rdisk(0) --> rdisk({bootloader_disk_number})"); + bootmgr_contents[index + 6] = 0x30 + bootloader_disk_number; } if &bootmgr_contents[index..index + win_nt_bt.len()] == win_nt_bt