Metin2 game is to set an opening limit. In the future, a client limit can be applied so that the entrances are not blocked when opening the server.
One of the attacks on the server is to attack from the client, thanks to this, it is to force server entries by opening 10 or 15 or even more games from 1 computer.
Thanks to this system, it is to reduce the attack from the client to some extent, it is sold for money in many places.
#include <string>
#include <windows.h>
bool genMutex(int id)
{
std::string mutex_name = "MultiBoxBlock";
mutex_name.push_back(static_cast<char>(id));
HANDLE Mutex = OpenMutexA(MUTEX_ALL_ACCESS, FALSE, mutex_name.c_str());
if (!Mutex || WaitForSingleObject(Mutex, 500) == WAIT_ABANDONED)
{
CreateMutexA(NULL, FALSE, mutex_name.c_str());
Sleep(INFINITE);
return true;
}
return false;
}
int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
bool ret = false;
for (int i = 0; i < 3; i++)
{
ret = genMutex(i);
if (ret)
break;
}
if (!ret)
{
MessageBoxA(NULL, "MultiBox detected", "", MB_OK);
ExitProcess(0);
}
return 0;
}