2019-09-24 10:30:08 +02:00
|
|
|
#include <std_include.hpp>
|
2022-03-23 13:48:13 +00:00
|
|
|
#include <loader/module_loader.hpp>
|
2019-09-24 10:30:08 +02:00
|
|
|
#include "game/game.hpp"
|
|
|
|
|
2022-12-09 14:50:13 +01:00
|
|
|
#include <utils/hook.hpp>
|
|
|
|
|
2019-09-24 10:30:08 +02:00
|
|
|
class security final : public module
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void post_load() override
|
|
|
|
{
|
2019-09-24 11:46:47 +02:00
|
|
|
if (game::is_mp())
|
2019-09-24 10:30:08 +02:00
|
|
|
{
|
|
|
|
utils::hook(0x4AECD4, read_p2p_auth_ticket_stub, HOOK_JUMP).install()->quick();
|
2022-05-13 10:49:15 +01:00
|
|
|
|
|
|
|
utils::hook(0x57680C, net_defer_packet_to_client, HOOK_CALL).install()->quick(); // SV_ConnectionlessPacket
|
2019-09-24 10:30:08 +02:00
|
|
|
}
|
2022-12-09 14:50:13 +01:00
|
|
|
else
|
2022-07-09 20:02:38 +02:00
|
|
|
{
|
|
|
|
// Disable CL_ShellExecute_URL_f
|
|
|
|
utils::hook::nop(0x4298F6, 5);
|
|
|
|
}
|
2019-09-24 10:30:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static void read_p2p_auth_ticket_stub(game::native::msg_t* msg, void* data, const int len)
|
|
|
|
{
|
|
|
|
if (len < 0) return;
|
|
|
|
return game::native::MSG_ReadData(msg, data, std::min(len, 200));
|
|
|
|
}
|
2022-05-13 10:49:15 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-12-09 14:50:13 +01:00
|
|
|
auto* msg = &game::native::deferredQueue->msgs[game::native::deferredQueue->send % std::extent_v<decltype(game::native::DeferredQueue::msgs)>];
|
2022-05-13 10:49:15 +01:00
|
|
|
std::memcpy(msg->data, net_message->data, net_message->cursize);
|
|
|
|
|
|
|
|
msg->datalen = net_message->cursize;
|
|
|
|
msg->addr = *net_from;
|
|
|
|
|
|
|
|
InterlockedIncrement(&game::native::deferredQueue->send);
|
|
|
|
}
|
2019-09-24 10:30:08 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
REGISTER_MODULE(security)
|