From b9c7e0a08ca609c9efda72fac47275c88670f299 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Fri, 28 Dec 2018 01:43:53 +0100 Subject: [PATCH] Move generic patches into an own module --- src/module/ceg.cpp | 5 ----- src/module/patches.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++ src/module/stats.cpp | 19 ----------------- 3 files changed, 48 insertions(+), 24 deletions(-) create mode 100644 src/module/patches.cpp delete mode 100644 src/module/stats.cpp diff --git a/src/module/ceg.cpp b/src/module/ceg.cpp index a413ea3..9516547 100644 --- a/src/module/ceg.cpp +++ b/src/module/ceg.cpp @@ -8,11 +8,6 @@ class ceg final : public module public: void post_load() override { - if (game::is_dedi()) return; - - // Remove improper quit check - utils::hook::nop(SELECT_VALUE(0x53444A, 0x5CCDC0, 0), 9); - // Only SP has CEG // CEG in MP has accidentally been removed due to CVE-2018-10718 if (!game::is_sp()) return; diff --git a/src/module/patches.cpp b/src/module/patches.cpp new file mode 100644 index 0000000..d3e893b --- /dev/null +++ b/src/module/patches.cpp @@ -0,0 +1,48 @@ +#include +#include "loader/module_loader.hpp" +#include "utils/hook.hpp" +#include "game/game.hpp" + +class patches final : public module +{ +public: + void post_load() override + { + if (!game::is_dedi()) this->patch_clients(); + + if (game::is_sp()) this->patch_sp(); + else if (game::is_mp()) this->patch_mp(); + else if (game::is_dedi()) this->patch_dedi(); + } + +private: + void patch_clients() const + { + // Remove improper quit check + utils::hook::nop(SELECT_VALUE(0x53444A, 0x5CCDC0, 0), 9); + + // Ignore sdm files + utils::hook::nop(SELECT_VALUE(0x4438BA, 0x6371EA, 0), 2); + } + + void patch_sp() const + { + // SP doesn't initialize WSA + WSADATA wsa_data; + WSAStartup(MAKEWORD(2, 2), &wsa_data); + + // Disable remote storage + utils::hook::set(0x663B5A, 0xEB); + utils::hook::set(0x663C54, 0xEB); + } + + void patch_mp() const + { + } + + void patch_dedi() const + { + } +}; + +REGISTER_MODULE(patches) diff --git a/src/module/stats.cpp b/src/module/stats.cpp deleted file mode 100644 index 9c3b2bd..0000000 --- a/src/module/stats.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include "loader/module_loader.hpp" -#include "utils/hook.hpp" -#include "game/game.hpp" - -class stats final : public module -{ -public: - void post_load() override - { - if (!game::is_sp()) return; - - // Disable remote storage - utils::hook::set(0x663B5A, 0xEB); - utils::hook::set(0x663C54, 0xEB); - } -}; - -REGISTER_MODULE(stats)