On Tue, 15 Jan 2019 12:10:19 +0100
Alexandre Chartre <alexandre.chartre@xxxxxxxxxx> wrote:
Thinking more about it (and I've probably missed something or I am just being
totally stupid because this seems way too simple), can't we just replace the
"call" with "push+jmp" and patch the jmp instruction?
Instead of having:
call target
Have:
push $done
static_call:
jmp target
done:
But how do you implement it? Inline assembly()? Then you need to be
able to do that for any type of function parameters (there will be
users that have 13 parameters!)
I believe people have mentioned having a gcc plugin that would do it
for us, which was one of the suggested solutions.
Then we can safely patch the "jmp" instruction to jump to a new target
with text_poke_bp(), using the new target as the text_poke_bp() handler:
new_jmp_code = opcode of "jmp new_target"
text_poke_bp(static_call, new_jmp_code, new_jmp_code_size, new_target);
Problems come with patching a call instruction, but there's no issue with patching
a jmp, no? (that's what jump labels do).
No change to the int3 handler, no thunk, this seems really too simple... :-)