//
// sub_1005502E0 from 0x1005502e0 to 0x1005505b0 (720 bytes)
//
// 2 xrefs:
// > sub_10055018C @ 0x100550230
// > sub_10055018C @ 0x1005502a0
//
// 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_1005502E0(const char **a1, __int64 a2, __int64 a3, __int64 a4, __int64 a5)
{
int v5; // w22
const char *v8; // x20
__int64 v9; // x8
_QWORD *v10; // x8
__int64 result; // x0
const char *v12; // x8
_QWORD *v13; // x24
__int64 v14; // x23
const char **v15; // x8
const char **v16; // x9
const char *v17; // x9
const char *v18; // x10
v5 = a5;
v8 = *a1;
v9 = *(_QWORD *)(a2 + 8);
if ( v9 <= 7 )
{
if ( v9 == 1 )
{
if ( (_DWORD)a5 )
{
if ( *((_BYTE *)a1 + 742) )
{
if ( *((_BYTE *)a1 + 739) && v8[976] )
v10 = v8 + 960;
else
v10 = v8 + 952;
v13 = (_QWORD *)*v10;
if ( *v10 )
{
while ( !(unsigned int)sub_10057405C(*v13, "Proxy-authorization:", 20) )
{
v13 = (_QWORD *)v13[1];
if ( !v13 )
goto LABEL_30;
}
goto LABEL_27;
}
goto LABEL_30;
}
}
else if ( *((_BYTE *)a1 + 741) )
{
v13 = *((_QWORD **)*a1 + 119);
if ( v13 )
{
while ( !(unsigned int)sub_10057405C(*v13, "Authorization:", 14) )
{
v13 = (_QWORD *)v13[1];
if ( !v13 )
goto LABEL_30;
}
LABEL_27:
if ( *v13 )
goto LABEL_28;
}
LABEL_30:
v14 = (__int64)*a1;
if ( v5 )
v15 = a1 + 50;
else
v15 = a1 + 46;
if ( v5 )
v16 = a1 + 51;
else
v16 = a1 + 47;
sub_100562884(v14 + 2384, 16385, "%s:%s", *v15, *v16);
strlen((const char *)(v14 + 2384));
result = sub_1005492A8(v14, (char *)(v14 + 2384));
if ( !(_DWORD)result )
return 9;
return result;
}
LABEL_28:
*(_BYTE *)(a2 + 24) = 1;
goto LABEL_29;
}
if ( v9 == 2 )
{
result = sub_10056FDF4(a1, a5);
if ( (_DWORD)result )
return result;
v12 = "Digest";
goto LABEL_38;
}
LABEL_29:
*(_BYTE *)(a2 + 25) = 0;
return 0;
}
if ( v9 != 32 )
{
if ( v9 == 8 )
{
result = sub_10057CE8C(a1, a5);
if ( (_DWORD)result )
return result;
v12 = "NTLM";
goto LABEL_38;
}
goto LABEL_29;
}
result = sub_10057D1A8(a1, a5);
if ( (_DWORD)result )
return result;
v12 = "NTLM_WB";
LABEL_38:
v17 = "Server";
if ( v5 )
{
v17 = "Proxy";
v18 = a1[50];
}
else
{
v18 = a1[46];
}
if ( !v18 )
v18 = "";
sub_1005524A4(v8, "%s auth using %s with user '%s'\n", v17, v12, v18);
*(_BYTE *)(a2 + 25) = *(_BYTE *)(a2 + 24) ^ 1;
return 0;
}