//
// __acrt_getptd from 0x1801352b8 to 0x18013538c (212 bytes)
//
// 13 xrefs:
// > _LocaleUpdate::_LocaleUpdate @ 0x18012948e
// > unknown_libname_61 @ 0x1801309a1
// > terminate @ 0x180132a88
// > __pctype_func @ 0x180136af8
// > raise @ 0x1801397ae
// > raise @ 0x1801397be
// > raise @ 0x180139834
// > raise @ 0x180139877
// > __acrt_update_thread_multibyte_data @ 0x18013a878
// > __acrt_update_thread_locale_data @ 0x18013c4d6
// > ___lc_codepage_func @ 0x18013d344
// > _write_nolock @ 0x18014040d
// > ??> @ 0x18020335c
//
// 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 _acrt_getptd()
{
DWORD LastError; // eax
DWORD v1; // ecx
DWORD v2; // ebx
__int64 Value; // rax
struct __acrt_ptd *v4; // rdi
struct __acrt_ptd *v5; // rsi
struct __acrt_ptd *v6; // rax
struct __acrt_ptd *v7; // rcx
__int64 result; // rax
LastError = GetLastError();
v1 = dword_1801B1870;
v2 = LastError;
if ( dword_1801B1870 == -1 )
{
LABEL_6:
if ( !(unsigned int)_acrt_FlsSetValue(v1, (LPVOID)0xFFFFFFFFFFFFFFFFLL) )
goto LABEL_4;
v6 = (struct __acrt_ptd *)calloc_base(1u, 0x3C8u);
v4 = v6;
if ( v6 )
{
if ( (unsigned int)_acrt_FlsSetValue(dword_1801B1870, v6) )
{
construct_ptd_array(v4);
free_base(nullptr);
goto LABEL_13;
}
_acrt_FlsSetValue(dword_1801B1870, nullptr);
v7 = v4;
}
else
{
_acrt_FlsSetValue(dword_1801B1870, nullptr);
v7 = nullptr;
}
free_base(v7);
goto LABEL_4;
}
Value = _acrt_FlsGetValue();
v4 = (struct __acrt_ptd *)Value;
if ( !Value )
{
v1 = dword_1801B1870;
goto LABEL_6;
}
if ( Value == -1 )
{
LABEL_4:
v4 = nullptr;
v5 = nullptr;
goto LABEL_14;
}
LABEL_13:
v5 = v4;
LABEL_14:
SetLastError(v2);
result = (unsigned __int64)v5 & -(__int64)(v4 != nullptr);
if ( !result )
abort();
return result;
}