Skip to content

Instantly share code, notes, and snippets.

@invokr
Created June 1, 2017 16:03
Show Gist options
  • Save invokr/9fd3e3ace2f8de8f1e051f6e7af7488b to your computer and use it in GitHub Desktop.
Save invokr/9fd3e3ace2f8de8f1e051f6e7af7488b to your computer and use it in GitHub Desktop.
int __fastcall rev_connect(__int64 a1, double a2)
{
__int64 v2; // r13@1
int result; // eax@3
int v4; // er15@5
__int64 v5; // rcx@5
__int64 v6; // rcx@6
__int64 v7; // rax@10
int v8; // eax@16
__int64 v9; // r15@18
__int64 v10; // rdx@18
__int64 v11; // rax@18
bool v12; // al@18
int v13; // er12@18
int v14; // er15@21
int v15; // ecx@21
bool v16; // al@22
char *v17; // rsi@23
__int64 v18; // rcx@23
signed __int64 v19; // rdi@25
_QWORD *v20; // rdi@26
int v21; // ebx@29
__int64 v22; // r15@29
int v23; // eax@29
int v24; // er12@41
__int64 v25; // rcx@55
int v26; // eax@57
__int64 v27; // rcx@63
double v28; // [sp+0h] [bp-140h]@2
__int64 v29; // [sp+8h] [bp-138h]@18
char v30; // [sp+10h] [bp-130h]@50
char v31; // [sp+50h] [bp-F0h]@10
__int64 v32; // [sp+54h] [bp-ECh]@10
int v33; // [sp+70h] [bp-D0h]@11
char v34; // [sp+D0h] [bp-70h]@39
__int64 v35; // [sp+110h] [bp-30h]@1
v2 = a1;
v35 = *__stack_chk_guard_ptr[0];
if ( !*(_BYTE *)(a1 + 201) )
{
if ( *(_DWORD *)(a1 + 64) )
{
v32 = 0LL;
LODWORD(v7) = (*(int (**)(void))(*qword_623940[0] + 552LL))();
if ( (unsigned __int8)(*(int (__fastcall **)(__int64, _QWORD, char *))(*(_QWORD *)v7 + 104LL))(
v7,
*(_DWORD *)(a1 + 64),
&v31) )
{
result = v33;
if ( v33 == 1 )
return result;
if ( v33 == 2 )
goto LABEL_13;
if ( (unsigned __int8)LoggingSystem_IsChannelEnabled((unsigned int)dword_614828, 2LL) )
{
v21 = dword_614828;
v22 = *(_QWORD *)(a1 + 80);
v23 = *(_DWORD *)(v22 + 28);
if ( (unsigned int)(v23 - 2) >= 2 )
{
if ( v23 == 1 )
{
if ( !*(_DWORD *)(v22 + 24) )
sub_1DCB70((unsigned __int64 *)(v22 + 12));
v25 = *(_DWORD *)(v22 + 20);
sub_24C0((unsigned __int64)&v34);
}
else if ( v23 )
{
v34 = 0;
}
else
{
sub_359D40(*(_QWORD *)(a1 + 80), (__int64)&v34, 0x40u, 0);
}
}
else
{
if ( !*(_DWORD *)(v22 + 24) )
sub_1DCB70((unsigned __int64 *)(v22 + 12));
sub_24C0((unsigned __int64)&v34);
}
LoggingSystem_Log((unsigned int)v21, 2LL, "Failed to connect to %s. Reason code %d. %s\n", &v34);
}
v17 = &v31;
v26 = (*(int (__fastcall **)(_QWORD *, char *))(*qword_623940[0] + 568LL))(qword_623940[0], &v31);
v19 = 30LL;
if ( v26 )
{
v19 = 72LL;
if ( v26 != 29 )
v19 = (unsigned int)v26;
}
}
else
{
v17 = (_BYTE *)(&dword_0 + 2);
if ( (unsigned __int8)LoggingSystem_IsChannelEnabled((unsigned int)dword_614828, 2LL) )
{
v17 = (_BYTE *)(&dword_0 + 2);
LoggingSystem_Log(
(unsigned int)dword_614828,
2LL,
"GetConnectionInfo failed. Did somebody else close the connection?\n",
v18);
}
v19 = 30LL;
}
sub_1CF6A0(v19, v17);
(*(void (__fastcall **)(_QWORD, _QWORD, signed __int64, _QWORD))(**(_QWORD **)v2 + 904LL))(
*(_QWORD *)v2,
0LL,
0xFFFFFFFFLL,
0LL);
v20 = qword_623940[0];
return (*(int (__fastcall **)(_QWORD *, _QWORD))(*v20 + 136LL))(v20, *(_DWORD *)(v2 + 96));
}
LABEL_13:
if ( sub_15A2F0(*(_QWORD *)a1) != 1 )
return sub_1505A0(*(_QWORD *)(a1 + 184), a2);
(*(void (**)(void))(*qword_623940[0] + 344LL))();
a2 = a2 - *(double *)(a1 + 120);
result = qword_5E3560;
if ( *(float *)(qword_5E3560 + 84) > a2 || *(_DWORD *)(a1 + 72) <= 0 )
return result;
v8 = *(_DWORD *)(a1 + 108);
if ( v8 <= 0 || *(_DWORD *)(a1 + 104) < v8 )
{
(*(void (**)(void))(*qword_623940[0] + 344LL))();
*(double *)(a1 + 120) = a2;
v9 = *(_QWORD *)(a1 + 80);
v29 = *(_QWORD *)(a1 + 80);
v10 = *(_DWORD *)(*(_QWORD *)(a1 + 192) + 64LL);
sub_35F0D0(a1 + 56);
v11 = sub_35ECE0(a1 + 56);
V_snprintf(&v31, 128LL, "%c%s", 113LL, v11);
v12 = 0;
v13 = dword_614828;
if ( !*(_DWORD *)(v9 + 28) )
v12 = sub_359E20(v29);
if ( (unsigned __int8)LoggingSystem_IsChannelEnabled((unsigned int)v13, !v12) )
{
v14 = dword_614828;
v15 = *(_DWORD *)(v29 + 28);
if ( v15 )
{
v16 = 0;
}
else
{
v16 = sub_359E20(v29);
v15 = *(_DWORD *)(v29 + 28);
}
v24 = !v16;
if ( (unsigned int)(v15 - 2) >= 2 )
{
if ( v15 == 1 )
{
if ( !*(_DWORD *)(v29 + 24) )
sub_1DCB70((unsigned __int64 *)(v29 + 12));
v27 = *(_DWORD *)(v29 + 20);
sub_24C0((unsigned __int64)&v30);
}
else if ( v15 )
{
v30 = 0;
}
else
{
sub_359D40(v29, (__int64)&v30, 0x40u, 0);
}
}
else
{
if ( !*(_DWORD *)(v29 + 24) )
sub_1DCB70((unsigned __int64 *)(v29 + 12));
sub_24C0((unsigned __int64)&v30);
}
LoggingSystem_Log((unsigned int)v14, (unsigned int)v24, "Sending connect to %s\n", &v30);
}
(*(void (__fastcall **)(_QWORD *, _QWORD, __int64, _QWORD, char *))(*qword_623940[0] + 320LL))(
qword_623940[0],
*(_DWORD *)(a1 + 96),
v29,
"%s",
&v31);
++*(_DWORD *)(a1 + 104);
return sub_1505A0(*(_QWORD *)(a1 + 184), a2);
}
if ( (unsigned __int8)LoggingSystem_IsChannelEnabled((unsigned int)dword_614828, 2LL) )
LoggingSystem_Log(
(unsigned int)dword_614828,
2LL,
"CL: Connection failed after %i retries.\n",
*(_DWORD *)(a1 + 108));
sub_1CF6A0(72LL, 2LL);
(*(void (__fastcall **)(_QWORD, _QWORD, signed __int64, _QWORD))(**(_QWORD **)a1 + 904LL))(
*(_QWORD *)a1,
0LL,
0xFFFFFFFFLL,
0LL);
v20 = qword_623940[0];
return (*(int (__fastcall **)(_QWORD *, _QWORD))(*v20 + 136LL))(v20, *(_DWORD *)(v2 + 96));
}
(*(void (**)(void))(*qword_623940[0] + 344LL))();
v28 = *(double *)(a1 + 128);
if ( (unsigned __int8)sub_346FA0() || (result = qword_5E3670, *(float *)(qword_5E3670 + 84) <= a2 - v28) )
{
if ( (unsigned __int8)LoggingSystem_IsChannelEnabled((unsigned int)dword_62030C, 0LL) )
{
v4 = dword_62030C;
(*(void (__fastcall **)(_QWORD *, _QWORD))(*qword_623940[0] + 344LL))(qword_623940[0], 0LL);
LoggingSystem_Log((unsigned int)v4, 0LL, "CL: MaybeSetPendingConnecting finished at time %4.2f\n", v5);
}
if ( (unsigned __int8)LoggingSystem_IsChannelEnabled((unsigned int)dword_62030C, 0LL) )
LoggingSystem_Log(
(unsigned int)dword_62030C,
0LL,
"CL: CConnectGameClient::PauseConnecting() calling Connect\n",
v6);
(*(void (__fastcall **)(_QWORD, _QWORD, _QWORD, __int64))(**(_QWORD **)a1 + 80LL))(
*(_QWORD *)a1,
0LL,
*(_DWORD *)(a1 + 96),
a1 + 8);
result = sub_164290(*(_QWORD *)a1);
*(_BYTE *)(a1 + 201) = 0;
}
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment