//
// sub_85106C from 0x85106c to 0x8511ae (322 bytes)
//
// 2 xrefs:
// > sub_84C4E0 @ 0x84c54e
// > sub_84DC64 @ 0x84dea8
//
// This function is hookable on this platform (idp: arm, 32 bit: True, 64 bit: False!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 12:02:31 +0000
//
int __fastcall sub_85106C(size_t a1, const char *a2, _DWORD *a3)
{
int v3; // r3
bool v5; // zf
int v6; // r4
int v9; // r0
unsigned __int8 *v10; // r7
size_t v11; // r3
int v12; // r4
int v13; // r0
unsigned __int8 *v14; // r7
_DWORD *v15; // r3
int v16; // r2
int v17; // r3
unsigned int v18; // r9
size_t v19; // r10
unsigned int v20; // r0
unsigned int v21; // r11
bool v22; // cc
void *v23; // r0
void *p; // [sp+0h] [bp-Ch] BYREF
size_t v25[2]; // [sp+4h] [bp-8h] BYREF
v3 = *(unsigned __int8 *)a2;
v5 = v3 == 61;
if ( v3 != 61 )
v5 = v3 == 0;
p = nullptr;
v25[0] = 0;
if ( v5 )
goto LABEL_5;
v9 = sub_81FB28(a2, &p, v25);
v6 = v9;
if ( v9 )
return v6;
v10 = (unsigned __int8 *)p;
if ( !p )
{
LABEL_5:
v6 = 61;
sub_8280FC(a1, "NTLM handshake failure (empty type-2 message)\n");
return v6;
}
v11 = v25[0];
a3[1] = 0;
if ( v11 > 0x1F && !strcmp((const char *)v10, "NTLMSSP") )
{
v12 = memcmp(v10 + 8, &unk_C20A30, 4u);
if ( !v12 )
{
v13 = sub_84FD80(v10 + 20);
v14 = (unsigned __int8 *)p;
v15 = p;
a3[1] = v13;
v16 = v15[6];
v17 = v15[7];
a3[2] = v16;
a3[3] = v17;
if ( (v13 & 0x800000) == 0 )
{
LABEL_16:
v6 = 0;
off_D200B0(v14);
return v6;
}
v18 = v25[0];
if ( v25[0] > 0x2F )
{
v19 = sub_84FD74(v14 + 40);
v20 = sub_84FD80(v14 + 44);
v21 = v20;
if ( v19 )
{
v12 = v19;
v22 = v18 > v19 + v20;
if ( v18 >= v19 + v20 )
v22 = v20 > 0x2F;
if ( v22 )
{
v23 = off_D200AC(v19);
a3[4] = v23;
if ( v23 )
{
memcpy(v23, &v14[v21], v19);
v14 = (unsigned __int8 *)p;
goto LABEL_15;
}
v6 = 27;
}
else
{
v6 = 61;
sub_8280FC(
a1,
"NTLM handshake failure (bad type-2 message). Target Info Offset Len is set incorrect by the peer\n");
}
off_D200B0(p);
sub_8280FC(a1, "NTLM handshake failure (bad type-2 message)\n");
return v6;
}
v12 = 0;
v14 = (unsigned __int8 *)p;
}
LABEL_15:
a3[5] = v12;
goto LABEL_16;
}
}
off_D200B0(v10);
sub_8280FC(a1, "NTLM handshake failure (bad type-2 message)\n");
return 61;
}