How could I hook anywhere but the beginning of a function? I'm trying to add features to a third party executable, and I need it to execute it's code completely, then pass its data onto my function. I can't quite conceive how to do this.
Is there an easy way to do this? I can't find any hooking engines that implement this. I can't find any information on it anywhere.
I saw someone saying that you could add an illegal opcode then catch the exception, but I do not know how to do that.
Example (pseudo-code):
int moveCharacter(int x, int y) {
x += 5;
y += 5;
return 0;
}
Say I want to hook right before return 0
, and pass the new x
and y
variables to my own function (in an injected DLL, or code-cave) that writes the variables to a log file. After my function, I want to return to the original function, so that it can return like normal.