From 90e389ecdd2144153153b70d81db219422e936c8 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 29 Feb 2016 17:30:04 +0100 Subject: [PATCH] Optimize anticheat --- src/Components/Modules/AntiCheat.cpp | 12 +++++++----- src/Components/Modules/AntiCheat.hpp | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index ee7299d6..8ab4a630 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -2,6 +2,7 @@ namespace Components { + int AntiCheat::LastCheck; std::string AntiCheat::Hash; void __declspec(naked) AntiCheat::CrashClient() @@ -39,16 +40,15 @@ namespace Components // This has to be called when doing .text changes during runtime void AntiCheat::EmptyHash() { + AntiCheat::LastCheck = 0; AntiCheat::Hash.clear(); } void AntiCheat::Frame() { - static int lastCheck = 0; - - // Perform check only every 20 seconds - if (lastCheck && (Game::Com_Milliseconds() - lastCheck) < 1000 * 20) return; - lastCheck = Game::Com_Milliseconds(); + // Perform check only every 30 seconds + if (AntiCheat::LastCheck && (Game::Com_Milliseconds() - AntiCheat::LastCheck) < 1000 * 30) return; + AntiCheat::LastCheck = Game::Com_Milliseconds(); // Get base module std::string hash = Utils::Cryptography::SHA512::Compute(reinterpret_cast(GetModuleHandle(NULL)) + 0x1000, 0x2D6000, false); @@ -67,6 +67,8 @@ namespace Components AntiCheat::AntiCheat() { + AntiCheat::EmptyHash(); + Renderer::OnFrame(AntiCheat::Frame); Dedicated::OnFrame(AntiCheat::Frame); diff --git a/src/Components/Modules/AntiCheat.hpp b/src/Components/Modules/AntiCheat.hpp index 59297ce9..4c322c98 100644 --- a/src/Components/Modules/AntiCheat.hpp +++ b/src/Components/Modules/AntiCheat.hpp @@ -11,6 +11,7 @@ namespace Components static void EmptyHash(); private: + static int LastCheck; static std::string Hash; static void Frame();