BEService spoofer refactoring.

This commit is contained in:
NukedBart 2025-12-11 23:35:30 +08:00
parent 444ccad844
commit 4a2dbcad27
6 changed files with 156 additions and 114 deletions

View file

@ -0,0 +1,44 @@
// services/GameMonitor.h
#pragma once
#include "core/WinApi.h"
#include <tlhelp32.h>
#include <string_view>
namespace GameMonitor
{
[[nodiscard]] inline bool IsGameRunning() noexcept
{
WinApi::UniqueHandle snapshot{ CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0) };
if (!snapshot || snapshot.get() == INVALID_HANDLE_VALUE)
return false;
PROCESSENTRY32W entry{ sizeof(entry) };
if (!Process32FirstW(snapshot.get(), &entry))
return false;
do
{
if (_wcsicmp(entry.szExeFile, L"EscapeFromTarkov.exe") == 0)
return true;
} while (Process32NextW(snapshot.get(), &entry));
return false;
}
[[nodiscard]] inline bool WaitForGame(DWORD maxWaitMs = 30 * 60 * 1000) noexcept
{
DWORD elapsed = 0;
const DWORD stepMs = 1000;
while (elapsed < maxWaitMs)
{
if (IsGameRunning())
return true;
Sleep(stepMs);
elapsed += stepMs;
}
return false;
}
}