If we can't detect original bytes, then check if patch is already
applied, if its not, provide further instructions
This commit is contained in:
1 parent
f86f7eaf1a
commit
75a2077b54
1 file changed
+12
-6
@@ -11,12 +11,12 @@ else:
|
|||||||
# But if that was all they needed to be, they could each be 3 hex characters long:
|
# But if that was all they needed to be, they could each be 3 hex characters long:
|
||||||
# original_bytes = b'\x48\x89\x54'
|
# original_bytes = b'\x48\x89\x54'
|
||||||
# new_and_improved_bytes = b'\xB0\x01\xC3'
|
# new_and_improved_bytes = b'\xB0\x01\xC3'
|
||||||
# However the issue is that this sequence of original_bytes shows up many many times in the executable,
|
# However the issue is that this sequence of original_bytes shows up many many times in the executable,
|
||||||
# so we would end up patching many places that don't need to be patched,
|
# so we would end up patching many places that don't need to be patched,
|
||||||
# causing unintended functionality (likely) or else just causing the program to crash (extremely likely)
|
# causing unintended functionality (likely) or else just causing the program to crash (extremely likely)
|
||||||
# instead, we specify *just* enough bytes such that the sequence only occurs in one place:
|
# instead, we specify *just* enough bytes such that the sequence only occurs in one place:
|
||||||
original_bytes = b'\x48\x89\x54\x24\x10\x55\x56\x57\x48\x81\xEC\xF0\x00\x00\x00\x48\xC7\x44\x24\x78'
|
original_bytes = b'\x48\x89\x54\x24\x10\x55\x56\x57\x48\x81\xEC\xF0\x00\x00\x00\x48\xC7\x44\x24\x78'
|
||||||
# translated (from Ghidra (used to disassemble this program)): 15a0b00dc(*)
|
# translated (from Ghidra (used to disassemble this program)): 15a0b00dc(*)
|
||||||
# 14178b6c0 48 89 54 MOV qword ptr [RSP + 0x10],RDX
|
# 14178b6c0 48 89 54 MOV qword ptr [RSP + 0x10],RDX
|
||||||
# 24 10
|
# 24 10
|
||||||
# 14178b6c5 55 PUSH RBP
|
# 14178b6c5 55 PUSH RBP
|
||||||
@@ -25,7 +25,7 @@ original_bytes = b'\x48\x89\x54\x24\x10\x55\x56\x57\x48\x81\xEC\xF0\x00\x00\x00\
|
|||||||
# 14178b6c8 48 81 ec SUB RSP,0xf0
|
# 14178b6c8 48 81 ec SUB RSP,0xf0
|
||||||
# f0 00 00 00
|
# f0 00 00 00
|
||||||
# 14178b6cf 48 c7 44 MOV qword ptr [RSP + 0x78],-0x2
|
# 14178b6cf 48 c7 44 MOV qword ptr [RSP + 0x78],-0x2
|
||||||
# 24 78 fe
|
# 24 78 fe
|
||||||
# ff ff ff
|
# ff ff ff
|
||||||
new_and_improved_bytes = b'\xB0\x01\xC3\x24\x10\x55\x56\x57\x48\x81\xEC\xF0\x00\x00\x00\x48\xC7\x44\x24\x78'
|
new_and_improved_bytes = b'\xB0\x01\xC3\x24\x10\x55\x56\x57\x48\x81\xEC\xF0\x00\x00\x00\x48\xC7\x44\x24\x78'
|
||||||
# Translated:
|
# Translated:
|
||||||
@@ -55,5 +55,11 @@ if patched_data != data:
|
|||||||
file.write(patched_data)
|
file.write(patched_data)
|
||||||
print(f"Success: Byte sequence found and replaced in {path}.")
|
print(f"Success: Byte sequence found and replaced in {path}.")
|
||||||
else:
|
else:
|
||||||
print("Notice: The search sequence was not found in the binary, no changes were made.")
|
if data.find(new_and_improved_bytes) >= 1:
|
||||||
|
print("The patch had already been applied to your .exe, no further changes were needed.")
|
||||||
|
else:
|
||||||
|
print("The original bytes were not found in the binary, and we couldn't detect the patch either. \n\n \
|
||||||
|
Please try running the patch again with the full path to your .exe, like this:")
|
||||||
|
print("python patch.py /path/to/trialsrising.exe")
|
||||||
|
print("")
|
||||||
|
print("If that still doesn't work, open an issue to let me know: https://github.com/kylefmohr/Trials-Rising-Steam-Deck-Patch/issues")
|
||||||
Reference in new issue
Block a user