L L4D2node

Hunk_AllocName

0x002404b0 · 597 bytes · __cdecl

_Z14Hunk_AllocNameiPKcb

Decompiled

undefined (3 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* Hunk_AllocName(int, char const*, bool) */

void * Hunk_AllocName(int param_1,char *param_2,bool param_3)

{
  int *piVar1;
  void *pvVar2;
  void *__s;
  char cVar3;
  char *__s_00;
  int iVar4;
  int iVar5;
  size_t __n;
  Node_t *local_30;
  char *local_24 [5];
  
  if (*(int *)(hunk_track_allocation_types._28_4_ + 0x30) != 0) {
    __s_00 = "unknown";
    if (param_2 != (char *)0x0) {
      __s_00 = param_2;
    }
    local_24[0] = __s_00;
    if (_DAT_003f2c90 != -1) {
      iVar4 = _DAT_003f2c90;
      do {
        while( true ) {
          iVar5 = iVar4 * 0x18;
          cVar3 = (*g_HunkAllocationsByName)(local_24,DAT_003f2c84 + 0x10 + iVar5);
          if (cVar3 != '\0') break;
          cVar3 = (*g_HunkAllocationsByName)(DAT_003f2c84 + iVar5 + 0x10,local_24);
          if (cVar3 == '\0') {
            if (iVar4 != -1) {
              piVar1 = (int *)(iVar5 + DAT_003f2c84 + 0x14);
              *piVar1 = *piVar1 + param_1;
              goto LAB_002405b0;
            }
            goto LAB_00240579;
          }
          if ((CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
               ::Links(int)::s_Sentinel == '\0') &&
             (iVar4 = __cxa_guard_acquire(&CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                                           ::Links(int)::s_Sentinel), iVar4 != 0)) {
            CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
            ::Links(int)::s_Sentinel = 0xffffffff;
            DAT_0034075c = 0xffffffff;
            DAT_00340760 = 0xffffffff;
            __cxa_guard_release(&CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                                 ::Links(int)::s_Sentinel);
          }
          iVar4 = *(int *)(DAT_003f2c84 + 4 + iVar5);
          if (iVar4 == -1) goto LAB_00240579;
        }
        if ((CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
             ::Links(int)::s_Sentinel == '\0') &&
           (iVar5 = __cxa_guard_acquire(&CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                                         ::Links(int)::s_Sentinel), iVar5 != 0)) {
          CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
          ::Links(int)::s_Sentinel = 0xffffffff;
          DAT_0034075c = 0xffffffff;
          DAT_00340760 = 0xffffffff;
          __cxa_guard_release(&CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                               ::Links(int)::s_Sentinel);
        }
        iVar4 = *(int *)(DAT_003f2c84 + iVar4 * 0x18);
      } while (iVar4 != -1);
    }
LAB_00240579:
    local_30 = (Node_t *)local_24;
    local_24[0] = strdup(__s_00);
    iVar4 = CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
            ::Insert((CUtlRBTree<CUtlMap<char_const*,int,int>::Node_t,int,CUtlMap<char_const*,int,int>::CKeyLess,CUtlMemory<UtlRBTreeNode_t<CUtlMap<char_const*,int,int>::Node_t,int>,int>>
                      *)&g_HunkAllocationsByName,local_30);
    *(int *)(DAT_003f2c84 + iVar4 * 0x18 + 0x14) = param_1;
  }
LAB_002405b0:
  __s = g_HunkMemoryStack;
  __n = DAT_003f2cbc;
  if (param_1 != 0) {
    __n = -DAT_003f2cbc & (DAT_003f2cbc - 1) + param_1;
  }
  pvVar2 = (void *)((int)g_HunkMemoryStack + __n);
  if ((pvVar2 <= DAT_003f2ca8) ||
     (cVar3 = CMemoryStack::CommitTo((uchar *)&g_HunkMemoryStack), cVar3 != '\0')) {
    if (param_3) {
      memset(__s,0,__n);
    }
    g_HunkMemoryStack = pvVar2;
    if (__s != (void *)0x0) {
      return __s;
    }
  }
  Error("Engine hunk overflow!\n");
  return (void *)0x0;
}

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)