//
// sub_824B7C from 0x824b7c to 0x824dde (610 bytes)
//
// 2 xrefs:
// > sub_826F08 @ 0x828004
// > sub_84BB58 @ 0x84c1c8
//
// 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:01:54 +0000
//
int __fastcall sub_824B7C(_DWORD *a1, int a2, const char *a3)
{
int v3; // r7
const char *v5; // r10
_DWORD *v6; // r4
int v7; // r11
int i; // r3
int v9; // r2
bool v10; // zf
int v11; // t1
bool v12; // zf
int v13; // r2
int v14; // t1
int v16; // t1
int v17; // r2
const char *v18; // r2
int v19; // t1
int v20; // r1
int v21; // r2
char *v22; // r0
const char *v24; // [sp+4h] [bp-18h]
v3 = *a1;
v5 = a3;
if ( a2 )
{
v6 = (_DWORD *)(*a1 + 34808);
v7 = *a1 + 34584;
}
else
{
v6 = (_DWORD *)(*a1 + 34812);
v7 = *a1 + 34568;
}
i = *(unsigned __int8 *)a3;
while ( 1 )
{
if ( !i )
return 0;
if ( sub_83ACFC("NTLM", v5, 4) )
break;
if ( !sub_83ACFC("Digest", v5, 6) )
{
if ( sub_83ACFC("Basic", v5, 5) )
{
*v6 |= 1u;
v21 = *(_DWORD *)(v7 + 4);
*(_DWORD *)(v7 + 8) |= 1u;
if ( v21 == 1 )
{
*(_DWORD *)(v7 + 8) = 0;
sub_8280FC(v3, "Authentication problem. Ignoring this.\n");
*(_BYTE *)(v3 + 34600) = 1;
i = *(unsigned __int8 *)v5;
goto LABEL_11;
}
}
goto LABEL_10;
}
if ( (*(_DWORD *)(v7 + 8) & 2) != 0 )
{
sub_8280FC(v3, "Ignoring duplicate digest auth header.\n");
i = *(unsigned __int8 *)v5;
goto LABEL_11;
}
if ( sub_850350() )
{
*v6 |= 2u;
*(_DWORD *)(v7 + 8) |= 2u;
if ( sub_841EC4(a1, a2, v5) )
goto LABEL_47;
}
LABEL_10:
for ( i = *(unsigned __int8 *)v5; ; i = v11 )
{
LABEL_11:
v12 = i == 44;
if ( i != 44 )
v12 = i == 0;
if ( v12 )
break;
v11 = *(unsigned __int8 *)++v5;
}
if ( i == 44 )
i = *(unsigned __int8 *)++v5;
LABEL_17:
if ( !i )
return 0;
v13 = ctype_ + i;
while ( (*(_BYTE *)(v13 + 1) & 8) != 0 )
{
v14 = *(unsigned __int8 *)++v5;
i = v14;
v13 = ctype_ + v14;
if ( !v14 )
return 0;
}
}
if ( (*(_DWORD *)(v7 + 8) & 0x28) == 0 && !sub_851068() )
goto LABEL_10;
*v6 |= 8u;
v9 = *(_DWORD *)(v7 + 4);
v10 = v9 == 8;
if ( v9 != 8 )
v10 = v9 == 32;
*(_DWORD *)(v7 + 8) |= 8u;
if ( !v10 )
goto LABEL_10;
if ( sub_84C4E0(a1, a2, v5) )
{
LABEL_47:
sub_8280FC(v3, "Authentication problem. Ignoring this.\n");
*(_BYTE *)(v3 + 34600) = 1;
goto LABEL_10;
}
*(_BYTE *)(v3 + 34600) = 0;
if ( *(_DWORD *)(v7 + 4) != 32 )
goto LABEL_10;
*v6 &= ~8u;
*(_DWORD *)(v7 + 8) &= ~8u;
*v6 |= 0x20u;
*(_DWORD *)(v7 + 8) |= 0x20u;
if ( *v5 && (*(_BYTE *)(*(unsigned __int8 *)v5 + ctype_ + 1) & 8) != 0 )
{
do
{
v16 = *(unsigned __int8 *)++v5;
v17 = ctype_ + v16;
}
while ( v16 && (*(_BYTE *)(v17 + 1) & 8) != 0 );
}
if ( !sub_83ACFC("NTLM", v5, 4) )
goto LABEL_10;
v18 = v5 + 4;
if ( !v5[4] )
goto LABEL_40;
if ( (*(_BYTE *)(*((unsigned __int8 *)v5 + 4) + ctype_ + 1) & 8) != 0 )
{
while ( 1 )
{
v19 = *(unsigned __int8 *)++v18;
v20 = ctype_ + v19;
if ( !v19 )
break;
if ( (*(_BYTE *)(v20 + 1) & 8) == 0 )
goto LABEL_49;
}
LABEL_40:
v5 = v18;
i = 0;
goto LABEL_17;
}
LABEL_49:
v24 = v18;
v5 = v18;
v22 = off_D200B8(v18);
a1[203] = v22;
if ( v22 )
{
i = *(unsigned __int8 *)v24;
goto LABEL_11;
}
return 27;
}