mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2026-06-19 23:20:57 +00:00
- Changed BlackList to std::set
This commit is contained in:
@@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <set>
|
||||||
|
|
||||||
class Memory{
|
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::vector<uint32_t>& BL);
|
static uint32_t GetBeamNGPID(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);
|
||||||
|
|||||||
+2
-2
@@ -105,11 +105,11 @@ void Launcher::LaunchGame() {
|
|||||||
|
|
||||||
void Launcher::WaitForGame() {
|
void Launcher::WaitForGame() {
|
||||||
LOG(INFO) << "Searching for a game process, please start BeamNG manually in case of steam issues";
|
LOG(INFO) << "Searching for a game process, please start BeamNG manually in case of steam issues";
|
||||||
std::vector<uint32_t> BlackList;
|
std::set<uint32_t> BlackList;
|
||||||
do {
|
do {
|
||||||
auto PID = Memory::GetBeamNGPID(BlackList);
|
auto PID = Memory::GetBeamNGPID(BlackList);
|
||||||
if(PID != 0 && IPC::mem_used(PID)) {
|
if(PID != 0 && IPC::mem_used(PID)) {
|
||||||
BlackList.emplace_back(PID);
|
BlackList.emplace(PID);
|
||||||
} else {
|
} else {
|
||||||
GamePID = PID;
|
GamePID = PID;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,7 @@
|
|||||||
#include <tlhelp32.h>
|
#include <tlhelp32.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
|
|
||||||
uint32_t Memory::GetBeamNGPID(const std::vector<uint32_t>& BL) {
|
uint32_t Memory::GetBeamNGPID(const std::set<uint32_t>& BL) {
|
||||||
SetLastError(0);
|
SetLastError(0);
|
||||||
PROCESSENTRY32 pe32;
|
PROCESSENTRY32 pe32;
|
||||||
pe32.dwSize = sizeof(PROCESSENTRY32);
|
pe32.dwSize = sizeof(PROCESSENTRY32);
|
||||||
@@ -19,9 +19,9 @@ uint32_t Memory::GetBeamNGPID(const std::vector<uint32_t>& BL) {
|
|||||||
|
|
||||||
if(Process32First(Snapshot, &pe32)) {
|
if(Process32First(Snapshot, &pe32)) {
|
||||||
do{
|
do{
|
||||||
if(std::string("BeamNG.drive.x64.exe") == pe32.szExeFile &&
|
if(std::string("BeamNG.drive.x64.exe") == pe32.szExeFile
|
||||||
std::find(BL.begin(), BL.end(), pe32.th32ProcessID) == BL.end() &&
|
&& BL.find(pe32.th32ProcessID) == BL.end()
|
||||||
std::find(BL.begin(), BL.end(), pe32.th32ParentProcessID) == BL.end()) {
|
&& BL.find(pe32.th32ParentProcessID) == BL.end()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}while(Process32Next(Snapshot, &pe32));
|
}while(Process32Next(Snapshot, &pe32));
|
||||||
|
|||||||
Reference in New Issue
Block a user