[c++]suspended thread

Posts 1–2 of 2 · Page 1 of 1
[Help] c++ suspended thread
Hello guys i have a problem in a c++ anticheat. (code is ready and is an old project of a friend, i need to add anti suspend thread) im very newbie in c++.
anticheat is a .dll file and hooked to an .exe
I want this .dll to make a ping or to send a message like hello somewhere, and IF ping or message doesnt receive an answer thats means the user has suspended-terminated this dll from the exe then the exe will close.
the dll is 'hooked' with loadlibrary in the exe.
When the exe run this dll works like anticheat with closing name exe checking bad words dll injection and etc.
but i want to do it unsuspended-cant be killed by a process explorer..so i need periodically to check from server side or just check somehow if this dll is running and if has been suspended/disabled then .exe will close.
have anyone a code for that?
@miomio
The best way to do this would be to modify the main .exe thread.
Make sure you save the thread handle from CreateThread in the DLL.
Make an external function in the DLL called "isRunning" or something else (make sure you encrypt or hide this function from hackers)
Then make a call to "isRunning" which will check if the DLL's anticheat thread is suspended or terminated.

In the DLL's isRunning function, which will run in the game's main thread, you can check suspension of the anticheat thread by calling SuspendThread, then immediately calling ResumeThread. If SuspendThread returns greater than 1, then the thread was previously suspended.

Next, you can check if the thread is terminated with WaitForSingleObject. If it returns WAIT_TIMEOUT, the thread is still alive. Otherwise, the thread has been terminated.

Then you can just return out of the exe if suspicious thread behavior is detected, or use ExitProcess(int exitCode);
Posts 1–2 of 2 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?