exception_handler_windows: Ignore irrelevant exceptions

This commit is contained in:
MerryMage 2020-04-23 20:38:57 +01:00
parent 0d041696f5
commit 69061d87fa
2 changed files with 9 additions and 0 deletions

View file

@ -63,6 +63,7 @@ if (MSVC)
/Zc:inline # Omits inline functions from object-file output. /Zc:inline # Omits inline functions from object-file output.
/Zc:throwingNew # Assumes new (without std::nothrow) never returns null. /Zc:throwingNew # Assumes new (without std::nothrow) never returns null.
/volatile:iso # Use strict standard-abiding volatile semantics /volatile:iso # Use strict standard-abiding volatile semantics
/bigobj # Increase number of sections in .obj files
/DNOMINMAX) /DNOMINMAX)
if (DYNARMIC_WARNINGS_AS_ERRORS) if (DYNARMIC_WARNINGS_AS_ERRORS)

View file

@ -14,6 +14,7 @@
#include "common/assert.h" #include "common/assert.h"
#include "common/cast_util.h" #include "common/cast_util.h"
#include "common/common_types.h" #include "common/common_types.h"
#include "common/safe_ops.h"
using UBYTE = u8; using UBYTE = u8;
@ -175,6 +176,13 @@ struct ExceptionHandler::Impl final {
code.align(16); code.align(16);
const u8* exception_handler_with_cb = code.getCurr<u8*>(); const u8* exception_handler_with_cb = code.getCurr<u8*>();
// Our 3rd argument is a PCONTEXT. // Our 3rd argument is a PCONTEXT.
// If not within our codeblock, ignore this exception.
code.mov(code.rax, Safe::Negate(Common::BitCast<u64>(code.getCode())));
code.add(code.rax, code.qword[code.ABI_PARAM3 + Xbyak::RegExp(offsetof(CONTEXT, Rip))]);
code.cmp(code.rax, static_cast<u32>(code.GetTotalCodeSize()));
code.ja(exception_handler_without_cb);
code.sub(code.rsp, 8); code.sub(code.rsp, 8);
code.mov(code.ABI_PARAM1, Common::BitCast<u64>(&cb)); code.mov(code.ABI_PARAM1, Common::BitCast<u64>(&cb));
code.mov(code.ABI_PARAM2, code.ABI_PARAM3); code.mov(code.ABI_PARAM2, code.ABI_PARAM3);