//
// sub_1800BF980 from 0x1800bf980 to 0x1800c035c (2524 bytes)
//
// 5 xrefs:
// > sub_1800BF970 @ 0x1800bf970
// > ??> @ 0x18018a4cc
// > ??> @ 0x18018a4dc
// > ??> @ 0x18018a4fc
// > ??> @ 0x1801fd9bc
//
// 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_1800BF980(__int64 a1)
{
unsigned int v1; // ebx
unsigned int v3; // r14d
__int64 v4; // rcx
__int64 result; // rax
HMODULE LibraryA; // rax
__int64 v7; // rcx
_QWORD *v8; // r12
int v9; // eax
unsigned __int64 v10; // r13
_QWORD *v11; // rax
__int64 v12; // rcx
int v13; // eax
__int64 v14; // rsi
unsigned int v15; // esi
_DWORD *v16; // rax
_DWORD *v17; // rbx
__int64 v18; // rdx
__int64 v19; // rax
__int16 v20; // cx
_DWORD *v21; // rdx
_DWORD *v22; // rbx
int v23; // eax
int v24; // eax
void *v25; // rax
unsigned __int16 i; // si
__int64 v27; // rbx
_DWORD *v28; // r8
unsigned int v29; // r9d
int v30; // [rsp+20h] [rbp-E0h]
_WORD v31[2]; // [rsp+40h] [rbp-C0h] BYREF
_WORD v32[2]; // [rsp+44h] [rbp-BCh] BYREF
__int64 v33; // [rsp+48h] [rbp-B8h] BYREF
unsigned int v34; // [rsp+50h] [rbp-B0h] BYREF
__int64 v35; // [rsp+58h] [rbp-A8h] BYREF
unsigned __int16 v36[2]; // [rsp+60h] [rbp-A0h] BYREF
int v37; // [rsp+64h] [rbp-9Ch] BYREF
int v38; // [rsp+68h] [rbp-98h] BYREF
__int64 v39; // [rsp+70h] [rbp-90h] BYREF
__int64 v40; // [rsp+78h] [rbp-88h] BYREF
__int64 v41; // [rsp+80h] [rbp-80h]
_QWORD v42[3]; // [rsp+88h] [rbp-78h] BYREF
wchar_t Source[256]; // [rsp+A0h] [rbp-60h] BYREF
v1 = 0;
*(_DWORD *)(a1 + 40) = 2;
*(_QWORD *)(a1 + 288) = 0;
*(_QWORD *)(a1 + 296) = 0;
*(_QWORD *)(a1 + 304) = 0;
v3 = 0;
*(_QWORD *)(a1 + 328) = 0;
*(_QWORD *)(a1 + 312) = 0;
*(_QWORD *)(a1 + 360) = 0;
*(_DWORD *)(a1 + 24) = 0;
*(_QWORD *)(a1 + 8) = 0;
v4 = *(_QWORD *)(a1 + 368);
v38 = 2;
v39 = 0;
result = sub_1800B3470(v4, (unsigned __int8 *)v42, 1, 16, nullptr);
if ( !(_DWORD)result )
{
if ( v42[0] != 0x11CF668E75B22630LL || v42[1] != 0x6CCE6200AA00D9A6LL )
return 19;
*(_BYTE *)(a1 + 408) = 1;
*(_QWORD *)(a1 + 416) = 0;
*(_DWORD *)(a1 + 412) = 0;
if ( !WMCreateSyncReader )
{
LibraryA = hModule;
if ( !hModule )
{
LibraryA = LoadLibraryA("wmvcore.dll");
hModule = LibraryA;
if ( !LibraryA )
return 55;
}
WMCreateSyncReader = (HRESULT (__stdcall *)(IUnknown *, DWORD, IWMSyncReader **))GetProcAddress(
LibraryA,
"WMCreateSyncReader");
if ( !WMCreateSyncReader )
return 55;
}
*(_OWORD *)(a1 + 432) = 0;
*(_OWORD *)(a1 + 448) = 0;
*(_OWORD *)(a1 + 464) = 0;
*(_QWORD *)(a1 + 480) = 0;
v7 = *(_QWORD *)(a1 + 368);
*(_QWORD *)(a1 + 8) = a1 + 432;
result = (*(__int64 (__fastcall **)(__int64, __int64))(*(_QWORD *)v7 + 16LL))(v7, a1 + 452);
if ( !(_DWORD)result )
{
result = sub_1800B3990(*(__int64 **)(a1 + 368), 0, 0);
if ( !(_DWORD)result )
{
v8 = (_QWORD *)(a1 + 376);
v9 = ((__int64 (__fastcall *)(_QWORD, _QWORD, __int64))WMCreateSyncReader)(0, 0, a1 + 376);
if ( v9 < 0 )
goto LABEL_17;
v10 = 24;
v11 = sub_1800B6880(
*((_QWORD *)off_1801AED20 + 52),
24,
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\platforms\\win\\src\\fmod_codec_asf.cpp",
224,
0);
if ( !v11 )
{
*(_QWORD *)(a1 + 384) = 0;
return 38;
}
v11[1] = 0;
*v11 = off_18016C0B8;
*((_DWORD *)v11 + 4) = 1;
v12 = *(_QWORD *)(a1 + 368);
*(_QWORD *)(a1 + 384) = v11;
v11[1] = v12;
v13 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)*v8 + 184LL))(*v8, *(_QWORD *)(a1 + 384));
if ( v13 != -2147221008 )
{
LABEL_22:
if ( v13 < 0 || (**(int (__fastcall ***)(_QWORD, void *, __int64 *))*v8)(*v8, &unk_18016C0A8, &v39) < 0 )
return 19;
v14 = v39;
v35 = 0;
LODWORD(v33) = 0;
if ( !v39 )
return 31;
if ( (*(int (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v39 + 64LL))(v39, &v33) < 0 )
return 13;
*(_DWORD *)(a1 + 392) = 0;
if ( (_DWORD)v33 )
{
while ( (*(int (__fastcall **)(__int64, _QWORD, __int64 *))(*(_QWORD *)v14 + 72LL))(v14, v1, &v35) >= 0 )
{
v31[0] = 0;
if ( (*(int (__fastcall **)(__int64, _WORD *))(*(_QWORD *)v35 + 32LL))(v35, v31) < 0
|| (*(int (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v35 + 24LL))(v35, &v40) < 0 )
{
break;
}
if ( v40 == 0x10000073647561LL && v41 == 0x719B3800AA000080LL )
{
*(_WORD *)(a1 + 392) = v31[0];
}
else if ( v40 == 0x10000073646976LL && v41 == 0x719B3800AA000080LL )
{
*(_WORD *)(a1 + 394) = v31[0];
}
if ( v35 )
(*(void (__fastcall **)(__int64))(*(_QWORD *)v35 + 16LL))(v35);
if ( ++v1 >= (unsigned int)v33 )
goto LABEL_40;
}
return 13;
}
LABEL_40:
(*(void (__fastcall **)(__int64))(*(_QWORD *)v39 + 16LL))(v39);
if ( (*(int (__fastcall **)(_QWORD, _QWORD, _QWORD))(*(_QWORD *)*v8 + 40LL))(*v8, 0, 0) < 0
|| (*(int (__fastcall **)(_QWORD, __int64, __int64, int *))(*(_QWORD *)*v8 + 64LL))(*v8, 1, a1 + 392, &v38) < 0
|| (*(int (__fastcall **)(_QWORD, _QWORD, _QWORD))(*(_QWORD *)*v8 + 80LL))(
*v8,
*(unsigned __int16 *)(a1 + 392),
0) < 0 )
{
return 19;
}
(*(void (__fastcall **)(_QWORD, int *))(*(_QWORD *)*v8 + 112LL))(*v8, &v37);
v15 = 0;
if ( v37 > 0 )
{
while ( (*(int (__fastcall **)(_QWORD, _QWORD, _QWORD, __int64 *, int))(*(_QWORD *)*v8 + 144LL))(
*v8,
v15,
0,
&v33,
v30) >= 0 )
{
if ( (*(int (__fastcall **)(__int64, _QWORD, unsigned int *))(*(_QWORD *)v33 + 32LL))(v33, 0, &v34) < 0 )
goto LABEL_71;
v16 = sub_1800B6880(
*((_QWORD *)off_1801AED20 + 52),
v34,
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\platforms\\win\\src\\fmod_codec_asf.cpp",
338,
0);
v17 = v16;
if ( !v16 )
{
(*(void (__fastcall **)(__int64))(*(_QWORD *)v33 + 16LL))(v33);
return 38;
}
if ( (*(int (__fastcall **)(__int64, _DWORD *, unsigned int *))(*(_QWORD *)v33 + 32LL))(v33, v16, &v34) < 0 )
{
LABEL_71:
(*(void (__fastcall **)(__int64))(*(_QWORD *)v33 + 16LL))(v33);
return 19;
}
if ( v17[10] > v3 )
v3 = v17[10];
if ( *(_QWORD *)(v17 + 11) == 0x11CEC35605589F81LL && *(_QWORD *)(v17 + 13) == 0x5A595500AA0001BFLL )
{
v18 = *((_QWORD *)v17 + 10);
v19 = *(_QWORD *)(a1 + 8);
v20 = *(_WORD *)(v18 + 14);
switch ( v20 )
{
case 8:
*(_DWORD *)(v19 + 8) = 1;
break;
case 16:
*(_DWORD *)(v19 + 8) = 2;
break;
case 24:
*(_DWORD *)(v19 + 8) = 3;
break;
case 32:
*(_DWORD *)(v19 + 8) = 4;
break;
default:
(*(void (__fastcall **)(__int64))(*(_QWORD *)v33 + 16LL))(v33);
goto LABEL_69;
}
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 12LL) = *(unsigned __int16 *)(v18 + 2);
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 16LL) = *(_DWORD *)(v18 + 4);
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v33 + 16LL))(v33);
LOBYTE(v30) = 1;
sub_1800B6AA0(*((_QWORD *)off_1801AED20 + 52), v17);
if ( (int)++v15 >= v37 )
goto LABEL_63;
}
return 19;
}
LABEL_63:
if ( (**(int (__fastcall ***)(_QWORD, void *, __int64 *))*v8)(*v8, &unk_18016C098, &v35) < 0 )
return 19;
v31[0] = 0;
if ( (*(int (__fastcall **)(__int64, _WORD *, const wchar_t *, unsigned int *, _QWORD, _WORD *))(*(_QWORD *)v35 + 40LL))(
v35,
v31,
L"Duration",
&v34,
0,
v32) < 0 )
return 19;
v17 = sub_1800B6880(
*((_QWORD *)off_1801AED20 + 52),
v32[0],
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\platforms\\win\\src\\fmod_codec_asf.cpp",
409,
0);
if ( !v17 )
return 38;
if ( (*(int (__fastcall **)(__int64, _WORD *, const wchar_t *, unsigned int *, _DWORD *, _WORD *))(*(_QWORD *)v35 + 40LL))(
v35,
v31,
L"Duration",
&v34,
v17,
v32) < 0 )
{
LABEL_69:
v21 = v17;
goto LABEL_70;
}
*(_DWORD *)(*(_QWORD *)(a1 + 8) + 24LL) = *(_QWORD *)v17
* *(int *)(*(_QWORD *)(a1 + 8) + 16LL)
/ 0x2710uLL
/ 0x3E8;
sub_1800B6AA0(*((_QWORD *)off_1801AED20 + 52), v17);
if ( (*(int (__fastcall **)(__int64, _WORD *, const wchar_t *, unsigned int *, _QWORD, _WORD *))(*(_QWORD *)v35 + 40LL))(
v35,
v31,
L"Seekable",
&v34,
0,
v32) < 0 )
return 19;
v22 = sub_1800B6880(
*((_QWORD *)off_1801AED20 + 52),
v32[0],
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\platforms\\win\\src\\fmod_codec_asf.cpp",
440,
0);
if ( !v22 )
return 38;
v23 = (*(__int64 (__fastcall **)(__int64, _WORD *, const wchar_t *, unsigned int *, _DWORD *, _WORD *))(*(_QWORD *)v35 + 40LL))(
v35,
v31,
L"Seekable",
&v34,
v22,
v32);
v21 = v22;
if ( v23 < 0 )
{
LABEL_70:
sub_1800B6AA0(*((_QWORD *)off_1801AED20 + 52), v21);
return 19;
}
*(_BYTE *)(a1 + 408) = *v22 != 0;
sub_1800B6AA0(*((_QWORD *)off_1801AED20 + 52), v22);
if ( (*(int (__fastcall **)(__int64, __int64 *))(*(_QWORD *)v35 + 56LL))(v35, &v33) < 0 )
return 19;
v24 = (unsigned __int16)v33;
if ( (_WORD)v33 )
{
*(_DWORD *)(a1 + 412) = (unsigned __int16)v33;
v25 = sub_1800B6530(
*((_QWORD *)off_1801AED20 + 52),
(unsigned int)(316 * v24),
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\platforms\\win\\src\\fmod_codec_asf.cpp",
472,
0,
0,
1);
*(_QWORD *)(a1 + 416) = v25;
if ( !v25 )
return 38;
for ( i = 0;
i < *(int *)(a1 + 412);
*(_DWORD *)(v27 + 48) = v40 * *(int *)(*(_QWORD *)(a1 + 8) + 16LL) / 0x989680uLL )
{
v36[0] = 256;
v27 = *(_QWORD *)(a1 + 416) + 316LL * i;
*(_QWORD *)(v27 + 32) = v27 + 60;
(*(void (__fastcall **)(__int64, _QWORD, wchar_t *, unsigned __int16 *, __int64 *))(*(_QWORD *)v35 + 64LL))(
v35,
i,
Source,
v36,
&v40);
wcstombs(*(char **)(v27 + 32), Source, v36[0]);
++i;
}
}
(*(void (__fastcall **)(__int64))(*(_QWORD *)v35 + 16LL))(v35);
v28 = *(_DWORD **)(a1 + 8);
if ( !v3 )
v3 = 0x10000;
v29 = v28[3];
if ( v29 )
{
if ( v28[2] == 1 )
{
v10 = 8;
}
else if ( v28[2] == 2 )
{
v10 = 16;
}
else if ( v28[2] != 3 )
{
if ( (unsigned int)(v28[2] - 4) >= 2 )
{
v28[7] = v3;
goto LABEL_93;
}
v10 = 32;
}
v28[7] = (unsigned int)(8 * (unsigned __int64)v3 / v10) / v29;
}
LABEL_93:
*(_QWORD *)(a1 + 400) = 0;
*(_DWORD *)(a1 + 272) = 0;
*(_DWORD *)(a1 + 24) = 0;
return 0;
}
if ( CoInitializeEx(nullptr, 2u) < 0 )
return 28;
(*(void (__fastcall **)(_QWORD))(*(_QWORD *)*v8 + 16LL))(*v8);
v9 = ((__int64 (__fastcall *)(_QWORD, _QWORD, __int64))WMCreateSyncReader)(0, 0, a1 + 376);
if ( v9 < 0 )
{
LABEL_17:
if ( v9 != -2147024882 )
return 19;
return 38;
}
result = sub_1800B3990(*(__int64 **)(a1 + 368), 0, 0);
if ( !(_DWORD)result )
{
v13 = (*(__int64 (__fastcall **)(_QWORD, _QWORD))(*(_QWORD *)*v8 + 184LL))(*v8, *(_QWORD *)(a1 + 384));
goto LABEL_22;
}
}
}
}
return result;
}