Okay so I got all this code working FINE! However after I press F2 to execute the function a couple of seconds following I get a just in time debugger exception in my game detected by visual studio. The game still keeps running though and doesn't crash unless I acknowledge the error window then it terminates the process. I'm new to C++ so I'm probably fucking up somewhere and just missing it been on this for literally hours to no success I'm pretty sure it's something to do with my create thread but I can't be sure.
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
void popup()
{
if (GetAsyncKeyState(VK_F2))
{
((void(__cdecl*) (int, const char*))0x59DD70) (0, "popup_gamesetup");
}
}
void snip()
{
for (;; )
{
popup();
}
}
BOOL APIENTRY DllMain(HMODULE hModule, DWORD dwReason, LPVOID lpReserved)
{
if (dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)snip, 0,0,0);
}
return TRUE;
}
ps. I have used this exact method of create thread to write to memory and it worked fine with no issues at all