//
// std::__ndk1::__assoc_sub_state::set_exception_at_thread_exit from 0xf87554 to 0xf876ac (344 bytes)
//
// 2 xrefs:
// > std::__ndk1::promise::set_exception_at_thread_exit @ 0xf8813c
// > ??> @ 0xa4638
//
// This function is hookable on this platform (idp: arm, 32 bit: False, 64 bit: True!
//
// Using BromaIDA 8.3.0 @ https://github.com/Stazzical/BromaIDA
// Using bindings at commit 1c6ec395 at Thu Nov 26 21:29:22 2026 from https://github.com/geode-sdk/bindings
// Generated at Fri, 27 Nov 2026 13:13:53 +0000
//
__int64 __fastcall std::__assoc_sub_state::set_exception_at_thread_exit(__int64 a1, _QWORD *a2)
{
pthread_mutex_t *v3; // x19
__int64 v5; // x22
pthread_key_t *v6; // x0
std::__thread_struct *v7; // x0
__int64 result; // x0
void *exception; // x0
unsigned __int8 v10; // w8
void *v11; // x20
_QWORD v12[2]; // [xsp+0h] [xbp-30h] BYREF
v3 = (pthread_mutex_t *)(a1 + 24);
v12[1] = *(_QWORD *)(_ReadStatusReg(TPIDR_EL0) + 40);
std::mutex::lock((pthread_mutex_t *)(a1 + 24));
if ( (*(_BYTE *)(a1 + 112) & 1) != 0
|| (v12[0] = 0, v5 = *(_QWORD *)(a1 + 16), std::exception_ptr::~exception_ptr((std::exception_ptr *)v12), v5) )
{
exception = _cxa_allocate_exception(0x20u);
v10 = atomic_load((unsigned __int8 *)&byte_1565EA8);
v11 = exception;
if ( (v10 & 1) == 0 && _cxa_guard_acquire((__guard *)&byte_1565EA8) )
{
qword_1565EA0 = (__int64)&off_1535E88;
__cxa_atexit((void (*)(void *))std::error_category::~error_category, &qword_1565EA0, &unk_1548000);
_cxa_guard_release((__guard *)&byte_1565EA8);
}
std::future_error::future_error((__int64)v11, 2, (__int64)&qword_1565EA0);
_cxa_throw(
v11,
(struct type_info *)&`typeinfo for'std::future_error,
(void (*)(void *))std::future_error::~future_error);
}
std::exception_ptr::operator=((_QWORD *)(a1 + 16), a2);
v6 = (pthread_key_t *)std::__thread_local_data();
v7 = (std::__thread_struct *)pthread_getspecific(*v6);
std::__thread_struct::__make_ready_at_thread_exit(v7, (std::__assoc_sub_state *)a1);
result = std::mutex::unlock(v3);
_ReadStatusReg(TPIDR_EL0);
return result;
}