L L4D2node

CUtlBuffer::VaScanf

0x0004d1c0 · 780 bytes · __thiscall

_ZN10CUtlBuffer7VaScanfEPKcPc

Decompiled

undefined (3 params)

/* CUtlBuffer::VaScanf(char const*, char*) */

int __thiscall CUtlBuffer::VaScanf(CUtlBuffer *this,char *param_1,char *param_2)

{
  ulong *puVar1;
  float *pfVar2;
  undefined1 *puVar3;
  char *pcVar4;
  char *pcVar5;
  char cVar6;
  char cVar7;
  ulong uVar8;
  int iVar9;
  double dVar10;
  CUtlBuffer *in_stack_ffffffb4;
  char **in_stack_ffffffb8;
  int *in_stack_ffffffbc;
  int local_38;
  int local_24;
  char *local_20 [4];
  
  if ((this[0x14] != (CUtlBuffer)0x0) || (((byte)this[0x15] & 1) == 0)) {
    return 0;
  }
  local_38 = 0;
LAB_0004d1e8:
  do {
    cVar6 = *param_1;
    pcVar5 = param_1 + 1;
    pcVar4 = param_1;
    while( true ) {
      param_1 = pcVar5;
      if (cVar6 == '\0') {
        return local_38;
      }
      if (*(int *)(this + 0x1c) <= *(int *)(this + 0xc)) {
        this[0x14] = (CUtlBuffer)((byte)this[0x14] | 2);
        return local_38;
      }
      if (cVar6 == ' ') {
        in_stack_ffffffb4 = this;
        EatWhiteSpace(this);
        goto LAB_0004d1e8;
      }
      if (cVar6 != '%') break;
      if (pcVar4[1] == '\0') {
        return local_38;
      }
      switch(pcVar4[1]) {
      case 'c':
        puVar3 = *(undefined1 **)param_2;
        if ((((byte)this[0x14] & 2) != 0) ||
           (cVar6 = CheckPeekGet(in_stack_ffffffb4,(int)in_stack_ffffffb8,(int)in_stack_ffffffbc),
           cVar6 == '\0')) {
          *puVar3 = 0;
          return local_38;
        }
        *puVar3 = *(undefined1 *)(*(int *)this + (*(int *)(this + 0xc) - *(int *)(this + 0x20)));
        *(int *)(this + 0xc) = *(int *)(this + 0xc) + 1;
        goto LAB_0004d2ce;
      case 'd':
      case 'i':
        local_24 = 0x80;
        puVar1 = *(ulong **)param_2;
        cVar6 = CheckArbitraryPeekGet(this,0,&local_24);
        if (cVar6 == '\0') {
LAB_0004d4dd:
          *puVar1 = 0;
          return local_38;
        }
        in_stack_ffffffbc = (int *)0xa;
        goto LAB_0004d299;
      default:
        goto switchD_0004d22f_caseD_65;
      case 'f':
        local_24 = 0x80;
        pfVar2 = *(float **)param_2;
        in_stack_ffffffbc = &local_24;
        cVar6 = CheckArbitraryPeekGet(this,0,in_stack_ffffffbc);
        if (cVar6 == '\0') {
          *pfVar2 = 0.0;
          return local_38;
        }
        in_stack_ffffffb8 = local_20;
        in_stack_ffffffb4 =
             (CUtlBuffer *)((*(int *)(this + 0xc) - *(int *)(this + 0x20)) + *(int *)this);
        dVar10 = strtod((char *)in_stack_ffffffb4,in_stack_ffffffb8);
        *pfVar2 = (float)dVar10;
        break;
      case 's':
        in_stack_ffffffbc = (int *)0x12c;
        in_stack_ffffffb8 = *(char ***)param_2;
        in_stack_ffffffb4 = this;
        GetString(this,(char *)in_stack_ffffffb8,300);
        goto LAB_0004d2ce;
      case 'u':
        local_24 = 0x80;
        puVar1 = *(ulong **)param_2;
        cVar6 = CheckArbitraryPeekGet(this,0,&local_24);
        if (cVar6 == '\0') goto LAB_0004d4dd;
        in_stack_ffffffb8 = local_20;
        in_stack_ffffffbc = (int *)0xa;
        in_stack_ffffffb4 =
             (CUtlBuffer *)((*(int *)(this + 0xc) - *(int *)(this + 0x20)) + *(int *)this);
        uVar8 = strtoul((char *)in_stack_ffffffb4,in_stack_ffffffb8,10);
        *puVar1 = uVar8;
        break;
      case 'x':
        local_24 = 0x80;
        puVar1 = *(ulong **)param_2;
        cVar6 = CheckArbitraryPeekGet(this,0,&local_24);
        if (cVar6 == '\0') goto LAB_0004d4dd;
        in_stack_ffffffbc = (int *)0x10;
LAB_0004d299:
        in_stack_ffffffb8 = local_20;
        in_stack_ffffffb4 =
             (CUtlBuffer *)((*(int *)(this + 0xc) - *(int *)(this + 0x20)) + *(int *)this);
        uVar8 = strtol((char *)in_stack_ffffffb4,in_stack_ffffffb8,(int)in_stack_ffffffbc);
        *puVar1 = uVar8;
      }
      iVar9 = (int)local_20[0] - ((*(int *)(this + 0xc) - *(int *)(this + 0x20)) + *(int *)this);
      if (iVar9 == 0) {
        return local_38;
      }
      *(int *)(this + 0xc) = *(int *)(this + 0xc) + iVar9;
LAB_0004d2ce:
      param_2 = param_2 + 4;
      local_38 = local_38 + 1;
      cVar6 = pcVar4[2];
      pcVar5 = pcVar4 + 3;
      pcVar4 = pcVar4 + 2;
    }
    if (((((byte)this[0x14] & 2) != 0) ||
        (cVar7 = CheckPeekGet(in_stack_ffffffb4,(int)in_stack_ffffffb8,(int)in_stack_ffffffbc),
        cVar7 == '\0')) ||
       (cVar6 != *(char *)(*(int *)this + (*(int *)(this + 0xc) - *(int *)(this + 0x20))))) {
switchD_0004d22f_caseD_65:
      return local_38;
    }
    *(int *)(this + 0xc) = *(int *)(this + 0xc) + 1;
  } while( true );
}

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)