aboutsummaryrefslogtreecommitdiff
path: root/primedev/shared/exploit_fixes/exploitfixes.cpp
diff options
context:
space:
mode:
authorAllusiveWheat <154700875+AllusiveWheat@users.noreply.github.com>2025-04-26 17:06:33 -0700
committerGitHub <noreply@github.com>2025-04-27 02:06:33 +0200
commit8290f7b3c05b9969e5c6090cda1ba68fb60cf56e (patch)
tree6d0081ab487fc2a0ce8b47c1183c8aef6686ccd7 /primedev/shared/exploit_fixes/exploitfixes.cpp
parent1277b3711d3aedb48e83d854e3c734c2f368c7ef (diff)
downloadNorthstarLauncher-1.30.2.tar.gz
NorthstarLauncher-1.30.2.zip
Set execution markers properly (#849)v1.30.2-rc2v1.30.2-rc1v1.30.2
Set execution markers properly if there's enough room or ignore command otherwise. Stops servers from executing commands on the client if not in vanilla. Co-authored-by: RoyalBlue1 <11448698+RoyalBlue1@users.noreply.github.com>
Diffstat (limited to 'primedev/shared/exploit_fixes/exploitfixes.cpp')
-rw-r--r--primedev/shared/exploit_fixes/exploitfixes.cpp22
1 files changed, 21 insertions, 1 deletions
diff --git a/primedev/shared/exploit_fixes/exploitfixes.cpp b/primedev/shared/exploit_fixes/exploitfixes.cpp
index 1b3069f5..eaf1784d 100644
--- a/primedev/shared/exploit_fixes/exploitfixes.cpp
+++ b/primedev/shared/exploit_fixes/exploitfixes.cpp
@@ -14,6 +14,8 @@ ConVar* Cvar_ns_should_log_all_clientcommands;
ConVar* Cvar_sv_cheats;
+int* g_ExecutionMarkerCount;
+
#define BLOCKED_INFO(s) \
( \
[=]() -> bool \
@@ -294,6 +296,24 @@ bool, __fastcall, (const char* pModName)) // 48 83 EC 28 48 8B 0D ? ? ? ? 48 8D
return (!strcmp("r2", pModName) || !strcmp("r1", pModName)) && !CommandLine()->CheckParm("-norestrictservercommands");
}
+// Checks if there's room left for execution markers
+bool Cbuf_HasRoomForExecutionMarkers(const int marker)
+{
+ return (*g_ExecutionMarkerCount + marker) < 2048;
+}
+
+// Set execution markers properly if there's space
+// If not enough space, ignore command
+// clang-format off
+AUTOHOOK(CBaseClientState_ProcessStringCmd, engine.dll + 0x1A1C20,
+bool, __fastcall, (CBaseClient* self, int64_t a2))
+// clang-format on
+{
+ if (!Cbuf_HasRoomForExecutionMarkers(2))
+ return true;
+ return CBaseClientState_ProcessStringCmd(self, a2);
+}
+
// ratelimit stringcmds, and prevent remote clients from calling commands that they shouldn't
// clang-format off
AUTOHOOK(CGameClient__ExecuteStringCommand, engine.dll + 0x1022E0,
@@ -428,7 +448,7 @@ bool, __fastcall, (void* a1))
ON_DLL_LOAD("engine.dll", EngineExploitFixes, (CModule module))
{
AUTOHOOK_DISPATCH_MODULE(engine.dll)
-
+ g_ExecutionMarkerCount = module.Offset(0x130DE8F0).RCast<int*>();
// allow client/ui to run clientcommands despite restricting servercommands
module.Offset(0x4FB65).Patch("EB 11");
module.Offset(0x4FBAC).Patch("EB 16");