" it looks like the access violation (on exit) is because you're calling that function ptr" that was also my thought after I went to bed yesterday.
When your DLL get's detached, Arma might've already destructed all its internals. And then suddenly you call the arma internal function, even though your thread is supposed to exit.
Turn the while loop into a do/while loop, and move the sleep after the callGame
Also you don't really need a atomic as a flag, doesn't hurt tho ofc.















not enough time)