L L4D2node

KeyValues::FindKey

0x0024dcb0 · 515 bytes · __thiscall

_ZN9KeyValues7FindKeyEPKcb

Decompiled

undefined (3 params)

/* KeyValues::FindKey(char const*, bool) */

KeyValues * __thiscall KeyValues::FindKey(KeyValues *this,char *param_1,bool param_2)

{
  int iVar1;
  char *pcVar2;
  char *pcVar3;
  int iVar4;
  KeyValues *pKVar5;
  int *piVar6;
  KeyValues *pKVar7;
  int in_GS_OFFSET;
  char *local_134;
  char local_120 [256];
  int local_20;
  
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (this != (KeyValues *)0x0) {
    if ((param_1 == (char *)0x0) || (*param_1 == '\0')) goto LAB_0024de65;
    pcVar2 = strchr(param_1,0x2f);
    if (pcVar2 == (char *)0x0) {
      local_134 = param_1;
    }
    else {
      local_134 = local_120;
      pcVar3 = (char *)0x100;
      if (pcVar2 + (1 - (int)param_1) < (char *)0x100) {
        pcVar3 = pcVar2 + (1 - (int)param_1);
      }
      V_strncpy(local_134,param_1,(int)pcVar3);
    }
    piVar6 = *(int **)(this + 0x14);
    if (piVar6 == (int *)0x0) {
      piVar6 = (int *)KeyValuesSystem();
    }
    pcVar3 = local_134;
    iVar4 = (**(code **)(*piVar6 + 0x14))(piVar6,local_134,param_2);
    if (iVar4 != -1) {
      pKVar7 = *(KeyValues **)(this + 0x20);
      if (pKVar7 == (KeyValues *)0x0) {
LAB_0024ddc2:
        if ((*(KeyValues **)(this + 0x24) == (KeyValues *)0x0) ||
           (pKVar5 = (KeyValues *)FindKey(*(KeyValues **)(this + 0x24),param_1,false),
           pcVar3 = param_1, pKVar5 == (KeyValues *)0x0)) {
          if (!param_2) goto LAB_0024de98;
          pKVar5 = operator_new((KeyValues *)0x2c,(uint)pcVar3);
          Init(pKVar5,*(IKeyValuesSystem **)(this + 0x14),false);
                    /* try { // try from 0024de22 to 0024de26 has its CatchHandler @ 0024dec5 */
          SetName(pKVar5,local_134);
          if (pKVar7 == (KeyValues *)0x0) {
            *(KeyValues **)(this + 0x20) = pKVar5;
          }
          else {
            *(KeyValues **)(pKVar7 + 0x1c) = pKVar5;
          }
          *(undefined4 *)(pKVar5 + 0x1c) = 0;
          this[0x10] = (KeyValues)0x0;
        }
      }
      else {
        iVar1 = *(int *)pKVar7;
        while (pKVar5 = pKVar7, iVar4 != iVar1) {
          pKVar5 = *(KeyValues **)(pKVar7 + 0x1c);
          if (pKVar5 == (KeyValues *)0x0) goto LAB_0024ddc2;
          pKVar7 = pKVar5;
          iVar1 = *(int *)pKVar5;
        }
      }
      this = pKVar5;
      if (pcVar2 != (char *)0x0) {
        this = (KeyValues *)FindKey(this,pcVar2 + 1,param_2);
      }
      goto LAB_0024de65;
    }
  }
LAB_0024de98:
  this = (KeyValues *)0x0;
LAB_0024de65:
  if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
    return this;
  }
                    /* WARNING: Subroutine does not return */
  __stack_chk_fail();
}

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)