aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/backend/x64/exception_handler_windows.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/x64/exception_handler_windows.cpp')
-rw-r--r--src/backend/x64/exception_handler_windows.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/x64/exception_handler_windows.cpp b/src/backend/x64/exception_handler_windows.cpp
index 3f65a9cf..12f417cc 100644
--- a/src/backend/x64/exception_handler_windows.cpp
+++ b/src/backend/x64/exception_handler_windows.cpp
@@ -14,6 +14,7 @@
#include "common/assert.h"
#include "common/cast_util.h"
#include "common/common_types.h"
+#include "common/safe_ops.h"
using UBYTE = u8;
@@ -175,6 +176,13 @@ struct ExceptionHandler::Impl final {
code.align(16);
const u8* exception_handler_with_cb = code.getCurr<u8*>();
// 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.mov(code.ABI_PARAM1, Common::BitCast<u64>(&cb));
code.mov(code.ABI_PARAM2, code.ABI_PARAM3);