From 579e0d1352971e8f0866ba583369869f3eab6a4c Mon Sep 17 00:00:00 2001 From: neru Date: Sat, 20 Jun 2026 06:53:20 -0300 Subject: [PATCH] feat: add mutex to prevent double runs --- src/unlocker/main.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/unlocker/main.cpp b/src/unlocker/main.cpp index 2c3676b..4ff889b 100644 --- a/src/unlocker/main.cpp +++ b/src/unlocker/main.cpp @@ -71,6 +71,21 @@ void StartWatchdog() 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"); mainLog.addSink(std::make_shared());