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.
This commit is contained in:
kernelpanic 2023-09-24 23:42:32 -04:00
parent ebe2ac98f8
commit ee513d7d0c

View file

@ -7,17 +7,20 @@ fn main() {
let args: Vec<String> = env::args().collect(); let args: Vec<String> = env::args().collect();
let iso_mount_dir = Path::new(args.get(1) 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."); .canonicalize().expect("Can't canonicalize path to XP ISO mount.");
if !iso_mount_dir.exists() || !iso_mount_dir.is_dir() { if !iso_mount_dir.exists() || !iso_mount_dir.is_dir() {
panic!("XP ISO mount is not a directory."); 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::<u8>().expect("Not a valid number for disk number!") i.parse::<u8>().expect("Not a valid number for disk number!")
} else { 1 }; } 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::<u8>().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 amd64_basedir = iso_mount_dir.join("amd64");
let i386_basedir = iso_mount_dir.join("i386"); 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()) { for index in 0..(bootmgr_contents.len() - win_nt_bt.len()) {
if &bootmgr_contents[index..index + rdisk0.len()] == rdisk0 { if &bootmgr_contents[index..index + rdisk0.len()] == rdisk0 {
println!("BOOTMGR: {index:#010x} Patching rdisk(0) --> rdisk({disk_number})"); println!("BOOTMGR: {index:#010x} Patching rdisk(0) --> rdisk({bootloader_disk_number})");
bootmgr_contents[index + 6] = 0x30 + disk_number; bootmgr_contents[index + 6] = 0x30 + bootloader_disk_number;
} }
if &bootmgr_contents[index..index + win_nt_bt.len()] == win_nt_bt if &bootmgr_contents[index..index + win_nt_bt.len()] == win_nt_bt