It should be possible to read a pointer to code from memory and use the address with lua's event.on_bux_exec. ARM processors such as the ARM9 in melonDS use the least-significant bit (in the address used for a jump) for handling switches between ARM mode and THUMB mode. Thus there are pointers to code in a game's memory that are not 2-byte aligned. Giving such a value to on_bus_exec will result in the hook never being triggered.
As a result:
local address = memory.read_u32_le(code_pointer_address)
event.on_bus_exec(function() print("exec") end, address)
may result in no output even when the game loads the value at code_pointer_address then does a branch to that code.
It should be possible to read a pointer to code from memory and use the address with lua's
event.on_bux_exec. ARM processors such as the ARM9 in melonDS use the least-significant bit (in the address used for a jump) for handling switches between ARM mode and THUMB mode. Thus there are pointers to code in a game's memory that are not 2-byte aligned. Giving such a value to on_bus_exec will result in the hook never being triggered.As a result:
may result in no output even when the game loads the value at
code_pointer_addressthen does a branch to that code.