BEService spoofer refactoring.
This commit is contained in:
parent
444ccad844
commit
4a2dbcad27
6 changed files with 156 additions and 114 deletions
44
service/services/GameMonitor.h
Normal file
44
service/services/GameMonitor.h
Normal 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;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue