mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-26 09:27:57 -05:00
fix includes + add some doccing
This commit is contained in:
parent
c8e627d921
commit
f089afc27c
7 changed files with 61 additions and 7 deletions
|
@ -4,6 +4,7 @@
|
|||
#include "loader/Loader.hpp"
|
||||
#include "loader/Log.hpp"
|
||||
#include "loader/Mod.hpp"
|
||||
#include "loader/ModEvent.hpp"
|
||||
#include "loader/Setting.hpp"
|
||||
#include "loader/Dirs.hpp"
|
||||
|
||||
|
|
|
@ -26,15 +26,50 @@ namespace geode {
|
|||
Result<> disable();
|
||||
|
||||
public:
|
||||
static Hook* create(Mod* owner, void* address, void* detour, std::string const& displayName, tulip::hook::HandlerMetadata const& handlerMetadata, tulip::hook::HookMetadata const& hookMetadata);
|
||||
/**
|
||||
* Create a hook at an address. The hook is enabled immediately. By
|
||||
* default, the hook is placed at the end of the detour list; however,
|
||||
* this can be controlled using metadata settings.
|
||||
* @param owner The mod that owns this hook; must be provided
|
||||
* @param address The address to hook
|
||||
* @param detour The detour to run when the hook is hit. The detour's
|
||||
* calling convention should be cdecl
|
||||
* @param displayName A human-readable name describing the hook,
|
||||
* usually the fully qualified name of the function being hooked
|
||||
* @param handlerMetadata Metadata for the hook handler
|
||||
* @param hookMetadata Metadata for the hook itself
|
||||
* @returns The created hook, or an error. Make sure to add the created
|
||||
* hook to the mod that owns it using mod->addHook!
|
||||
*/
|
||||
static Hook* create(
|
||||
Mod* owner,
|
||||
void* address,
|
||||
void* detour,
|
||||
std::string const& displayName,
|
||||
tulip::hook::HandlerMetadata const& handlerMetadata,
|
||||
tulip::hook::HookMetadata const& hookMetadata
|
||||
);
|
||||
|
||||
template <class Convention, class DetourType>
|
||||
static Hook* create(Mod* owner, void* address, DetourType detour, std::string const& displayName, tulip::hook::HookMetadata const& hookMetadata = tulip::hook::HookMetadata()) {
|
||||
static Hook* create(
|
||||
Mod* owner,
|
||||
void* address,
|
||||
DetourType detour,
|
||||
std::string const& displayName,
|
||||
tulip::hook::HookMetadata const& hookMetadata = tulip::hook::HookMetadata()
|
||||
) {
|
||||
auto handlerMetadata = tulip::hook::HandlerMetadata{
|
||||
.m_convention = std::make_shared<Convention>(),
|
||||
.m_abstract = tulip::hook::AbstractFunction::from(detour)
|
||||
};
|
||||
return Hook::create(owner, address, reinterpret_cast<void*>(detour), displayName, handlerMetadata, hookMetadata);
|
||||
return Hook::create(
|
||||
owner,
|
||||
address,
|
||||
reinterpret_cast<void*>(detour),
|
||||
displayName,
|
||||
handlerMetadata,
|
||||
hookMetadata
|
||||
);
|
||||
}
|
||||
|
||||
Hook(Hook const&) = delete;
|
||||
|
|
|
@ -15,8 +15,17 @@ USE_GEODE_NAMESPACE();
|
|||
Hook::Hook(std::shared_ptr<Impl>&& impl) : m_impl(std::move(impl)) {}
|
||||
Hook::~Hook() {}
|
||||
|
||||
Hook* Hook::create(Mod* owner, void* address, void* detour, std::string const& displayName, tulip::hook::HandlerMetadata const& handlerMetadata, tulip::hook::HookMetadata const& hookMetadata) {
|
||||
auto impl = std::make_shared<Hook::Impl>(address, detour, displayName, handlerMetadata, hookMetadata, owner);
|
||||
Hook* Hook::create(
|
||||
Mod* owner,
|
||||
void* address,
|
||||
void* detour,
|
||||
std::string const& displayName,
|
||||
tulip::hook::HandlerMetadata const& handlerMetadata,
|
||||
tulip::hook::HookMetadata const& hookMetadata
|
||||
) {
|
||||
auto impl = std::make_shared<Hook::Impl>(
|
||||
address, detour, displayName, handlerMetadata, hookMetadata, owner
|
||||
);
|
||||
return new Hook(std::move(impl));
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,14 @@ USE_GEODE_NAMESPACE();
|
|||
|
||||
class Hook::Impl {
|
||||
public:
|
||||
Impl(void* address, void* detour, std::string const& displayName, tulip::hook::HandlerMetadata const& handlerMetadata, tulip::hook::HookMetadata const& hookMetadata, Mod* owner);
|
||||
Impl(
|
||||
void* address,
|
||||
void* detour,
|
||||
std::string const& displayName,
|
||||
tulip::hook::HandlerMetadata const& handlerMetadata,
|
||||
tulip::hook::HookMetadata const& hookMetadata,
|
||||
Mod* owner
|
||||
);
|
||||
~Impl();
|
||||
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include <Geode/loader/Loader.hpp>
|
||||
#include <Geode/loader/Log.hpp>
|
||||
#include <Geode/loader/Mod.hpp>
|
||||
#include <Geode/loader/ModEvent.hpp>
|
||||
#include <Geode/utils/file.hpp>
|
||||
#include <Geode/utils/JsonValidation.hpp>
|
||||
#include <optional>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <Geode/Loader.hpp>
|
||||
#include <Geode/loader/ModJsonTest.hpp>
|
||||
#include <Geode/loader/ModEvent.hpp>
|
||||
|
||||
USE_GEODE_NAMESPACE();
|
||||
|
||||
|
|
Loading…
Reference in a new issue