#include <stdio.h>
#include <windows.h>
long WINAPI handler(EXCEPTION_POINTERS* lpExceptionInfo) //
{
printf("%d", 5);
return EXCEPTION_EXECUTE_HANDLER;
}
int main(int argc, char* argv[])
{
printf("Going to assign value to null pointer!\n");
SetUnhandledExceptionFilter(handler);
*(int*)0 = 1;
return 0;
}
為什么直接到*(int*)0 = 1的位置蹦掉, 我希望的是我會捕捉到例外跳到函式handler()里面的
uj5u.com熱心網友回復:
try {
printf("Going to assign value to null pointer!\n");
SetUnhandledExceptionFilter(handler);
*(int*)0 = 1;
return 0;
}
catch (...) {
handler
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/87267.html
