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
This commit is contained in:
1 parent
229a058208
commit
c7a0470585
1 file changed
+16
-10
+16
-10
@@ -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
|
||||
|
||||
Reference in new issue
Block a user