Port sec patches from iw4x
This commit is contained in:
parent
dd55c64092
commit
52d0326562
@ -57,6 +57,8 @@ namespace game
|
||||
|
||||
SV_SendServerCommand_t SV_SendServerCommand;
|
||||
|
||||
Sys_IsServerThread_t Sys_IsServerThread;
|
||||
|
||||
XUIDToString_t XUIDToString;
|
||||
|
||||
SEH_LocalizeTextMessage_t SEH_LocalizeTextMessage;
|
||||
@ -106,6 +108,8 @@ namespace game
|
||||
|
||||
gentity_s* g_entities;
|
||||
|
||||
DeferredQueue* deferredQueue;
|
||||
|
||||
namespace mp
|
||||
{
|
||||
client_t* svs_clients;
|
||||
@ -726,6 +730,8 @@ namespace game
|
||||
|
||||
native::SV_SendServerCommand = native::SV_SendServerCommand_t(SELECT_VALUE(0x4F6990, 0x575DE0, 0x4FD5A0));
|
||||
|
||||
native::Sys_IsServerThread = native::Sys_IsServerThread_t(SELECT_VALUE(0x4CC5A0, 0x55F9A0, 0x0));
|
||||
|
||||
native::XUIDToString = native::XUIDToString_t(SELECT_VALUE(0x4FAA30, 0x55CC20, 0x0));
|
||||
|
||||
native::SEH_LocalizeTextMessage = native::SEH_LocalizeTextMessage_t(
|
||||
@ -785,5 +791,7 @@ namespace game
|
||||
|
||||
native::g_entities = reinterpret_cast<native::gentity_s*>(SELECT_VALUE(0, 0x1A66E28, 0x191B900));
|
||||
native::sp::g_entities = reinterpret_cast<native::sp::gentity_s*>(0x1197AD8);
|
||||
|
||||
native::deferredQueue = reinterpret_cast<native::DeferredQueue*>(SELECT_VALUE(0x0, 0x1D55438, 0x0));
|
||||
}
|
||||
}
|
||||
|
@ -91,6 +91,9 @@ namespace game
|
||||
typedef void (*SV_SendServerCommand_t)(dedi::client_t* cl, svscmd_type type, const char* fmt, ...);
|
||||
extern SV_SendServerCommand_t SV_SendServerCommand;
|
||||
|
||||
typedef bool (*Sys_IsServerThread_t)();
|
||||
extern Sys_IsServerThread_t Sys_IsServerThread;
|
||||
|
||||
typedef void (*XUIDToString_t)(const unsigned __int64* xuid, char* str);
|
||||
extern XUIDToString_t XUIDToString;
|
||||
|
||||
@ -160,6 +163,8 @@ namespace game
|
||||
constexpr auto ENTITYNUM_NONE = MAX_GENTITIES - 1u;
|
||||
extern gentity_s* g_entities;
|
||||
|
||||
extern DeferredQueue* deferredQueue;
|
||||
|
||||
// PM Global Definitions & Functions
|
||||
constexpr auto JUMP_LAND_SLOWDOWN_TIME = 1800;
|
||||
|
||||
|
@ -548,6 +548,7 @@ namespace game
|
||||
enum dvar_flags : std::uint16_t
|
||||
{
|
||||
DVAR_ARCHIVE = 1 << 0,
|
||||
DVAR_LATCH = 1 << 1,
|
||||
DVAR_CHEAT = 1 << 2,
|
||||
DVAR_CODINFO = 1 << 3,
|
||||
DVAR_SCRIPTINFO = 1 << 4,
|
||||
@ -1031,6 +1032,24 @@ namespace game
|
||||
|
||||
static_assert(sizeof(netadr_s) == 24);
|
||||
|
||||
struct DeferredMsg
|
||||
{
|
||||
netadr_s addr;
|
||||
unsigned char data[1262];
|
||||
int datalen;
|
||||
};
|
||||
|
||||
static_assert(sizeof(DeferredMsg) == 0x50C);
|
||||
|
||||
struct DeferredQueue
|
||||
{
|
||||
DeferredMsg msgs[16];
|
||||
volatile long get;
|
||||
volatile long send;
|
||||
};
|
||||
|
||||
static_assert(sizeof(DeferredQueue) == 0x50C8);
|
||||
|
||||
struct netProfileInfo_t // Unused
|
||||
{
|
||||
unsigned char __pad0[0x5E0];
|
||||
|
@ -417,7 +417,7 @@ namespace demonware
|
||||
va_list ap;
|
||||
va_start(ap, msg);
|
||||
|
||||
vsnprintf_s(buffer, sizeof(buffer), _TRUNCATE, msg, ap);
|
||||
_vsnprintf_s(buffer, _TRUNCATE, msg, ap);
|
||||
printf("%s: %s\n", function, buffer);
|
||||
|
||||
va_end(ap);
|
||||
|
@ -12,6 +12,8 @@ public:
|
||||
if (game::is_mp())
|
||||
{
|
||||
utils::hook(0x4AECD4, read_p2p_auth_ticket_stub, HOOK_JUMP).install()->quick();
|
||||
|
||||
utils::hook(0x57680C, net_defer_packet_to_client, HOOK_CALL).install()->quick(); // SV_ConnectionlessPacket
|
||||
}
|
||||
}
|
||||
|
||||
@ -21,6 +23,25 @@ private:
|
||||
if (len < 0) return;
|
||||
return game::native::MSG_ReadData(msg, data, std::min(len, 200));
|
||||
}
|
||||
|
||||
static void net_defer_packet_to_client(game::native::netadr_s* net_from, game::native::msg_t* net_message)
|
||||
{
|
||||
assert(game::native::Sys_IsServerThread());
|
||||
|
||||
if (static_cast<std::size_t>(net_message->cursize) >= sizeof(game::native::DeferredMsg::data))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
auto* msg = &game::native::deferredQueue->msgs[game::native::deferredQueue->send
|
||||
% std::extent_v<decltype(game::native::DeferredQueue::msgs)>];
|
||||
std::memcpy(msg->data, net_message->data, net_message->cursize);
|
||||
|
||||
msg->datalen = net_message->cursize;
|
||||
msg->addr = *net_from;
|
||||
|
||||
InterlockedIncrement(&game::native::deferredQueue->send);
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_MODULE(security)
|
||||
|
Loading…
Reference in New Issue
Block a user