//
// sub_BB3B38 from 0xbb3b38 to 0xbb3d18 (480 bytes)
//
// 2 xrefs:
// > sub_BACC2C @ 0xbaccd4
// > sub_BAEE2C @ 0xbaf0ec
//
// 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_BB3B38(__int64 a1, const char *a2, __int64 a3)
{
int v5; // w3
unsigned int v6; // w19
unsigned __int8 *v8; // x19
void *v9; // x0
unsigned int v10; // w19
size_t v11; // x22
int v12; // w0
char *v13; // x19
unsigned __int64 v14; // x23
void *v15; // x0
unsigned int v16; // w0
unsigned int v17; // w25
void *v18; // x0
void *p; // [xsp+50h] [xbp+50h] BYREF
size_t v20; // [xsp+58h] [xbp+58h] BYREF
p = nullptr;
v5 = *(unsigned __int8 *)a2;
v20 = 0;
if ( v5 == 61 || !v5 )
goto LABEL_3;
v6 = sub_B70E70(a2, &p, &v20);
if ( v6 )
return v6;
v8 = (unsigned __int8 *)p;
if ( !p )
{
LABEL_3:
v6 = 61;
sub_B7B528(a1, "NTLM handshake failure (empty type-2 message)\n");
return v6;
}
*(_DWORD *)(a3 + 4) = 0;
if ( v20 > 0x1F && !strcmp((const char *)v8, "NTLMSSP") )
{
LODWORD(v11) = memcmp(v8 + 8, &unk_F28290, 4u);
if ( !(_DWORD)v11 )
{
v12 = sub_BB1F20(v8 + 20);
v13 = (char *)p;
*(_DWORD *)(a3 + 4) = v12;
*(_QWORD *)(a3 + 8) = *((_QWORD *)v13 + 3);
if ( (v12 & 0x800000) == 0 )
{
LABEL_15:
v15 = v13;
v6 = 0;
off_1231008(v15);
return v6;
}
v14 = v20;
if ( v20 <= 0x2F )
{
LABEL_14:
*(_DWORD *)(a3 + 24) = v11;
goto LABEL_15;
}
v11 = (unsigned __int16)sub_BB1F10((unsigned __int8 *)v13 + 40);
v16 = sub_BB1F20((unsigned __int8 *)v13 + 44);
v17 = v16;
if ( (_DWORD)v11 )
{
if ( v14 < (unsigned int)v11 + v16 || v16 <= 0x2F )
{
v10 = 61;
sub_B7B528(
a1,
"NTLM handshake failure (bad type-2 message). Target Info Offset Len is set incorrect by the peer\n");
v9 = p;
goto LABEL_10;
}
v18 = off_1231000(v11);
*(_QWORD *)(a3 + 16) = v18;
if ( !v18 )
{
v10 = 27;
v9 = p;
goto LABEL_10;
}
memcpy(v18, &v13[v17], v11);
}
v13 = (char *)p;
goto LABEL_14;
}
}
v9 = v8;
v10 = 61;
LABEL_10:
off_1231008(v9);
sub_B7B528(a1, "NTLM handshake failure (bad type-2 message)\n");
return v10;
}