Advertisement
Guest User

Untitled

a guest
Apr 3rd, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <signal.h>
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #include <exception>
  5. #include <sstream>
  6.  
  7. LONG ExceptionFilter(PEXCEPTION_POINTERS exp) {
  8.  
  9.     char tmp[1000];
  10.  
  11.     sprintf(tmp, "RAX: %p\n", exp->ContextRecord->Rax);
  12.     sprintf(tmp + strlen(tmp), "RBX: %p\n", exp->ContextRecord->Rbx);
  13.     sprintf(tmp + strlen(tmp), "RCX: %p\n", exp->ContextRecord->Rcx);
  14.     sprintf(tmp + strlen(tmp), "R8: %p\n", exp->ContextRecord->R8);
  15.     sprintf(tmp + strlen(tmp), "R9: %p\n", exp->ContextRecord->R9);
  16.     sprintf(tmp + strlen(tmp), "R10: %p\n", exp->ContextRecord->R10);
  17.     sprintf(tmp + strlen(tmp), "R11: %p\n", exp->ContextRecord->R11);
  18.     sprintf(tmp + strlen(tmp), "R12: %p\n", exp->ContextRecord->R12);
  19.     sprintf(tmp + strlen(tmp), "R13: %p\n", exp->ContextRecord->R13);
  20.     sprintf(tmp + strlen(tmp), "R14: %p\n", exp->ContextRecord->R14);
  21.     sprintf(tmp + strlen(tmp), "R15: %p\n", exp->ContextRecord->R15);
  22.  
  23.     sprintf(tmp + strlen(tmp), "---------------\nRSI: %p\n", exp->ContextRecord->Rsi);
  24.     sprintf(tmp + strlen(tmp), "RDI: %p\n", exp->ContextRecord->Rdi);
  25.  
  26.     sprintf(tmp + strlen(tmp), "---------------\nRSP: %p\n", exp->ContextRecord->Rsp);
  27.     sprintf(tmp + strlen(tmp), "RBP: %p\n", exp->ContextRecord->Rbp);
  28.     sprintf(tmp + strlen(tmp), "RIP: %p\n", exp->ContextRecord->Rip);
  29.  
  30.     sprintf(tmp + strlen(tmp), "---------------\nException address: %p\n", exp->ExceptionRecord->ExceptionAddress);
  31.     sprintf(tmp + strlen(tmp), "Exception code: %lu\n", exp->ExceptionRecord->ExceptionCode);
  32.     sprintf(tmp + strlen(tmp), "---------------\n");
  33.  
  34.     switch (exp->ExceptionRecord->ExceptionCode) {
  35.         case EXCEPTION_ACCESS_VIOLATION:
  36.             sprintf(tmp + strlen(tmp), "Exception Detailed: ACCESS_VIOLATION\n");
  37.             break;
  38.     }
  39.  
  40.     MessageBoxA(0, tmp, "Crash Report", MB_ICONERROR);
  41.  
  42.     return EXCEPTION_EXECUTE_HANDLER;
  43. }
  44.  
  45. int main() {
  46.  
  47.     __try {
  48.         *(int *)0 = 0;
  49.     }
  50.     __except (ExceptionFilter(GetExceptionInformation()))
  51.     {
  52.        
  53.     }
  54.  
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement