SetUnhandledExceptionFilter function

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 thelpTopLevelExceptionFilter parameter.调用这个函数之后,如果一个异常发生在为被调试的进程中,那么这个异常会引起异常处理程序的调用,也就是说过滤器会调用thelpTopLevelExceptionFilter参数指定的异常处理程序。

Syntax

C++
LPTOP_LEVEL_EXCEPTION_FILTER WINAPI SetUnhandledExceptionFilter(
  _In_  LPTOP_LEVEL_EXCEPTION_FILTER lpTopLevelExceptionFilter
);

Parameters

lpTopLevelExceptionFilter [in]

A pointer to a top-level exception filter function that will be called whenever theUnhandledExceptionFilter function gets control, and the process is not being debugged.指向顶层异常过滤处理函数的指针, A value ofNULL for this parameter specifies default handling withinUnhandledExceptionFilter.

The filter function has syntax similar to that of UnhandledExceptionFilter: It takes a single parameter of typeLPEXCEPTION_POINTERS, has a WINAPI calling convention, and returns a value of typeLONG. The filter function should return one of the following values.

ValueMeaning
EXCEPTION_EXECUTE_HANDLER 0x1

Return from UnhandledExceptionFilter and execute the associated exception handler. This usually results in process termination.

EXCEPTION_CONTINUE_EXECUTION 0xffffffff

Return from UnhandledExceptionFilter and continue execution from the point of the exception. Note that the filter function is free to modify the continuation state by modifying the exception information supplied through itsLPEXCEPTION_POINTERS parameter.

EXCEPTION_CONTINUE_SEARCH 0x0

Proceed with normal execution of UnhandledExceptionFilter. That means obeying the SetErrorMode flags, or invoking the Application Error pop-up message box.

 

Return value

The SetUnhandledExceptionFilter function returns the address of the previous exception filter established with the function. ANULL return value means that there is no current top-level exception handler.

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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值