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);