From 2056f5957fb24d3e5e60ad471c901dbae7f99df7 Mon Sep 17 00:00:00 2001 From: AtomCrafty Date: Sun, 10 Nov 2024 15:48:29 +0100 Subject: [PATCH] return null when patching call that was replaced with nop slide --- include/SKSE/Trampoline.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/SKSE/Trampoline.h b/include/SKSE/Trampoline.h index a630896da..326533b4a 100644 --- a/include/SKSE/Trampoline.h +++ b/include/SKSE/Trampoline.h @@ -138,9 +138,10 @@ namespace SKSE template [[nodiscard]] std::uintptr_t write_branch(std::uintptr_t a_src, std::uintptr_t a_dst, std::uint8_t a_data) { + const auto isNop = *reinterpret_cast(a_src) == 0x90; const auto disp = reinterpret_cast(a_src + N - 4); const auto nextOp = a_src + N; - const auto func = nextOp + *disp; + const auto func = isNop ? 0 : nextOp + *disp; if constexpr (N == 5) { write_5branch(a_src, a_dst, a_data);