Skip to content

Commit 35f1e3b

Browse files
authored
Merge pull request powerof3#148 from AtomCrafty/dev
Return null when patching call that was replaced with nop slide
2 parents 99cc220 + 2056f59 commit 35f1e3b

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/SKSE/Trampoline.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,10 @@ namespace SKSE
138138
template <std::size_t N>
139139
[[nodiscard]] std::uintptr_t write_branch(std::uintptr_t a_src, std::uintptr_t a_dst, std::uint8_t a_data)
140140
{
141+
const auto isNop = *reinterpret_cast<std::int8_t*>(a_src) == 0x90;
141142
const auto disp = reinterpret_cast<std::int32_t*>(a_src + N - 4);
142143
const auto nextOp = a_src + N;
143-
const auto func = nextOp + *disp;
144+
const auto func = isNop ? 0 : nextOp + *disp;
144145

145146
if constexpr (N == 5) {
146147
write_5branch(a_src, a_dst, a_data);

0 commit comments

Comments
 (0)