Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <signal.h>
- #include <windows.h>
- #include <stdio.h>
- #include <exception>
- #include <sstream>
- LONG ExceptionFilter(PEXCEPTION_POINTERS exp) {
- char tmp[1000];
- sprintf(tmp, "RAX: %p\n", exp->ContextRecord->Rax);
- sprintf(tmp + strlen(tmp), "RBX: %p\n", exp->ContextRecord->Rbx);
- sprintf(tmp + strlen(tmp), "RCX: %p\n", exp->ContextRecord->Rcx);
- sprintf(tmp + strlen(tmp), "R8: %p\n", exp->ContextRecord->R8);
- sprintf(tmp + strlen(tmp), "R9: %p\n", exp->ContextRecord->R9);
- sprintf(tmp + strlen(tmp), "R10: %p\n", exp->ContextRecord->R10);
- sprintf(tmp + strlen(tmp), "R11: %p\n", exp->ContextRecord->R11);
- sprintf(tmp + strlen(tmp), "R12: %p\n", exp->ContextRecord->R12);
- sprintf(tmp + strlen(tmp), "R13: %p\n", exp->ContextRecord->R13);
- sprintf(tmp + strlen(tmp), "R14: %p\n", exp->ContextRecord->R14);
- sprintf(tmp + strlen(tmp), "R15: %p\n", exp->ContextRecord->R15);
- sprintf(tmp + strlen(tmp), "---------------\nRSI: %p\n", exp->ContextRecord->Rsi);
- sprintf(tmp + strlen(tmp), "RDI: %p\n", exp->ContextRecord->Rdi);
- sprintf(tmp + strlen(tmp), "---------------\nRSP: %p\n", exp->ContextRecord->Rsp);
- sprintf(tmp + strlen(tmp), "RBP: %p\n", exp->ContextRecord->Rbp);
- sprintf(tmp + strlen(tmp), "RIP: %p\n", exp->ContextRecord->Rip);
- sprintf(tmp + strlen(tmp), "---------------\nException address: %p\n", exp->ExceptionRecord->ExceptionAddress);
- sprintf(tmp + strlen(tmp), "Exception code: %lu\n", exp->ExceptionRecord->ExceptionCode);
- sprintf(tmp + strlen(tmp), "---------------\n");
- switch (exp->ExceptionRecord->ExceptionCode) {
- case EXCEPTION_ACCESS_VIOLATION:
- sprintf(tmp + strlen(tmp), "Exception Detailed: ACCESS_VIOLATION\n");
- break;
- }
- MessageBoxA(0, tmp, "Crash Report", MB_ICONERROR);
- return EXCEPTION_EXECUTE_HANDLER;
- }
- int main() {
- __try {
- *(int *)0 = 0;
- }
- __except (ExceptionFilter(GetExceptionInformation()))
- {
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement