praydog / REFramework

Scripting platform, modding framework and VR support for all RE Engine games
https://cursey.github.io/reframework-book/
MIT License
2.92k stars 356 forks source link

emulation-dumper fails for Apollo Justice Trilogy #1101

Open ThePaSch opened 3 months ago

ThePaSch commented 3 months ago

I am attempting to regenerate RSZ structures for the Apollo Justice trilogy in order to troubleshoot an instant CTD after EMV Engine with the Resource Editor script is enabled. Since the most recent public RSZ dumps seem to be from release, and the game has received a patch since, my first suspicion was that the dumps may be outdated, so I went ahead and tried to dump the data myself.

The IL2CPP dump was freshly generated using the DD2 build from the most recent REFramework release, 1.5.7. Upon trying to run the emulation-dumper.py script from the game's executable directory with the following commandline:

python emulation-dumper.py -p GS456.exe -il2cpp_path il2cpp_dump.json

the script crashes with the following exception:

Traceback (most recent call last):
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 880, in <module>
    fire.Fire(main)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 853, in main
    struct_layout = detect_members_chain(struct_name, chains[struct_name]["deserializer_chain"])
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 796, in detect_members_chain
    "layout": detect_members(int(entry["address"], 16))
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 767, in detect_members
    emu.emu_start(meta_frame["start"], deserializer_start + 0x10000)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\unicorn\unicorn.py", line 344, in emu_start
    raise self._hook_exception
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\unicorn\unicorn.py", line 212, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\unicorn\unicorn.py", line 513, in _hook_mem_invalid_cb
    return cb(self, access, address, size, value, data)
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 518, in hook_unmapped
    nops.fill(0x90)
OverflowError: Python integer 144 out of bounds for int8

OS is Windows 11 Build 22621.3958. Python version is 3.9.5.

praydog commented 3 months ago

Dump GS456.exe with x64dbg's Scylla plugin and use that instead.

These are the correct commands for DD2:

python .\emulation-dumper.py --p="DD2_dumpv3.exe" --il2cpp_path="il2cpp_dump.json" --test_mode=False

python .\non-native-dumper.py --out_postfix="dd2" --natives_path=".\native_layouts_DD2_dumpv3.exe.json" --il2cpp_path="il2cpp_dump.json" --use_typedefs=False --use_hashkeys=True

ThePaSch commented 3 months ago

Thank you! I've dumped the executable using Scylla and the script does indeed run a lot farther than before (it previously crashed pretty much immediately), but it does still end up crashing about 90% in. The stack trace looks pretty much identical:

90.265477%via.ColorRamp
STOPPING EXECUTION!!!!
Invalidating 1477B6A12
Invalidating 1477B6A3A
Invalidating 1477B6A70
Traceback (most recent call last):
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 880, in <module>
    fire.Fire(main)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 143, in Fire
    component_trace = _Fire(component, args, parsed_flag_args, context, name)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 477, in _Fire
    component, remaining_args = _CallAndUpdateTrace(
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\fire\core.py", line 693, in _CallAndUpdateTrace
    component = fn(*varargs, **kwargs)
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 853, in main
    struct_layout = detect_members_chain(struct_name, chains[struct_name]["deserializer_chain"])
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 796, in detect_members_chain
    "layout": detect_members(int(entry["address"], 16))
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 767, in detect_members
    emu.emu_start(meta_frame["start"], deserializer_start + 0x10000)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\unicorn\unicorn.py", line 344, in emu_start
    raise self._hook_exception
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\unicorn\unicorn.py", line 212, in wrapper
    return func(self, *args, **kwargs)
  File "C:\Users\XXXXX\AppData\Local\Programs\Python\Python39\lib\site-packages\unicorn\unicorn.py", line 513, in _hook_mem_invalid_cb
    return cb(self, access, address, size, value, data)
  File "F:\SteamLibrary\steamapps\common\Apollo Justice Ace Attorney Trilogy\emulation-dumper.py", line 518, in hook_unmapped
    nops.fill(0x90)
OverflowError: Python integer 144 out of bounds for int8