//
// sub_1800A4BC0 from 0x1800a4bc0 to 0x1800a4edd (797 bytes)
//
// 5 xrefs:
// > sub_1800A4FC0 @ 0x1800a502e
// > ??> @ 0x1801869d4
// > ??> @ 0x1801869f4
// > ??> @ 0x180186a04
// > ??> @ 0x1801fb6dc
//
// 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_1800A4BC0(__int64 *a1)
{
__int64 v1; // rbx
__int64 result; // rax
_QWORD *v3; // rdi
HRESULT Instance; // eax
int v5; // eax
int v6; // ecx
unsigned int v7; // edi
__int64 v8; // rax
__int64 v9; // rsi
__int64 *v10; // r14
const wchar_t *bstrVal; // rcx
__int64 v12; // rax
__int64 v13; // rcx
__int64 v14; // rax
__int64 v15; // rcx
__int64 v16; // [rsp+30h] [rbp-9h] BYREF
LPVOID v17; // [rsp+38h] [rbp-1h] BYREF
PROPVARIANT pvar; // [rsp+40h] [rbp+7h] BYREF
unsigned int v19; // [rsp+A0h] [rbp+67h] BYREF
__int64 v20; // [rsp+A8h] [rbp+6Fh] BYREF
__int64 v21; // [rsp+B0h] [rbp+77h] BYREF
LPVOID pv; // [rsp+B8h] [rbp+7Fh] BYREF
v1 = *a1;
result = sub_1800A48C0(a1);
if ( !(_DWORD)result )
{
if ( !(unsigned __int8)sub_1800C0750() )
{
*(_BYTE *)(v1 + 180) = 1;
return 0;
}
v3 = (_QWORD *)(v1 + 704);
if ( !*(_QWORD *)(v1 + 704) )
{
Instance = CoCreateInstance(&rclsid, nullptr, 0x17u, &riid, (LPVOID *)(v1 + 704));
if ( Instance == -2147221008 )
{
if ( CoInitializeEx(nullptr, 2u) < 0 )
return 51;
Instance = CoCreateInstance(&rclsid, nullptr, 0x17u, &riid, (LPVOID *)(v1 + 704));
}
if ( Instance < 0 )
return 51;
}
v20 = 0;
v5 = (*(__int64 (__fastcall **)(_QWORD, _QWORD, _QWORD, __int64 *))(*(_QWORD *)*v3 + 32LL))(*v3, 0, 0, &v20);
if ( (int)(v5 + 0x80000000) < 0 || v5 == -2147023728 )
{
v17 = nullptr;
if ( v5 == -2147023728 )
{
LABEL_15:
v21 = 0;
if ( (*(int (__fastcall **)(_QWORD, _QWORD, __int64, __int64 *))(*(_QWORD *)*v3 + 24LL))(*v3, 0, 1, &v21) >= 0 )
{
v19 = 0;
if ( (*(int (__fastcall **)(__int64, unsigned int *))(*(_QWORD *)v21 + 24LL))(v21, &v19) >= 0 )
{
v6 = 32;
v7 = 0;
if ( v19 < 0x20 )
v6 = v19;
v19 = v6;
if ( !v6 )
{
LABEL_36:
CoTaskMemFree(v17);
(*(void (__fastcall **)(__int64))(*(_QWORD *)v21 + 16LL))(v21);
*(_BYTE *)(v1 + 180) = 1;
return 0;
}
while ( (*(int (__fastcall **)(__int64, _QWORD, __int64 *))(*(_QWORD *)v21 + 32LL))(v21, v7, &v20) >= 0 )
{
pv = nullptr;
if ( (*(int (__fastcall **)(__int64, LPVOID *))(*(_QWORD *)v20 + 40LL))(v20, &pv) < 0 )
break;
v8 = sub_1800B8300(pv);
v9 = v1 + 16LL * v7;
*(_QWORD *)(v9 + 184) = v8;
if ( !v8 )
return 38;
CoTaskMemFree(pv);
v16 = 0;
v10 = (__int64 *)(v1 + 16 * (v7 + 12LL));
if ( (*(int (__fastcall **)(__int64, _QWORD, __int64 *))(*(_QWORD *)v20 + 32LL))(v20, 0, &v16) >= 0 )
{
memset(&pvar, 0, sizeof(pvar));
if ( (*(int (__fastcall **)(__int64, void *, PROPVARIANT *))(*(_QWORD *)v16 + 40LL))(
v16,
&unk_18016FAD0,
&pvar) >= 0 )
{
bstrVal = L"Unknown";
if ( pvar.vt == 31 )
bstrVal = pvar.bstrVal;
v12 = sub_1800B8300(bstrVal);
*v10 = v12;
if ( v12 && PropVariantClear(&pvar) >= 0 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v16 + 16LL))(v16);
}
}
if ( !*v10 )
return 38;
(*(void (__fastcall **)(__int64))(*(_QWORD *)v20 + 16LL))(v20);
if ( v17 && v7 && !(unsigned int)sub_1800B82D0(v17, *(_QWORD *)(v9 + 184)) )
{
v13 = *(_QWORD *)(v1 + 184);
*(_QWORD *)(v1 + 184) = *(_QWORD *)(v9 + 184);
v14 = *v10;
*(_QWORD *)(v9 + 184) = v13;
v15 = *(_QWORD *)(v1 + 192);
*(_QWORD *)(v1 + 192) = v14;
*v10 = v15;
}
++*(_DWORD *)(v1 + 696);
if ( ++v7 >= v19 )
goto LABEL_36;
}
}
}
return 49;
}
if ( (*(int (__fastcall **)(__int64, LPVOID *))(*(_QWORD *)v20 + 40LL))(v20, &v17) >= 0 )
{
(*(void (__fastcall **)(__int64))(*(_QWORD *)v20 + 16LL))(v20);
goto LABEL_15;
}
}
return 49;
}
return result;
}