This commit is contained in:
Argon 2022-09-23 07:21:25 +08:00
parent f31608749c
commit 3fabc589a6
1 changed files with 15 additions and 1 deletions

View File

@ -227,9 +227,23 @@ fn apply_code(patch_file : &str, codes : &Vec<(u32, u32)>) -> Result<(), String>
}
pos += 4;
}
0x5 | 0x8 => {
0x5 => {
return Err(format!("apply code error at line {}: not supported", line));
}
0x8 => {
let count = (codes[pos].1 & 0xfff0000) >> 16;
let search_bytes = (first_code & 0xffff) as usize;
let code_len = ((search_bytes - 1) / 4 + 1) * 2;
let mut bytes = 0;
let mut search = Vec::with_capacity(search_bytes);
while bytes < search_bytes {
let offset = pos + 1 + (bytes / 4);
let shift = (3 - (bytes % 4)) * 8;
search.push(((codes[offset].1 >> shift) & 0xff) as u8);
bytes += 1;
}
pos += code_len;
}
0xa => {
let mut addr = (codes[pos].1 & 0xfffffff) as usize;
let write_bytes = codes[pos + 1].1 as usize;