//
// FMOD_OS_Thread_Create from 0x1800c15c0 to 0x1800c1730 (368 bytes)
//
// 3 xrefs:
// > sub_1800B8690 @ 0x1800b879e
// > ??> @ 0x180194348
// > ??> @ 0x1801fdbf0
//
// 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 FMOD_OS_Thread_Create(
__int64 a1,
__int64 a2,
__int64 a3,
DWORD_PTR a4,
int a5,
unsigned int StackSize,
_QWORD *a7)
{
DWORD_PTR v8; // rbx
_QWORD *v12; // rax
void *v14; // rsi
int v15; // ecx
int v16; // edx
v8 = 0;
v12 = sub_1800B6530(
*((_QWORD *)off_1801AED20 + 52),
24,
"C:\\buildagent1\\work\\570ad728b1678096\\core_api\\platforms\\win\\src\\fmod_os_misc.cpp",
690,
0,
0,
1);
if ( !v12 )
return 38;
v12[2] = a1;
*v12 = a2;
v12[1] = a3;
v14 = (void *)beginthreadex(nullptr, StackSize, (_beginthreadex_proc_type)StartAddress, v12, 0, nullptr);
if ( !v14 )
return 28;
v15 = a5;
switch ( a5 )
{
case -32770:
v16 = -1;
break;
case -32771:
v16 = 0;
break;
case -32772:
v16 = 1;
break;
case -32773:
v16 = 2;
break;
default:
v16 = 15;
if ( a5 != -32774 )
{
if ( a5 == -32775 )
v15 = 15;
v16 = v15;
}
break;
}
if ( a4 != 0x4000000000000001LL && a4 != 0x4000000000000002LL )
{
if ( a4 == 0x4000000000000003LL )
a4 = 0;
v8 = a4;
}
if ( !SetThreadPriority(v14, v16) || v8 && !SetThreadAffinityMask(v14, v8) )
return 28;
*a7 = v14;
return 0;
}