I made a trainer for gta san andreas samp.
its an external hack that once it starts it uses a base address and some offsets to find the dynamic address that it will write to. it does this once.
in the infinite loop, if i press a button example 4,6 it increments or decrements the x.y player values
the code is somewhat like this (its simplified)
Simplified code
HWND hwnd = FindWindowA(0, "GTA:SA:MP");
GetWindowThreadProcessId(handle, &pid);
HANDLE phandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
if(4 is pressed)
{
PlayerX--;
}
if(6 is pressed)
{
PlayerX++;
}
WriteProcessMemory(phandle, (LPVOID)(PointerX), &PlayerX, sizeof(float), 0);
The hack works just as intended but...
The problem is after some seconds or minutes later after use in samp. the game sorta locks. but not crash. everything works but. it doesnt register input like mouse and keyboard. and when i minimize the game and focus it again it doesnt go to the main menu!
This shit only happen when i use the trainer.
HELP PLZ!!

BTW this only happens when writeprocessmemory is spammed
readprocessmemory is fine when spammed every 50ms