diff --git a/README.md b/README.md index 8d659ba..4fd26a5 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ A tool aimed at enhancing the experience when playing the game on linux through ## Dependencies -- Python >= 3.8.xx (lowest tested) +- Python >= 3.8 ## Usage diff --git a/er-patcher b/er-patcher index fdd5350..69ce45a 100755 --- a/er-patcher +++ b/er-patcher @@ -32,58 +32,80 @@ if __name__ == "__main__": exe_hex = f.read().hex() if patch.rate != 60 and patch.rate > 0: - exe_hex = exe_hex.replace( - "c743208988883ceb43897318ebca897318", - "c743208988883ceb43897318ebca897318".replace( - "8988883c", struct.pack(' XORPS XMM1,XMM1; PXOR XMM1,XMM1 - if exe_hex[iad_addr + iad_offset:iad_addr + iad_offset + len(iad_patch)] == "f3 41 0f 5e 4c 24 54".replace(" ", ""): + iad_pattern = "e8 .. .. .. .. 0f 28 .. 0f 28 .. e8 .. .. .. .. f3 0f .. .. 0f 28 .. f3 41 0f 5e 4c 24 54".replace(" ", "") + if (res := re.search(iad_pattern, exe_hex)) is not None: + iad_addr = res.span()[0] + 46 + iad_patch = "0f 57 c9 66 0f ef c9".replace(" ", "") # DIVSS XMM1,dword ptr [R12 + 0x54] -> XORPS XMM1,XMM1; PXOR XMM1,XMM1 exe_hex = exe_hex[:iad_addr] + iad_patch + exe_hex[iad_addr + len(iad_patch):] + else: + print("er-patcher: increase_animation_distance pattern scan failed") if patch.skip_intro or patch.all: - exe_hex = exe_hex.replace( - "80 bf b8 00 00 00 00 74 53 48".replace(" ", ""), - "80 bf b8 00 00 00 00 90 90 48".replace(" ", "") - ) + si_pattern = "80 bf b8 00 00 00 00 74 53 48".replace(" ", "") + if (res := re.search(si_pattern, exe_hex)) is not None: + si_addr = res.span()[0] + 14 + si_patch = "90 90".replace(" ", "") + exe_hex = exe_hex[:si_addr] + si_patch + exe_hex[si_addr + len(si_patch):] + else: + print("er-patcher: skip_intro pattern scan failed") if patch.remove_60hz_fullscreen or patch.all: - exe_hex = exe_hex.replace( - "c745ef3c000000", - "c745ef00000000" - ) - + fs_pattern = "c7 45 ef 3c 00 00 00".replace(" ", "") + if (res := re.search(fs_pattern, exe_hex)) is not None: + fs_addr = res.span()[0] + 6 + fs_patch = "00" + exe_hex = exe_hex[:fs_addr] + fs_patch + exe_hex[fs_addr + len(fs_patch):] + else: + print("er-patcher: remove_60hz_fullscreen pattern scan failed") + game_dir_patched = Path("er-patcher-tmp") if not game_dir_patched.is_dir(): game_dir_patched.mkdir()