Skip to content

Commit

Permalink
return null when patching call that was replaced with nop slide
Browse files Browse the repository at this point in the history
  • Loading branch information
AtomCrafty authored and powerof3 committed Nov 16, 2024
1 parent 0d4615d commit f6e9dce
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion include/SKSE/Trampoline.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,10 @@ namespace SKSE
template <std::size_t N>
[[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<std::int8_t*>(a_src) == 0x90;
const auto disp = reinterpret_cast<std::int32_t*>(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);
Expand Down

0 comments on commit f6e9dce

Please sign in to comment.