So what I'm trying to do is simple; I want to write a function into the memory of another process and execute it. What I've done is gotten the size of the function and just used WriteProcessMemory to do this. I have successfully created a thread to run this function, confirmed using cheat engine's debugging features. The function looks like so:
inline void __cdecl Test( )
{ }
Looks pretty simple. It shouldn't rely on anything that needs to be relocated, so it should work just fine. It is inline because I defined it in a header, if that is relevant. Although this function does NOTHING, this is what is happening in cheat engine:
It's odd that it's copying a string, but more so that it's calling a function? Since this random function call is happening, the program crashes because the address isn't relocated to match where functions are in the new process. So, my question is: why in the world is it calling a function and how can I stop this from happening?
So basically, debug mode was the cause for this issue and does not occur in release.