Skip to content

MelonDS on_bus_exec hook doesn't respect ARM/THUMB switching bit #4649

@SuuperW

Description

@SuuperW

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Core: melonDSNintendo DS corere: APIHawkRelating to EmuHawk's public .NET API or to the creation of external toolsre: Lua API/scriptingRelating to EmuHawk's Lua API (not the Lua Console)

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions