L L4D2node

CNetChan::ProcessPacket

0x001b7f60 · 2542 bytes · __thiscall

_ZN8CNetChan13ProcessPacketEP11netpacket_sb

Decompiled

undefined (3 params)

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */
/* CNetChan::ProcessPacket(netpacket_s*, bool) */

void __thiscall CNetChan::ProcessPacket(CNetChan *this,netpacket_s *param_1,bool param_2)

{
  CBitRead *this_00;
  netadr_s *this_01;
  uint *puVar1;
  undefined4 *puVar2;
  byte bVar3;
  char cVar4;
  int iVar5;
  INetChannelPacketProcessingCallback *pIVar6;
  int iVar7;
  SocketProcessingStats_t *this_02;
  undefined4 uVar8;
  undefined4 uVar9;
  undefined4 uVar10;
  uint uVar11;
  uint uVar12;
  int in_GS_OFFSET;
  longlong lVar13;
  CNetChan *pCVar14;
  char *local_d4;
  SocketProcessingStats_t *local_c4;
  INetChannelPacketProcessingCallback *local_c0;
  undefined4 local_bc;
  undefined4 local_b8;
  undefined4 local_b0;
  undefined4 local_ac;
  CNetChan *local_a8;
  undefined4 local_a4;
  char local_a0 [128];
  int local_20;
  
  local_bc = 0;
  local_b8 = 0;
  local_20 = *(int *)(in_GS_OFFSET + 0x14);
  if (_exit == (CNetChan *)0x0) {
    local_a8 = (CNetChan *)0x0;
  }
  else {
    (**(code **)(_exit + 0x50))
              (_exit,&local_bc,0,0,0,0,"/data/src/engine/./net_chan.cpp",0xbfe,
               &ProcessPacket(netpacket_s*,bool)::tm_fmt,"(%s)%s","Unaccounted",
               "CNetChan::ProcessPacket");
    local_a8 = _exit;
  }
  iVar5 = _DAT_0040b9d4;
  local_b0 = local_bc;
  local_ac = local_b8;
                    /* try { // try from 001b8276 to 001b82c4 has its CatchHandler @ 001b89b5 */
  if (((_DAT_0040b028 != 0) || (DAT_0040b02c == '\0')) &&
     (iVar7 = ThreadGetCurrentId(), iVar5 == iVar7)) {
    if (*(char **)_DAT_0040b030 != "CNetChan::ProcessPacket") {
      _DAT_0040b030 =
           (CNetChan *)CVProfNode::GetSubNode((char *)_DAT_0040b030,0x2bb3dc,&DAT_00000001,0x2a054b)
      ;
    }
    CVProfNode::EnterScope();
    DAT_0040b02c = '\0';
  }
  this_00 = (CBitRead *)(param_1 + 0x1c);
                    /* try { // try from 001b8059 to 001b80f7 has its CatchHandler @ 001b89eb */
  CBitRead::Seek(this_00,0);
  this_01 = (netadr_s *)(this + 0x98);
  cVar4 = netadr_s::IsValid(this_01);
                    /* try { // try from 001b82fd to 001b8301 has its CatchHandler @ 001b89eb */
  if ((cVar4 == '\0') ||
     (pCVar14 = (CNetChan *)param_1, cVar4 = netadr_s::CompareAdr((netadr_s *)param_1,this_01,false)
     , cVar4 != '\0')) {
    CNetchanParanoidMode::StartPacket((CNetchanParanoidMode *)g_NetParanoid,(bf_read *)this_00);
    iVar5 = *(int *)(param_1 + 0x44) + 0x1c;
    FlowUpdate(this,1,iVar5);
    if (*(int *)(this + 17000) == 0) {
                    /* try { // try from 001b8397 to 001b839b has its CatchHandler @ 001b89eb */
      this_02 = operator_new(0x48);
                    /* try { // try from 001b83a1 to 001b83a5 has its CatchHandler @ 001b89fb */
      SocketProcessingStats_t::SocketProcessingStats_t(this_02);
      local_c4 = this_02;
                    /* try { // try from 001b83c7 to 001b83cb has its CatchHandler @ 001b89eb */
      CUtlVector<CNetChan::SocketProcessingStats_t*,CUtlMemory<CNetChan::SocketProcessingStats_t*,int>>
      ::InsertBefore((CUtlVector<CNetChan::SocketProcessingStats_t*,CUtlMemory<CNetChan::SocketProcessingStats_t*,int>>
                      *)(this + 0x425c),0,&local_c4);
    }
    else {
      local_c4 = (SocketProcessingStats_t *)**(undefined4 **)(this + 0x425c);
    }
    g_pNetChannelProcessingActivePacket = this;
    *(int *)(local_c4 + 0x10) = *(int *)(local_c4 + 0x10) + 1;
    *(int *)(local_c4 + 0x20) = *(int *)(local_c4 + 0x20) + iVar5;
    *(int *)(this + 0x4294) = *(int *)(this + 0x4294) + 1;
    *(int *)(this + 0x42a4) = *(int *)(this + 0x42a4) + iVar5;
    pIVar6 = operator_new(0x10);
    *(undefined ***)pIVar6 = &PTR_OnProcessingFinished_002bb730;
    *(CNetChan **)(pIVar6 + 4) = this;
                    /* try { // try from 001b8103 to 001b8107 has its CatchHandler @ 001b89ef */
    iVar7 = Plat_MSTime();
    *(undefined4 *)(pIVar6 + 0xc) = 0;
    *(int *)(pIVar6 + 8) = iVar7 * 1000;
    local_c0 = pIVar6;
                    /* try { // try from 001b8138 to 001b813c has its CatchHandler @ 001b89eb */
    CUtlVector<INetChannelPacketProcessingCallback*,CUtlMemory<INetChannelPacketProcessingCallback*,int>>
    ::InsertBefore((CUtlVector<INetChannelPacketProcessingCallback*,CUtlMemory<INetChannelPacketProcessingCallback*,int>>
                    *)&g_arrNetChannelProcessingCallbacks,DAT_003ab954,&local_c0);
    local_c0 = (INetChannelPacketProcessingCallback *)this;
                    /* try { // try from 001b8146 to 001b81bb has its CatchHandler @ 001b89cd */
    cVar4 = BContinueSocketProcessingFrameCheckpoint(this);
    if (cVar4 == '\0') {
      uVar8 = *(undefined4 *)(**(int **)(this + 0x425c) + 0x14);
      uVar9 = *(undefined4 *)(**(int **)(this + 0x425c) + 0x18);
                    /* try { // try from 001b8683 to 001b86bd has its CatchHandler @ 001b89cd */
      uVar10 = (**(code **)(*(int *)this + 4))(this);
      Msg("Packet from %s after processing time exceeded (%d bytes pkt), aborting connection after %llu usec tick\n"
          ,uVar10,iVar5,uVar8,uVar9);
      pCVar14 = *(CNetChan **)(this + 0x4208);
      (**(code **)(*(int *)pCVar14 + 0x10))(pCVar14,"Processing time exceeded");
    }
    else {
      uVar12 = 0;
                    /* try { // try from 001b8727 to 001b882c has its CatchHandler @ 001b89cd */
      if ((!param_2) ||
         (pCVar14 = this, uVar12 = ProcessPacketHeader(this,param_1), uVar12 != 0xffffffff)) {
        CNetchanParanoidMode::NoteHeaderSize
                  ((CNetchanParanoidMode *)g_NetParanoid,(bf_read *)this_00,uVar12);
        if (((*(int *)(net_showudp._28_4_ + 0x30) != 0) &&
            (*(int *)(net_showudp._28_4_ + 0x30) != 3)) &&
           ((*(int *)(net_showudp_remoteonly._28_4_ + 0x30) == 0 ||
            ((cVar4 = netadr_s::IsLocalhost(this_01), cVar4 == '\0' &&
             (cVar4 = netadr_s::IsLoopback(this_01), cVar4 == '\0')))))) {
                    /* try { // try from 001b840d to 001b85c1 has its CatchHandler @ 001b89cd */
          lVar13 = (**(code **)(*(int *)g_pSteamSocketMgr + 0x1c))(g_pSteamSocketMgr,this_01);
          local_a4 = 0xffffc800;
          if (lVar13 == 0) {
            uVar8 = netadr_s::ToString(this_01,false);
            uVar9 = (*(code *)**(undefined4 **)this)(this);
            V_snprintf(local_a0,0x80,"%12.12s %21.21s",uVar9,uVar8);
          }
          else {
            local_a4 = 0xff64ffff;
            uVar8 = netadr_s::ToString(this_01,false);
            uVar9 = (*(code *)**(undefined4 **)this)(this);
            V_snprintf(local_a0,0x80,"%12.12s %21.21s s(%llx)",uVar9,uVar8,(int)lVar13,
                       (int)((ulonglong)lVar13 >> 0x20));
          }
          local_d4 = local_a0;
          ConColorMsg((Color *)&local_a4,
                      "UDP <- %s: sz=%5i seq=%5i ack=%5i rel=%1i tm=%8.3f wire=%i\n",local_d4,
                      *(undefined4 *)(param_1 + 0x40),*(uint *)(this + 0xc) & 0x3f,
                      *(uint *)(this + 0x10) & 0x3f,uVar12 & 1,net_time,
                      *(undefined4 *)(param_1 + 0x44));
        }
        *(float *)(this + 0xa4) = (float)net_time;
        (**(code **)(**(int **)(this + 0x4208) + 0x14))
                  (*(int **)(this + 0x4208),*(undefined4 *)(this + 0xc),*(undefined4 *)(this + 0x10)
                  );
        if ((uVar12 & 1) != 0) {
          iVar5 = *(int *)(param_1 + 0x30);
          if (iVar5 < 3) {
            puVar1 = *(uint **)(param_1 + 0x34);
            uVar8 = *(undefined4 *)(param_1 + 0x2c);
            if (puVar1 == *(uint **)(param_1 + 0x38)) {
              *(undefined4 *)(param_1 + 0x2c) = 0;
              iVar5 = 1;
              *(uint **)(param_1 + 0x34) = puVar1 + 1;
              param_1[0x20] = (netpacket_s)0x1;
            }
            else {
              if (puVar1 <= *(uint **)(param_1 + 0x38)) {
                *(uint **)(param_1 + 0x34) = puVar1 + 1;
                uVar12 = *puVar1;
                *(uint *)(param_1 + 0x2c) = uVar12;
                if (param_1[0x20] == (netpacket_s)0x0) {
                  uVar11 = uVar12 & (&CBitBuffer::s_nMaskTable)[3 - iVar5];
                  local_d4._0_1_ = (byte)(3 - iVar5);
                  uVar12 = uVar12 >> ((byte)local_d4 & 0x1f);
                  *(uint *)(param_1 + 0x2c) = uVar12;
                  local_d4 = (char *)(1 << (((byte)(uVar11 << ((byte)iVar5 & 0x1f)) | (byte)uVar8) &
                                           0x1f));
                  iVar5 = iVar5 + 0x1d;
                }
                else {
                  local_d4 = (char *)0x1;
                }
                goto LAB_001b8203;
              }
              param_1[0x20] = (netpacket_s)0x1;
              *(undefined4 *)(param_1 + 0x2c) = 0;
            }
            local_d4 = (char *)0x1;
            uVar12 = 0;
          }
          else {
            iVar5 = iVar5 + -3;
            *(int *)(param_1 + 0x30) = iVar5;
            bVar3 = (byte)*(uint *)(param_1 + 0x2c);
            if (iVar5 == 0) {
              puVar1 = *(uint **)(param_1 + 0x34);
              *(undefined4 *)(param_1 + 0x30) = 0x20;
              if (puVar1 == *(uint **)(param_1 + 0x38)) {
                *(undefined4 *)(param_1 + 0x2c) = 0;
                uVar12 = 0;
                local_d4 = (char *)(1 << (bVar3 & 7));
                *(uint **)(param_1 + 0x34) = puVar1 + 1;
                iVar5 = 1;
              }
              else if (*(uint **)(param_1 + 0x38) < puVar1) {
                param_1[0x20] = (netpacket_s)0x1;
                iVar5 = 0x20;
                uVar12 = 0;
                local_d4 = (char *)(1 << (bVar3 & 7));
                *(undefined4 *)(param_1 + 0x2c) = 0;
              }
              else {
                local_d4 = (char *)(1 << (bVar3 & 7));
                *(uint **)(param_1 + 0x34) = puVar1 + 1;
                uVar12 = *puVar1;
                iVar5 = 0x20;
                *(uint *)(param_1 + 0x2c) = uVar12;
              }
            }
            else {
              uVar12 = *(uint *)(param_1 + 0x2c) >> 3;
              local_d4 = (char *)(1 << (bVar3 & 7));
              *(uint *)(param_1 + 0x2c) = uVar12;
            }
          }
LAB_001b8203:
          iVar7 = 0;
          uVar11 = uVar12 & 1;
          *(int *)(param_1 + 0x30) = iVar5 + -1;
          if (iVar5 + -1 != 0) goto LAB_001b8261;
          do {
            puVar2 = *(undefined4 **)(param_1 + 0x34);
            *(undefined4 *)(param_1 + 0x30) = 0x20;
            if (puVar2 == *(undefined4 **)(param_1 + 0x38)) {
              *(undefined4 *)(param_1 + 0x30) = 1;
              *(undefined4 *)(param_1 + 0x2c) = 0;
              *(undefined4 **)(param_1 + 0x34) = puVar2 + 1;
            }
            else if (*(undefined4 **)(param_1 + 0x38) < puVar2) {
              param_1[0x20] = (netpacket_s)0x1;
              *(undefined4 *)(param_1 + 0x2c) = 0;
            }
            else {
              *(undefined4 **)(param_1 + 0x34) = puVar2 + 1;
              *(undefined4 *)(param_1 + 0x2c) = *puVar2;
            }
            while( true ) {
              if ((uVar11 != 0) &&
                 (pCVar14 = this, cVar4 = ReadSubChannelData(this,(bf_read *)this_00,iVar7),
                 cVar4 == '\0')) goto LAB_001b86be;
              iVar7 = iVar7 + 1;
              if (iVar7 == 2) {
                uVar12 = *(uint *)(this + 0x18);
                if (((uint)local_d4 & uVar12) == 0) {
                  *(uint *)(this + 0x18) = uVar12 | (uint)local_d4;
                }
                else {
                  *(uint *)(this + 0x18) = ~(uint)local_d4 & uVar12;
                }
                pCVar14 = this;
                cVar4 = CheckReceivingList(this,0);
                if ((cVar4 == '\0') ||
                   (pCVar14 = this, cVar4 = CheckReceivingList(this,1), cVar4 == '\0'))
                goto LAB_001b86be;
                goto LAB_001b8564;
              }
              iVar5 = *(int *)(param_1 + 0x30);
              uVar12 = *(uint *)(param_1 + 0x2c);
              *(int *)(param_1 + 0x30) = iVar5 + -1;
              uVar11 = uVar12 & 1;
              if (iVar5 + -1 == 0) break;
LAB_001b8261:
              *(uint *)(param_1 + 0x2c) = uVar12 >> 1;
            }
          } while( true );
        }
LAB_001b8564:
        iVar5 = *(int *)(param_1 + 0x24);
        if (*(int *)(param_1 + 0x3c) == 0) {
          iVar7 = 0;
        }
        else {
          iVar7 = (((uint)(*(int *)(param_1 + 0x34) - *(int *)(param_1 + 0x3c)) >> 2) * 0x20 -
                  *(int *)(param_1 + 0x30)) + (*(uint *)(param_1 + 0x28) & 3) * 8;
          if (iVar5 < iVar7) {
            iVar7 = iVar5;
          }
        }
        if (iVar5 != iVar7 && -1 < iVar5 - iVar7) {
          *(CNetChan **)(this + 0x423c) = this;
          pCVar14 = this;
          cVar4 = _ProcessMessages(this,(bf_read *)this_00);
          if (cVar4 == '\0') goto LAB_001b86be;
        }
        pCVar14 = *(CNetChan **)(this + 0x4208);
        (**(code **)(*(int *)pCVar14 + 0x18))(pCVar14);
        if ((g_pNetChannelProcessingActivePacket != (CNetChan *)0x0) &&
           (g_pNetChannelProcessingActivePacket == (CNetChan *)local_c0)) {
          NetChannelProcessingCallbacksRunOnProcessingFinished
                    (g_pNetChannelProcessingActivePacket,true);
        }
        iVar5 = _DAT_0040b9d4;
        if (((DAT_0040b02c == '\0') || (_DAT_0040b028 != 0)) &&
           (iVar7 = ThreadGetCurrentId(), iVar5 == iVar7)) {
          pCVar14 = _DAT_0040b030;
          cVar4 = CVProfNode::ExitScope();
          if (cVar4 != '\0') {
            _DAT_0040b030 = *(CNetChan **)(_DAT_0040b030 + 100);
          }
          DAT_0040b02c = _DAT_0040b030 == (CNetChan *)0x40b034;
        }
        if (local_a8 != (CNetChan *)0x0) {
          pCVar14 = local_a8;
          (**(code **)(local_a8 + 0x54))(local_a8,local_b0,local_ac,0,0,0);
        }
        goto LAB_001b836b;
      }
    }
LAB_001b86be:
    if ((g_pNetChannelProcessingActivePacket != (CNetChan *)0x0) &&
       (g_pNetChannelProcessingActivePacket == (CNetChan *)local_c0)) {
      NetChannelProcessingCallbacksRunOnProcessingFinished(g_pNetChannelProcessingActivePacket,true)
      ;
    }
  }
  iVar5 = _DAT_0040b9d4;
  if (((DAT_0040b02c == '\0') || (_DAT_0040b028 != 0)) &&
     (iVar7 = ThreadGetCurrentId(), iVar5 == iVar7)) {
    pCVar14 = _DAT_0040b030;
    cVar4 = CVProfNode::ExitScope();
    if (cVar4 != '\0') {
      _DAT_0040b030 = *(CNetChan **)(_DAT_0040b030 + 100);
    }
    DAT_0040b02c = _DAT_0040b030 == (CNetChan *)0x40b034;
  }
  if (local_a8 != (CNetChan *)0x0) {
    pCVar14 = local_a8;
    (**(code **)(local_a8 + 0x54))(local_a8,local_b0,local_ac,0,0,0);
  }
LAB_001b836b:
  if (local_20 != *(int *)(in_GS_OFFSET + 0x14)) {
                    /* WARNING: Subroutine does not return */
    __stack_chk_fail(pCVar14);
  }
  return;
}

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)