OpenSocketInternal
0x001c7ab0 · 713 bytes · __regparm3
_ZL18OpenSocketInternaliiiPKcib.constprop.102
Decompiled
undefined (6 params)
/* OpenSocketInternal(int, int, int, char const*, int, bool) [clone .constprop.102] */
void __regparm3
OpenSocketInternal(int param_1,int param_2,int param_3,char *param_4,int param_5,bool param_6)
{
char *pcVar1;
int iVar2;
CUtlMemory<unsigned_char,int> *pCVar3;
int *piVar4;
int iVar5;
int iVar6;
int *piVar7;
int local_44;
CUtlString local_40 [16];
int local_30 [8];
local_30[0] = 0;
local_30[1] = 0;
local_30[2] = 0;
local_30[3] = 0;
local_30[4] = 0;
pcVar1 = "FCVAR_NEVER_AS_STRING";
if ((ipname[0x15] & 0x10) == 0) {
pcVar1 = "";
if (*(char **)(ipname._28_4_ + 0x24) != (char *)0x0) {
pcVar1 = *(char **)(ipname._28_4_ + 0x24);
}
}
/* try { // try from 001c7b21 to 001c7b25 has its CatchHandler @ 001c7dda */
CUtlString::CUtlString(local_40,pcVar1);
/* try { // try from 001c7b3a to 001c7b3e has its CatchHandler @ 001c7d81 */
CUtlVector<CUtlString,CUtlMemory<CUtlString,int>>::InsertBefore
((CUtlVector<CUtlString,CUtlMemory<CUtlString,int>> *)local_30,local_30[3],local_40);
CUtlMemory<unsigned_char,int>::Purge((CUtlMemory<unsigned_char,int> *)local_40);
pcVar1 = " or any";
local_44 = param_2;
if (param_2 == 0) {
local_44 = param_3;
}
if ((char)param_5 == '\0') {
pcVar1 = "";
}
/* try { // try from 001c7b82 to 001c7d66 has its CatchHandler @ 001c7dda */
DevMsg(1,"Trying to open %s socket on port %d%s\n",param_4,local_44,pcVar1);
iVar6 = local_44;
piVar7 = (int *)(net_sockets + param_1 * 0x10);
if (*piVar7 == 0) {
if (local_30[3] < 1) {
piVar4 = piVar7;
if (piVar7[2] != 0) {
LAB_001c7ccc:
*piVar4 = local_44;
goto LAB_001c7cce;
}
}
else {
iVar5 = 0;
do {
local_44 = iVar6;
pcVar1 = (char *)CUtlString::Get((CUtlString *)(iVar5 * 0x10 + local_30[0]));
if (iVar5 != 0) {
Msg("Trying to open socket on %s\n",pcVar1);
}
iVar2 = NET_OpenSocket(pcVar1,&local_44,0x11);
piVar7[2] = iVar2;
if (iVar2 != 0) {
LAB_001c7cc0:
piVar4 = (int *)(param_1 * 0x10 + net_sockets);
goto LAB_001c7ccc;
}
if ((char)param_5 != '\0') {
local_44 = -1;
iVar2 = NET_OpenSocket(pcVar1,&local_44,0x11);
piVar7[2] = iVar2;
if (iVar2 != 0) goto LAB_001c7cc0;
}
iVar5 = iVar5 + 1;
} while (iVar5 < local_30[3]);
}
Sys_Exit("Couldn\'t allocate any %s IP port, tried %d addresses",param_4,local_30[3]);
iVar6 = local_30[3] + -1;
iVar5 = iVar6 * 0x10;
if (-1 < iVar6) {
do {
iVar6 = iVar6 + -1;
pCVar3 = (CUtlMemory<unsigned_char,int> *)(local_30[0] + iVar5);
iVar5 = iVar5 + -0x10;
CUtlMemory<unsigned_char,int>::Purge(pCVar3);
} while (iVar6 != -1);
}
}
else {
Msg("WARNING: NET_OpenSockets: %s port %i already open.\n",param_4,*piVar7);
LAB_001c7cce:
if (piVar7 != (int *)0xfffffff8) {
(**(code **)(*(int *)g_pSteamSocketMgr + 0xc))
(g_pSteamSocketMgr,piVar7[2],param_1,param_2,param_3,param_4,0x11,param_5 & 0xff);
}
iVar6 = local_30[3] + -1;
iVar5 = iVar6 * 0x10;
if (-1 < iVar6) {
do {
iVar6 = iVar6 + -1;
pCVar3 = (CUtlMemory<unsigned_char,int> *)(local_30[0] + iVar5);
iVar5 = iVar5 + -0x10;
CUtlMemory<unsigned_char,int>::Purge(pCVar3);
} while (iVar6 != -1);
}
}
local_30[3] = 0;
CUtlMemory<CUtlString,int>::Purge((CUtlMemory<CUtlString,int> *)local_30);
local_30[4] = local_30[0];
CUtlMemory<CUtlString,int>::Purge((CUtlMemory<CUtlString,int> *)local_30);
return;
}
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.