From c7a0470585e7734b90c1b69f569f1294de2a1098 Mon Sep 17 00:00:00 2001 From: Kyle Mohr <6644803+kylefmohr@users.noreply.github.com> Date: Fri, 9 May 2025 17:15:41 -0500 Subject: [PATCH] Update patcher.py to reflect the most recent update to the game Removed support for Ubisoft exe (unless it happens to be at the exact same offset) as I only analyzed the Steam version of the game --- patcher.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/patcher.py b/patcher.py index 1d82322..e321018 100644 --- a/patcher.py +++ b/patcher.py @@ -3,10 +3,10 @@ import shutil import getpass def modify_exe(input_path): - steam_version_offset = 0x0178ACC0 - ubisoft_connect_version_offset = 0x01789EE0 - expected_bytes = bytes.fromhex("48 89 54 24 10 55 56 57 48 81 EC F0 00 00 00 48") - replacement_bytes = bytes.fromhex("B0 01 C3 24 10 55 56 57 48 81 EC F0 00 00 00 48") + steam_version_offset = 0x0178bac2 + #ubisoft_connect_version_offset = 0x01789EE0 + expected_bytes = bytes.fromhex("40 0f b6 c7 0f 28 74 24 50 48 83 c4 68 5f 5b c3") + replacement_bytes = bytes.fromhex("31 C0 B0 01 0f 28 74 24 50 48 83 c4 68 5f 5b c3") expected_path_linux = '/home/' + getpass.getuser() + '/.local/share/Steam/steamapps/common/Trials Rising/datapack/trialsrising.exe' if not os.path.exists(input_path): @@ -24,22 +24,28 @@ def modify_exe(input_path): if offset + len(expected_bytes) > len(data): return False, "Offset exceeds file size" read_bytes = bytes(data[offset: offset + len(expected_bytes)]) + # Search for the expected bytes throughout the entire file, not just at the offset + # for i in range(len(data) - len(expected_bytes)): + # read_bytes = bytes(data[i: i + len(expected_bytes)]) + # if read_bytes == expected_bytes: + # print(f"Found expected bytes at offset: {hex(i)}") + # offset = i + # continue + # exit() if read_bytes == expected_bytes: print(f"Bytes matched at offset: {hex(offset)}. Modifying...") for i, byte in enumerate(replacement_bytes): data[offset + i] = byte return True, None + else: + print(f"These bytes: {read_bytes.hex()} did not match expected bytes: {expected_bytes.hex()}") return False, "Bytes did not match" modified, message = check_and_patch(steam_version_offset) if not modified: - print("This does not appear to be a Steam version of the game. Checking if it's Ubisoft Connect version...") - modified, message = check_and_patch(ubisoft_connect_version_offset) - if not modified: - print("Error: could not find bytes to patch. Is it possible that the file is already patched?") - print("Ensure you're only trying to patch the original trialsrising.exe file.") - return False + print(f"Error: {message}") + return False if modified: # backup original file