diff options
author | pg9182 <96569817+pg9182@users.noreply.github.com> | 2023-03-05 16:42:42 -0500 |
---|---|---|
committer | pg9182 <96569817+pg9182@users.noreply.github.com> | 2023-04-17 14:50:10 -0400 |
commit | 29c6aeca11a52339025b46ce7854e6f81e119fd4 (patch) | |
tree | 32c184ed26f7defcaf9d1be4b06e2c83b82ffe99 /NorthstarDLL | |
parent | 2c889a0bc06b19f5842d002f5d671aaab8c3b419 (diff) | |
download | NorthstarLauncher-29c6aeca11a52339025b46ce7854e6f81e119fd4.tar.gz NorthstarLauncher-29c6aeca11a52339025b46ce7854e6f81e119fd4.zip |
Add support for Atlas connectionless packets
Diffstat (limited to 'NorthstarDLL')
-rw-r--r-- | NorthstarDLL/server/servernethooks.cpp | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/NorthstarDLL/server/servernethooks.cpp b/NorthstarDLL/server/servernethooks.cpp index c5f4f75f..1a760419 100644 --- a/NorthstarDLL/server/servernethooks.cpp +++ b/NorthstarDLL/server/servernethooks.cpp @@ -1,10 +1,42 @@ +#include "core/convar/convar.h" #include "engine/r2engine.h" #include "shared/exploit_fixes/ns_limits.h" +#include <string> + AUTOHOOK_INIT() +static ConVar* Cvar_net_debug_atlas_packet; + +static void ProcessAtlasConnectionlessPacket(R2::netpacket_t* packet) +{ + bool dbg = Cvar_net_debug_atlas_packet->GetBool(); + + // extract kind, null-terminated type, data + std::string pType, pData; + for (int i = 5; i < packet->size; i++) + { + if (packet->data[i] == '\x00') + { + pType.assign((char*)(&packet->data[5]), (size_t)(i - 5)); + if (i + 1 < packet->size) + pData.assign((char*)(&packet->data[i + 1]), (size_t)(packet->size - i - 1)); + break; + } + } + + if (dbg) + spdlog::warn("ignoring Atlas connectionless packet (size={} type={}): unknown type", packet->size, pType); + return; +} + AUTOHOOK(ProcessConnectionlessPacket, engine.dll + 0x117800, bool, , (void* a1, R2::netpacket_t* packet)) { + if (4 < packet->size && packet->data[4] == 'T') + { + ProcessAtlasConnectionlessPacket(packet); + return false; + } if (!g_pServerLimits->CheckConnectionlessPacketLimits(packet)) return false; return ProcessConnectionlessPacket(a1, packet); @@ -13,4 +45,11 @@ AUTOHOOK(ProcessConnectionlessPacket, engine.dll + 0x117800, bool, , (void* a1, ON_DLL_LOAD_RELIESON("engine.dll", ServerNetHooks, ConVar, (CModule module)) { AUTOHOOK_DISPATCH_MODULE(engine.dll) + + Cvar_net_debug_atlas_packet = new ConVar( + "net_debug_atlas_packet", + "0", + FCVAR_NONE, + "Whether to log detailed debugging information for Atlas connectionless packets (warning: this allows unlimited amounts of " + "arbitrary data to be logged)"); } |