L L4D2node

ReadKeyValuesFile

0x000d8760 · 384 bytes · __cdecl

_Z17ReadKeyValuesFilePKc

Decompiled

undefined (1 param)

/* ReadKeyValuesFile(char const*) */

KeyValues * ReadKeyValuesFile(char *param_1)

{
  char cVar1;
  FILE *__stream;
  long lVar2;
  int iVar3;
  KeyValues *this;
  uint uVar4;
  char *local_30;
  undefined4 local_2c;
  undefined4 local_28;
  int local_24;
  char *local_20;
  
  __stream = (FILE *)__wrap_fopen(param_1,&DAT_002a3e98);
  if (__stream == (FILE *)0x0) {
    this = (KeyValues *)0x0;
  }
  else {
    local_30 = (char *)0x0;
    local_2c = 0;
    local_28 = 0;
    local_24 = 0;
    local_20 = (char *)0x0;
    fseek(__stream,0,2);
                    /* try { // try from 000d87c7 to 000d8833 has its CatchHandler @ 000d8900 */
    lVar2 = ftell(__stream);
    iVar3 = lVar2 + 1;
    local_24 = 0;
    if (iVar3 != 0) {
      CUtlVector<char,CUtlMemory<char,int>>::GrowVector
                ((CUtlVector<char,CUtlMemory<char,int>> *)&local_30,iVar3);
      CUtlVector<char,CUtlMemory<char,int>>::ShiftElementsRight
                ((CUtlVector<char,CUtlMemory<char,int>> *)&local_30,0,iVar3);
    }
    fseek(__stream,0,0);
    uVar4 = 1;
    fread(local_30,1,local_24 - 1,__stream);
    fclose(__stream);
    local_30[local_24 + -1] = '\0';
    this = KeyValues::operator_new((KeyValues *)0x2c,uVar4);
                    /* try { // try from 000d8851 to 000d8855 has its CatchHandler @ 000d88e4 */
    KeyValues::KeyValues(this,"",(IKeyValuesSystem *)0x0,false);
                    /* try { // try from 000d8874 to 000d88d8 has its CatchHandler @ 000d8900 */
    cVar1 = KeyValues::LoadFromBuffer(this,param_1,local_30,(IBaseFileSystem *)0x0,(char *)0x0);
    if (cVar1 == '\0') {
      KeyValues::deleteThis();
      this = (KeyValues *)0x0;
    }
    local_24 = 0;
    CUtlMemory<char,int>::Purge((CUtlMemory<char,int> *)&local_30);
    local_20 = local_30;
    CUtlMemory<char,int>::Purge((CUtlMemory<char,int> *)&local_30);
  }
  return this;
}

SourceMod gamedata

paste into addons/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.



        

        

          

Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.

Return-type handling cheatsheet (DHookReturn)