Advertisement
Guest User

Untitled

a guest
May 25th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. #include "stdafx.h"
  2. #include <Windows.h>
  3.  
  4. #define CALL_FIRST 1
  5. #define CALL_LAST 0
  6.  
  7. LONG WINAPI MyVectoredHandler(struct _EXCEPTION_POINTERS *ExceptionInfo)
  8. {
  9. UNREFERENCED_PARAMETER(ExceptionInfo);
  10.  
  11. printf("MyVectoredHandlern");
  12. return EXCEPTION_CONTINUE_SEARCH;
  13. }
  14.  
  15. LONG WINAPI MyUnhandledExceptionFilter(_In_ struct _EXCEPTION_POINTERS *ExceptionInfo)
  16. {
  17. printf("SetUnhandledExceptionFiltern");
  18.  
  19. return EXCEPTION_CONTINUE_SEARCH;
  20. }
  21.  
  22. void f()
  23. {
  24. __try
  25. {
  26. char p[20] = "hello,world!";
  27. p[24] = '!';
  28. printf("%sn", p);
  29. }
  30. __except (EXCEPTION_EXECUTE_HANDLER)
  31. {
  32. printf("f() exceptionn");
  33. }
  34. }
  35.  
  36. int _tmain(int argc, _TCHAR* argv[])
  37. {
  38. AddVectoredExceptionHandler(CALL_FIRST, MyVectoredHandler);
  39. SetUnhandledExceptionFilter(MyUnhandledExceptionFilter);
  40.  
  41. try{
  42. f();
  43. }
  44. catch (...){
  45. printf("catched f exceptionn");
  46. }
  47. return 0;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement