From 2d8a6a8516714d8535badd740830d2d6aae8c8ad Mon Sep 17 00:00:00 2001 From: SirPlease Date: Tue, 19 Sep 2023 15:41:15 +0200 Subject: [PATCH] Fix a longstanding Server Crash cause Fixes: CLagCompensationManager::StartLagCompensation with NULL CUserCmd!!! --- .../gamedata/l4d2_null_cusercmd_fix.txt | 41 ++++++++++++++++++ .../plugins/fixes/l4d2_null_cusercmd_fix.smx | Bin 0 -> 3096 bytes .../scripting/l4d2_null_cusercmd_fix.sp | 34 +++++++++++++++ cfg/generalfixes.cfg | 1 + 4 files changed, 76 insertions(+) create mode 100644 addons/sourcemod/gamedata/l4d2_null_cusercmd_fix.txt create mode 100644 addons/sourcemod/plugins/fixes/l4d2_null_cusercmd_fix.smx create mode 100644 addons/sourcemod/scripting/l4d2_null_cusercmd_fix.sp diff --git a/addons/sourcemod/gamedata/l4d2_null_cusercmd_fix.txt b/addons/sourcemod/gamedata/l4d2_null_cusercmd_fix.txt new file mode 100644 index 000000000..1f510d4b1 --- /dev/null +++ b/addons/sourcemod/gamedata/l4d2_null_cusercmd_fix.txt @@ -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 */ + } + } + } +} + diff --git a/addons/sourcemod/plugins/fixes/l4d2_null_cusercmd_fix.smx b/addons/sourcemod/plugins/fixes/l4d2_null_cusercmd_fix.smx new file mode 100644 index 0000000000000000000000000000000000000000..aaee8f81dad67056321d5b859c37d329b55fafab GIT binary patch literal 3096 zcmXw!c|4SB8^<4eF*vf#WNVIuV!|Lx=){OD*&W$4ma$G4V@s&Uu?@16WU0oIoKdnB zGS0k`J%ljI6lutk$ub$dkCs1v&-Z&@*Y#ZY=QcI9vFGIAfIpQQmniW2}3pzDH7Es*T|6Y3ZCv-o@ej|uW+!?i&XzioVg4#x(?Jn=O97ut`}%G=a>e5S^7IS@*(o%zn$35Y!6j^&!Y8XI zV>+a9SX}kEql3eOO=nti+C_1#2THpy4E*tf?|OIqT9@dX#Vhy?HfsPsP_kqF{gyz^ zMZW{z8|1a%{roHo`71&gWjk4n%y4fSQZuxGPDIikLGUH?Pq1Zvs=I%)J_MgdSF+D? z?Z6(R`a(mcsDemZ0)YuzhEj{s&Cal86>716a}1&7KkPVcS%|8t=2o3lh$kRn2r708 z8k$G1fGr=`pG89ONp!Lr&5F>{h3(H=e>Mua<=vb>m>R?yQe}LabqV@ZtR!?+esvm#px^at$fvmovS~<7MXf(`gftQ98jz-Z`ga(3;|9_# zhfY+ZT_zOyG><^=L^?u^ra)-v!JdLG8&Vsz)tLj>X~_5>_9NsJ725?}7NZvX>_6fq z77ruiz_xcYgu1RyONTh4n;$?eW2v_erJm_l9{SO_>l^Oec@g zJ)G)nSQm2kjFm#b+ zI=YEVt7Px+3CqSGzHK~d64YiD=dYStYUMaFAJcgQcYRLcVFDvWB_KYx+8^0=vZ1kJ zvEFfqeQAl+7an3|Fv}9eeTm@r-8MQXSD||zA4x(o`Uml$hYD4t^c#b}^hHMf)&8*Z z=>x@)a*yebte)CK4ed3H6W2xgx3hUQ6K*Z7)T_3Cn2S=DJHAN z^|*_5LYd7*NY_S{Ww$}Vcok}8*06SFs*UWLF-v_R(=&nT6`0Gxj5AT}KEv_elr@`j zF$P}3-Qwh_4{<#H#|Kuh?BuID17Y}zv_>bxMZ3<+34JBm)jCGAu?mlrs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&0&EbEJ$?x&&eLSWX@O_(M8eZi1&d;`yT`wlrCYRoG0w!dflg zGS@iZOkZ!6cqq za*9I2HM%X&h-sa+ZIIFq8XB|NtV-h??mnh7`I;A1ThRBy0n0u(VDzNUKo8m3qa5SK zZ*6HpP+&MH)Yj(P)%4LSCeZ@k_&j-PG>cBo0S*d%(44e RrE#(By22h`nI=d1{{f|0oQnVe literal 0 HcmV?d00001 diff --git a/addons/sourcemod/scripting/l4d2_null_cusercmd_fix.sp b/addons/sourcemod/scripting/l4d2_null_cusercmd_fix.sp new file mode 100644 index 000000000..b2e912919 --- /dev/null +++ b/addons/sourcemod/scripting/l4d2_null_cusercmd_fix.sp @@ -0,0 +1,34 @@ +#pragma semicolon 1 +#pragma newdecls required + +#define VERSION "0.2" + +#include +#include // 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."); +} diff --git a/cfg/generalfixes.cfg b/cfg/generalfixes.cfg index 71d06f1a0..3f1ba57b7 100644 --- a/cfg/generalfixes.cfg +++ b/cfg/generalfixes.cfg @@ -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