Support non-x64 Edition ISOs.
This commit is contained in:
parent
ce94ebd099
commit
8ef6666613
1 changed files with 24 additions and 12 deletions
26
src/main.rs
26
src/main.rs
|
@ -17,6 +17,8 @@ fn main() {
|
|||
let amd64_basedir = iso_mount_dir.join("amd64");
|
||||
let i386_basedir = iso_mount_dir.join("i386");
|
||||
|
||||
let x64_edition = amd64_basedir.is_dir();
|
||||
|
||||
{
|
||||
let mut ntdetect = File::open(amd64_basedir.join("ntdetect.com"))
|
||||
.or(File::open(i386_basedir.join("ntdetect.com")))
|
||||
|
@ -76,7 +78,8 @@ fn main() {
|
|||
let rdisk0 = b"rdisk(0)".as_slice();
|
||||
let win_nt_bt = b"$win_nt$.~bt".as_slice();
|
||||
let win_nt_bt_caps = b"$WIN_NT$.~BT".as_slice();
|
||||
let amd64_bytes = b"amd64";
|
||||
let new_dir_bytes = b"i386";
|
||||
let new_dir_bytes_x64 = b"amd64";
|
||||
|
||||
for index in 0..(bootmgr_contents.len() - win_nt_bt.len()) {
|
||||
if &bootmgr_contents[index..index + rdisk0.len()] == rdisk0 {
|
||||
|
@ -84,16 +87,25 @@ fn main() {
|
|||
bootmgr_contents[index + 6] = 0x31;
|
||||
}
|
||||
|
||||
// $WIN_NT$_~BT -> i386/amd64
|
||||
if &bootmgr_contents[index..index + win_nt_bt.len()] == win_nt_bt
|
||||
|| &bootmgr_contents[index..index + win_nt_bt.len()] == win_nt_bt_caps {
|
||||
if x64_edition {
|
||||
println!("BOOTMGR: {index:#010x} Patching {:?} --> \"amd64\"", bootmgr_contents[index..index + win_nt_bt.len()].to_vec());
|
||||
for i in 0..amd64_bytes.len() {
|
||||
bootmgr_contents[index+i] = amd64_bytes[i];
|
||||
for i in 0..new_dir_bytes_x64.len() {
|
||||
bootmgr_contents[index + i] = new_dir_bytes_x64[i];
|
||||
}
|
||||
bootmgr_contents[index + new_dir_bytes_x64.len()] = 0;
|
||||
bootmgr_contents[index + new_dir_bytes_x64.len()] = bootmgr_contents[index + win_nt_bt.len()];
|
||||
bootmgr_contents[index + new_dir_bytes_x64.len() + 1] = 0;
|
||||
} else {
|
||||
println!("BOOTMGR: {index:#010x} Patching {:?} --> \"i386\"", bootmgr_contents[index..index + win_nt_bt.len()].to_vec());
|
||||
for i in 0..new_dir_bytes.len() {
|
||||
bootmgr_contents[index + i] = new_dir_bytes[i];
|
||||
}
|
||||
bootmgr_contents[index + new_dir_bytes.len()] = 0;
|
||||
bootmgr_contents[index + new_dir_bytes.len()] = bootmgr_contents[index + win_nt_bt.len()];
|
||||
bootmgr_contents[index + new_dir_bytes.len() + 1] = 0;
|
||||
}
|
||||
bootmgr_contents[index + amd64_bytes.len()] = 0;
|
||||
bootmgr_contents[index + amd64_bytes.len()] = bootmgr_contents[index + win_nt_bt.len()];
|
||||
bootmgr_contents[index + amd64_bytes.len() + 1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue