Optimize anticheat

This commit is contained in:
momo5502 2016-02-29 17:30:04 +01:00
parent 8d9f8749aa
commit 90e389ecdd
2 changed files with 8 additions and 5 deletions

View File

@ -2,6 +2,7 @@
namespace Components namespace Components
{ {
int AntiCheat::LastCheck;
std::string AntiCheat::Hash; std::string AntiCheat::Hash;
void __declspec(naked) AntiCheat::CrashClient() void __declspec(naked) AntiCheat::CrashClient()
@ -39,16 +40,15 @@ namespace Components
// This has to be called when doing .text changes during runtime // This has to be called when doing .text changes during runtime
void AntiCheat::EmptyHash() void AntiCheat::EmptyHash()
{ {
AntiCheat::LastCheck = 0;
AntiCheat::Hash.clear(); AntiCheat::Hash.clear();
} }
void AntiCheat::Frame() void AntiCheat::Frame()
{ {
static int lastCheck = 0; // Perform check only every 30 seconds
if (AntiCheat::LastCheck && (Game::Com_Milliseconds() - AntiCheat::LastCheck) < 1000 * 30) return;
// Perform check only every 20 seconds AntiCheat::LastCheck = Game::Com_Milliseconds();
if (lastCheck && (Game::Com_Milliseconds() - lastCheck) < 1000 * 20) return;
lastCheck = Game::Com_Milliseconds();
// Get base module // Get base module
std::string hash = Utils::Cryptography::SHA512::Compute(reinterpret_cast<uint8_t*>(GetModuleHandle(NULL)) + 0x1000, 0x2D6000, false); std::string hash = Utils::Cryptography::SHA512::Compute(reinterpret_cast<uint8_t*>(GetModuleHandle(NULL)) + 0x1000, 0x2D6000, false);
@ -67,6 +67,8 @@ namespace Components
AntiCheat::AntiCheat() AntiCheat::AntiCheat()
{ {
AntiCheat::EmptyHash();
Renderer::OnFrame(AntiCheat::Frame); Renderer::OnFrame(AntiCheat::Frame);
Dedicated::OnFrame(AntiCheat::Frame); Dedicated::OnFrame(AntiCheat::Frame);

View File

@ -11,6 +11,7 @@ namespace Components
static void EmptyHash(); static void EmptyHash();
private: private:
static int LastCheck;
static std::string Hash; static std::string Hash;
static void Frame(); static void Frame();