KeyValues::FromString
0x00251500 · 840 bytes · __cdecl
_ZN9KeyValues10FromStringEPKcS1_PS1_
Decompiled
undefined (3 params)
/* KeyValues::FromString(char const*, char const*, char const**) */
KeyValues * KeyValues::FromString(char *param_1,char *param_2,char **param_3)
{
int iVar1;
int iVar2;
KeyValues *this;
char *pcVar3;
long lVar4;
KeyValues *pKVar5;
int iVar6;
char cVar7;
char *pcVar8;
int in_GS_OFFSET;
byte bVar9;
uint in_stack_fffffda8;
char *local_230;
undefined4 local_22c [3];
char local_220 [256];
char local_120 [256];
int local_20;
bVar9 = 0;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (param_1 == (char *)0x0) {
param_1 = "";
}
if (param_2 == (char *)0x0) {
param_2 = "";
}
this = operator_new((KeyValues *)0x2c,in_stack_fffffda8);
Init(this,(IKeyValuesSystem *)0x0,false);
/* try { // try from 00251568 to 0025156c has its CatchHandler @ 00251858 */
SetName(this,param_1);
pKVar5 = (KeyValues *)0x0;
if (this != (KeyValues *)0x0) {
pcVar3 = local_220;
for (iVar6 = 0x40; iVar6 != 0; iVar6 = iVar6 + -1) {
pcVar3[0] = '\0';
pcVar3[1] = '\0';
pcVar3[2] = '\0';
pcVar3[3] = '\0';
pcVar3 = pcVar3 + ((uint)bVar9 * -2 + 1) * 4;
}
pcVar3 = local_120;
for (iVar6 = 0x40; iVar6 != 0; iVar6 = iVar6 + -1) {
pcVar3[0] = '\0';
pcVar3[1] = '\0';
pcVar3[2] = '\0';
pcVar3[3] = '\0';
pcVar3 = pcVar3 + ((uint)bVar9 * -2 + 1) * 4;
}
LAB_002515a0:
pcVar3 = (char *)ParseStringToken(param_2,&local_230);
cVar7 = *pcVar3;
if (cVar7 != '\0') {
while( true ) {
if (cVar7 == '}') {
param_2 = pcVar3 + 1;
goto LAB_002516d0;
}
pcVar8 = local_230 + (1 - (int)pcVar3);
if ((char *)0x100 < pcVar8) {
pcVar8 = (char *)0x100;
}
V_strncpy(local_220,pcVar3,(int)pcVar8);
if (local_220[0] == '{') break;
pcVar3 = (char *)ParseStringToken(local_230,&local_230);
if (*pcVar3 == '}') {
param_2 = pcVar3 + 1;
SetString(this,local_220,"");
goto LAB_002516d0;
}
pcVar8 = local_230 + (1 - (int)pcVar3);
if ((char *)0x100 < pcVar8) {
pcVar8 = (char *)0x100;
}
V_strncpy(local_120,pcVar3,(int)pcVar8);
param_2 = local_230;
if (local_120[0] == '{') {
pcVar3 = local_220;
goto LAB_0025170e;
}
pcVar3 = (char *)StringAfterPrefix(local_120,"#int#");
if (pcVar3 == (char *)0x0) {
pcVar3 = (char *)StringAfterPrefix(local_120,"#uint64#");
if (pcVar3 == (char *)0x0) {
iVar6 = _V_stricmp(local_120,"#empty#");
if (iVar6 == 0) {
pcVar3 = "";
}
else {
pcVar3 = local_120;
}
SetString(this,local_220,pcVar3);
}
else {
sscanf(pcVar3,"%llu",local_22c);
SetUint64((char *)this,CONCAT44(local_22c[0],local_220));
}
goto LAB_002515a0;
}
lVar4 = strtol(pcVar3,(char **)0x0,10);
iVar6 = FindKey(this,local_220,true);
if (iVar6 == 0) goto LAB_002515a0;
*(undefined1 *)(iVar6 + 0x10) = 2;
*(long *)(iVar6 + 0xc) = lVar4;
pcVar3 = (char *)ParseStringToken(param_2,&local_230);
cVar7 = *pcVar3;
if (cVar7 == '\0') goto LAB_002516d0;
}
pcVar3 = "";
LAB_0025170e:
iVar6 = FromString(pcVar3,local_230,&local_230);
param_2 = local_230;
if (iVar6 != 0) {
iVar1 = *(int *)(this + 0x20);
if (iVar1 == 0) {
*(int *)(this + 0x20) = iVar6;
}
else {
for (iVar2 = *(int *)(iVar1 + 0x1c); iVar2 != 0; iVar2 = *(int *)(iVar2 + 0x1c)) {
iVar1 = iVar2;
}
*(int *)(iVar1 + 0x1c) = iVar6;
}
}
goto LAB_002515a0;
}
LAB_002516d0:
pKVar5 = this;
if (param_3 != (char **)0x0) {
*param_3 = param_2;
}
}
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return pKVar5;
}
/* 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.