Skip to content
This repository was archived by the owner on Sep 16, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CommonLibSF/include/SFSE/SFSE.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
#include "SFSE/Interfaces.h"
#include "SFSE/Logger.h"
#include "SFSE/Trampoline.h"
#include "SFSE/Utilities.h"
#include "SFSE/Version.h"
39 changes: 39 additions & 0 deletions CommonLibSF/include/SFSE/Utilities.h
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
Comment thread
powerof3 marked this conversation as resolved.
{
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