network: improve a patch

This commit is contained in:
Diavolo 2023-04-18 10:49:02 +02:00
parent 3d440eabc5
commit f27a1b97e7
4 changed files with 85 additions and 63 deletions

View File

@ -163,7 +163,6 @@ namespace network
: 0;
}
uint64_t ret2()
{
return 2;
@ -173,6 +172,15 @@ namespace network
{
return 0;
}
void com_error_oob_stub(const char* file, int line, int code, [[maybe_unused]] const char* fmt, const char* error)
{
char buffer[1024]{};
strncpy_s(buffer, error, _TRUNCATE);
game::Com_Error_(file, line, code, "%s", buffer);
}
}
void on(const std::string& command, const callback& callback)
@ -321,10 +329,20 @@ namespace network
// NA_IP -> NA_RAWIP in NetAdr_ToString
utils::hook::set<uint8_t>(game::select(0x142172ED4, 0x140515864), game::NA_RAWIP);
// Kill 'echo' OOB handler
utils::hook::set<uint8_t>(game::select(0x14134D0FB, 0x14018EE82), 0xEB);
if (game::is_server())
{
// Remove restrictions for rcon commands
utils::hook::call(0x140538D5C_g, &con_restricted_execute_buf_stub); // SVC_RemoteCommand
utils::hook::call(0x140538D5C_g, con_restricted_execute_buf_stub); // SVC_RemoteCommand
// Kill 'error' OOB handler on the dedi
utils::hook::nop(0x14018EF8B_g, 5);
}
else
{
utils::hook::call(0x14134D206_g, com_error_oob_stub);
}
// TODO: Fix that

View File

@ -4,6 +4,7 @@
#include <game/game.hpp>
#include <game/utils.hpp>
#include "network.hpp"
#include "scheduler.hpp"
#include <utils/hook.hpp>
@ -12,17 +13,18 @@ namespace patches
{
namespace
{
utils::hook::detour sv_executeclientmessages_hook;
utils::hook::detour sv_execute_client_messages_hook;
void sv_executeclientmessages_stub(game::client_s* client, game::msg_t* msg)
void sv_execute_client_messages_stub(game::client_s* client, game::msg_t* msg)
{
if (client->reliableAcknowledge < 0)
{
client->reliableAcknowledge = client->reliableSequence;
network::send(client->address, "error", "EXE_LOSTRELIABLECOMMANDS");
return;
}
sv_executeclientmessages_hook.invoke<void>(client, msg);
sv_execute_client_messages_hook.invoke<void>(client, msg);
}
void script_errors_stub(const char* file, int line, unsigned int code, const char* fmt, ...)
@ -53,7 +55,7 @@ namespace patches
utils::hook::set<uint8_t>(game::select(0x14224DF8C, 0x1405316DC), 3);
// make sure client's reliableAck are not negative
sv_executeclientmessages_hook.create(game::select(0x14224A460, 0x14052F840), sv_executeclientmessages_stub);
sv_execute_client_messages_hook.create(game::select(0x14224A460, 0x14052F840), sv_execute_client_messages_stub);
scheduler::once([]
{

View File

@ -1583,20 +1583,20 @@ namespace game
int client_state;
char __pad0[0x28];
netadr_t address;
char gap_3C[20468];
char __pad1[20468];
int reliableSequence;
int reliableAcknowledge;
char gap_5038[4];
char __pad2[4];
int messageAcknowledge;
char gap_5040[1416];
uint64_t xuid;
char __pad2[0xB5D84];
char __pad3[0xB5D84];
int guid;
char __pad3[0x8];
char __pad4[0x8];
bool bIsTestClient;
char gap_BB361[3];
char __pad5[3];
int serverId;
char gap_BB368[171432];
char __pad6[171432];
};

View File

@ -78,6 +78,8 @@ namespace game
// G
WEAK symbol<void()> G_ClearVehicleInputs{0x1423812E0, 0x1405C1200};
WEAK symbol<qboolean(void* ent)> StuckInClient{0x1415A8360, 0x14023BFE0};
// Live
WEAK symbol<bool(uint64_t, int*, bool)> Live_GetConnectivityInformation{0x141E0C380};