From a5ce3bed947ab1c9e386f1c98f0ed66cf4eb410f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Branimir=20Karad=C5=BEi=C4=87?= Date: Sat, 10 Jan 2026 09:46:57 -0800 Subject: [PATCH] Fixed amalgamated build. (#362) --- src/debug.cpp | 19 +++++++++++++++---- src/thread.cpp | 8 ++++---- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/debug.cpp b/src/debug.cpp index a721364..726d67f 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -1289,15 +1289,26 @@ namespace bx }; typedef uint32_t (__stdcall* TopLevelExceptionFilterFn)(ExceptionPointers* _exceptionInfo); - - extern "C" __declspec(dllimport) TopLevelExceptionFilterFn __stdcall SetUnhandledExceptionFilter(TopLevelExceptionFilterFn _topLevelExceptionFilter); + typedef TopLevelExceptionFilterFn (__stdcall* SetUnhandledExceptionFilterFn)(TopLevelExceptionFilterFn _topLevelExceptionFilter); struct ExceptionHandler { ExceptionHandler() { - BX_TRACE("ExceptionHandler - Windows SEH"); - SetUnhandledExceptionFilter(topLevelExceptionFilter); + void* kernel32Dll = bx::dlopen("kernel32.dll"); + + if (NULL != kernel32Dll) + { + SetUnhandledExceptionFilterFn setUnhandledExceptionFilter = bx::dlsym(kernel32Dll, "SetUnhandledExceptionFilter"); + + if (NULL != setUnhandledExceptionFilter) + { + BX_TRACE("ExceptionHandler - Windows SEH"); + setUnhandledExceptionFilter(topLevelExceptionFilter); + } + + bx::dlclose(kernel32Dll); + } } static uint32_t __stdcall topLevelExceptionFilter(ExceptionPointers* _info) diff --git a/src/thread.cpp b/src/thread.cpp index 53ce517..8d5e3db 100644 --- a/src/thread.cpp +++ b/src/thread.cpp @@ -234,17 +234,17 @@ namespace bx #elif BX_PLATFORM_LINUX prctl(PR_SET_NAME, m_name.getCPtr(), 0, 0, 0); #elif BX_PLATFORM_WINDOWS - typedef HRESULT (WINAPI *SetThreadDescriptionProc)(HANDLE, PCWSTR); - SetThreadDescriptionProc SetThreadDescription = dlsym( (void*)GetModuleHandleA("Kernel32.dll"), "SetThreadDescription"); + typedef HRESULT (WINAPI *SetThreadDescriptionFn)(HANDLE, PCWSTR); + SetThreadDescriptionFn setThreadDescription = dlsym( (void*)GetModuleHandleA("kernel32.dll"), "SetThreadDescription"); - if (NULL != SetThreadDescription) + if (NULL != setThreadDescription) { const uint32_t length = m_name.getLength(); const uint32_t max = (length+1)*sizeof(wchar_t); wchar_t* name = (wchar_t*)BX_STACK_ALLOC(max); mbstowcs(name, m_name.getCPtr(), length); name[length] = 0; - SetThreadDescription(ti->m_handle, name); + setThreadDescription(ti->m_handle, name); } else {