//
// sub_10057E194 from 0x10057e194 to 0x10057e36c (472 bytes)
//
// 2 xrefs:
// > sub_10057CCF8 @ 0x10057cd9c
// > sub_100580780 @ 0x100580aac
//
// This function is hookable on this platform!
//
// Using BromaIDA 8.0.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit ba9f177b at Thu Jul 16 22:52:06 2026 from https://github.com/geode-sdk/bindings
//
__int64 __fastcall sub_10057E194(size_t a1, const char *a2, __int64 a3)
{
__int64 v5; // x21
_DWORD *v6; // x0
unsigned __int64 v8; // x24
char *v9; // x23
size_t v10; // x21
unsigned int v11; // w0
unsigned int v12; // w22
void *v13; // x0
size_t v14; // [xsp+0h] [xbp-40h] BYREF
void *v15; // [xsp+8h] [xbp-38h] BYREF
v14 = 0;
v15 = nullptr;
if ( !*a2 || *a2 == 61 )
goto LABEL_9;
v5 = sub_100548FAC(a2, &v15, &v14);
if ( !(_DWORD)v5 )
{
v6 = v15;
if ( v15 )
{
*(_DWORD *)(a3 + 4) = 0;
if ( v14 < 0x20 || *(_QWORD *)v6 != 0x5053534D4C544ELL || v6[2] != 2 )
{
off_10085DEB8(v6);
sub_1005524A4(a1, "NTLM handshake failure (bad type-2 message)\n", v14);
return 61;
}
*(_DWORD *)(a3 + 4) = sub_100582EC4(v6 + 5);
*(_QWORD *)(a3 + 8) = *((_QWORD *)v15 + 3);
if ( (*(_BYTE *)(a3 + 6) & 0x80) == 0 )
{
LABEL_22:
off_10085DEB8(v15);
return 0;
}
v8 = v14;
if ( v14 >= 0x30 )
{
v9 = (char *)v15;
v10 = sub_100582EB0((char *)v15 + 40);
v11 = sub_100582EC4(v9 + 44);
v12 = v11;
if ( !(_DWORD)v10 )
{
LODWORD(v10) = 0;
goto LABEL_21;
}
if ( v11 < 0x30 || v11 + (unsigned int)v10 > v8 )
{
sub_1005524A4(
a1,
"NTLM handshake failure (bad type-2 message). Target Info Offset Len is set incorrect by the peer\n",
v14);
v5 = 61;
}
else
{
v13 = off_10085DEB0(v10);
*(_QWORD *)(a3 + 16) = v13;
if ( v13 )
{
memcpy(v13, &v9[v12], v10);
LABEL_21:
*(_DWORD *)(a3 + 24) = v10;
goto LABEL_22;
}
v5 = 27;
}
off_10085DEB8(v15);
sub_1005524A4(a1, "NTLM handshake failure (bad type-2 message)\n");
return v5;
}
LODWORD(v10) = 0;
goto LABEL_21;
}
LABEL_9:
sub_1005524A4(a1, "NTLM handshake failure (empty type-2 message)\n", v14);
return 61;
}
return v5;
}