Fixed amalgamated build. (#362)

This commit is contained in:
Branimir Karadžić
2026-01-10 09:46:57 -08:00
committed by GitHub
parent 01cf049f97
commit a5ce3bed94
2 changed files with 19 additions and 8 deletions

View File

@@ -1289,15 +1289,26 @@ namespace bx
}; };
typedef uint32_t (__stdcall* TopLevelExceptionFilterFn)(ExceptionPointers* _exceptionInfo); typedef uint32_t (__stdcall* TopLevelExceptionFilterFn)(ExceptionPointers* _exceptionInfo);
typedef TopLevelExceptionFilterFn (__stdcall* SetUnhandledExceptionFilterFn)(TopLevelExceptionFilterFn _topLevelExceptionFilter);
extern "C" __declspec(dllimport) TopLevelExceptionFilterFn __stdcall SetUnhandledExceptionFilter(TopLevelExceptionFilterFn _topLevelExceptionFilter);
struct ExceptionHandler struct ExceptionHandler
{ {
ExceptionHandler() ExceptionHandler()
{ {
BX_TRACE("ExceptionHandler - Windows SEH"); void* kernel32Dll = bx::dlopen("kernel32.dll");
SetUnhandledExceptionFilter(topLevelExceptionFilter);
if (NULL != kernel32Dll)
{
SetUnhandledExceptionFilterFn setUnhandledExceptionFilter = bx::dlsym<SetUnhandledExceptionFilterFn>(kernel32Dll, "SetUnhandledExceptionFilter");
if (NULL != setUnhandledExceptionFilter)
{
BX_TRACE("ExceptionHandler - Windows SEH");
setUnhandledExceptionFilter(topLevelExceptionFilter);
}
bx::dlclose(kernel32Dll);
}
} }
static uint32_t __stdcall topLevelExceptionFilter(ExceptionPointers* _info) static uint32_t __stdcall topLevelExceptionFilter(ExceptionPointers* _info)

View File

@@ -234,17 +234,17 @@ namespace bx
#elif BX_PLATFORM_LINUX #elif BX_PLATFORM_LINUX
prctl(PR_SET_NAME, m_name.getCPtr(), 0, 0, 0); prctl(PR_SET_NAME, m_name.getCPtr(), 0, 0, 0);
#elif BX_PLATFORM_WINDOWS #elif BX_PLATFORM_WINDOWS
typedef HRESULT (WINAPI *SetThreadDescriptionProc)(HANDLE, PCWSTR); typedef HRESULT (WINAPI *SetThreadDescriptionFn)(HANDLE, PCWSTR);
SetThreadDescriptionProc SetThreadDescription = dlsym<SetThreadDescriptionProc>( (void*)GetModuleHandleA("Kernel32.dll"), "SetThreadDescription"); SetThreadDescriptionFn setThreadDescription = dlsym<SetThreadDescriptionFn>( (void*)GetModuleHandleA("kernel32.dll"), "SetThreadDescription");
if (NULL != SetThreadDescription) if (NULL != setThreadDescription)
{ {
const uint32_t length = m_name.getLength(); const uint32_t length = m_name.getLength();
const uint32_t max = (length+1)*sizeof(wchar_t); const uint32_t max = (length+1)*sizeof(wchar_t);
wchar_t* name = (wchar_t*)BX_STACK_ALLOC(max); wchar_t* name = (wchar_t*)BX_STACK_ALLOC(max);
mbstowcs(name, m_name.getCPtr(), length); mbstowcs(name, m_name.getCPtr(), length);
name[length] = 0; name[length] = 0;
SetThreadDescription(ti->m_handle, name); setThreadDescription(ti->m_handle, name);
} }
else else
{ {