commit 348e578cebd6315d82035428c66421e54f5c3f35 Author: Hane Date: Tue Sep 16 17:00:52 2025 +0200 First commit diff --git a/src/main.c b/src/main.c new file mode 100644 index 0000000..f73d17e --- /dev/null +++ b/src/main.c @@ -0,0 +1,77 @@ +//clang -v -std=c11 -g -gcodeview -O0 main.c -o main.exe -LF:/carpincho/cositas/luar/src -ldlltest -Wl,--pdb= +#include +#include +#include + +LONG WINAPI exception_handler(PEXCEPTION_POINTERS exception) +{ + //System sounds sound + MessageBeep(MB_ICONERROR); + + int bufsize = 4096; + char* message = calloc(bufsize, 1); + int consumed = 0; + consumed += snprintf(message, bufsize, + "Got an unhandled exception.\ + Exception code: 0x%lx\nContinuable: %lu\nAddress: 0x%016llx\n", + exception->ExceptionRecord->ExceptionCode, + exception->ExceptionRecord->ExceptionFlags, + exception->ExceptionRecord->ExceptionAddress); + if(exception->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && exception->ExceptionRecord->NumberParameters == 2) + { + printf("hey %d", consumed); + consumed += snprintf(message + consumed, bufsize - consumed, + "\tOperation type: %llu\tVirtualAddr: 0x%016llx", + exception->ExceptionRecord->ExceptionInformation[0], + exception->ExceptionRecord->ExceptionInformation[1]); + } + if(exception->ExceptionRecord->ExceptionCode == EXCEPTION_IN_PAGE_ERROR && exception->ExceptionRecord->NumberParameters == 3) + { + consumed += snprintf(message + consumed, bufsize - consumed, + "\tOperation type: %llu\tVirtualAddr: 0x%016llx\tNTSTATUS code:%llu", + exception->ExceptionRecord->ExceptionInformation[0], + exception->ExceptionRecord->ExceptionInformation[1], + exception->ExceptionRecord->ExceptionInformation[2]); + } + MessageBoxExA( + NULL, + message, + "Fatal Crash", + MB_ICONERROR, + MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL) + ); + + printf("Got an unhandled exception.\n"); + printf("Exception code: 0x%lx\nContinuable: %lu\nAddress: 0x%016llx\n", + exception->ExceptionRecord->ExceptionCode, + exception->ExceptionRecord->ExceptionFlags, + exception->ExceptionRecord->ExceptionAddress); + if(exception->ExceptionRecord->ExceptionCode == EXCEPTION_ACCESS_VIOLATION && exception->ExceptionRecord->NumberParameters == 2) + { + printf("\tOperation type: %llu\tVirtualAddr: 0x%016llx", + exception->ExceptionRecord->ExceptionInformation[0], + exception->ExceptionRecord->ExceptionInformation[1]); + } + if(exception->ExceptionRecord->ExceptionCode == EXCEPTION_IN_PAGE_ERROR && exception->ExceptionRecord->NumberParameters == 3) + { + printf("\tOperation type: %llu\tVirtualAddr: 0x%016llx\tNTSTATUS code:%llu", + exception->ExceptionRecord->ExceptionInformation[0], + exception->ExceptionRecord->ExceptionInformation[1], + exception->ExceptionRecord->ExceptionInformation[2]); + } + + //FatalAppExitW + //FatalAppExitW(0, L"bro"); + return EXCEPTION_CONTINUE_SEARCH; +} + +int main() { + unsigned int em = SetErrorMode(0); + LPTOP_LEVEL_EXCEPTION_FILTER filter = SetUnhandledExceptionFilter(exception_handler); + printf("prints\n"); + int *cosa = NULL; + int b = 0; + int a = 4 + *cosa; + //printf("%d", numerito); + return 0; +}