From 3fabc589a6b09c189daaf5d034241699ccac00fc Mon Sep 17 00:00:00 2001 From: Argon Date: Fri, 23 Sep 2022 07:21:25 +0800 Subject: [PATCH] update --- src/main.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index e6a8ffe..5ec68f4 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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;