From cace0ece8c0340cc68d66f64d307303d3e33f9f2 Mon Sep 17 00:00:00 2001 From: BrentVL-1952840 <70229620+Brentdevent@users.noreply.github.com> Date: Sat, 18 Mar 2023 18:44:44 +0100 Subject: [PATCH 1/8] Also skip DOA/Campaign intro --- src/client/component/client_patches.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/client/component/client_patches.cpp b/src/client/component/client_patches.cpp index 54c4318a..10393f01 100644 --- a/src/client/component/client_patches.cpp +++ b/src/client/component/client_patches.cpp @@ -14,9 +14,10 @@ namespace client_patches { utils::hook::detour preload_map_hook; - void stop_zombies_intro_if_needed() + void stop_intro_if_needed() { - if (game::Com_SessionMode_GetMode() != game::MODE_ZOMBIES) + if (game::Com_SessionMode_GetMode() != game::MODE_ZOMBIES && + game::Com_SessionMode_GetMode() != game::MODE_CAMPAIGN) { return; } @@ -39,7 +40,7 @@ namespace client_patches void preload_map_stub(int localClientNum, const char* mapname, const char* gametype) { game::Com_GametypeSettings_SetGametype(gametype, false, false); - stop_zombies_intro_if_needed(); + stop_intro_if_needed(); preload_map_hook.invoke(localClientNum, mapname, gametype); } From de3c598885ead153de5fafe0064639e680d21f93 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 19 Mar 2023 18:21:48 +0100 Subject: [PATCH 2/8] Add call_safe method to symbols to spoof call stack --- src/client/component/arxan.cpp | 82 +++++++++++++++++++++++++++++++++- src/client/game/game.hpp | 28 ++++++++++-- 2 files changed, 106 insertions(+), 4 deletions(-) diff --git a/src/client/component/arxan.cpp b/src/client/component/arxan.cpp index c99b3d45..fcaa3220 100644 --- a/src/client/component/arxan.cpp +++ b/src/client/component/arxan.cpp @@ -4,14 +4,16 @@ #include "game/game.hpp" #include "steam/steam.hpp" -#include #include +#include #include #include #include "integrity.hpp" +#include + #define ProcessDebugPort 7 #define ProcessDebugObjectHandle 30 #define ProcessDebugFlags 31 @@ -19,8 +21,84 @@ namespace arxan { + namespace detail + { + void* callstack_proxy_addr{nullptr}; + static thread_local const void* address_to_call{}; + + void set_address_to_call(const void* address) + { + address_to_call = address; + } + } + namespace { + thread_local std::stack address_stack{}; + + const void* get_address_to_call() + { + return detail::address_to_call; + } + + void store_address(const uint64_t address) + { + address_stack.push(address); + } + + uint64_t get_stored_address() + { + const auto res = address_stack.top(); + address_stack.pop(); + + return res; + } + + void callstack_return_stub(utils::hook::assembler& a) + { + a.push(rax); + a.pushad64(); + + a.call_aligned(get_stored_address); + a.mov(qword_ptr(rsp, 0x80), rax); + + a.popad64(); + + a.add(rsp, 8); + + a.jmp(qword_ptr(rsp, -8)); + } + + uint64_t get_callstack_return_stub() + { + const auto placeholder = game::select(0x140001056, 0x140101167); + utils::hook::nop(placeholder, 1); + utils::hook::jump(placeholder + 1, utils::hook::assemble(callstack_return_stub)); + + return placeholder; + } + + void callstack_stub(utils::hook::assembler& a) + { + a.push(rax); + + a.pushad64(); + a.call_aligned(get_address_to_call); + a.mov(qword_ptr(rsp, 0x80), rax); + + a.mov(rcx, qword_ptr(rsp, 0x88)); + a.call_aligned(store_address); + + a.mov(rax, get_callstack_return_stub()); + a.mov(qword_ptr(rsp, 0x88), rax); + + a.popad64(); + + a.add(rsp, 8); + + a.jmp(qword_ptr(rsp, -8)); + } + constexpr auto pseudo_steam_id = 0x1337; const auto pseudo_steam_handle = reinterpret_cast(reinterpret_cast(INVALID_HANDLE_VALUE) - pseudo_steam_id); @@ -788,6 +866,8 @@ namespace arxan { search_and_patch_integrity_checks(); //restore_debug_functions(); + + detail::callstack_proxy_addr = utils::hook::assemble(callstack_stub); } component_priority priority() const override diff --git a/src/client/game/game.hpp b/src/client/game/game.hpp index 6c48470f..08c6ea96 100644 --- a/src/client/game/game.hpp +++ b/src/client/game/game.hpp @@ -3,6 +3,12 @@ #include "structs.hpp" #include +namespace arxan::detail +{ + void set_address_to_call(const void* address); + extern void* callstack_proxy_addr; +} + namespace game { size_t get_base(); @@ -42,15 +48,15 @@ namespace game } template - class symbol + class base_symbol { public: - symbol(const size_t address) + base_symbol(const size_t address) : address_(address) { } - symbol(const size_t address, const size_t server_address) + base_symbol(const size_t address, const size_t server_address) : address_(address) , server_address_(server_address) { @@ -76,6 +82,22 @@ namespace game size_t server_address_{}; }; + template + struct callable_symbol : base_symbol + { + using base_symbol::base_symbol; + + template + std::invoke_result_t call_safe(Args... args) + { + arxan::detail::set_address_to_call(this->get()); + return static_cast(arxan::detail::callstack_proxy_addr)(args...); + } + }; + + template + using symbol = std::conditional_t, callable_symbol, base_symbol>; + std::filesystem::path get_appdata_path(); } From 32040ce966fa788ab0da43f05c7532e651729c24 Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 19 Mar 2023 19:37:26 +0100 Subject: [PATCH 3/8] Override localized strings --- src/client/component/demonware.cpp | 4 ++ src/client/component/localized_strings.cpp | 52 ++++++++++++++++++++++ src/client/component/localized_strings.hpp | 6 +++ 3 files changed, 62 insertions(+) create mode 100644 src/client/component/localized_strings.cpp create mode 100644 src/client/component/localized_strings.hpp diff --git a/src/client/component/demonware.cpp b/src/client/component/demonware.cpp index dd868173..dc42f578 100644 --- a/src/client/component/demonware.cpp +++ b/src/client/component/demonware.cpp @@ -11,6 +11,8 @@ #include "game/demonware/servers/umbrella_server.hpp" #include "game/demonware/server_registry.hpp" +#include "localized_strings.hpp" + #define TCP_BLOCKING true #define UDP_BLOCKING false @@ -497,6 +499,8 @@ namespace demonware utils::hook::set(0x141F03130_g, 0xC300000001B8); // Kill LPC_DeleteStale utils::hook::set(0x141E0AA1B_g, 0xEB); // Release un-handled reportReward spamming loop + + localized_strings::override("MENU_CONNECTING_DW", "Emulating Online Service"); } void pre_destroy() override diff --git a/src/client/component/localized_strings.cpp b/src/client/component/localized_strings.cpp new file mode 100644 index 00000000..05d3242e --- /dev/null +++ b/src/client/component/localized_strings.cpp @@ -0,0 +1,52 @@ +#include +#include "loader/component_loader.hpp" +#include "localized_strings.hpp" +#include +#include +#include +#include "game/game.hpp" + +namespace localized_strings +{ + namespace + { + utils::hook::detour seh_string_ed_get_string_hook; + + using localized_map = std::unordered_map; + utils::concurrency::container localized_overrides; + + const char* seh_string_ed_get_string(const char* reference) + { + return localized_overrides.access([&](const localized_map& map) + { + const auto entry = map.find(reference); + if (entry != map.end()) + { + return utils::string::va("%s", entry->second.data()); + } + + return seh_string_ed_get_string_hook.invoke(reference); + }); + } + } + + void override(const std::string& key, const std::string& value) + { + localized_overrides.access([&](localized_map& map) + { + map[key] = value; + }); + } + + class component final : public client_component + { + public: + void post_unpack() override + { + // Change some localized strings + seh_string_ed_get_string_hook.create(0x1422796E0_g, &seh_string_ed_get_string); + } + }; +} + +REGISTER_COMPONENT(localized_strings::component) diff --git a/src/client/component/localized_strings.hpp b/src/client/component/localized_strings.hpp new file mode 100644 index 00000000..47c43894 --- /dev/null +++ b/src/client/component/localized_strings.hpp @@ -0,0 +1,6 @@ +#pragma once + +namespace localized_strings +{ + void override(const std::string& key, const std::string& value); +} From 638ea0862a212da92a047e68fc56d8606685163f Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 19 Mar 2023 21:22:59 +0100 Subject: [PATCH 4/8] Fix callable symbols --- src/client/game/game.hpp | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/client/game/game.hpp b/src/client/game/game.hpp index 08c6ea96..1e7c80f2 100644 --- a/src/client/game/game.hpp +++ b/src/client/game/game.hpp @@ -83,20 +83,24 @@ namespace game }; template - struct callable_symbol : base_symbol + struct symbol : base_symbol { using base_symbol::base_symbol; - - template - std::invoke_result_t call_safe(Args... args) - { - arxan::detail::set_address_to_call(this->get()); - return static_cast(arxan::detail::callstack_proxy_addr)(args...); - } }; - template - using symbol = std::conditional_t, callable_symbol, base_symbol>; + template + struct symbol : base_symbol + { + using func_type = T(Args...); + + using base_symbol::base_symbol; + + T call_safe(Args... args) + { + arxan::detail::set_address_to_call(this->get()); + return static_cast(arxan::detail::callstack_proxy_addr)(args...); + } + }; std::filesystem::path get_appdata_path(); } From c796aea416a1857387b4c4090736c562eebda422 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 19 Mar 2023 23:26:39 -0400 Subject: [PATCH 5/8] Change 4 character name limit to 2 characters --- src/client/component/network.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/client/component/network.cpp b/src/client/component/network.cpp index 4dbe5f1a..019edb72 100644 --- a/src/client/component/network.cpp +++ b/src/client/component/network.cpp @@ -291,6 +291,9 @@ namespace network // Set cl_maxpackets to 100 utils::hook::set(game::select(0x1412FF342, 0x140177A32), 100 - 15); + + // Change 4 character name limit to 2 characters + utils::hook::set(game::select(0x14224DBB4, 0x1405312A8), 0x02); } }; } From 0483ee2bd6ae2059e0de7b14c24b2277be1e0e1e Mon Sep 17 00:00:00 2001 From: Michael Date: Mon, 20 Mar 2023 08:36:19 -0400 Subject: [PATCH 6/8] Move 4 char name fix to patches.cpp --- src/client/component/network.cpp | 3 --- src/client/component/patches.cpp | 3 +++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/client/component/network.cpp b/src/client/component/network.cpp index 019edb72..4dbe5f1a 100644 --- a/src/client/component/network.cpp +++ b/src/client/component/network.cpp @@ -291,9 +291,6 @@ namespace network // Set cl_maxpackets to 100 utils::hook::set(game::select(0x1412FF342, 0x140177A32), 100 - 15); - - // Change 4 character name limit to 2 characters - utils::hook::set(game::select(0x14224DBB4, 0x1405312A8), 0x02); } }; } diff --git a/src/client/component/patches.cpp b/src/client/component/patches.cpp index abe3c552..a0df5c81 100644 --- a/src/client/component/patches.cpp +++ b/src/client/component/patches.cpp @@ -29,6 +29,9 @@ namespace patches { // don't make script errors fatal error utils::hook::call(game::select(0x1412CAC4D, 0x140158EB2), script_errors_stub); + + // Change 4 character name limit to 3 characters + utils::hook::set(game::select(0x14224DBB4, 0x1405312A8), 3); } }; } From 3a2c94faef3198541b94d0219ef896bfab91aeaa Mon Sep 17 00:00:00 2001 From: momo5502 Date: Mon, 20 Mar 2023 18:32:37 +0100 Subject: [PATCH 7/8] Make sure to save all GP registers --- src/common/utils/hook.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/common/utils/hook.cpp b/src/common/utils/hook.cpp index 2ba72fb9..f79874b4 100644 --- a/src/common/utils/hook.cpp +++ b/src/common/utils/hook.cpp @@ -190,12 +190,26 @@ namespace utils::hook this->push(rsi); this->push(rdi); - this->sub(rsp, 0x40); + this->push(r8); + this->push(r9); + this->push(r10); + this->push(r11); + this->push(r12); + this->push(r13); + this->push(r14); + this->push(r15); } void assembler::popad64() { - this->add(rsp, 0x40); + this->pop(r15); + this->pop(r14); + this->pop(r13); + this->pop(r12); + this->pop(r11); + this->pop(r10); + this->pop(r9); + this->pop(r8); this->pop(rdi); this->pop(rsi); From e7308c305ee6986f8ecbac4a059996399e019948 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Mar 2023 18:02:31 +0000 Subject: [PATCH 8/8] Bump deps/curl from `c3f3c25` to `b16d1fa` Bumps [deps/curl](https://github.com/curl/curl) from `c3f3c25` to `b16d1fa`. - [Release notes](https://github.com/curl/curl/releases) - [Commits](https://github.com/curl/curl/compare/c3f3c2557c64d4947f8c6337a0590cd28304d8fd...b16d1fa8ee567b52c09a0f89940b07d8491b881d) --- updated-dependencies: - dependency-name: deps/curl dependency-type: direct:production ... Signed-off-by: dependabot[bot] --- deps/curl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/curl b/deps/curl index c3f3c255..b16d1fa8 160000 --- a/deps/curl +++ b/deps/curl @@ -1 +1 @@ -Subproject commit c3f3c2557c64d4947f8c6337a0590cd28304d8fd +Subproject commit b16d1fa8ee567b52c09a0f89940b07d8491b881d