NET_ProcessSocket
0x001c73d0 · 1052 bytes · __cdecl
_Z17NET_ProcessSocketiP28IConnectionlessPacketHandler
Decompiled
undefined (2 params)
/* NET_ProcessSocket(int, IConnectionlessPacketHandler*) */
void NET_ProcessSocket(int param_1,IConnectionlessPacketHandler *param_2)
{
CNetChan *this;
uint *puVar1;
undefined4 uVar2;
uint uVar3;
char cVar4;
uint uVar5;
int iVar6;
int *piVar7;
undefined4 *puVar8;
netadr_s *this_00;
undefined4 uVar9;
undefined4 uVar10;
uchar *puVar11;
int iVar12;
int iVar13;
bool bVar14;
uVar5 = ThreadGetCurrentId();
if (uVar5 != DAT_003ac4b4) {
LOCK();
bVar14 = DAT_003ac4b4 != 0;
uVar3 = uVar5;
if (bVar14) {
uVar3 = DAT_003ac4b4;
}
DAT_003ac4b4 = uVar3;
UNLOCK();
if (bVar14) {
CThreadFastMutex::Lock(0x3ac4b4,uVar5);
goto LAB_001c7406;
}
}
DAT_003ac4b8 = DAT_003ac4b8 + 1;
LAB_001c7406:
iVar12 = DAT_003ac4ac + -1;
if (-1 < iVar12) {
iVar13 = iVar12 * 4;
do {
while( true ) {
this = *(CNetChan **)(s_NetChannels + iVar13);
/* try { // try from 001c7438 to 001c7474 has its CatchHandler @ 001c7802 */
iVar6 = (**(code **)(*(int *)this + 0xd4))(this);
if (iVar6 == param_1) break;
LAB_001c7420:
iVar12 = iVar12 + -1;
iVar13 = iVar13 + -4;
if (iVar12 == -1) goto LAB_001c7480;
}
CNetChan::BeginSocketProcessingFrame(this);
cVar4 = (**(code **)(*(int *)this + 0xa0))(this);
if (cVar4 != '\0') goto LAB_001c7420;
piVar7 = (int *)(**(code **)(*(int *)this + 0xcc))(this);
(**(code **)(*piVar7 + 0x10))(piVar7,"TCP connection failed.");
iVar12 = iVar12 + -1;
iVar13 = iVar13 + -4;
} while (iVar12 != -1);
}
LAB_001c7480:
DAT_003ac4b8 = DAT_003ac4b8 + -1;
if (DAT_003ac4b8 == 0) {
LOCK();
UNLOCK();
DAT_003ac4b4 = 0;
}
do {
puVar8 = g_NetScratchBuffers;
if (g_NetScratchBuffers == (undefined4 *)0x0) {
puVar8 = operator_new(0x37ab8);
break;
}
cVar4 = ThreadInterlockedAssignIf64
(&g_NetScratchBuffers,*g_NetScratchBuffers,DAT_003ac0e4 + -1,
g_NetScratchBuffers,DAT_003ac0e4);
} while (cVar4 == '\0');
puVar11 = (uchar *)(puVar8 + 2);
if (puVar11 == (uchar *)0x0) {
puVar11 = operator_new(0x37ab0);
}
do {
while( true ) {
while( true ) {
do {
this_00 = (netadr_s *)NET_GetPacket(param_1,puVar11);
if (this_00 == (netadr_s *)0x0) {
do {
iVar12 = DAT_003ac0e4;
puVar8 = g_NetScratchBuffers;
iVar13 = DAT_003ac0e4 + 0x10001;
*(undefined4 **)(puVar11 + -8) = g_NetScratchBuffers;
cVar4 = ThreadInterlockedAssignIf64
(&g_NetScratchBuffers,puVar11 + -8,iVar13,puVar8,iVar12);
} while (cVar4 == '\0');
return;
}
} while (*(int *)(this_00 + 0x40) == 0);
cVar4 = Filter_ShouldDiscard(this_00);
if (cVar4 == '\0') break;
Filter_SendBan(this_00);
}
if (**(int **)(this_00 + 0x18) == -1) break;
piVar7 = (int *)NET_FindNetChannel(param_1,this_00);
if (piVar7 != (int *)0x0) {
(**(code **)(*piVar7 + 0xa4))(piVar7,this_00,1);
}
}
iVar12 = *(int *)(this_00 + 0x30);
if (iVar12 < 0x20) {
puVar1 = *(uint **)(this_00 + 0x34);
if (puVar1 == *(uint **)(this_00 + 0x38)) {
*(undefined4 *)(this_00 + 0x30) = 1;
*(undefined4 *)(this_00 + 0x2c) = 0;
*(uint **)(this_00 + 0x34) = puVar1 + 1;
this_00[0x20] = (netadr_s)0x1;
}
else {
if (*(uint **)(this_00 + 0x38) <= puVar1) {
LAB_001c771b:
this_00[0x20] = (netadr_s)0x1;
goto LAB_001c771f;
}
*(uint **)(this_00 + 0x34) = puVar1 + 1;
uVar5 = *puVar1;
*(uint *)(this_00 + 0x2c) = uVar5;
if (this_00[0x20] == (netadr_s)0x0) {
*(int *)(this_00 + 0x30) = iVar12;
*(uint *)(this_00 + 0x2c) = uVar5 >> (0x20U - (char)iVar12 & 0x1f);
}
}
}
else {
*(int *)(this_00 + 0x30) = iVar12 + -0x20;
if (iVar12 + -0x20 == 0) {
puVar8 = *(undefined4 **)(this_00 + 0x34);
*(undefined4 *)(this_00 + 0x30) = 0x20;
if (puVar8 == *(undefined4 **)(this_00 + 0x38)) {
*(undefined4 *)(this_00 + 0x30) = 1;
*(undefined4 *)(this_00 + 0x2c) = 0;
*(undefined4 **)(this_00 + 0x34) = puVar8 + 1;
}
else {
if (*(undefined4 **)(this_00 + 0x38) < puVar8) goto LAB_001c771b;
*(undefined4 **)(this_00 + 0x34) = puVar8 + 1;
*(undefined4 *)(this_00 + 0x2c) = *puVar8;
}
}
else {
LAB_001c771f:
*(undefined4 *)(this_00 + 0x2c) = 0;
}
}
iVar12 = *(int *)(this_00 + 0x3c);
iVar13 = *(int *)(this_00 + 0x24);
if (iVar12 == 0) {
iVar6 = 0;
}
else {
iVar6 = (((uint)(*(int *)(this_00 + 0x34) - iVar12) >> 2) * 0x20 - *(int *)(this_00 + 0x30)) +
(*(uint *)(this_00 + 0x28) & 3) * 8;
if (iVar13 < iVar6) {
iVar6 = iVar13;
}
}
if (*(int *)(net_showudp._28_4_ + 0x30) != 0) {
if (iVar13 == iVar6 || iVar13 - iVar6 < 0) {
uVar10 = *(undefined4 *)(this_00 + 0x44);
uVar2 = *(undefined4 *)(this_00 + 0x40);
uVar9 = netadr_s::ToString(this_00,false);
Msg("UDP <- %s: sz=%i OOB empty wire=%i\n",uVar9,uVar2,uVar10);
iVar13 = *(int *)(this_00 + 0x24);
iVar12 = *(int *)(this_00 + 0x3c);
}
else {
uVar10 = *(undefined4 *)(this_00 + 0x44);
uVar2 = *(undefined4 *)(this_00 + 0x40);
cVar4 = (char)(*(int **)(this_00 + 0x18))[1];
iVar12 = (int)cVar4;
if (cVar4 == '\0') {
iVar12 = 0x30;
}
uVar9 = netadr_s::ToString(this_00,false);
Msg("UDP <- %s: sz=%i OOB \'%c\' wire=%i\n",uVar9,uVar2,iVar12,uVar10);
iVar13 = *(int *)(this_00 + 0x24);
iVar12 = *(int *)(this_00 + 0x3c);
}
}
if (iVar12 == 0) {
iVar12 = 0;
}
else {
iVar12 = (((uint)(*(int *)(this_00 + 0x34) - iVar12) >> 2) * 0x20 - *(int *)(this_00 + 0x30))
+ (*(uint *)(this_00 + 0x28) & 3) * 8;
if (iVar13 < iVar12) {
iVar12 = iVar13;
}
}
if (iVar13 == iVar12 || iVar13 - iVar12 < 0) {
uVar10 = netadr_s::ToString(this_00,false);
uVar10 = va("NET_ProcessSocket: Empty packet received from %s\n",uVar10);
PacketErrorMessage(6,uVar10);
}
else {
(**(code **)(*(int *)param_2 + 8))(param_2,this_00);
}
} while( true );
}
SourceMod gamedata
paste intoaddons/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.
Signatures + Functions block. The plugin uses
DHookCreateFromConf - DHooks reads return type, this-type,
calling convention, and argument types straight from the gamedata. Less
boilerplate in the plugin, types travel with the gamedata.
Gamedata KeyValues
DHooks plugin example
Type inference is best-effort from the C signature - sanity-check the DHooks types before shipping.