I'm reversing this x64 program and I'm trying to call a function of this target program through a debugger. Everytime I click "Hit me" a numeric value gets subtracted.
I've found the caller of that function (I've added a breakpoint on it and it breaks when I click on the "Hit me" button). Here it is the relevant code:
I know that x64 calling convention is to pass arguments via RCX, RDX, R8 and R9. I want call this function programmatically, and I'm planning to do it by allocating memory to the program (through debugger function) and inject the "hit me" call relevant code. After I'd create a thread on the right address allocated memory (this would call the "hit me" function" programmatically).
This is the code I've wrote:
but just after that (creating a thread on 0x014D0000
), the program crashes. Why? Am I missing something?