fix(patches): move this

This commit is contained in:
Diavolo 2023-04-19 11:43:19 +02:00
parent ad17d30992
commit 973720eda9
No known key found for this signature in database
GPG Key ID: FA77F074E98D98A5
2 changed files with 20 additions and 20 deletions

View File

@ -6,7 +6,6 @@
#include "command.hpp" #include "command.hpp"
#include "console.hpp" #include "console.hpp"
#include "dvars.hpp" #include "dvars.hpp"
#include "network.hpp"
#include "filesystem.hpp" #include "filesystem.hpp"
#include "scheduler.hpp" #include "scheduler.hpp"
@ -251,20 +250,6 @@ namespace patches
cmd_lui_notify_server_hook.invoke<void>(ent); cmd_lui_notify_server_hook.invoke<void>(ent);
} }
void sv_execute_client_message_stub(game::mp::client_t* client, game::msg_t* msg)
{
if (client->reliableAcknowledge < 0)
{
client->reliableAcknowledge = client->reliableSequence;
console::info("Negative reliableAcknowledge from %s - cl->reliableSequence is %i, reliableAcknowledge is %i\n",
client->name, client->reliableSequence, client->reliableAcknowledge);
network::send(client->header.netchan.remoteAddress, "error", "EXE_LOSTRELIABLECOMMANDS", '\n');
return;
}
reinterpret_cast<void(*)(game::mp::client_t*, game::msg_t*)>(0x140472500)(client, msg);
}
void update_last_seen_players_stub(utils::hook::assembler& a) void update_last_seen_players_stub(utils::hook::assembler& a)
{ {
const auto safe_continue = a.newLabel(); const auto safe_continue = a.newLabel();
@ -405,10 +390,6 @@ namespace patches
// Prevent clients from ending the game as non host by sending 'end_game' lui notification // Prevent clients from ending the game as non host by sending 'end_game' lui notification
cmd_lui_notify_server_hook.create(0x1403926A0, cmd_lui_notify_server_stub); cmd_lui_notify_server_hook.create(0x1403926A0, cmd_lui_notify_server_stub);
// Checks that reliableAcknowledge isn't negative
// It is possible to make the server hang if left unchecked
utils::hook::call(0x14047A29A, sv_execute_client_message_stub);
// Remove cheat protection from r_umbraExclusive // Remove cheat protection from r_umbraExclusive
dvars::override::register_bool("r_umbraExclusive", false, game::DVAR_FLAG_NONE); dvars::override::register_bool("r_umbraExclusive", false, game::DVAR_FLAG_NONE);

View File

@ -1,8 +1,11 @@
#include <std_include.hpp> #include <std_include.hpp>
#include "loader/component_loader.hpp" #include "loader/component_loader.hpp"
#include <utils/hook.hpp>
#include "game/game.hpp" #include "game/game.hpp"
#include "console.hpp"
#include <utils/hook.hpp>
namespace security namespace security
{ {
namespace namespace
@ -14,6 +17,19 @@ namespace security
reinterpret_cast<void(*)(int, int, int)>(0x1405834B0)(localclient, index1, index2); reinterpret_cast<void(*)(int, int, int)>(0x1405834B0)(localclient, index1, index2);
} }
} }
void sv_execute_client_message_stub(game::mp::client_t* client, game::msg_t* msg)
{
if ((client->reliableSequence - client->reliableAcknowledge) < 0)
{
client->reliableAcknowledge = client->reliableSequence;
console::info("Negative reliableAcknowledge from %s - cl->reliableSequence is %i, reliableAcknowledge is %i\n",
client->name, client->reliableSequence, client->reliableAcknowledge);
return;
}
utils::hook::invoke<void>(0x140472500, client, msg);
}
} }
class component final : public component_interface class component final : public component_interface
@ -25,6 +41,9 @@ namespace security
// Patch vulnerability in PlayerCards_SetCachedPlayerData // Patch vulnerability in PlayerCards_SetCachedPlayerData
utils::hook::call(0x140287C5C, set_cached_playerdata_stub); utils::hook::call(0x140287C5C, set_cached_playerdata_stub);
// It is possible to make the server hang if left unchecked
utils::hook::call(0x14047A29A, sv_execute_client_message_stub);
} }
}; };
} }