-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
22bf4c9
commit c9ab5be
Showing
2 changed files
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "REL/Relocation.h" | ||
#include "SFSE/API.h" | ||
|
||
namespace SFSE | ||
{ | ||
namespace stl | ||
{ | ||
template <class T, std::size_t Size = 5> | ||
constexpr void write_thunk_call() noexcept | ||
{ | ||
SFSE::AllocTrampoline(14); | ||
auto& trampoline = SFSE::GetTrampoline(); | ||
T::func = trampoline.write_call<Size>(T::address, T::Thunk); | ||
} | ||
|
||
template <class To, class From> | ||
constexpr void write_vfunc() noexcept | ||
{ | ||
REL::Relocation<std::uintptr_t> vtbl{ To::VTABLE[0] }; | ||
From::func = vtbl.write_vfunc(From::idx, From::Thunk); | ||
} | ||
|
||
template <class To, class From> | ||
constexpr void write_vfunc(const std::size_t a_vtable_idx) noexcept | ||
{ | ||
REL::Relocation<std::uintptr_t> vtbl{ To::VTABLE[a_vtable_idx] }; | ||
From::func = vtbl.write_vfunc(From::idx, From::Thunk); | ||
} | ||
|
||
template <class T> | ||
constexpr void write_vfunc(const REL::Offset a_offset) noexcept | ||
{ | ||
REL::Relocation<std::uintptr_t> vtbl{ a_offset }; | ||
T::func = vtbl.write_vfunc(T::idx, T::Thunk); | ||
} | ||
} // namespace stl | ||
} // namespace SFSE |