feat: add mutex to prevent double runs

This commit is contained in:
2026-06-20 06:53:20 -03:00
parent 26a4406c88
commit 579e0d1352
+15
View File
@@ -71,6 +71,21 @@ void StartWatchdog()
bool run() bool run()
{ {
/*
mutex check before running
*/
HANDLE mtx = CreateMutexA(NULL, TRUE, "Global\\HexUnlocked");
if (mtx == NULL) return false;
if (GetLastError() == ERROR_ALREADY_EXISTS)
{
MessageBoxA(NULL, "Program is already running", "Hex: Unlocked", MB_OK | MB_ICONERROR | MB_ICONINFORMATION);
CloseHandle(mtx);
return false;
}
/*
init
*/
seallib::Logger mainLog("Main"); seallib::Logger mainLog("Main");
mainLog.addSink(std::make_shared<ConOutSink>()); mainLog.addSink(std::make_shared<ConOutSink>());