First commit
This commit is contained in:
commit
348e578ceb
1 changed files with 77 additions and 0 deletions
77
src/main.c
Normal file
77
src/main.c
Normal file
|
|
@ -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 <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include <Windows.h>
|
||||
|
||||
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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue