SetUnhandledExceptionFilter以后try-catch为什么还会有效?
我用VC写了一段测试代码,连续两次调用SetUnhandledExceptionFilter,参数分别是ExceptionFilter和ExceptionFilter2,然后写一个__asm int 3,非调试状态运行,回调的是最后调用的ExceptionFilter2。
在SetUnhandledExceptionFilter之后,我写了一段try-catch,里面写*(int*)NULL=0,可是catch还是被触发了。应该是我调用SetUnhandledExceptionFilter覆盖了默认的C++异常回调函数了,为什么try-catch还会有效?try里面又没有重新SetUnhandledExceptionFilter。
Enables an application to supersede the top-level exception handler of each thread of a process.
After calling this function, if an exception occurs in a process that is not being debugged, and the exception makes it to the unhandled exception filter, that filter will call the exception filter function specified by the lpTopLevelExceptionFilter parameter.
最后,不同的context当然参数也不同
Remarks
Issuing SetUnhandledExceptionFilter replaces the existing top-level exception filter for all existing and all future threads in the calling process.
The exception handler specified by lpTopLevelExceptionFilter is executed in the context of the thread that caused the fault. This can affect the exception handler's ability to recover from certain exceptions, such as an invalid stack.