From 3cc705df27a1cb259155e1632c1d48ddaeb13be5 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 7 Mar 2016 22:52:53 +0100 Subject: [PATCH] Fix vidrestart bug --- deps/protobuf | 2 +- src/Components/Modules/AntiCheat.cpp | 34 ++++++++++++++++++++++------ src/Components/Modules/AntiCheat.hpp | 4 ++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/deps/protobuf b/deps/protobuf index 9242d9b7..6a8815be 160000 --- a/deps/protobuf +++ b/deps/protobuf @@ -1 +1 @@ -Subproject commit 9242d9b7f431e40d119faef8b583d945362ef04c +Subproject commit 6a8815bef9696e3cdd7365e103c30f38dd7ce940 diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index f319b244..64f53739 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -4,6 +4,7 @@ namespace Components { int AntiCheat::LastCheck; std::string AntiCheat::Hash; + Utils::Hook AntiCheat::LoadLibHook[4]; // This function does nothing, it only adds the two passed variables and returns the value // The only important thing it does is to clean the first parameter, and then return @@ -90,6 +91,17 @@ namespace Components AntiCheat::Hash.clear(); } + void AntiCheat::InitLoadLibHook() + { + static uint8_t loadLibStub[] = { 0x33, 0xC0, 0xC2, 0x04, 0x00 }; // xor eax, eax; retn 04h + static uint8_t loadLibExStub[] = { 0x33, 0xC0, 0xC2, 0x0C, 0x00 }; // xor eax, eax; retn 0Ch + + AntiCheat::LoadLibHook[0].Initialize(LoadLibraryA, loadLibStub, HOOK_JUMP); + AntiCheat::LoadLibHook[1].Initialize(LoadLibraryW, loadLibStub, HOOK_JUMP); + AntiCheat::LoadLibHook[2].Initialize(LoadLibraryExA, loadLibExStub, HOOK_JUMP); + AntiCheat::LoadLibHook[3].Initialize(LoadLibraryExW, loadLibExStub, HOOK_JUMP); + } + void AntiCheat::PerformCheck() { // Hash .text segment @@ -121,13 +133,18 @@ namespace Components void AntiCheat::PatchWinAPI() { - static uint8_t loadLibStub[] = { 0x33, 0xC0, 0xC2, 0x04, 0x00 }; // xor eax, eax; retn 04h - static uint8_t loadLibExStub[] = { 0x33, 0xC0, 0xC2, 0x0C, 0x00 }; // xor eax, eax; retn 0Ch + AntiCheat::LoadLibHook[0].Uninstall(); + AntiCheat::LoadLibHook[1].Uninstall(); + AntiCheat::LoadLibHook[2].Uninstall(); + AntiCheat::LoadLibHook[3].Uninstall(); - Utils::Hook(LoadLibraryA, loadLibStub, HOOK_JUMP).Install()->Quick(); - Utils::Hook(LoadLibraryW, loadLibStub, HOOK_JUMP).Install()->Quick(); - Utils::Hook(LoadLibraryExA, loadLibExStub, HOOK_JUMP).Install()->Quick(); - Utils::Hook(LoadLibraryExW, loadLibExStub, HOOK_JUMP).Install()->Quick(); + // Initialize directx :P + Utils::Hook::Call(0x5078C0)(); + + AntiCheat::LoadLibHook[0].Install(); + AntiCheat::LoadLibHook[1].Install(); + AntiCheat::LoadLibHook[2].Install(); + AntiCheat::LoadLibHook[3].Install(); } AntiCheat::AntiCheat() @@ -141,7 +158,10 @@ namespace Components }); #else QuickPatch::OnFrame(AntiCheat::Frame); - QuickPatch::Once(AntiCheat::PatchWinAPI); + Utils::Hook(0x507BD5, AntiCheat::PatchWinAPI, HOOK_CALL).Install()->Quick(); + + // TODO: Probably move that :P + AntiCheat::InitLoadLibHook(); #endif } diff --git a/src/Components/Modules/AntiCheat.hpp b/src/Components/Modules/AntiCheat.hpp index c647db44..ee869575 100644 --- a/src/Components/Modules/AntiCheat.hpp +++ b/src/Components/Modules/AntiCheat.hpp @@ -10,6 +10,8 @@ namespace Components static void CrashClient(); static void EmptyHash(); + static void InitLoadLibHook(); + private: static int LastCheck; static std::string Hash; @@ -19,5 +21,7 @@ namespace Components static void PatchWinAPI(); static void NullSub(); + + static Utils::Hook LoadLibHook[4]; }; }