From 66dd013925b21f043b5f8c091c379eca1e66cbad Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 30 Jun 2017 10:37:29 +0200 Subject: [PATCH] [AntiCheat] Fix linux usage --- src/Components/Modules/AntiCheat.cpp | 1 - src/Main.cpp | 27 +++++++++++---------------- src/Utils/Utils.cpp | 11 +++++++++++ src/Utils/Utils.hpp | 2 ++ 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index ec206659..0e05336a 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -466,7 +466,6 @@ namespace Components unsigned long AntiCheat::ProtectProcess() { #ifdef PROCTECT_PROCESS - if (Dedicated::IsEnabled()) return 0; Utils::Memory::Allocator allocator; HANDLE hToken = nullptr; diff --git a/src/Main.cpp b/src/Main.cpp index 9a151023..fa6dfa0d 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -2,20 +2,9 @@ namespace Main { - void SetEnvironment() - { - wchar_t exeName[512]; - GetModuleFileName(GetModuleHandle(nullptr), exeName, sizeof(exeName) / 2); - - wchar_t* exeBaseName = wcsrchr(exeName, L'\\'); - exeBaseName[0] = L'\0'; - - SetCurrentDirectory(exeName); - } - void Initialize() { - Main::SetEnvironment(); + Utils::SetEnvironment(); Utils::Cryptography::Initialize(); Components::Loader::Initialize(); @@ -71,8 +60,11 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l #ifndef DISABLE_ANTICHEAT []() { - Components::AntiCheat::ProtectProcess(); - Components::AntiCheat::PatchThreadCreation(); + if (!Components::Dedicated::IsEnabled()) + { + Components::AntiCheat::ProtectProcess(); + Components::AntiCheat::PatchThreadCreation(); + } }(); #endif @@ -88,12 +80,15 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l { Main::Uninitialize(); } - else if(ul_reason_for_call == DLL_THREAD_ATTACH) + else if (ul_reason_for_call == DLL_THREAD_ATTACH) { #ifndef DISABLE_ANTICHEAT []() { - Components::AntiCheat::VerifyThreadIntegrity(); + if (!Components::Dedicated::IsEnabled()) + { + Components::AntiCheat::VerifyThreadIntegrity(); + } }(); #endif } diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index 2bca4d44..1000679d 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -104,6 +104,17 @@ namespace Utils return address; } + void SetEnvironment() + { + wchar_t exeName[512]; + GetModuleFileName(GetModuleHandle(nullptr), exeName, sizeof(exeName) / 2); + + wchar_t* exeBaseName = wcsrchr(exeName, L'\\'); + exeBaseName[0] = L'\0'; + + SetCurrentDirectory(exeName); + } + HMODULE GetNTDLL() { static uint8_t ntdll[] = { 0x91, 0x8B, 0x9B, 0x93, 0x93, 0xD1, 0x9B, 0x93, 0x93 }; // ntdll.dll diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index afcb1a0b..08d46d21 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -19,6 +19,8 @@ namespace Utils void* GetThreadStartAddress(HANDLE hThread); HMODULE GetNTDLL(); + void SetEnvironment(); + void OpenUrl(std::string url); bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);