From 99a23e453c56cc76c0741e184c2baf03e7a2bb92 Mon Sep 17 00:00:00 2001 From: fed <58637860+fedddddd@users.noreply.github.com> Date: Fri, 20 May 2022 09:51:17 +0200 Subject: [PATCH] Server list --- src/client/component/console.cpp | 2 +- src/client/component/party.cpp | 2 +- src/client/component/server_list.cpp | 65 +++++++++++++++++++++++++--- src/client/game/symbols.hpp | 8 ++-- 4 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/client/component/console.cpp b/src/client/component/console.cpp index a54b60ee..ae040b5d 100644 --- a/src/client/component/console.cpp +++ b/src/client/component/console.cpp @@ -33,7 +33,7 @@ namespace console void dispatch_message(const int type, const std::string& message) { - printf(message.data()); + printf("%s", message.data()); game_console::print(type, message); } diff --git a/src/client/component/party.cpp b/src/client/component/party.cpp index 37fd040b..298eade2 100644 --- a/src/client/component/party.cpp +++ b/src/client/component/party.cpp @@ -573,7 +573,7 @@ namespace party network::on("infoResponse", [](const game::netadr_s& target, const std::string_view& data) { const utils::info_string info{data}; - // server_list::handle_info_response(target, info); + server_list::handle_info_response(target, info); if (connect_state.host != target) { diff --git a/src/client/component/server_list.cpp b/src/client/component/server_list.cpp index 342ba50e..cb51dc81 100644 --- a/src/client/component/server_list.cpp +++ b/src/client/component/server_list.cpp @@ -118,8 +118,7 @@ namespace server_list return diff > server_limit ? server_limit : static_cast(diff); } - const char* ui_feeder_item_text(int /*localClientNum*/, void* /*a2*/, void* /*a3*/, const int index, - const int column) + const char* ui_feeder_item_text(const int index, const int column) { std::lock_guard _(mutex); @@ -366,13 +365,65 @@ namespace server_list lui_open_menu_hook.create(game::LUI_OpenMenu, lui_open_menu_stub); // replace UI_RunMenuScript call in LUI_CoD_LuaCall_RefreshServerList to our refresh_servers - utils::hook::call(0x28E049_b, &refresh_server_list); - utils::hook::call(0x28E55E_b, &join_server); + utils::hook::jump(0x28E049_b, utils::hook::assemble([](utils::hook::assembler& a) + { + a.pushad64(); + a.call_aligned(refresh_server_list); + a.popad64(); + + a.xor_(eax, eax); + a.mov(rbx, qword_ptr(rsp, 0x38)); + a.add(rsp, 0x20); + a.pop(rdi); + a.ret(); + }), true); + + utils::hook::jump(0x28E557_b, utils::hook::assemble([](utils::hook::assembler& a) + { + a.mov(r8d, edi); + a.mov(ecx, eax); + a.mov(ebx, eax); + + a.pushad64(); + a.call_aligned(join_server); + a.popad64(); + + a.jmp(0x28E563_b); + }), true); + utils::hook::nop(0x28E57D_b, 5); // do feeder stuff - utils::hook::call(0x28E119_b, &ui_feeder_count); - utils::hook::call(0x28E331_b, &ui_feeder_item_text); + utils::hook::jump(0x28E117_b, utils::hook::assemble([](utils::hook::assembler& a) + { + a.mov(ecx, eax); + + a.pushad64(); + a.call_aligned(ui_feeder_count); + a.movd(xmm0, eax); + a.popad64(); + + a.mov(rax, qword_ptr(rbx, 0x48)); + a.cvtdq2ps(xmm0, xmm0); + a.mov(rdi, 0x28E12B_b); + a.jmp(rdi); + }), true); + + utils::hook::jump(0x28E331_b, utils::hook::assemble([](utils::hook::assembler& a) + { + a.push(rax); + a.pushad64(); + a.mov(rcx, r9); // index + a.mov(rdx, qword_ptr(rsp, 0x88 + 0x20)); // column + a.call_aligned(ui_feeder_item_text); + a.mov(qword_ptr(rsp, 0x80), rax); + a.popad64(); + a.pop(rax); + + a.mov(rsi, qword_ptr(rsp, 0x90)); + a.mov(rdi, rax); + a.jmp(0x28E341_b); + }), true); scheduler::loop(do_frame_work, scheduler::pipeline::main); @@ -423,4 +474,4 @@ namespace server_list }; } -//REGISTER_COMPONENT(server_list::component) +REGISTER_COMPONENT(server_list::component) diff --git a/src/client/game/symbols.hpp b/src/client/game/symbols.hpp index c602e6f1..b9016cbf 100644 --- a/src/client/game/symbols.hpp +++ b/src/client/game/symbols.hpp @@ -160,7 +160,7 @@ namespace game WEAK symbol LUI_EnterCriticalSection{0x0, 0x2669B0}; WEAK symbol LUI_LeaveCriticalSection{0x0, 0x26BDC0}; - WEAK symbol Menu_IsMenuOpenAndVisible{0x0, 0x0}; + WEAK symbol Menu_IsMenuOpenAndVisible{0x0, 0x389F70}; WEAK symbol SL_FindString{0x0, 0x0}; WEAK symbol SL_GetString{0x0, 0x5083A0}; @@ -192,13 +192,13 @@ namespace game WEAK symbol Sys_Error{0x0, 0x0}; WEAK symbol Sys_BuildAbsPath{0x0, 0x0}; - WEAK symbol Sys_Milliseconds{0x0, 0x0}; + WEAK symbol Sys_Milliseconds{0x0, 0x5BDDF0}; WEAK symbol Sys_IsDatabaseReady2{0x0, 0x4F79C0}; WEAK symbol Sys_SendPacket{0x0, 0x5BDA90}; WEAK symbol Sys_FileExists{0x0, 0x0}; - WEAK symbol UI_GetMapDisplayName{0x0, 0x0}; - WEAK symbol UI_GetGameTypeDisplayName{0x0, 0x4DD8C0}; + WEAK symbol UI_GetMapDisplayName{0x0, 0x4DDEE0}; + WEAK symbol UI_GetGameTypeDisplayName{0x0, 0x4DD8C0}; WEAK symbol UI_RunMenuScript{0x0, 0x1E35B0}; WEAK symbol UI_TextWidth{0x0, 0x0};