Skip to content

Commit f92e5b6

Browse files
committed
Return success from Patch::enable/disable if there's nothing to do
1 parent fb766fe commit f92e5b6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

loader/src/loader/PatchImpl.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ std::vector<Patch::Impl*>& Patch::Impl::allEnabled() {
4646
}
4747

4848
Result<> Patch::Impl::enable() {
49+
if (m_enabled) {
50+
return Ok();
51+
}
52+
4953
auto const thisMin = this->getAddress();
5054
auto const thisMax = this->getAddress() + this->m_patch.size() - 1;
5155
// TODO: this feels slow. can be faster
@@ -68,6 +72,10 @@ Result<> Patch::Impl::enable() {
6872
}
6973

7074
Result<> Patch::Impl::disable() {
75+
if (!m_enabled) {
76+
return Ok();
77+
}
78+
7179
auto res = tulip::hook::writeMemory(m_address, m_original.data(), m_original.size());
7280
if (!res) return Err("Failed to disable patch: {}", res.unwrapErr());
7381

0 commit comments

Comments
 (0)