feat: Improved exception handling (#969)
This commit is contained in:
parent
94b1917796
commit
53061a98c1
@ -22,12 +22,16 @@ namespace big
|
|||||||
exception_code == DBG_PRINTEXCEPTION_WIDE_C)
|
exception_code == DBG_PRINTEXCEPTION_WIDE_C)
|
||||||
return EXCEPTION_CONTINUE_SEARCH;
|
return EXCEPTION_CONTINUE_SEARCH;
|
||||||
|
|
||||||
LOG(FATAL) << stack_trace(exception_info);
|
stack_trace stack_trace(exception_info);
|
||||||
|
LOG(FATAL) << stack_trace;
|
||||||
|
|
||||||
ZyanU64 opcode_address = exception_info->ContextRecord->Rip;
|
ZyanU64 opcode_address = exception_info->ContextRecord->Rip;
|
||||||
ZydisDisassembledInstruction instruction;
|
ZydisDisassembledInstruction instruction;
|
||||||
ZydisDisassembleIntel(ZYDIS_MACHINE_MODE_LONG_64, opcode_address, reinterpret_cast<void*>(opcode_address), 32, &instruction);
|
ZydisDisassembleIntel(ZYDIS_MACHINE_MODE_LONG_64, opcode_address, reinterpret_cast<void*>(opcode_address), 32, &instruction);
|
||||||
|
|
||||||
|
if(stack_trace.m_ret_context.Rip)
|
||||||
|
*exception_info->ContextRecord = stack_trace.m_ret_context;
|
||||||
|
else
|
||||||
exception_info->ContextRecord->Rip += instruction.info.length;
|
exception_info->ContextRecord->Rip += instruction.info.length;
|
||||||
|
|
||||||
return EXCEPTION_CONTINUE_EXECUTION;
|
return EXCEPTION_CONTINUE_EXECUTION;
|
||||||
|
@ -172,6 +172,9 @@ namespace big
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
m_frame_pointers[i] = frame.AddrPC.Offset;
|
m_frame_pointers[i] = frame.AddrPC.Offset;
|
||||||
|
|
||||||
|
if (i == 1)
|
||||||
|
m_ret_context = context;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,9 +9,12 @@ namespace big
|
|||||||
stack_trace(EXCEPTION_POINTERS* exception_info);
|
stack_trace(EXCEPTION_POINTERS* exception_info);
|
||||||
virtual ~stack_trace();
|
virtual ~stack_trace();
|
||||||
|
|
||||||
|
CONTEXT m_ret_context{};
|
||||||
|
|
||||||
std::string str() const;
|
std::string str() const;
|
||||||
|
|
||||||
friend std::ostream& operator<< (std::ostream& os, const stack_trace& st);
|
friend std::ostream& operator<< (std::ostream& os, const stack_trace& st);
|
||||||
|
friend std::ostream& operator<< (std::ostream& os, const stack_trace* st);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct module_info
|
struct module_info
|
||||||
@ -57,4 +60,11 @@ namespace big
|
|||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline std::ostream& operator<< (std::ostream& os, const stack_trace* st)
|
||||||
|
{
|
||||||
|
os << st->str();
|
||||||
|
|
||||||
|
return os;
|
||||||
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user