Skip to content

Commit

Permalink
ok fine
Browse files Browse the repository at this point in the history
  • Loading branch information
user95401 committed Apr 6, 2024
1 parent e9f6870 commit 4328c77
Showing 1 changed file with 33 additions and 2 deletions.
35 changes: 33 additions & 2 deletions src/_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,44 @@ BOOL WINAPI ConsoleHandler(DWORD CEvent) {
auto iAlreadyWas = false;

LONG WINAPI VectoredExceptionHandler(_EXCEPTION_POINTERS* pExceptInfo) {
if(iAlreadyWas) {
log::error("{}, its me, im already was called so i return EXCEPTION_EXECUTE_HANDLER", __FUNCTION__);
return EXCEPTION_EXECUTE_HANDLER;//hl shed
}
else iAlreadyWas = true;
//save game
SaveMethods();
return EXCEPTION_CONTINUE_EXECUTION;
//error msg
DWORD exc_code = pExceptInfo->ExceptionRecord->ExceptionCode;
bool dontCare = false;
//msg text
std::stringstream buffer;
buffer << "Was received fatal exception: ";
switch (exc_code) {
case DBG_PRINTEXCEPTION_WIDE_C:
buffer << "DBG_PRINTEXCEPTION_WIDE_C";
dontCare = true;
break;
case DBG_PRINTEXCEPTION_C:
buffer << "DBG_PRINTEXCEPTION_C";
dontCare = true;
break;
default:
buffer << "0x" << std::hex << exc_code;
break;
}
log::warn("{}", buffer.str());
//msg text makeup end
if (dontCare) {
iAlreadyWas = false;
return EXCEPTION_CONTINUE_EXECUTION;//came from 2.2 pc gdps... idk if needs here
}
return EXCEPTION_CONTINUE_SEARCH;
}

$on_mod(Loaded) {
//VectoredExceptionHandler
AddVectoredExceptionHandler(0, VectoredExceptionHandler);
AddVectoredExceptionHandler(1, VectoredExceptionHandler);
//ConsoleHandler for idk
if (SetConsoleCtrlHandler((PHANDLER_ROUTINE)ConsoleHandler, TRUE) == FALSE) {//c cast???!!((
log::error("{}", "Can't install console handler!");
Expand Down

0 comments on commit 4328c77

Please sign in to comment.