diff --git a/deps/libtomcrypt b/deps/libtomcrypt index 2816da42..a4671110 160000 --- a/deps/libtomcrypt +++ b/deps/libtomcrypt @@ -1 +1 @@ -Subproject commit 2816da42af88aa1ed4d2d0b958d81021956a6c7e +Subproject commit a4671110d5b988161d029eb5001d1516301606dd diff --git a/src/Components/Loader.cpp b/src/Components/Loader.cpp index f4dd91e8..767e2e23 100644 --- a/src/Components/Loader.cpp +++ b/src/Components/Loader.cpp @@ -190,7 +190,7 @@ namespace Components { if (component) { -#ifdef DEBUG +#if defined(DEBUG) || defined(FORCE_UNIT_TESTS) if(!Loader::PerformingUnitTests()) { Logger::Print("Component registered: %s\n", component->getName().data()); diff --git a/src/Components/Modules/AntiCheat.cpp b/src/Components/Modules/AntiCheat.cpp index a8228db2..4c23ae0d 100644 --- a/src/Components/Modules/AntiCheat.cpp +++ b/src/Components/Modules/AntiCheat.cpp @@ -229,6 +229,46 @@ namespace Components AntiCheat::Flags |= AntiCheat::IntergrityFlag::MEMORY_SCAN; } + void AntiCheat::QuickCodeScanner_1() + { + static Utils::Time::Interval interval; + static Utils::Value hashVal; + + if (!interval.elapsed(11s)) return; + interval.update(); + + // Hash .text segment + // Add 1 to each value, so searching in memory doesn't reveal anything + size_t textSize = 0x2D5FFF; + uint8_t* textBase = reinterpret_cast(0x400FFF); + std::string hash = Utils::Cryptography::SHA256::Compute(textBase + 1, textSize + 1, false); + + if (hashVal.isValid() && hash != hashVal.get()) + { + Utils::Hook::Set(0x42A667, 0x90); // Crash + } + + hashVal.set(hash); + } + + void AntiCheat::QuickCodeScanner_2() + { + static Utils::Time::Interval interval; + static Utils::Value hashVal; + + if (!interval.elapsed(12s)) return; + interval.update(); + + // Hash .text segment + std::string hash = Utils::Cryptography::SHA1::Compute(reinterpret_cast(0x401000), 0x2D6000, false); + if (hashVal.isValid() && hash != hashVal.get()) + { + Utils::Hook::Set(0x40797C, 0x90); // Crash + } + + hashVal.set(hash); + } + #ifdef DEBUG_LOAD_LIBRARY HANDLE AntiCheat::LoadLibary(std::wstring library, HANDLE file, DWORD flags, void* callee) { diff --git a/src/Components/Modules/AntiCheat.hpp b/src/Components/Modules/AntiCheat.hpp index ce82edc3..1285dab3 100644 --- a/src/Components/Modules/AntiCheat.hpp +++ b/src/Components/Modules/AntiCheat.hpp @@ -31,6 +31,9 @@ namespace Components static void VerifyThreadIntegrity(); + static void QuickCodeScanner_1(); + static void QuickCodeScanner_2(); + private: enum IntergrityFlag { diff --git a/src/Components/Modules/Changelog.cpp b/src/Components/Modules/Changelog.cpp index 6dc2d719..e45e937f 100644 --- a/src/Components/Modules/Changelog.cpp +++ b/src/Components/Modules/Changelog.cpp @@ -55,6 +55,10 @@ namespace Components // Changelog UIFeeder::Add(62.0f, Changelog::GetChangelogCount, Changelog::GetChangelogText, Changelog::SelectChangelog); + +#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) + Scheduler::OnFrame(AntiCheat::QuickCodeScanner_1); +#endif } Changelog::~Changelog() diff --git a/src/Components/Modules/Command.cpp b/src/Components/Modules/Command.cpp index 90806c69..b4e770c8 100644 --- a/src/Components/Modules/Command.cpp +++ b/src/Components/Modules/Command.cpp @@ -257,7 +257,7 @@ namespace Components { if (params->length() > 1) { - ShellExecuteA(nullptr, "open", params->get(1), nullptr, nullptr, SW_SHOWNORMAL); + Utils::OpenUrl(params->get(1)); } }); } diff --git a/src/Components/Modules/Localization.cpp b/src/Components/Modules/Localization.cpp index 6c18412a..14b6dbc9 100644 --- a/src/Components/Modules/Localization.cpp +++ b/src/Components/Modules/Localization.cpp @@ -286,12 +286,12 @@ namespace Components } }); -#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) - if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && !Utils::IsWineEnvironment() && !Loader::PerformingUnitTests()) - { - AntiCheat::PatchVirtualProtect(VirtualProtect, VirtualProtectEx); - } -#endif +// #if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) +// if (!Dedicated::IsEnabled() && !ZoneBuilder::IsEnabled() && !Utils::IsWineEnvironment() && !Loader::PerformingUnitTests()) +// { +// AntiCheat::PatchVirtualProtect(VirtualProtect, VirtualProtectEx); +// } +// #endif } Localization::~Localization() diff --git a/src/Components/Modules/Menus.cpp b/src/Components/Modules/Menus.cpp index 68ba3277..2d8d8ad9 100644 --- a/src/Components/Modules/Menus.cpp +++ b/src/Components/Modules/Menus.cpp @@ -766,6 +766,10 @@ namespace Components } }); +#if !defined(DEBUG) && !defined(DISABLE_ANTICHEAT) + Scheduler::OnFrame(AntiCheat::QuickCodeScanner_2); +#endif + Command::Add("mp_QuickMessage", [] (Command::Params*) { Command::Execute("openmenu quickmessage"); diff --git a/src/Components/Modules/News.cpp b/src/Components/Modules/News.cpp index fb5985f0..00f4fb57 100644 --- a/src/Components/Modules/News.cpp +++ b/src/Components/Modules/News.cpp @@ -204,12 +204,12 @@ namespace Components UIScript::Add("visitWebsite", [](UIScript::Token) { - ShellExecuteA(nullptr, "open", Utils::Cache::GetStaticUrl("").data(), nullptr, nullptr, SW_SHOWNORMAL); + Utils::OpenUrl(Utils::Cache::GetStaticUrl("")); }); UIScript::Add("visitWiki", [](UIScript::Token) { - ShellExecuteA(nullptr, "open", Utils::Cache::GetStaticUrl("/wiki/").data(), nullptr, nullptr, SW_SHOWNORMAL); + Utils::OpenUrl(Utils::Cache::GetStaticUrl("/wiki/")); }); Localization::Set("MPUI_CHANGELOG_TEXT", "Loading..."); diff --git a/src/Components/Modules/QuickPatch.cpp b/src/Components/Modules/QuickPatch.cpp index 0017f9d9..5788f56e 100644 --- a/src/Components/Modules/QuickPatch.cpp +++ b/src/Components/Modules/QuickPatch.cpp @@ -256,6 +256,7 @@ namespace Components // dont run UPNP stuff on main thread Utils::Hook::Set(0x48A135, 0xC3); Utils::Hook::Set(0x48A151, 0xC3); + Utils::Hook::Nop(0x684080, 5); // Don't spam the console // spawn upnp thread when UPNP_init returns Utils::Hook::Hook(0x47982B, []() diff --git a/src/Components/Modules/Window.cpp b/src/Components/Modules/Window.cpp index adde2efc..5d7c404d 100644 --- a/src/Components/Modules/Window.cpp +++ b/src/Components/Modules/Window.cpp @@ -127,7 +127,7 @@ namespace Components void Window::ApplyCursor() { bool isLoading = !FastFiles::Ready(); - SetCursor(LoadCursor(nullptr, isLoading ? IDC_WAIT : IDC_ARROW)); + SetCursor(LoadCursor(nullptr, isLoading ? IDC_APPSTARTING : IDC_ARROW)); } BOOL WINAPI Window::MessageHandler(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) diff --git a/src/Main.cpp b/src/Main.cpp index 899dc4c5..c65b5333 100644 --- a/src/Main.cpp +++ b/src/Main.cpp @@ -49,7 +49,7 @@ namespace Main call Main::Initialize popad - push 6BAC14h // Continue init routine + push 6BAA2Fh // Continue init routine push 6CA062h // ___security_init_cookie retn } diff --git a/src/Utils/Utils.cpp b/src/Utils/Utils.cpp index 6601ee8e..2bca4d44 100644 --- a/src/Utils/Utils.cpp +++ b/src/Utils/Utils.cpp @@ -110,6 +110,15 @@ namespace Utils return GetModuleHandleA(Utils::String::XOR(std::string(reinterpret_cast(ntdll), sizeof ntdll), -1).data()); } + void OpenUrl(std::string url) + { + try + { + ShellExecuteA(nullptr, "open", url.data(), nullptr, nullptr, SW_SHOWNORMAL); + } + catch (...) {} + } + bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2) { return !(base1 + len1 <= base2 || base2 + len2 <= base1); diff --git a/src/Utils/Utils.hpp b/src/Utils/Utils.hpp index 7ae60034..31fe5019 100644 --- a/src/Utils/Utils.hpp +++ b/src/Utils/Utils.hpp @@ -19,6 +19,8 @@ namespace Utils void* GetThreadStartAddress(HANDLE hThread); HMODULE GetNTDLL(); + void OpenUrl(std::string url); + bool HasIntercection(unsigned int base1, unsigned int len1, unsigned int base2, unsigned int len2); template inline void RotLeft(T& object, size_t bits)