//
// sub_63C8AC from 0x63c8ac to 0x63cc30 (900 bytes)
//
// 2 xrefs:
// > sub_614770 @ 0x61484c
// > sub_614770 @ 0x6149bc
//
// 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
//
int __fastcall sub_63C8AC(int a1, int a2)
{
int v4; // r5
char *v5; // r6
int v6; // r5
void **v7; // r8
int *v8; // r10
int v9; // r3
int result; // r0
char *v11; // r0
char *v12; // r11
int v13; // r6
const char *v14; // r1
const char *v15; // r1
char *v16; // r0
char *v17; // r0
char *v18; // r5
char *v19; // r0
char *v20; // r11
int v21; // r5
int v22; // r6
int v23; // r0
int v24; // r4
char *v25; // r0
int v26; // r5
int v27; // r0
int v28; // r4
char *v29; // r0
__pid_t v30; // r0
int v31; // r5
int v32; // r6
char *v33; // r0
int v34; // r5
int v35; // r6
char *v36; // r0
int v37; // r5
int v38; // r0
int v39; // r4
char *v40; // r0
int v41; // r5
int v42; // r0
int v43; // r4
char *v44; // r0
__pid_t v45; // [sp+1Ch] [bp-10h]
int fd; // [sp+20h] [bp-Ch] BYREF
int v47; // [sp+24h] [bp-8h]
v4 = *(_DWORD *)a1;
if ( a2 )
{
v5 = *(char **)(a1 + 252);
v6 = v4 + 34584;
v7 = (void **)(a1 + 684);
v8 = (int *)(a1 + 780);
*(_BYTE *)(v6 + 12) = 0;
if ( v5 )
goto LABEL_3;
LABEL_8:
v9 = *v8;
v5 = &byte_9B1912;
if ( *v8 != 2 )
goto LABEL_4;
LABEL_9:
v11 = sub_626FC4("TT %s\n", *(const char **)(a1 + 812));
v12 = v11;
if ( !v11 )
return 27;
v13 = sub_63C6D0((int *)(a1 + 804), (char **)(a1 + 816), v11, *v8);
off_ABAEB0(v12);
result = v13;
if ( !v13 )
{
off_ABAEB0(*v7);
if ( a2 )
v14 = "Proxy-";
else
v14 = &byte_9B1912;
*v7 = sub_626FC4("%sAuthorization: %s\r\n", v14, *(const char **)(a1 + 816));
*v8 = 3;
*(_BYTE *)(v6 + 12) = 1;
sub_63C80C(a1);
return 0;
}
return result;
}
v5 = *(char **)(a1 + 376);
v6 = v4 + 34568;
v7 = (void **)(a1 + 696);
v8 = (int *)(a1 + 756);
*(_BYTE *)(v6 + 12) = 0;
if ( !v5 )
goto LABEL_8;
LABEL_3:
v9 = *v8;
if ( *v8 == 2 )
goto LABEL_9;
LABEL_4:
if ( v9 == 3 )
{
off_ABAEB0(*v7);
result = 0;
*v7 = nullptr;
*(_BYTE *)(v6 + 12) = 1;
return result;
}
if ( *(_DWORD *)(a1 + 804) == -1 && !*(_DWORD *)(a1 + 808) )
{
if ( !*v5 )
{
v16 = getenv("NTLMUSER");
if ( v16 && *v16 || (v16 = getenv("LOGNAME")) != nullptr && *v16 )
{
v5 = v16;
}
else
{
v17 = getenv("USER");
if ( v17 && *v17 )
v5 = v17;
}
}
v18 = strpbrk(v5, "\\/");
if ( v18 )
{
v19 = off_ABAEB8(v5);
v20 = v19;
if ( !v19 )
return 27;
v21 = v18 - v5;
v5 += v21 + 1;
v19[v21] = 0;
}
else
{
v20 = nullptr;
}
if ( access("/usr/bin/ntlm_auth", 1) )
{
v22 = *(_DWORD *)_errno();
v23 = a1;
v24 = *(_DWORD *)a1;
v25 = sub_6325A4(v23, v22);
sub_6180F8(v24, "Could not access ntlm_auth: %s errno %d: %s", "/usr/bin/ntlm_auth", v22, v25);
LABEL_34:
off_ABAEB0(v20);
off_ABAEB0(nullptr);
return 9;
}
if ( socketpair(1, 1, 0, &fd) )
{
v26 = *(_DWORD *)_errno();
v27 = a1;
v28 = *(_DWORD *)a1;
v29 = sub_6325A4(v27, v26);
sub_6180F8(v28, "Could not open socket pair. errno %d: %s", v26, v29);
goto LABEL_34;
}
v30 = fork();
if ( v30 == -1 )
{
v34 = *(_DWORD *)_errno();
close(fd);
close(v47);
v35 = *(_DWORD *)a1;
v36 = sub_6325A4(a1, v34);
sub_6180F8(v35, "Could not fork. errno %d: %s", v34, v36);
goto LABEL_34;
}
if ( !v30 )
{
close(fd);
if ( dup2(v47, 0) != -1 )
{
if ( dup2(v47, 1) != -1 )
{
if ( v20 )
execl(
"/usr/bin/ntlm_auth",
"/usr/bin/ntlm_auth",
"--helper-protocol",
"ntlmssp-client-1",
"--use-cached-creds",
"--username",
v5,
"--domain",
v20,
0);
else
execl(
"/usr/bin/ntlm_auth",
"/usr/bin/ntlm_auth",
"--helper-protocol",
"ntlmssp-client-1",
"--use-cached-creds",
"--username",
v5,
0);
v31 = *(_DWORD *)_errno();
close(v47);
v32 = *(_DWORD *)a1;
v33 = sub_6325A4(a1, v31);
sub_6180F8(v32, "Could not execl(). errno %d: %s", v31, v33);
exit(1);
}
v37 = *(_DWORD *)_errno();
v38 = a1;
v39 = *(_DWORD *)a1;
v40 = sub_6325A4(v38, v37);
sub_6180F8(v39, "Could not redirect child stdout. errno %d: %s", v37, v40);
exit(1);
}
v41 = *(_DWORD *)_errno();
v42 = a1;
v43 = *(_DWORD *)a1;
v44 = sub_6325A4(v42, v41);
sub_6180F8(v43, "Could not redirect child stdin. errno %d: %s", v41, v44);
exit(1);
}
v45 = v30;
close(v47);
*(_DWORD *)(a1 + 804) = fd;
*(_DWORD *)(a1 + 808) = v45;
off_ABAEB0(v20);
off_ABAEB0(nullptr);
v9 = *v8;
}
result = sub_63C6D0((int *)(a1 + 804), (char **)(a1 + 816), "YR\n", v9);
if ( !result )
{
off_ABAEB0(*v7);
if ( a2 )
v15 = "Proxy-";
else
v15 = &byte_9B1912;
*v7 = sub_626FC4("%sAuthorization: %s\r\n", v15, *(const char **)(a1 + 816));
off_ABAEB0(*(void **)(a1 + 816));
*(_DWORD *)(a1 + 816) = 0;
return 0;
}
return result;
}