SetUnhandledExceptionFilter function

来源:互联网 发布:社工库数据库共享平台 编辑:程序博客网 时间:2024/05/16 03:16

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
原创粉丝点击