Skip to content

Instantly share code, notes, and snippets.

@ShellyHerself
Created October 17, 2021 20:42
Show Gist options
  • Save ShellyHerself/41918a554145e2994ec3f881e02604cc to your computer and use it in GitHub Desktop.
Save ShellyHerself/41918a554145e2994ec3f881e02604cc to your computer and use it in GitHub Desktop.
A simple tool that patches out the code that forces any of the Halo 3 tools to close when it hits a failed assertion.
DESCRIPTION = '''
A simple tool that patches out the code that forces any
of the Halo 3 tools to close when it hits a failed assertion.
Should work for all H3EK exes except the "fast" versions.
Licensed under GPLv3 https://www.gnu.org/licenses/gpl-3.0.en.html
Made by Shelly Herself!
Socials:
https://twitter.com/Shelly_Herself
https://github.com/gbMichelle
Donations are also welcome :)
https://ko-fi.com/shellyherself
https://paypal.me/gbmichelle
'''
print(DESCRIPTION)
print("""
#################################################
""")
import sys
import glob
from traceback import format_exc
args = sys.argv[1:]
if len(args) < 1:
print("Error: User didn't supply any exe paths to patch")
for arg in args:
print("Attempting to open", arg, "for patching")
with open(arg, 'rb+') as file:
# Read file into string
s = file.read()
# Search for code of the function that exits the game
i = s.find(b'\x48\x83\xEC\x48\x0F\x10\x01\xF2\x0F\x10\x49\x10\x48\x8D\x4C\x24\x20\x0F\x11\x44\x24\x20\x48\x89\x54\x24\x20\xF2\x0F\x11\x4C\x24\x30\xE8')
s = bytearray(s)
# Patch if found
if i != -1:
print("SUCCESS: Found the assertion exit code. Patching it out.")
s[i] = (b'\xC3')[0]
# Cry if not found
else:
print("ERROR: Couldn't find assertion exit code in given binary. So I can't patch it out.")
exit(1)
# Empty the file
file.seek(0)
file.truncate(0)
# Write new contents to the file
file.write(s)
file.flush()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment