Finish some stuff

This commit is contained in:
Federico Cecchetto 2022-05-28 15:51:38 +02:00
parent d2ec7fff4c
commit a2ce078549
4 changed files with 31 additions and 69 deletions

View File

@ -150,23 +150,7 @@ namespace colors
utils::hook::jump(0x5AEDF0_b, com_clean_name_stub, true); utils::hook::jump(0x5AEDF0_b, com_clean_name_stub, true);
// don't apply colors to overhead names // don't apply colors to overhead names
/*utils::hook::jump(0xF7B6A_b, utils::hook::assemble([](utils::hook::assembler& a) utils::hook::call(0xF7B85_b, get_client_name_stub);
{
a.lea(rax, qword_ptr(rbp, -0x10));
a.mov(dword_ptr(rsp, 0x28), 0xB);
a.mov(r9d, 0x20);
a.mov(qword_ptr(rsp, 0x20), rax);
a.lea(r8, qword_ptr(rbp));
a.push(rax);
a.pushad64();
a.call_aligned(get_client_name_stub);
a.mov(qword_ptr(rsp, 0x80), rax);
a.popad64();
a.pop(rax);
a.jmp(0xF7B8A_b);
}), true);*/
// patch I_CleanStr // patch I_CleanStr
utils::hook::jump(0x5AF2E0_b, i_clean_str_stub, true); utils::hook::jump(0x5AF2E0_b, i_clean_str_stub, true);

View File

@ -111,15 +111,16 @@ namespace party
return false; return false;
} }
void didyouknow_stub(const char* dvar_name, const char* string) const char* get_didyouknow_stub(void* a1, int a2, int a3)
{ {
if (!party::sv_motd.empty()) if (party::sv_motd.empty())
{ {
string = party::sv_motd.data(); return utils::hook::invoke<const char*>(0x5A0AC0_b, a1, a2, a3);
}
else
{
return utils::string::va("%s", party::sv_motd.data());
} }
// This function either does Dvar_SetString or Dvar_RegisterString for the given dvar
utils::hook::invoke<void>(0x1404FB210, dvar_name, string);
} }
void disconnect() void disconnect()
@ -146,13 +147,6 @@ namespace party
cl_disconnect_hook.invoke<void>(a1); cl_disconnect_hook.invoke<void>(a1);
} }
const auto drop_reason_stub = utils::hook::assemble([](utils::hook::assembler& a)
{
a.mov(rdx, rsi);
a.mov(ecx, 2);
a.jmp(0x12EF27_b);
});
void menu_error(const std::string& error) void menu_error(const std::string& error)
{ {
utils::hook::invoke<void>(0x17D770_b, error.data(), "MENU_NOTICE"); utils::hook::invoke<void>(0x17D770_b, error.data(), "MENU_NOTICE");
@ -334,8 +328,13 @@ namespace party
if (game::environment::is_mp()) if (game::environment::is_mp())
{ {
// show custom drop reason // show custom drop reason
// utils::hook::nop(0x12EF4E_b, 13); utils::hook::nop(0x12EF4E_b, 13);
// utils::hook::jump(0x12EF4E_b, drop_reason_stub, true); utils::hook::jump(0x12EF4E_b, utils::hook::assemble([](utils::hook::assembler& a)
{
a.mov(rdx, rsi);
a.mov(ecx, 2);
a.jmp(0x12EF27_b);
}), true);
command::add("disconnect", disconnect); command::add("disconnect", disconnect);
} }
@ -343,6 +342,9 @@ namespace party
// enable custom kick reason in GScr_KickPlayer // enable custom kick reason in GScr_KickPlayer
utils::hook::set<uint8_t>(0xE423D_b, 0xEB); utils::hook::set<uint8_t>(0xE423D_b, 0xEB);
// allow custom didyouknow based on sv_motd
utils::hook::call(0x1A8A3A_b, get_didyouknow_stub);
command::add("map", [](const command::params& argument) command::add("map", [](const command::params& argument)
{ {
if (argument.size() != 2) if (argument.size() != 2)
@ -557,8 +559,6 @@ namespace party
printf("%s\n", message.data()); printf("%s\n", message.data());
}); });
// utils::hook::call(0x1404C6E8D, didyouknow_stub); // allow custom didyouknow based on sv_motd
network::on("getInfo", [](const game::netadr_s& target, const std::string_view& data) network::on("getInfo", [](const game::netadr_s& target, const std::string_view& data)
{ {
utils::info_string info{}; utils::info_string info{};

View File

@ -121,7 +121,6 @@ namespace patches
return; return;
} }
command::params_sv params{}; command::params_sv params{};
const auto menu_id = atoi(params.get(1)); const auto menu_id = atoi(params.get(1));
const auto client = &svs_clients[ent->s.entityNum]; const auto client = &svs_clients[ent->s.entityNum];
@ -152,21 +151,12 @@ namespace patches
void aim_assist_add_to_target_list(void* a1, void* a2) void aim_assist_add_to_target_list(void* a1, void* a2)
{ {
if (!dvars::aimassist_enabled->current.enabled) if (!dvars::aimassist_enabled->current.enabled)
{
return; return;
}
game::AimAssist_AddToTargetList(a1, a2); game::AimAssist_AddToTargetList(a1, a2);
} }
void* sub_5BB990_stub()
{
auto v0 = !utils::hook::invoke<bool>(0x1B19E0_b, 0x3426D20_b);
auto result = *reinterpret_cast<void**>(0x3426D20_b);
if (v0)
{
result = reinterpret_cast<void*>(0xB807260_b);
}
return result;
}
} }
class component final : public component_interface class component final : public component_interface
@ -200,7 +190,7 @@ namespace patches
utils::hook::nop(SELECT_VALUE(0x1A9DDC_b, 0x13388F_b), 6); utils::hook::nop(SELECT_VALUE(0x1A9DDC_b, 0x13388F_b), 6);
// Allow executing custom cfg files with the "exec" command // Allow executing custom cfg files with the "exec" command
// utils::hook::jump(SELECT_VALUE(0x376EB5_b, 0x156D41_b), db_read_raw_file_stub); utils::hook::call(SELECT_VALUE(0x376EB5_b, 0x156D41_b), db_read_raw_file_stub);
if (!game::environment::is_sp()) if (!game::environment::is_sp())
{ {
@ -210,15 +200,7 @@ namespace patches
static void patch_mp() static void patch_mp()
{ {
// Use name dvar utils::hook::jump(0x5BB9C0_b, &live_get_local_client_name);
utils::hook::nop(0x5BB990_b, 0x27); // clear function
// jmp from 0x5BB9C0 to 0x5BB9A2 (leave some space for far jmp above)
utils::hook::set<uint16_t>(0x5BB9C0_b, 0xE0EB);
utils::hook::jump(0x5BB9A2_b, &live_get_local_client_name, true);
utils::hook::jump(0x5BB990_b, sub_5BB990_stub, true); // replace original function
// Make name save
dvars::override::register_string("name", get_login_username().data(), game::DVAR_FLAG_SAVED);
// Disable data validation error popup // Disable data validation error popup
dvars::override::register_int("data_validation_allow_drop", 0, 0, 0, game::DVAR_FLAG_NONE); dvars::override::register_int("data_validation_allow_drop", 0, 0, 0, game::DVAR_FLAG_NONE);
@ -230,20 +212,16 @@ namespace patches
utils::hook::set<uint8_t>(0x54CFF0_b, 0xC3); utils::hook::set<uint8_t>(0x54CFF0_b, 0xC3);
// client side aim assist dvar // client side aim assist dvar
/*dvars::aimassist_enabled = dvars::register_bool("aimassist_enabled", true, dvars::aimassist_enabled = dvars::register_bool("aimassist_enabled", true,
game::DvarFlags::DVAR_FLAG_SAVED, game::DvarFlags::DVAR_FLAG_SAVED,
"Enables aim assist for controllers"); "Enables aim assist for controllers");
utils::hook::call(0xE857F_b, aim_assist_add_to_target_list);*/ utils::hook::call(0xE857F_b, aim_assist_add_to_target_list);
// patch "Couldn't find the bsp for this map." error to not be fatal in mp // patch "Couldn't find the bsp for this map." error to not be fatal in mp
// utils::hook::jump(0x39465B_b, bsp_sys_error_stub); utils::hook::call(0x39465B_b, bsp_sys_error_stub);
// isProfanity // isProfanity
utils::hook::set(0x361AA0_b, 0xC3C033); // inlined? utils::hook::set(0x361AA0_b, 0xC3C033);
/*// disable emblems
dvars::override::register_int("emblems_active", 0, 0, 0, game::DVAR_FLAG_NONE);
utils::hook::set<uint8_t>(0x140479590, 0xC3); // don't register commands*/
// disable elite_clan // disable elite_clan
dvars::override::register_int("elite_clan_active", 0, 0, 0, game::DVAR_FLAG_NONE); dvars::override::register_int("elite_clan_active", 0, 0, 0, game::DVAR_FLAG_NONE);
@ -256,7 +234,7 @@ namespace patches
utils::hook::nop(0x47408E_b, 5); // dvar_foreach utils::hook::nop(0x47408E_b, 5); // dvar_foreach
// patch "Server is different version" to show the server client version // patch "Server is different version" to show the server client version
//utils::hook::inject(0x54DCE5_b, VERSION); // we can't inject utils::hook::inject(0x54DCE5_b, VERSION);
// prevent servers overriding our fov // prevent servers overriding our fov
set_client_dvar_from_server_hook.create(0x11AA90_b, set_client_dvar_from_server_stub); set_client_dvar_from_server_hook.create(0x11AA90_b, set_client_dvar_from_server_stub);
@ -268,8 +246,8 @@ namespace patches
dvars::override::register_int("dvl", 0, 0, 0, game::DVAR_FLAG_READ); dvars::override::register_int("dvl", 0, 0, 0, game::DVAR_FLAG_READ);
// unlock safeArea_* // unlock safeArea_*
/*utils::hook::jump(0x1402624F5, 0x140262503); utils::hook::jump(0x347BC9_b, 0x347BD3_b);
utils::hook::jump(0x14026251C, 0x140262547);*/ utils::hook::jump(0x347BF0_b, 0x347C17_b);
dvars::override::register_float("safeArea_adjusted_horizontal", 1, 0, 1, game::DVAR_FLAG_SAVED); dvars::override::register_float("safeArea_adjusted_horizontal", 1, 0, 1, game::DVAR_FLAG_SAVED);
dvars::override::register_float("safeArea_adjusted_vertical", 1, 0, 1, game::DVAR_FLAG_SAVED); dvars::override::register_float("safeArea_adjusted_vertical", 1, 0, 1, game::DVAR_FLAG_SAVED);
dvars::override::register_float("safeArea_horizontal", 1, 0, 1, game::DVAR_FLAG_SAVED); dvars::override::register_float("safeArea_horizontal", 1, 0, 1, game::DVAR_FLAG_SAVED);
@ -294,7 +272,7 @@ namespace patches
cmd_lui_notify_server_hook.create(0x412D50_b, cmd_lui_notify_server_stub); cmd_lui_notify_server_hook.create(0x412D50_b, cmd_lui_notify_server_stub);
// Prevent clients from sending invalid reliableAcknowledge // Prevent clients from sending invalid reliableAcknowledge
// utils::hook::jump(0x1CBD06_b, sv_execute_client_message_stub); utils::hook::call(0x1CBD06_b, sv_execute_client_message_stub);
// "fix" for rare 'Out of memory error' error // "fix" for rare 'Out of memory error' error
if (utils::flags::has_flag("memoryfix")) if (utils::flags::has_flag("memoryfix"))

View File

@ -197,7 +197,7 @@ namespace game
WEAK symbol<void(void* cl, int type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x1CC040}; WEAK symbol<void(void* cl, int type, const char* fmt, ...)> SV_SendServerCommand{0x0, 0x1CC040};
WEAK symbol<void()> Sys_ShowConsole{0x0, 0x0}; WEAK symbol<void()> Sys_ShowConsole{0x0, 0x0};
WEAK symbol<void(const char* error, ...)> Sys_Error{0x0, 0x0}; WEAK symbol<void(const char* error, ...)> Sys_Error{0x0, 0x1D8710};
WEAK symbol<void(char* path, int pathSize, Sys_Folder folder, const char* filename, const char* ext)> WEAK symbol<void(char* path, int pathSize, Sys_Folder folder, const char* filename, const char* ext)>
Sys_BuildAbsPath{0x42C330, 0x0}; Sys_BuildAbsPath{0x42C330, 0x0};
WEAK symbol<int()> Sys_Milliseconds{0x462B30, 0x5BDDF0}; WEAK symbol<int()> Sys_Milliseconds{0x462B30, 0x5BDDF0};