From 43122555662fdc255479ecc2cd63065a6cd10d02 Mon Sep 17 00:00:00 2001 From: Maurice Heumann Date: Fri, 6 Jan 2023 10:29:24 +0100 Subject: [PATCH] Adjust console for servers --- src/client/component/arxan.cpp | 6 +++--- src/client/component/branding.cpp | 2 -- src/client/component/console.cpp | 32 +++++++++++++++++-------------- src/client/game/symbols.hpp | 24 +++++++++++------------ 4 files changed, 33 insertions(+), 31 deletions(-) diff --git a/src/client/component/arxan.cpp b/src/client/component/arxan.cpp index f9c8bb1e..dc43c6e3 100644 --- a/src/client/component/arxan.cpp +++ b/src/client/component/arxan.cpp @@ -6,9 +6,9 @@ #include "steam/steam.hpp" #include -#include "utils/io.hpp" -#include "utils/string.hpp" -#include "utils/thread.hpp" +#include +#include +#include #define ProcessDebugPort 7 #define ProcessDebugObjectHandle 30 diff --git a/src/client/component/branding.cpp b/src/client/component/branding.cpp index c638a5d5..dc8a48d6 100644 --- a/src/client/component/branding.cpp +++ b/src/client/component/branding.cpp @@ -5,8 +5,6 @@ #include "scheduler.hpp" -#include - namespace branding { namespace diff --git a/src/client/component/console.cpp b/src/client/component/console.cpp index df31d086..9c7a2481 100644 --- a/src/client/component/console.cpp +++ b/src/client/component/console.cpp @@ -23,11 +23,12 @@ namespace console void print_message(const char* message) { +#ifndef NDEBUG + OutputDebugStringA(message); +#endif + if (started && !terminate_runner) { -#ifndef NDEBUG - OutputDebugStringA(message); -#endif game::Com_Printf(0, 0, "%s", message); } } @@ -46,7 +47,7 @@ namespace console { a.push(rbx); a.mov(eax, 0x8030); - a.jmp(0x142333667_g); + a.jmp(game::select(0x142333667, 0x140597527)); }); static_cast(print_func)(message); @@ -97,13 +98,13 @@ namespace console game::Cbuf_AddText(0, "quit\n"); [[fallthrough]]; default: - return utils::hook::invoke(0x142333520_g, hwnd, msg, wparam, lparam); + return utils::hook::invoke(game::select(0x142333520, 0x1405973E0), hwnd, msg, wparam, lparam); } } LRESULT input_line_wnd_proc(const HWND hwnd, const UINT msg, const WPARAM wparam, const LPARAM lparam) { - return utils::hook::invoke(0x142333820_g, hwnd, msg, wparam, lparam); + return utils::hook::invoke(game::select(0x142333820, 0x1405976E0), hwnd, msg, wparam, lparam); } void sys_create_console_stub(const HINSTANCE h_instance) @@ -111,7 +112,7 @@ namespace console char text[CONSOLE_BUFFER_SIZE]{0}; const auto* class_name = "BOIII WinConsole"; - const auto* window_name = "BOIII Console"; + const auto* window_name = game::is_server() ? "BOIII Server" : "BOIII Console"; WNDCLASSA wnd_class{}; wnd_class.style = 0; @@ -193,14 +194,19 @@ namespace console } } - struct component final : client_component + struct component final : generic_component { void post_unpack() override { - utils::hook::set(0x14133D2FE_g, 0xEB); // Always enable ingame console + utils::hook::jump(printf, print_stub); - utils::hook::jump(0x1423337F0_g, queue_message); - utils::hook::nop(0x14233380A_g, 2); // Print from every thread + if (!game::is_server()) + { + utils::hook::set(0x14133D2FE_g, 0xEB); // Always enable ingame console + } + + utils::hook::jump(game::select(0x1423337F0, 0x1405976B0), queue_message); + utils::hook::nop(game::select(0x14233380A, 0x1405976CA), 2); // Print from every thread //const auto self = utils::nt::library::get_by_address(sys_create_console_stub); //logo = LoadImageA(self.get_handle(), MAKEINTRESOURCEA(IMAGE_LOGO), 0, 0, 0, LR_COPYFROMRESOURCE); @@ -209,8 +215,6 @@ namespace console const auto img = utils::image::load_image(res); logo = utils::image::create_bitmap(img); - utils::hook::jump(printf, print_stub); - terminate_runner = false; this->message_runner_ = utils::thread::create_named_thread("Console IO", [] @@ -240,7 +244,7 @@ namespace console { { static utils::hook::detour sys_create_console_hook; - sys_create_console_hook.create(0x1423339C0_g, sys_create_console_stub); + sys_create_console_hook.create(game::select(0x1423339C0, 0x140597880), sys_create_console_stub); game::Sys_ShowConsole(); started = true; diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index 28cd008c..b3b2194d 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -14,14 +14,14 @@ namespace game {0x14134C570}; // Com - WEAK symbol Com_Printf{0x1421499C0}; + WEAK symbol Com_Printf{0x1421499C0, 0x140505630}; WEAK symbol Com_Error_{0x1420F8BD0}; WEAK symbol Com_SessionMode_IsMode{0x1420F7DD0}; WEAK symbol Com_SwitchMode{ 0x14214AF30 }; - WEAK symbol Cbuf_AddText{0x1420EC8B0}; + WEAK symbol Cbuf_AddText{0x1420EC8B0, 0x1404F75B0}; WEAK symbol Cmd_AddCommandInternal{ 0x1420ED530, 0x1404F8210 }; @@ -29,7 +29,7 @@ namespace game bool fromRemoteConsol)> Cmd_ExecuteSingleCommand{ 0x1420EDC20 }; - WEAK symbol Con_GetTextCopy{0x14133A7D0}; + WEAK symbol Con_GetTextCopy{0x14133A7D0, 0x140182C40}; // DB WEAK symbol DB_LoadXAssets{ @@ -48,7 +48,7 @@ namespace game // Sys WEAK symbol Sys_Milliseconds{0x142333430}; - WEAK symbol Sys_ShowConsole{0x142333F80}; + WEAK symbol Sys_ShowConsole{0x142333F80, 0x140597E40 }; WEAK symbol Sys_GetTLS{0x142184210, 0x140525EB0}; // Dvar @@ -81,14 +81,14 @@ namespace game namespace s_wcd { - WEAK symbol codLogo{0x157E77A50}; - WEAK symbol hfBufferFont{0x157E77A58}; - WEAK symbol hWnd{0x157E77A40}; - WEAK symbol hwndBuffer{0x157E77A48}; - WEAK symbol hwndInputLine{0x157E77A60}; - WEAK symbol windowHeight{0x157E7806C}; - WEAK symbol windowWidth{0x157E78068}; - WEAK symbol SysInputLineWndProc{0x157E78070}; + WEAK symbol codLogo{0x157E77A50, 0x14A640BC0}; + WEAK symbol hfBufferFont{0x157E77A58, 0x14A640BC8}; + WEAK symbol hWnd{0x157E77A40, 0x14A640BB0}; + WEAK symbol hwndBuffer{0x157E77A48, 0x14A640BB8}; + WEAK symbol hwndInputLine{0x157E77A60, 0x14A640BD0}; + WEAK symbol windowHeight{0x157E7806C, 0x14A6411DC}; + WEAK symbol windowWidth{0x157E78068, 0x14A6411D8}; + WEAK symbol SysInputLineWndProc{0x157E78070, 0x14A6411E0}; } // Global game definitions