Add explanation for common exception codes (#386)

## Link to GitHub Issue, if one exists
#345 

## Description of change
Add a little warning message that shows when well-known exception codes
are encountered & caught by signal hooks.

## Testing
Tested by injecting bad instructions into the DLL.
This commit is contained in:
bicarus-dev
2025-09-28 23:49:08 -07:00
committed by GitHub
parent 61d79f76b2
commit 07cb6048a0
+17
View File
@@ -6,6 +6,7 @@
#include <dbghelp.h> #include <dbghelp.h>
#include "avs/core.h" #include "avs/core.h"
#include "avs/game.h"
#include "acio/acio.h" #include "acio/acio.h"
#include "external/stackwalker/stackwalker.h" #include "external/stackwalker/stackwalker.h"
#include "hooks/libraryhook.h" #include "hooks/libraryhook.h"
@@ -103,6 +104,22 @@ static LONG WINAPI TopLevelExceptionFilter(struct _EXCEPTION_POINTERS *Exception
// print signal // print signal
log_warning("signal", "exception raised: {}", exception_code(ExceptionRecord)); log_warning("signal", "exception raised: {}", exception_code(ExceptionRecord));
std::string err;
switch (ExceptionRecord->ExceptionCode) {
case EXCEPTION_ILLEGAL_INSTRUCTION:
err = "Illegal instruction: either your CPU is too old (e.g., does not support "
"SSE4.2 or AVX2 but perhaps the game requires it); or, a bad patch was applied.";
break;
default:
break;
}
if (!err.empty()) {
log_warning(
"signal",
"likely cause for your error based on the exception code:\n {}",
err.c_str());
}
// check ACIO init failures // check ACIO init failures
if (acio::IO_INIT_IN_PROGRESS) { if (acio::IO_INIT_IN_PROGRESS) {
log_warning( log_warning(