Client>Server Communication
There is no singular function that is responsible for this task. In Apex, we rather have multiple of those working together.
Let's get started with the most common function, R5AC::PushViolation:
void __fastcall R5AC::PushViolation(
const __m128i *pszIdentifierStr,
char Severity,
__int64 ExtraDataPtr,
__int64 ExtraDataLen);
In case of client-side abnormalities being detected, it will be invoked like this:
LBL_ON_ABNORMALITY_FOUND:
v119 = v116();
v120 = 0;
v121 = 0i64;
do
{
v122 = *(_BYTE *)(v121 + 41489128); // these are just data and key, and the RVA can be computed with analysis of a runtime dump.
++v120;
v123 = *(_BYTE *)(v121 + 27928337);
v188[++v121 + 15] = v123 ^ v122;
}
while ( v120 < 0xC ); // C-String encryption using simple xor
sprintf_s_2(Buffer, 0x104ui64, Format, v119);
}
}
R5AC::PushViolation(v200, 1, v177, (__int64)Buffer);
It's purpose is to enqueue a new violation record into a list that is fetched and emptied by numerous callers, all originating from r5apex_dx12.exe. These are to be considered slaves because they simply check if there is any messages pending, use CLC_AntiCheat virtual method table to setup a new netmessage in source engine, and then puts the data of the anti-cheat violation/message into the netmsg and sends it to the game server.
__int64 __fastcall R5AC::PopAnticheatMsg(_WORD *a1, int *a2)
{
__int64 v2; // r15
unsigned int v4; // edi
unsigned int i; // edx
unsigned int v6; // ebp
_WORD *v7; // rsi
unsigned int v8; // eax
__m128i *j; // r14
__int64 v10; // rbx
int v11; // er8
__int8 *v12; // r14
__int64 v13; // rax
int v14; // er14
__int64 v15; // rax
unsigned __int8 v16; // bl
__int64 dwEncryptionKey; // [rsp+70h] [rbp+18h]v2 = qword_5D553D0;
MEMORY[0x7FFE8D5790A0](&R5AC::ViolationLock);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v2 + 24i64))(v2);
if ( R5AC::NumSecondaryVIolations )
{
v4 = 0;
for ( i = 0; i < R5AC::NumSecondaryVIolations; ++i )
{
if ( *(_DWORD *)(32i64 * i + R5AC::SecondaryViolationList + 8) )
{
v6 = 0;
*a1 = 0;
v7 = a1 + 1;
v8 = R5AC::NumSecondaryVIolations;
for ( j = (__m128i *)(a1 + 1); v6 < v8; ++v6 )
{
v10 = R5AC::SecondaryViolationList + 32i64 * v6;
if ( *(_DWORD *)(v10 + 8) )
{
v11 = *(_DWORD *)(*(_QWORD *)v10 - 4i64);
if ( (unsigned int)(v11 + *(_DWORD *)(*(_QWORD *)(v10 + 24) - 4i64) + 15) > (char *)(a1 + 512) - (char *)j )
break;
sse_memcpy(j, *(const __m128i **)v10, (unsigned int)(v11 + 1));
v12 = &j->m128i_i8[*(_DWORD *)(*(_QWORD *)v10 - 4i64) + 1];
*(_DWORD *)v12 = *(_DWORD *)(v10 + 8);
v12[4] = *(_BYTE *)(v10 + 12);
*(_QWORD *)(v12 + 5) = *(_QWORD *)(v10 + 16);
sse_memcpy(
(__m128i *)(v12 + 13),
*(const __m128i **)(v10 + 24),
(unsigned int)(*(_DWORD *)(*(_QWORD *)(v10 + 24) - 4i64) + 1));
v13 = (unsigned int)(*(_DWORD *)(*(_QWORD *)(v10 + 24) - 4i64) + 14);
*(_DWORD *)(v10 + 8) = 0;
j = (__m128i *)&v12[v13];
v8 = R5AC::NumSecondaryVIolations;
}
}
v14 = (_DWORD)j - (_DWORD)a1;
*a2 = v14;
dwEncryptionKey = 0x42A1110F96B5E116i64;
if ( v14 != 2 )
{
do
{
v7 = (_WORD *)((char *)v7 + 1);
v15 = v4++ & 7;
*((_BYTE *)v7 - 1) ^= *((_BYTE *)&dwEncryptionKey + v15);
}
while ( v4 < v14 - 2 );
}
v16 = 1;
goto LABEL_15;
}
}
}
v16 = 0;
LABEL_15:
(*(void (__fastcall **)(__int64))(*(_QWORD *)v2 + 32i64))(v2);
MEMORY[0x7FFE8D562C70](&R5AC::ViolationLock);
return v16;
}_BYTE *__fastcall R5::BuildAnticheatMsg3(__int64 a1)
{
if ( !*(_QWORD *)a1 || !*result )
return result;
v3 = 0;
v4 = gpNetChan;
if ( gpNetChan )
{
v14 = vft::CLC_AntiCheatMsg;
v15 = 0;
v17 = 0i64;
v5 = 5;
v16 = 1;
// send all of them in bulk
for ( i = 0; (unsigned __int8)R5AC::PopAnticheatMsg(v20, &i); --v5 )
{
if ( !v5 )
break;
v18 = v20;
v19 = i;
C_NetChan::SendNetMsg(v4, &v14, 0, 0);
C_NetChan::SendDatagram(v4, 0i64);
}
}