Skip to content

Commit

Permalink
Fix a longstanding Server Crash cause
Browse files Browse the repository at this point in the history
Fixes: CLagCompensationManager::StartLagCompensation with NULL CUserCmd!!!
  • Loading branch information
SirPlease committed Sep 19, 2023
1 parent c711b3d commit 2d8a6a8
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 0 deletions.
41 changes: 41 additions & 0 deletions addons/sourcemod/gamedata/l4d2_null_cusercmd_fix.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
"Games"
{
"left4dead2"
{
"MemPatches"
{
"CLagCompensationManager::StartLagCompensation"
{
"signature" "CLagCompensationManager::StartLagCompensation"

// if (!cmd) jump to the return branch.

"linux"
{
"offset" "6CEh"
"verify" "\xC7"
"patch" "\xE9\x32\xFC\xFF\xFF\x90\x90"
}

"windows"
{
"offset" "477h"
"verify" "\x68"
"patch" "\xE9\x96\x02\x00\x00"
}
}
}

"Signatures"
{
"CLagCompensationManager::StartLagCompensation"
{
"library" "server"
"linux" "@_ZN23CLagCompensationManager20StartLagCompensationEP11CBasePlayer19LagCompensationTypeRK6VectorRK6QAnglef"
"windows" "\x55\x8B\xEC\x83\xEC\x64\x53\x33\xC0"
/* 55 8B EC 83 EC 64 53 33 C0 */
}
}
}
}

Binary file not shown.
34 changes: 34 additions & 0 deletions addons/sourcemod/scripting/l4d2_null_cusercmd_fix.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#pragma semicolon 1
#pragma newdecls required

#define VERSION "0.2"

#include <sourcemod>
#include <sourcescramble> // https://github.com/nosoop/SMExt-SourceScramble

public Plugin myinfo =
{
name = "L4D2 Lag Compensation Null CUserCmd fix",
author = "fdxx",
description = "Prevent crash: CLagCompensationManager::StartLagCompensation with NULL CUserCmd!!!",
version = VERSION,
}

public void OnPluginStart()
{
Init();
CreateConVar("l4d2_null_cusercmd_fix_version", VERSION, "Version", FCVAR_NONE | FCVAR_DONTRECORD);
}

void Init()
{
GameData hGameData = new GameData("l4d2_null_cusercmd_fix");
if (hGameData == null)
SetFailState("Failed to load \"l4d2_null_cusercmd_fix.txt\" gamedata.");

MemoryPatch mPatch = MemoryPatch.CreateFromConf(hGameData, "CLagCompensationManager::StartLagCompensation");
if (!mPatch.Validate())
SetFailState("Verify patch failed.");
if (!mPatch.Enable())
SetFailState("Enable patch failed.");
}
1 change: 1 addition & 0 deletions cfg/generalfixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ sm plugins load fixes/l4d2_sg552_zoom_fix.smx
sm plugins load fixes/l4d2_changelevel.smx
sm plugins load fixes/weapon_spawn_duplicate_fix.smx
sm plugins load fixes/l4d_fix_common_shove.smx
sm plugins load fixes/l4d2_null_cusercmd_fix.smx

// Anti-Cheat.
sm plugins load anticheat/l4d2_noghostcheat.smx

0 comments on commit 2d8a6a8

Please sign in to comment.