示例#1
0
文件: mdump.cpp 项目: dulton/Bull
//程序崩溃注册函数
//IsPreventOtherExceptionHandling如果设置成true会屏蔽其他地方对SetUnhandledExceptionFilter的调用
void MiniDump(bool IsDumpWithFullMemory,
              bool IsPreventOtherExceptionHandling)
{

    ::SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
    ::SetUnhandledExceptionFilter( (LPTOP_LEVEL_EXCEPTION_FILTER)my_exception_handle );
    ::_set_purecall_handler(purecall_handler);
    ::_set_invalid_parameter_handler(invalidparameter_handle);

    g_IsDumpWithFullMemory = IsDumpWithFullMemory;

    //申请保留虚拟地址空间
    g_ReserveVirtualMemManage.GetAddrsSpace(R_A_S);

    if(IsPreventOtherExceptionHandling)
        DisableSetUnhandledExceptionFilter();

    return;
}
void CExceptionParser::Init(UINT HandleMode)
{
	

	if(HandleMode&EXCEPTION_SET_DEFAULT_HANDLER)
	{
		SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)ExceptionHander);

		

		//_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
		signal(SIGABRT,SignalHandler);
		//_set_invalid_parameter_handler(InvalidParameterHandler);

	}
	if(HandleMode&EXCEPTION_USE_API_HOOK)
	{
		DisableSetUnhandledExceptionFilter();
	}
	if(HandleMode&EXCEPTION_SET_TRANSLATOR)
		_set_se_translator(ExceptionTranslator);
}