diff options
| -rw-r--r-- | primedev/shared/exploit_fixes/exploitfixes.cpp | 22 |
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"); |
