CDemoFile::ReadCustomData
0x00130d50 · 1011 bytes · __thiscall
_ZN9CDemoFile14ReadCustomDataEPiPPh
Decompiled
undefined (3 params)
/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CDemoFile::ReadCustomData(int*, unsigned char**) */
int __thiscall CDemoFile::ReadCustomData(CDemoFile *this,int *param_1,uchar **param_2)
{
CUtlBuffer *this_00;
int iVar1;
uchar *puVar2;
char cVar3;
int iVar4;
int *piVar5;
int iVar6;
int local_30;
int local_24;
undefined4 local_20;
if ((ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer == '\0') &&
(iVar6 = __cxa_guard_acquire(&ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer),
iVar6 != 0)) {
ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer = (uchar *)0x0;
DAT_0039d324 = 0;
DAT_0039d328 = 0;
DAT_0039d32c = 0;
_DAT_0039d330 = (uchar *)0x0;
__cxa_guard_release(&ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer);
__cxa_atexit(CUtlVector<unsigned_char,CUtlMemory<unsigned_char,int>>::~CUtlVector,
&ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer,&__dso_handle);
}
this_00 = (CUtlBuffer *)(this + 0x534);
if (((byte)this[0x549] & 1) == 0) {
cVar3 = CUtlBuffer::CheckGet(this_00,4);
local_30 = 0;
if (cVar3 != '\0') {
if (((byte)this[0x568] & 1) == 0) {
iVar6 = *(int *)(this + 0x540);
local_30 = *(int *)(*(int *)(this + 0x534) + (iVar6 - *(int *)(this + 0x554)));
}
else {
piVar5 = (int *)((*(int *)(this + 0x540) - *(int *)(this + 0x554)) + *(int *)(this + 0x534))
;
if (piVar5 == (int *)0x0) {
piVar5 = &local_24;
}
local_20 = local_24;
local_20._1_3_ = (undefined3)((uint)local_24 >> 8);
local_20 = CONCAT31(local_20._1_3_,*(undefined1 *)((int)piVar5 + 3));
local_20._2_2_ = (undefined2)((uint)local_24 >> 0x10);
local_20._0_2_ = CONCAT11(*(undefined1 *)((int)piVar5 + 2),*(undefined1 *)((int)piVar5 + 3))
;
local_20._3_1_ = (undefined1)((uint)local_24 >> 0x18);
local_20._0_3_ = CONCAT12(*(undefined1 *)((int)piVar5 + 1),(undefined2)local_20);
local_20 = CONCAT13((char)*piVar5,(undefined3)local_20);
_V_memcpy(&local_24,&local_20,4);
iVar6 = *(int *)(this + 0x540);
local_30 = local_24;
}
*(int *)(this + 0x540) = iVar6 + 4;
}
}
else {
local_24 = 0;
CUtlBuffer::Scanf(this_00,"%d",&local_24);
local_30 = local_24;
}
if (((byte)this[0x549] & 1) == 0) {
iVar6 = 0;
cVar3 = CUtlBuffer::CheckGet(this_00,4);
if (cVar3 != '\0') {
if (((byte)this[0x568] & 1) == 0) {
iVar4 = *(int *)(this + 0x540);
iVar6 = *(int *)(*(int *)(this + 0x534) + (iVar4 - *(int *)(this + 0x554)));
}
else {
piVar5 = (int *)((*(int *)(this + 0x540) - *(int *)(this + 0x554)) + *(int *)(this + 0x534))
;
if (piVar5 == (int *)0x0) {
piVar5 = &local_24;
}
local_20 = local_24;
local_20._1_3_ = (undefined3)((uint)local_24 >> 8);
local_20 = CONCAT31(local_20._1_3_,*(undefined1 *)((int)piVar5 + 3));
local_20._2_2_ = (undefined2)((uint)local_24 >> 0x10);
local_20._0_2_ = CONCAT11(*(undefined1 *)((int)piVar5 + 2),*(undefined1 *)((int)piVar5 + 3))
;
local_20._3_1_ = (undefined1)((uint)local_24 >> 0x18);
local_20._0_3_ = CONCAT12(*(undefined1 *)((int)piVar5 + 1),(undefined2)local_20);
local_20 = CONCAT13((char)*piVar5,(undefined3)local_20);
_V_memcpy(&local_24,&local_20,4);
iVar4 = *(int *)(this + 0x540);
iVar6 = local_24;
}
*(int *)(this + 0x540) = iVar4 + 4;
}
}
else {
local_24 = 0;
CUtlBuffer::Scanf(this_00,"%d",&local_24);
iVar6 = local_24;
}
if ((param_1 == (int *)0x0) || (param_2 == (uchar **)0x0)) {
CUtlBuffer::SeekGet(this_00,1,iVar6);
return 0;
}
DAT_0039d32c = 0;
iVar4 = DAT_0039d32c;
puVar2 = _DAT_0039d330;
if (((iVar6 == 0) ||
(iVar4 = iVar6, puVar2 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer,
iVar6 <= (int)DAT_0039d324)) ||
(puVar2 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer, DAT_0039d328 < 0))
goto LAB_00130def;
if (DAT_0039d328 == 0) {
if (DAT_0039d324 == 0) {
if (iVar6 < 0x21) {
DAT_0039d324 = 0x20;
goto LAB_00130fc6;
}
DAT_0039d324 = 0x20;
}
do {
DAT_0039d324 = DAT_0039d324 * 2;
} while ((int)DAT_0039d324 < iVar6);
}
else {
for (DAT_0039d324 = ((iVar6 + -1) / DAT_0039d328 + 1) * DAT_0039d328; (int)DAT_0039d324 < iVar6;
DAT_0039d324 = (int)(DAT_0039d324 + iVar6) / 2) {
}
}
LAB_00130fc6:
if (ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer == (uchar *)0x0) {
ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer = malloc(DAT_0039d324);
puVar2 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer;
}
else {
ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer =
realloc(ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer,DAT_0039d324);
iVar1 = DAT_0039d32c;
iVar4 = iVar6 + DAT_0039d32c;
puVar2 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer;
if ((0 < iVar6) &&
(puVar2 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer, 0 < DAT_0039d32c)) {
DAT_0039d32c = iVar4;
_DAT_0039d330 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer;
_V_memmove(ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer + iVar6,
ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer,iVar1);
iVar4 = DAT_0039d32c;
puVar2 = _DAT_0039d330;
}
}
LAB_00130def:
_DAT_0039d330 = puVar2;
DAT_0039d32c = iVar4;
*param_2 = ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer;
*param_1 = local_30;
CUtlBuffer::Get(this_00,ReadCustomData(int*,unsigned_char**)::s_TempMemoryBuffer,iVar6);
if (this[0x548] != (CDemoFile)0x0) {
iVar6 = -1;
Host_EndGame(true,"Error reading demo message data.\n");
}
return iVar6;
}
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.