From d3d8884f931700483b1a9852fb8898252883c8ed Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Sat, 27 Aug 2016 21:18:51 +0200 Subject: [PATCH] Generate a more complete context in debug_minidump. --- src/Components/Modules/Exception.cpp | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/src/Components/Modules/Exception.cpp b/src/Components/Modules/Exception.cpp index 624c5564..e4f6bd6b 100644 --- a/src/Components/Modules/Exception.cpp +++ b/src/Components/Modules/Exception.cpp @@ -193,19 +193,34 @@ namespace Components Command::Execute(command, false); }); +#pragma warning(push) +#pragma warning(disable:4740) // flow in or out of inline asm code suppresses global optimization Command::Add("debug_minidump", [](Command::Params) { CONTEXT ectx; - + ZeroMemory(&ectx, sizeof(CONTEXT)); + ectx.ContextFlags = CONTEXT_CONTROL; + + __asm + { + Label: + mov[ectx.Ebp], ebp; + mov[ectx.Esp], esp; + mov eax, [Label]; + mov[ectx.Eip], eax; + } + EXCEPTION_RECORD erec; - erec.ExceptionAddress = 0x0; + ZeroMemory(&erec, sizeof(EXCEPTION_RECORD)); + erec.ExceptionAddress = _ReturnAddress(); erec.ExceptionCode = EXCEPTION_BREAKPOINT; - EXCEPTION_POINTERS eptr; - eptr.ContextRecord = &ectx; - eptr.ExceptionRecord = &erec; + auto eptr = new EXCEPTION_POINTERS(); + eptr->ContextRecord = &ectx; + eptr->ExceptionRecord = &erec; - Exception::ExceptionFilter(&eptr); + Exception::ExceptionFilter(eptr); }); +#pragma warning(pop) } }