Skip to content

Instantly share code, notes, and snippets.

@ShellyHerself
Last active October 17, 2021 04:55
Show Gist options
  • Save ShellyHerself/715b5727cfee03ccf348ff9b37355626 to your computer and use it in GitHub Desktop.
Save ShellyHerself/715b5727cfee03ccf348ff9b37355626 to your computer and use it in GitHub Desktop.
A simple tool that patches out the code that forces any of the Halo 2 tools to close when it hits an assertion. Should work for all H2EK exes except the "fast" versions.
DESCRIPTION = '''
A simple tool that patches out the code that forces any
of the Halo 2 tools to close when it hits an assertion.
Should work for all H2EK exes except the "fast" versions.
Combining this with the following .bat script allows you
to use any of the tools completely without assertion messageboxes:
```
set DONT_TREAD_ON_ME_WITH_DEBUGGING_DIALOGS=TRUE
set DONT_SPAWN_TOOL_FOR_UPLOADS=TRUE
start halo2_tag_test.exe
```
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'\x55\x8B\xEC\xCC\xFF\x75\x08\xFF\x15')
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()
; Starts Halo 2 tag test while keeping debug messageboxes disabled.
; Combined with the patch from h2ek_tools_assertion_exit_patch.py
; this should effectively disable assertion errors.
set DONT_TREAD_ON_ME_WITH_DEBUGGING_DIALOGS=TRUE
set DONT_SPAWN_TOOL_FOR_UPLOADS=TRUE
start halo2_tag_test.exe
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment