diff --git a/src/core/kernel/init/CxbxKrnl.cpp b/src/core/kernel/init/CxbxKrnl.cpp index 9ee8ece79..1d8152ea2 100644 --- a/src/core/kernel/init/CxbxKrnl.cpp +++ b/src/core/kernel/init/CxbxKrnl.cpp @@ -1017,6 +1017,10 @@ static bool CxbxrKrnlPrepareXbeMap() void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_reserved) { + // This is beginning of emulation process start, therefore require to have exception manager initialized + // and capture any crash from this point and beyond. Useful for capture live crash and generate crash report. + g_ExceptionManager = new ExceptionManager(); + // First of all, check if the EmuShared version matches the emu version and abort otherwise char GitVersionEmuShared[GitVersionMaxLength]; g_EmuShared->GetGitVersion(GitVersionEmuShared); @@ -1175,8 +1179,6 @@ void CxbxKrnlEmulate(unsigned int reserved_systems, blocks_reserved_t blocks_res CxbxrKrnlXbePatchXBEHSig(); - g_ExceptionManager = new ExceptionManager(); // If in need to add VEHs, move this line earlier. (just in case) - // Launch the XBE : { // Load TLS diff --git a/src/core/kernel/support/Emu.cpp b/src/core/kernel/support/Emu.cpp index 0f31fdea0..5eec5646e 100644 --- a/src/core/kernel/support/Emu.cpp +++ b/src/core/kernel/support/Emu.cpp @@ -389,6 +389,12 @@ ExceptionManager *g_ExceptionManager = nullptr; ExceptionManager::ExceptionManager() { accept_request = true; + // Last call plus show exception error than terminate early. +#ifdef _MSC_VER // Windows' C++ exception is using SEH, we cannot use VEH for error reporter system. + (void)SetUnhandledExceptionFilter(EmuException); +#else // Untested for other platforms, may will behave as expected. + AddVEH(0, EmuException, true); +#endif } ExceptionManager::~ExceptionManager() @@ -407,12 +413,6 @@ void ExceptionManager::EmuX86_Init() { accept_request = false; // Do not allow add VEH during emulation. AddVEH(1, lleException, true); // Front line call - // Last call plus show exception error than terminate early. -#ifdef _MSC_VER // Windows' C++ exception is using SEH, we cannot use VEH for error reporter system. - (void)SetUnhandledExceptionFilter(EmuException); -#else // Untested for other platforms, may will behave as expected. - AddVEH(0, EmuException, true); -#endif } bool ExceptionManager::AddVEH(unsigned long first, PVECTORED_EXCEPTION_HANDLER veh_handler)