Adjust console for servers

This commit is contained in:
Maurice Heumann 2023-01-06 10:29:24 +01:00
parent f12e6261d1
commit 4312255566
4 changed files with 33 additions and 31 deletions

View File

@ -6,9 +6,9 @@
#include "steam/steam.hpp"
#include <utils/hook.hpp>
#include "utils/io.hpp"
#include "utils/string.hpp"
#include "utils/thread.hpp"
#include <utils/io.hpp>
#include <utils/string.hpp>
#include <utils/thread.hpp>
#define ProcessDebugPort 7
#define ProcessDebugObjectHandle 30

View File

@ -5,8 +5,6 @@
#include "scheduler.hpp"
#include <utils/hook.hpp>
namespace branding
{
namespace

View File

@ -23,11 +23,12 @@ namespace console
void print_message(const char* message)
{
if (started && !terminate_runner)
{
#ifndef NDEBUG
OutputDebugStringA(message);
#endif
if (started && !terminate_runner)
{
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<void(*)(const char*)>(print_func)(message);
@ -97,13 +98,13 @@ namespace console
game::Cbuf_AddText(0, "quit\n");
[[fallthrough]];
default:
return utils::hook::invoke<LRESULT>(0x142333520_g, hwnd, msg, wparam, lparam);
return utils::hook::invoke<LRESULT>(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<LRESULT>(0x142333820_g, hwnd, msg, wparam, lparam);
return utils::hook::invoke<LRESULT>(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<uint8_t>(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<uint8_t>(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;

View File

@ -14,14 +14,14 @@ namespace game
{0x14134C570};
// Com
WEAK symbol<void(int channel, unsigned int label, const char* fmt, ...)> Com_Printf{0x1421499C0};
WEAK symbol<void(int channel, unsigned int label, const char* fmt, ...)> Com_Printf{0x1421499C0, 0x140505630};
WEAK symbol<void(const char* file, int line, int code, const char* fmt, ...)> Com_Error_{0x1420F8BD0};
WEAK symbol<bool(eModes mode)> Com_SessionMode_IsMode{0x1420F7DD0};
WEAK symbol<void(uint32_t localClientNum, eModes fromMode, eModes toMode, uint32_t flags)> Com_SwitchMode{
0x14214AF30
};
WEAK symbol<void(uint32_t localClientNum, const char* text)> Cbuf_AddText{0x1420EC8B0};
WEAK symbol<void(uint32_t localClientNum, const char* text)> Cbuf_AddText{0x1420EC8B0, 0x1404F75B0};
WEAK symbol<void(const char* cmdName, xcommand_t function, cmd_function_s* allocedCmd)> Cmd_AddCommandInternal{
0x1420ED530, 0x1404F8210
};
@ -29,7 +29,7 @@ namespace game
bool fromRemoteConsol)> Cmd_ExecuteSingleCommand{
0x1420EDC20
};
WEAK symbol<void(char* text, int maxSize)> Con_GetTextCopy{0x14133A7D0};
WEAK symbol<void(char* text, int maxSize)> Con_GetTextCopy{0x14133A7D0, 0x140182C40};
// DB
WEAK symbol<void(XZoneInfo* zoneInfo, uint32_t zoneCount, bool sync, bool suppressSync)> DB_LoadXAssets{
@ -48,7 +48,7 @@ namespace game
// Sys
WEAK symbol<int()> Sys_Milliseconds{0x142333430};
WEAK symbol<void()> Sys_ShowConsole{0x142333F80};
WEAK symbol<void()> Sys_ShowConsole{0x142333F80, 0x140597E40 };
WEAK symbol<TLSData*()> Sys_GetTLS{0x142184210, 0x140525EB0};
// Dvar
@ -81,14 +81,14 @@ namespace game
namespace s_wcd
{
WEAK symbol<HWND> codLogo{0x157E77A50};
WEAK symbol<HFONT> hfBufferFont{0x157E77A58};
WEAK symbol<HWND> hWnd{0x157E77A40};
WEAK symbol<HWND> hwndBuffer{0x157E77A48};
WEAK symbol<HWND> hwndInputLine{0x157E77A60};
WEAK symbol<int> windowHeight{0x157E7806C};
WEAK symbol<int> windowWidth{0x157E78068};
WEAK symbol<WNDPROC> SysInputLineWndProc{0x157E78070};
WEAK symbol<HWND> codLogo{0x157E77A50, 0x14A640BC0};
WEAK symbol<HFONT> hfBufferFont{0x157E77A58, 0x14A640BC8};
WEAK symbol<HWND> hWnd{0x157E77A40, 0x14A640BB0};
WEAK symbol<HWND> hwndBuffer{0x157E77A48, 0x14A640BB8};
WEAK symbol<HWND> hwndInputLine{0x157E77A60, 0x14A640BD0};
WEAK symbol<int> windowHeight{0x157E7806C, 0x14A6411DC};
WEAK symbol<int> windowWidth{0x157E78068, 0x14A6411D8};
WEAK symbol<WNDPROC> SysInputLineWndProc{0x157E78070, 0x14A6411E0};
}
// Global game definitions