Cbuf_AddTextWithMarkers
0x00118710 · 670 bytes · __cdecl
_Z23Cbuf_AddTextWithMarkers16ECommandTarget_t19ECmdExecutionMarkerPKcS0_
Decompiled
undefined (4 params)
/* Cbuf_AddTextWithMarkers(ECommandTarget_t, ECmdExecutionMarker, char const*, ECmdExecutionMarker)
*/
undefined4 Cbuf_AddTextWithMarkers(int param_1,undefined4 param_2,char *param_3,undefined4 param_4)
{
uint uVar1;
char cVar2;
int iVar3;
int iVar4;
uint uVar5;
uint uVar6;
uint uVar7;
size_t sVar8;
undefined4 uVar9;
uint *puVar10;
uint *puVar11;
uint *puVar12;
int iVar13;
int in_GS_OFFSET;
bool bVar14;
uint uVar15;
char *pcVar16;
uint local_420 [128];
uint local_220 [128];
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (0x7fd < DAT_003887e0) {
ConMsg("Cbuf_AddTextWithMarkers: execution marker overflow\n");
uVar9 = 0;
goto LAB_0011890e;
}
iVar3 = CreateExecutionMarker();
iVar4 = CreateExecutionMarker();
V_snprintf((char *)local_420,0x200,";%s %c %d;","[$&*,`]",(int)(char)param_2,iVar3);
pcVar16 = ";%s %c %d;";
uVar15 = 0x200;
V_snprintf((char *)local_220,0x200,";%s %c %d;","[$&*,`]",(int)(char)param_4,iVar4);
puVar12 = local_420;
do {
puVar11 = puVar12;
uVar5 = *puVar11 + 0xfefefeff & ~*puVar11;
uVar6 = uVar5 & 0x80808080;
puVar12 = puVar11 + 1;
} while (uVar6 == 0);
if ((uVar5 & 0x8080) == 0) {
puVar12 = (uint *)((int)puVar11 + 6);
uVar6 = uVar6 >> 0x10;
}
puVar11 = local_220;
do {
puVar10 = puVar11;
uVar7 = *puVar10 + 0xfefefeff & ~*puVar10;
uVar5 = uVar7 & 0x80808080;
puVar11 = puVar10 + 1;
} while (uVar5 == 0);
if ((uVar7 & 0x8080) == 0) {
puVar11 = (uint *)((int)puVar10 + 6);
uVar5 = uVar5 >> 0x10;
}
sVar8 = strlen(param_3);
uVar7 = ThreadGetCurrentId();
if (uVar7 == s_CommandBufferMutex) {
LAB_00118930:
DAT_003887ec = DAT_003887ec + 1;
}
else {
LOCK();
bVar14 = s_CommandBufferMutex == 0;
uVar1 = uVar7;
if (!bVar14) {
uVar1 = s_CommandBufferMutex;
}
s_CommandBufferMutex = uVar1;
UNLOCK();
if (bVar14) goto LAB_00118930;
pcVar16 = (char *)0x0;
CThreadFastMutex::Lock(0x3887e8,uVar7);
uVar15 = uVar7;
}
iVar13 = param_1 * 0x2554;
if ((int)((int)puVar12 +
(int)((int)puVar11 +
*(int *)(s_CommandBuffer + iVar13 + 0x2004) +
sVar8 + (-(int)local_420 - (uint)CARRY1((byte)uVar6,(byte)uVar6)) +
((-3 - (uint)CARRY1((byte)uVar5,(byte)uVar5)) - (int)local_220))) <
*(int *)(s_CommandBuffer + iVar13 + 0x2044)) {
/* try { // try from 00118959 to 001189b3 has its CatchHandler @ 001189c5 */
cVar2 = Cbuf_AddExecutionMarker(param_1,param_2,local_420);
if (((cVar2 == '\0') ||
(cVar2 = CCommandBuffer::AddText((CCommandBuffer *)(s_CommandBuffer + iVar13),param_3,0),
cVar2 == '\0')) ||
(cVar2 = Cbuf_AddExecutionMarker(param_1,param_4,local_220), cVar2 == '\0')) {
Host_Error("Cbuf_AddTextWithMarkers: buffer overflow\n");
}
uVar9 = 1;
}
else {
/* try { // try from 001188bf to 001188da has its CatchHandler @ 001189c5 */
FindAndRemoveExecutionMarker(iVar3);
FindAndRemoveExecutionMarker(iVar4);
ConMsg("Cbuf_AddTextWithMarkers: buffer overflow\n",uVar15,pcVar16);
uVar9 = 0;
}
DAT_003887ec = DAT_003887ec + -1;
if (DAT_003887ec == 0) {
LOCK();
UNLOCK();
s_CommandBufferMutex = 0;
}
LAB_0011890e:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return uVar9;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
SourceMod gamedata
paste intoaddons/sourcemod/gamedata/<your_plugin>.txt
used as the SourceMod key — change to fit your plugin's convention
SourceMod library name (server / engine / matchmaking)
Just a Signatures{} block, ready to drop into a gamedata
file. Wire it up in your plugin however you like - SDKCall, DHooks,
raw memory ops, or anything else.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.