ReadEncryptedKVFile
0x00585210 · 559 bytes · __cdecl
_Z19ReadEncryptedKVFileP11IFileSystemPKcPKh
Decompiled
undefined (3 params)
/* ReadEncryptedKVFile(IFileSystem*, char const*, unsigned char const*) */
KeyValues * ReadEncryptedKVFile(IFileSystem *param_1,char *param_2,uchar *param_3)
{
IBaseFileSystem *pIVar1;
undefined4 *puVar2;
code *pcVar3;
int iVar4;
char *pcVar5;
char cVar6;
KeyValues *this;
IBaseFileSystem *pIVar7;
int iVar8;
int iVar9;
undefined4 *puVar10;
undefined4 *puVar11;
int in_GS_OFFSET;
undefined4 uStackY_260;
uint in_stack_fffffda8;
undefined4 auStack_24c [3];
int local_240;
int local_23c;
uchar *local_238;
int local_234;
char *local_230;
char local_220 [512];
int local_20;
puVar10 = (undefined4 *)&stack0xfffffda4;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
local_238 = param_3;
uStackY_260 = 0x585245;
this = KeyValues::operator_new((KeyValues *)0x2c,in_stack_fffffda8);
/* try { // try from 00585262 to 00585266 has its CatchHandler @ 00585441 */
uStackY_260 = 0x585267;
KeyValues::KeyValues(this,"WeaponDatafile",(IKeyValuesSystem *)0x0,false);
uStackY_260 = 0x585277;
KeyValues::UsesEscapeSequences(this,true);
local_230 = param_2;
pIVar1 = (IBaseFileSystem *)(param_1 + 4);
uStackY_260 = 0x5852a2;
V_snprintf(local_220,0x200,"%s.txt");
pIVar7 = (IBaseFileSystem *)0x0;
if (param_1 != (IFileSystem *)0x0) {
pIVar7 = pIVar1;
}
uStackY_260 = 0x5852c7;
cVar6 = KeyValues::LoadFromFile(this,pIVar7,local_220,"GAME");
if (cVar6 == '\0') {
puVar11 = (undefined4 *)&stack0xfffffda4;
if (local_238 != (uchar *)0x0) {
uStackY_260 = 0x585305;
V_snprintf(local_220,0x200,"%s.ctx");
uStackY_260 = 0x585328;
iVar8 = (**(code **)(*(int *)(param_1 + 4) + 8))();
puVar11 = (undefined4 *)&stack0xfffffda4;
if (iVar8 != 0) {
uStackY_260 = 0x585345;
local_23c = iVar8;
iVar9 = (**(code **)(*(int *)(param_1 + 4) + 0x18))();
iVar8 = local_23c;
local_240 = local_23c;
iVar4 = -((iVar9 + 0x10U & 0xfffffff0) + 0x10);
puVar10 = (undefined4 *)(&stack0xfffffda4 + iVar4);
puVar11 = (undefined4 *)(&stack0xfffffda4 + iVar4);
local_234 = (int)&local_240 + iVar4;
puVar2 = *(undefined4 **)(param_1 + 4);
local_23c = iVar9;
*(int *)(&stack0xfffffdac + iVar4) = iVar9;
*(int *)(&stack0xfffffdb0 + iVar4) = iVar8;
*(IBaseFileSystem **)(&stack0xfffffda4 + iVar4) = pIVar1;
*(int *)(&stack0xfffffda8 + iVar4) = local_234;
pcVar3 = (code *)*puVar2;
*(undefined4 *)((int)&uStackY_260 + iVar4) = 0x58538f;
(*pcVar3)();
*(undefined1 *)(local_234 + local_23c) = 0;
iVar8 = *(int *)(param_1 + 4);
*(int *)(&stack0xfffffda8 + iVar4) = local_240;
*(IBaseFileSystem **)(&stack0xfffffda4 + iVar4) = pIVar1;
pcVar3 = *(code **)(iVar8 + 0xc);
*(undefined4 *)((int)&uStackY_260 + iVar4) = 0x5853b2;
(*pcVar3)();
iVar9 = local_234;
*(uchar **)(&stack0xfffffdac + iVar4) = local_238;
iVar8 = local_23c;
*(int *)(&stack0xfffffda4 + iVar4) = iVar9;
*(int *)(&stack0xfffffda8 + iVar4) = iVar8;
*(undefined4 *)((int)&uStackY_260 + iVar4) = 0x5853d4;
UTIL_DecodeICE(*(uchar **)(&stack0xfffffda4 + iVar4),*(int *)(&stack0xfffffda8 + iVar4),
*(uchar **)(&stack0xfffffdac + iVar4));
*(IBaseFileSystem **)(&stack0xfffffdb0 + iVar4) = pIVar1;
*(undefined4 *)((int)auStack_24c + iVar4) = 0;
*(int *)(&stack0xfffffdac + iVar4) = iVar9;
*(char **)(&stack0xfffffda8 + iVar4) = local_220;
*(KeyValues **)(&stack0xfffffda4 + iVar4) = this;
*(undefined4 *)((int)&uStackY_260 + iVar4) = 0x5853f6;
cVar6 = KeyValues::LoadFromBuffer
(*(KeyValues **)(&stack0xfffffda4 + iVar4),
*(char **)(&stack0xfffffda8 + iVar4),*(char **)(&stack0xfffffdac + iVar4)
,*(IBaseFileSystem **)(&stack0xfffffdb0 + iVar4),
*(char **)((int)auStack_24c + iVar4));
if (cVar6 != '\0') goto LAB_005853fa;
}
}
*puVar11 = this;
puVar11[-1] = 0x585438;
KeyValues::deleteThis();
this = (KeyValues *)0x0;
}
else {
LAB_005853fa:
pcVar5 = local_230;
puVar10[1] = "SERVER: Weapon Script \"%s\" loaded.\n";
*puVar10 = 2;
puVar10[2] = pcVar5;
puVar10[-1] = 0x585418;
DevMsg();
puVar11 = puVar10;
}
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return this;
}
/* WARNING: Subroutine does not return */
*(undefined1 **)((int)puVar11 + -4) = &LAB_00585441;
__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.