initialize exception manager at beginning of emulation process

This commit is contained in:
RadWolfie 2022-02-04 12:24:30 -06:00
parent db1bae2d4e
commit da72da4d03
2 changed files with 10 additions and 8 deletions

View File

@ -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

View File

@ -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)