mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-04 00:47:23 +00:00
- shutdown if two launchers are open with no game
- send message if launcher is skipping a channel
This commit is contained in:
parent
f93536758f
commit
b233778ae0
@ -11,6 +11,7 @@ class Memory {
|
|||||||
public:
|
public:
|
||||||
static uint64_t FindPattern(const char* module, const char* Pattern[]);
|
static uint64_t FindPattern(const char* module, const char* Pattern[]);
|
||||||
static uint32_t GetBeamNGPID(const std::set<uint32_t>& BL);
|
static uint32_t GetBeamNGPID(const std::set<uint32_t>& BL);
|
||||||
|
static uint32_t GetLauncherPID(const std::set<uint32_t>& BL);
|
||||||
static uint64_t GetModuleBase(const char* Name);
|
static uint64_t GetModuleBase(const char* Name);
|
||||||
static void Print(const std::string& msg);
|
static void Print(const std::string& msg);
|
||||||
static void Inject(uint32_t PID);
|
static void Inject(uint32_t PID);
|
||||||
|
@ -118,10 +118,16 @@ void Launcher::LaunchGame() {
|
|||||||
|
|
||||||
void Launcher::WaitForGame() {
|
void Launcher::WaitForGame() {
|
||||||
std::set<uint32_t> BlackList;
|
std::set<uint32_t> BlackList;
|
||||||
|
int chan = 1;
|
||||||
do {
|
do {
|
||||||
auto PID = Memory::GetBeamNGPID(BlackList);
|
auto PID = Memory::GetBeamNGPID(BlackList);
|
||||||
|
if(PID == 0 && BlackList.empty() && Memory::GetLauncherPID({GetCurrentProcessId()})) {
|
||||||
|
Shutdown.store(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (PID != 0 && IPC::mem_used(PID)) {
|
if (PID != 0 && IPC::mem_used(PID)) {
|
||||||
BlackList.emplace(PID);
|
BlackList.emplace(PID);
|
||||||
|
LOG(INFO) << "Skipping Channel #" << chan++;
|
||||||
} else {
|
} else {
|
||||||
GamePID = PID;
|
GamePID = PID;
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,28 @@ uint32_t Memory::GetBeamNGPID(const std::set<uint32_t>& BL) {
|
|||||||
return pe32.th32ProcessID;
|
return pe32.th32ProcessID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t Memory::GetLauncherPID(const std::set<uint32_t>& BL) {
|
||||||
|
SetLastError(0);
|
||||||
|
PROCESSENTRY32 pe32;
|
||||||
|
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||||
|
HANDLE Snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
|
||||||
|
|
||||||
|
if (Process32First(Snapshot, &pe32)) {
|
||||||
|
do {
|
||||||
|
if (std::string("BeamMP-Launcher.exe") == pe32.szExeFile &&
|
||||||
|
BL.find(pe32.th32ProcessID) == BL.end() &&
|
||||||
|
BL.find(pe32.th32ParentProcessID) == BL.end()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} while (Process32Next(Snapshot, &pe32));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Snapshot != INVALID_HANDLE_VALUE) { CloseHandle(Snapshot); }
|
||||||
|
|
||||||
|
if (GetLastError() != 0) return 0;
|
||||||
|
return pe32.th32ProcessID;
|
||||||
|
}
|
||||||
|
|
||||||
uint64_t Memory::GetModuleBase(const char* Name) {
|
uint64_t Memory::GetModuleBase(const char* Name) {
|
||||||
return (uint64_t)GetModuleHandleA(Name);
|
return (uint64_t)GetModuleHandleA(Name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user