Skip to content

Commit 9dbb466

Browse files
committed
feat: Relocation
1 parent 6a77502 commit 9dbb466

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

CommonLibF4/include/REL/Relocation.h

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -300,28 +300,32 @@ namespace REL
300300
safe_write(address(), a_data.data(), a_data.size_bytes());
301301
}
302302

303-
template <std::size_t N>
304-
std::uintptr_t write_branch(const std::uintptr_t a_dst) requires(std::same_as<value_type, std::uintptr_t>)
303+
template <std::size_t N, std::ptrdiff_t O = 0>
304+
std::uintptr_t write_branch(const std::uintptr_t a_dst)
305+
requires(std::same_as<value_type, std::uintptr_t>)
305306
{
306-
return F4SE::GetTrampoline().write_branch<N>(address(), a_dst);
307+
return F4SE::GetTrampoline().write_branch<N>(address() + O, a_dst);
307308
}
308309

309-
template <std::size_t N, class F>
310-
std::uintptr_t write_branch(const F a_dst) requires(std::same_as<value_type, std::uintptr_t>)
310+
template <std::size_t N, std::ptrdiff_t O = 0, class F>
311+
std::uintptr_t write_branch(const F a_dst)
312+
requires(std::same_as<value_type, std::uintptr_t>)
311313
{
312-
return F4SE::GetTrampoline().write_branch<N>(address(), stl::unrestricted_cast<std::uintptr_t>(a_dst));
314+
return F4SE::GetTrampoline().write_branch<N>(address() + O, stl::unrestricted_cast<std::uintptr_t>(a_dst));
313315
}
314316

315-
template <std::size_t N>
316-
std::uintptr_t write_call(const std::uintptr_t a_dst) requires(std::same_as<value_type, std::uintptr_t>)
317+
template <std::size_t N, std::ptrdiff_t O = 0>
318+
std::uintptr_t write_call(const std::uintptr_t a_dst)
319+
requires(std::same_as<value_type, std::uintptr_t>)
317320
{
318-
return F4SE::GetTrampoline().write_call<N>(address(), a_dst);
321+
return F4SE::GetTrampoline().write_call<N>(address() + O , a_dst);
319322
}
320323

321-
template <std::size_t N, class F>
322-
std::uintptr_t write_call(const F a_dst) requires(std::same_as<value_type, std::uintptr_t>)
324+
template <std::size_t N, std::ptrdiff_t O = 0, class F>
325+
std::uintptr_t write_call(const F a_dst)
326+
requires(std::same_as<value_type, std::uintptr_t>)
323327
{
324-
return F4SE::GetTrampoline().write_call<N>(address(), stl::unrestricted_cast<std::uintptr_t>(a_dst));
328+
return F4SE::GetTrampoline().write_call<N>(address() + O, stl::unrestricted_cast<std::uintptr_t>(a_dst));
325329
}
326330

327331
void write_fill(const std::uint8_t a_value, const std::size_t a_count) requires(std::same_as<value_type, std::uintptr_t>)

0 commit comments

Comments
 (0)