mirror of
https://github.com/BeamMP/BeamMP-Launcher.git
synced 2025-07-01 23:46:59 +00:00
check fix
This commit is contained in:
parent
db3f7b9988
commit
5753ebb887
@ -17,6 +17,7 @@ extern std::string UlStatus;
|
|||||||
extern std::string ListOfMods;
|
extern std::string ListOfMods;
|
||||||
void UDPSend(std::string Data);
|
void UDPSend(std::string Data);
|
||||||
int KillSocket(uint64_t Dead);
|
int KillSocket(uint64_t Dead);
|
||||||
|
void ClosePublic();
|
||||||
void CoreNetwork();
|
void CoreNetwork();
|
||||||
void GameSend(std::string Data);
|
void GameSend(std::string Data);
|
||||||
void SendLarge(std::string Data);
|
void SendLarge(std::string Data);
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
void PreGame(int argc, char* argv[],const std::string& GamePath);
|
void PreGame(int argc, char* argv[],const std::string& GamePath);
|
||||||
void InitGame(const std::string& Dir,const std::string&Current);
|
void InitGame(const std::string& Dir,const std::string&Current);
|
||||||
std::string CheckVer(const std::string &path);
|
std::string CheckVer(const std::string &path);
|
||||||
|
void FindDLL(const std::string& Name);
|
||||||
void SecurityCheck(char* argv[]);
|
void SecurityCheck(char* argv[]);
|
||||||
void FindDLL(char* args[]);
|
|
||||||
std::string GetGameDir();
|
std::string GetGameDir();
|
||||||
void LegitimacyCheck();
|
void LegitimacyCheck();
|
||||||
|
@ -66,12 +66,9 @@ void warn(const std::string& toPrint){
|
|||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
}
|
}
|
||||||
void error(const std::string& toPrint) {
|
void error(const std::string& toPrint) {
|
||||||
static int ECounter = 0;
|
|
||||||
std::string Print = getDate() + Sec("[ERROR] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[ERROR] ") + toPrint + "\n";
|
||||||
std::cout << Print;
|
std::cout << Print;
|
||||||
addToLog(Print);
|
addToLog(Print);
|
||||||
if(ECounter > 10)exit(7);
|
|
||||||
ECounter++;
|
|
||||||
}
|
}
|
||||||
void except(const std::string& toPrint) {
|
void except(const std::string& toPrint) {
|
||||||
std::string Print = getDate() + Sec("[EXCEP] ") + toPrint + "\n";
|
std::string Print = getDate() + Sec("[EXCEP] ") + toPrint + "\n";
|
||||||
|
@ -227,7 +227,7 @@ void CoreMain() {
|
|||||||
int Handle(EXCEPTION_POINTERS *ep){
|
int Handle(EXCEPTION_POINTERS *ep){
|
||||||
char* hex = new char[100];
|
char* hex = new char[100];
|
||||||
sprintf_s(hex,100, "%lX", ep->ExceptionRecord->ExceptionCode);
|
sprintf_s(hex,100, "%lX", ep->ExceptionRecord->ExceptionCode);
|
||||||
except(Sec("(Core) Code : ") + std::string(hex));
|
except(Sec("(Core) ") + std::string(hex));
|
||||||
delete [] hex;
|
delete [] hex;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -90,12 +90,7 @@ void ServerSend(std::string Data, bool Rel){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetReset(){
|
void ClosePublic(){
|
||||||
TCPTerminate = false;
|
|
||||||
GConnected = false;
|
|
||||||
Terminate = false;
|
|
||||||
UlStatus = Sec("Ulstart");
|
|
||||||
MStatus = " ";
|
|
||||||
if(UDPSock != (SOCKET)(-1)){
|
if(UDPSock != (SOCKET)(-1)){
|
||||||
debug(Sec("Terminating UDP Socket : ") + std::to_string(TCPSock));
|
debug(Sec("Terminating UDP Socket : ") + std::to_string(TCPSock));
|
||||||
KillSocket(UDPSock);
|
KillSocket(UDPSock);
|
||||||
@ -106,6 +101,15 @@ void NetReset(){
|
|||||||
KillSocket(TCPSock);
|
KillSocket(TCPSock);
|
||||||
}
|
}
|
||||||
TCPSock = -1;
|
TCPSock = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void NetReset(){
|
||||||
|
TCPTerminate = false;
|
||||||
|
GConnected = false;
|
||||||
|
Terminate = false;
|
||||||
|
UlStatus = Sec("Ulstart");
|
||||||
|
MStatus = " ";
|
||||||
|
ClosePublic();
|
||||||
if(GSocket != (SOCKET)(-1)){
|
if(GSocket != (SOCKET)(-1)){
|
||||||
debug(Sec("Terminating GTCP Socket : ") + std::to_string(GSocket));
|
debug(Sec("Terminating GTCP Socket : ") + std::to_string(GSocket));
|
||||||
KillSocket(GSocket);
|
KillSocket(GSocket);
|
||||||
|
@ -4,52 +4,44 @@
|
|||||||
#include "Network/network.h"
|
#include "Network/network.h"
|
||||||
#include "Security/Enc.h"
|
#include "Security/Enc.h"
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include "Logger.h"
|
#include <Logger.h>
|
||||||
#include <psapi.h>
|
#include <psapi.h>
|
||||||
#include <string>
|
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
|
|
||||||
DWORD getParentPID(DWORD pid);
|
|
||||||
HANDLE getProcess(DWORD pid, LPSTR fname, DWORD sz);
|
|
||||||
|
|
||||||
void Kill(){
|
void Kill(){
|
||||||
static bool Run = false;
|
static bool Run = false;
|
||||||
if(!Run)Run = true;
|
if(!Run)Run = true;
|
||||||
else return;
|
else return;
|
||||||
while(Run){
|
while(Run){
|
||||||
std::this_thread::sleep_for(std::chrono::seconds(2));
|
std::this_thread::sleep_for(std::chrono::milliseconds(200));
|
||||||
NetReset();
|
ClosePublic();
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
debug(Sec("Attention! NetReset Check!"));
|
debug("NetReset Check!");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void FindDLL(char* args[]){
|
void FindDLL(const std::string& Name) {
|
||||||
static auto argv = args;
|
static std::string PName = LocalEnc(Name.substr(0,Name.rfind(Sec("\\"))));
|
||||||
|
static bool Running = false;
|
||||||
|
if(Running)return;
|
||||||
HANDLE hProcess = GetCurrentProcess();
|
HANDLE hProcess = GetCurrentProcess();
|
||||||
std::string Parent(MAX_PATH,0);
|
HMODULE hMods[1024];
|
||||||
DWORD ppid = getParentPID(GetCurrentProcessId());
|
DWORD cbNeeded;
|
||||||
HANDLE Process = getProcess(ppid, &Parent[0], MAX_PATH);
|
unsigned int i;
|
||||||
if(Process == nullptr){
|
TCHAR szModName[MAX_PATH];
|
||||||
HMODULE hMods[1024];
|
if (K32EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)) {
|
||||||
DWORD cbNeeded;
|
for (i = 1; i < (cbNeeded / sizeof(HMODULE)); i++) {
|
||||||
unsigned int i;
|
if (K32GetModuleFileNameExA(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))) {
|
||||||
if(K32EnumProcessModules(hProcess, hMods, sizeof(hMods), &cbNeeded)){
|
std::string MName(szModName);
|
||||||
for ( i = 1; i < (cbNeeded / sizeof(HMODULE)); i++ ){
|
MName = MName.substr(0, MName.rfind(Sec("\\")));
|
||||||
TCHAR szModName[MAX_PATH];
|
if (MName == LocalDec(PName)) {
|
||||||
if (K32GetModuleFileNameExA(hProcess, hMods[i], szModName, sizeof(szModName) / sizeof(TCHAR))){
|
Running = true;
|
||||||
std::string Name(szModName),PName(argv[0]);
|
std::thread t1(Kill);
|
||||||
Name = Name.substr(0,Name.rfind(Sec("\\")));
|
t1.detach();
|
||||||
PName = PName.substr(0,PName.rfind(Sec("\\")));
|
|
||||||
if(Name == PName){
|
|
||||||
std::thread t1(Kill);
|
|
||||||
t1.detach();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
ZeroMemory(szModName,MAX_PATH);
|
|
||||||
}
|
}
|
||||||
|
ZeroMemory(szModName, MAX_PATH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
CloseHandle(hProcess);
|
CloseHandle(hProcess);
|
||||||
|
@ -181,7 +181,7 @@ void InitLauncher(int argc, char* argv[]) {
|
|||||||
SetConsoleTitleA((Sec("BeamMP Launcher v") + std::string(GetVer()) + GetPatch()).c_str());
|
SetConsoleTitleA((Sec("BeamMP Launcher v") + std::string(GetVer()) + GetPatch()).c_str());
|
||||||
InitLog();
|
InitLog();
|
||||||
CheckName(argc, argv);
|
CheckName(argc, argv);
|
||||||
FindDLL(argv);
|
FindDLL(argv[0]);
|
||||||
SecurityCheck(argv);
|
SecurityCheck(argv);
|
||||||
Discord_Main();
|
Discord_Main();
|
||||||
RequestRole();
|
RequestRole();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user