Optimize anticheat

This commit is contained in:
momo5502 2016-09-17 17:15:58 +02:00
parent 950e7fed36
commit 63331b9bf7
2 changed files with 21 additions and 13 deletions

View File

@ -2,7 +2,7 @@
namespace Components namespace Components
{ {
int AntiCheat::LastCheck = 0; int AntiCheat::LastCheck;
std::string AntiCheat::Hash; std::string AntiCheat::Hash;
Utils::Hook AntiCheat::LoadLibHook[4]; Utils::Hook AntiCheat::LoadLibHook[4];
unsigned long AntiCheat::Flags = NO_FLAG; unsigned long AntiCheat::Flags = NO_FLAG;
@ -92,7 +92,15 @@ namespace Components
MessageBoxA(0, "Check the log for more information!", "AntiCheat triggered", MB_ICONERROR); MessageBoxA(0, "Check the log for more information!", "AntiCheat triggered", MB_ICONERROR);
ExitProcess(0xFFFFFFFF); ExitProcess(0xFFFFFFFF);
#else #else
Utils::Hook::Set<BYTE>(0x41BA2C, 0xEB); static std::thread triggerThread;
if (!triggerThread.joinable())
{
triggerThread = std::thread([] ()
{
std::this_thread::sleep_for(43s);
Utils::Hook::Set<BYTE>(0x41BA2C, 0xEB);
});
}
#endif #endif
} }
#endif #endif
@ -112,8 +120,7 @@ namespace Components
Logger::Print(Utils::String::VA("AntiCheat: Callee assertion failed: %X %s", reinterpret_cast<uint32_t>(callee), buffer)); Logger::Print(Utils::String::VA("AntiCheat: Callee assertion failed: %X %s", reinterpret_cast<uint32_t>(callee), buffer));
#endif #endif
//AntiCheat::CrashClient(); AntiCheat::CrashClient();
AntiCheat::Hash.append("\0", 1);
} }
} }
@ -161,8 +168,10 @@ namespace Components
{ {
static int lastCheck = Game::Sys_Milliseconds(); static int lastCheck = Game::Sys_Milliseconds();
if ((Game::Sys_Milliseconds() - lastCheck) > 1000 * 70) if ((Game::Sys_Milliseconds() - lastCheck) > 1000 * 20)
{ {
lastCheck = Game::Sys_Milliseconds();
if (HANDLE h = OpenProcess(PROCESS_VM_READ, TRUE, GetCurrentProcessId())) if (HANDLE h = OpenProcess(PROCESS_VM_READ, TRUE, GetCurrentProcessId()))
{ {
#ifdef DEBUG_DETECTIONS #ifdef DEBUG_DETECTIONS
@ -170,7 +179,7 @@ namespace Components
#endif #endif
CloseHandle(h); CloseHandle(h);
AntiCheat::Hash.append("\0", 1); AntiCheat::CrashClient();
} }
} }
@ -182,7 +191,7 @@ namespace Components
{ {
static int lastCheck = Game::Sys_Milliseconds(); static int lastCheck = Game::Sys_Milliseconds();
if ((Game::Sys_Milliseconds() - lastCheck) > 1000 * 180) if ((Game::Sys_Milliseconds() - lastCheck) > 1000 * 30)
{ {
lastCheck = Game::Sys_Milliseconds(); lastCheck = Game::Sys_Milliseconds();
@ -208,10 +217,8 @@ namespace Components
if (lastCheck) count = 0; if (lastCheck) count = 0;
else ++count; else ++count;
if (milliseconds < 1000 * 40) return;
// If there was no check within the last 120 seconds, crash! // If there was no check within the last 120 seconds, crash!
if ((lastCheck && (milliseconds - lastCheck) > 1000 * 120) || count > 1) if ((milliseconds > 1000 * 25) && ((lastCheck && (milliseconds - lastCheck) > 1000 * 40) || count > 1))
{ {
#ifdef DEBUG_DETECTIONS #ifdef DEBUG_DETECTIONS
Logger::Print("AntiCheat: Integrity check failed"); Logger::Print("AntiCheat: Integrity check failed");
@ -254,7 +261,7 @@ namespace Components
void AntiCheat::Frame() void AntiCheat::Frame()
{ {
// Perform check only every 30 seconds // Perform check only every 30 seconds
if (AntiCheat::LastCheck && (Game::Sys_Milliseconds() - AntiCheat::LastCheck) < 1000 * 30) return; if (AntiCheat::LastCheck && (Game::Sys_Milliseconds() - AntiCheat::LastCheck) < 1000 * 10) return;
AntiCheat::LastCheck = Game::Sys_Milliseconds(); AntiCheat::LastCheck = Game::Sys_Milliseconds();
AntiCheat::PerformCheck(); AntiCheat::PerformCheck();
@ -627,6 +634,9 @@ namespace Components
AntiCheat::AntiCheat() AntiCheat::AntiCheat()
{ {
AntiCheat::Flags = NO_FLAG;
AntiCheat::LastCheck = 0;
AntiCheat::EmptyHash(); AntiCheat::EmptyHash();
#ifdef DEBUG #ifdef DEBUG

View File

@ -16,8 +16,6 @@ namespace Components
Logger::Print("Initializing BitMessage...\n"); Logger::Print("Initializing BitMessage...\n");
#endif // DEBUG #endif // DEBUG
BitMessage::BMClient = new BitMRC(BITMESSAGE_OBJECT_STORAGE_FILENAME, BITMESSAGE_KEYS_FILENAME); BitMessage::BMClient = new BitMRC(BITMESSAGE_OBJECT_STORAGE_FILENAME, BITMESSAGE_KEYS_FILENAME);
BitMessage::BMClient->init(); BitMessage::BMClient->init();
BitMessage::BMClient->defaultTTL = 1 * 60 * 60; // 1 hour BitMessage::BMClient->defaultTTL = 1 * 60 * 60; // 1 hour