debug_minidump now uses code from VC++ 8.0 CRT to generate fake exception info.
This commit is contained in:
parent
624173f7cf
commit
1d5927f093
@ -197,27 +197,65 @@ namespace Components
|
|||||||
#pragma warning(disable:4740) // flow in or out of inline asm code suppresses global optimization
|
#pragma warning(disable:4740) // flow in or out of inline asm code suppresses global optimization
|
||||||
Command::Add("debug_minidump", [](Command::Params)
|
Command::Add("debug_minidump", [](Command::Params)
|
||||||
{
|
{
|
||||||
CONTEXT ectx;
|
// The following code was taken from VC++ 8.0 CRT (invarg.c: line 104)
|
||||||
ZeroMemory(&ectx, sizeof(CONTEXT));
|
|
||||||
ectx.ContextFlags = CONTEXT_CONTROL;
|
|
||||||
|
|
||||||
__asm
|
EXCEPTION_RECORD ExceptionRecord;
|
||||||
{
|
CONTEXT ContextRecord;
|
||||||
Label:
|
memset(&ContextRecord, 0, sizeof(CONTEXT));
|
||||||
mov[ectx.Ebp], ebp;
|
|
||||||
mov[ectx.Esp], esp;
|
#ifdef _X86_
|
||||||
mov eax, [Label];
|
|
||||||
mov[ectx.Eip], eax;
|
__asm {
|
||||||
|
mov dword ptr[ContextRecord.Eax], eax
|
||||||
|
mov dword ptr[ContextRecord.Ecx], ecx
|
||||||
|
mov dword ptr[ContextRecord.Edx], edx
|
||||||
|
mov dword ptr[ContextRecord.Ebx], ebx
|
||||||
|
mov dword ptr[ContextRecord.Esi], esi
|
||||||
|
mov dword ptr[ContextRecord.Edi], edi
|
||||||
|
mov word ptr[ContextRecord.SegSs], ss
|
||||||
|
mov word ptr[ContextRecord.SegCs], cs
|
||||||
|
mov word ptr[ContextRecord.SegDs], ds
|
||||||
|
mov word ptr[ContextRecord.SegEs], es
|
||||||
|
mov word ptr[ContextRecord.SegFs], fs
|
||||||
|
mov word ptr[ContextRecord.SegGs], gs
|
||||||
|
pushfd
|
||||||
|
pop[ContextRecord.EFlags]
|
||||||
}
|
}
|
||||||
|
|
||||||
EXCEPTION_RECORD erec;
|
ContextRecord.ContextFlags = CONTEXT_CONTROL;
|
||||||
ZeroMemory(&erec, sizeof(EXCEPTION_RECORD));
|
#pragma warning(push)
|
||||||
erec.ExceptionAddress = _ReturnAddress();
|
#pragma warning(disable:4311)
|
||||||
erec.ExceptionCode = EXCEPTION_BREAKPOINT;
|
ContextRecord.Eip = (ULONG)_ReturnAddress();
|
||||||
|
ContextRecord.Esp = (ULONG)_AddressOfReturnAddress();
|
||||||
|
#pragma warning(pop)
|
||||||
|
ContextRecord.Ebp = *((ULONG *)_AddressOfReturnAddress() - 1);
|
||||||
|
|
||||||
auto eptr = new EXCEPTION_POINTERS();
|
|
||||||
eptr->ContextRecord = &ectx;
|
#elif defined (_IA64_) || defined (_AMD64_)
|
||||||
eptr->ExceptionRecord = &erec;
|
|
||||||
|
/* Need to fill up the Context in IA64 and AMD64. */
|
||||||
|
RtlCaptureContext(&ContextRecord);
|
||||||
|
|
||||||
|
#else /* defined (_IA64_) || defined (_AMD64_) */
|
||||||
|
|
||||||
|
ZeroMemory(&ContextRecord, sizeof(ContextRecord));
|
||||||
|
|
||||||
|
#endif /* defined (_IA64_) || defined (_AMD64_) */
|
||||||
|
|
||||||
|
ZeroMemory(&ExceptionRecord, sizeof(EXCEPTION_RECORD));
|
||||||
|
|
||||||
|
ExceptionRecord.ExceptionCode = EXCEPTION_BREAKPOINT;
|
||||||
|
ExceptionRecord.ExceptionAddress = _ReturnAddress();
|
||||||
|
|
||||||
|
|
||||||
|
EXCEPTION_RECORD* pExceptionRecord = new EXCEPTION_RECORD;
|
||||||
|
memcpy(pExceptionRecord, &ExceptionRecord, sizeof(EXCEPTION_RECORD));
|
||||||
|
CONTEXT* pContextRecord = new CONTEXT;
|
||||||
|
memcpy(pContextRecord, &ContextRecord, sizeof(CONTEXT));
|
||||||
|
|
||||||
|
auto eptr = new EXCEPTION_POINTERS;
|
||||||
|
eptr->ExceptionRecord = pExceptionRecord;
|
||||||
|
eptr->ContextRecord = pContextRecord;
|
||||||
|
|
||||||
Exception::ExceptionFilter(eptr);
|
Exception::ExceptionFilter(eptr);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user