[AntiCheat] Fix linux usage

This commit is contained in:
momo5502 2017-06-30 10:37:29 +02:00
parent d697c94388
commit 66dd013925
4 changed files with 24 additions and 17 deletions

View File

@ -466,7 +466,6 @@ namespace Components
unsigned long AntiCheat::ProtectProcess() unsigned long AntiCheat::ProtectProcess()
{ {
#ifdef PROCTECT_PROCESS #ifdef PROCTECT_PROCESS
if (Dedicated::IsEnabled()) return 0;
Utils::Memory::Allocator allocator; Utils::Memory::Allocator allocator;
HANDLE hToken = nullptr; HANDLE hToken = nullptr;

View File

@ -2,20 +2,9 @@
namespace Main 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() void Initialize()
{ {
Main::SetEnvironment(); Utils::SetEnvironment();
Utils::Cryptography::Initialize(); Utils::Cryptography::Initialize();
Components::Loader::Initialize(); Components::Loader::Initialize();
@ -71,8 +60,11 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l
#ifndef DISABLE_ANTICHEAT #ifndef DISABLE_ANTICHEAT
[]() []()
{ {
Components::AntiCheat::ProtectProcess(); if (!Components::Dedicated::IsEnabled())
Components::AntiCheat::PatchThreadCreation(); {
Components::AntiCheat::ProtectProcess();
Components::AntiCheat::PatchThreadCreation();
}
}(); }();
#endif #endif
@ -88,12 +80,15 @@ BOOL APIENTRY DllMain(HMODULE /*hModule*/, DWORD ul_reason_for_call, LPVOID /*l
{ {
Main::Uninitialize(); Main::Uninitialize();
} }
else if(ul_reason_for_call == DLL_THREAD_ATTACH) else if (ul_reason_for_call == DLL_THREAD_ATTACH)
{ {
#ifndef DISABLE_ANTICHEAT #ifndef DISABLE_ANTICHEAT
[]() []()
{ {
Components::AntiCheat::VerifyThreadIntegrity(); if (!Components::Dedicated::IsEnabled())
{
Components::AntiCheat::VerifyThreadIntegrity();
}
}(); }();
#endif #endif
} }

View File

@ -104,6 +104,17 @@ namespace Utils
return address; 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() HMODULE GetNTDLL()
{ {
static uint8_t ntdll[] = { 0x91, 0x8B, 0x9B, 0x93, 0x93, 0xD1, 0x9B, 0x93, 0x93 }; // ntdll.dll static uint8_t ntdll[] = { 0x91, 0x8B, 0x9B, 0x93, 0x93, 0xD1, 0x9B, 0x93, 0x93 }; // ntdll.dll

View File

@ -19,6 +19,8 @@ namespace Utils
void* GetThreadStartAddress(HANDLE hThread); void* GetThreadStartAddress(HANDLE hThread);
HMODULE GetNTDLL(); HMODULE GetNTDLL();
void SetEnvironment();
void OpenUrl(std::string url); void OpenUrl(std::string url);
bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2); bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2);