CSocketCreator::CreateListenSocket
0x0028c200 · 417 bytes · __thiscall
_ZN14CSocketCreator18CreateListenSocketERK8netadr_sb
Decompiled
undefined (3 params)
/* CSocketCreator::CreateListenSocket(netadr_s const&, bool) */
undefined4 __thiscall
CSocketCreator::CreateListenSocket(CSocketCreator *this,netadr_s *param_1,bool param_2)
{
int iVar1;
undefined4 uVar2;
int *piVar3;
char *pcVar4;
int in_GS_OFFSET;
sockaddr local_30;
int local_20;
local_20 = *(int *)(in_GS_OFFSET + 0x14);
if (*(int *)(this + 0x18) != -1) {
close(*(int *)(this + 0x18));
*(undefined4 *)(this + 0x18) = 0xffffffff;
}
*(undefined4 *)(this + 0x1c) = *(undefined4 *)param_1;
*(undefined4 *)(this + 0x20) = *(undefined4 *)(param_1 + 4);
*(undefined2 *)(this + 0x24) = *(undefined2 *)(param_1 + 8);
iVar1 = socket(2,1,6);
*(int *)(this + 0x18) = iVar1;
if (iVar1 == -1) {
piVar3 = __errno_location();
uVar2 = 0;
pcVar4 = strerror(*piVar3);
Warning("Socket unable to create socket (%s)\n",pcVar4);
}
else {
uVar2 = ConfigureSocket(this,iVar1);
if ((char)uVar2 == '\0') {
if (*(int *)(this + 0x18) != -1) {
close(*(int *)(this + 0x18));
*(undefined4 *)(this + 0x18) = 0xffffffff;
goto LAB_0028c29c;
}
}
else {
netadr_s::ToSockadr((netadr_s *)(this + 0x1c),&local_30);
if (param_2) {
local_30.sa_data[2] = '\0';
local_30.sa_data[3] = '\0';
local_30.sa_data[4] = '\0';
local_30.sa_data[5] = '\0';
}
iVar1 = bind(*(int *)(this + 0x18),&local_30,0x10);
if (iVar1 == -1) {
piVar3 = __errno_location();
pcVar4 = strerror(*piVar3);
Warning("Socket bind failed (%s)\n",pcVar4);
iVar1 = *(int *)(this + 0x18);
}
else {
iVar1 = listen(*(int *)(this + 0x18),2);
if (iVar1 != -1) goto LAB_0028c29c;
piVar3 = __errno_location();
pcVar4 = strerror(*piVar3);
Warning("Socket listen failed (%s)\n",pcVar4);
iVar1 = *(int *)(this + 0x18);
}
if (iVar1 != -1) {
close(iVar1);
*(undefined4 *)(this + 0x18) = 0xffffffff;
}
}
uVar2 = 0;
}
LAB_0028c29c:
if (local_20 == *(int *)(in_GS_OFFSET + 0x14)) {
return uVar2;
}
/* WARNING: Subroutine does not return */
__stack_chk_fail();
}
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.