Hooking invalid instructions is essential for various purposes, however Unicorn would not recover from a hooked invalid instruction. The UC_HOOK_INSN_INVALID hook handler returns a boolean which supposed to indicate whether the incident has been handled successfully, however it seems that Unicorn ignores that return value and throws an exception either way.
Unicorn is expected to honor the return value and resume emulation if it got an indication that the incident has been handled, while the handler is expected to modify the PC appropriately before returning.
Attached here is a regress test file that may placed in the regress folder to test this behavior (note the .txt extension).
invalid_insn.py.txt
Hooking invalid instructions is essential for various purposes, however Unicorn would not recover from a hooked invalid instruction. The
UC_HOOK_INSN_INVALID
hook handler returns a boolean which supposed to indicate whether the incident has been handled successfully, however it seems that Unicorn ignores that return value and throws an exception either way.Unicorn is expected to honor the return value and resume emulation if it got an indication that the incident has been handled, while the handler is expected to modify the PC appropriately before returning.
Attached here is a regress test file that may placed in the
regress
folder to test this behavior (note the .txt extension). invalid_insn.py.txt