fix compilation error caused by substitution failure when installing hook at raw pointer, implement InstallAtSymbol with exlaunch's symbol lookup#27
Open
Werechang wants to merge 3 commits into
Conversation
…ation on non-matching template substitution
|
Nice, I've been doing something similar in https://github.com/aquacluck/totk-lotuskit/blob/main/exlaunch/patches/0002-feature-install-at-named-reloc.patch#L1-L18, using exlaunch's new symbol table utility: static ALWAYS_INLINE void Install() {
_HOOK_STATIC_CALLBACK_ASSERT();
const auto entry = exl::reloc::GetLookupTable().FindByName(Derived::s_name);
//auto mod = exl::util::GetModuleInfo(entry->m_ModuleIndex); // XXX cheat: always main module anyways for now
hook::HookInline(util::modules::GetTargetOffset(entry->m_Offset), Derived::Callback);
}Usage: HOOK_DEFINE_INLINE(OnRecallUpdateHighlightActorHook) {
static constexpr auto s_name = "game::ai::execute::ExecutePlayerReverseRecorder::updateImpl_::state0";
static void Callback(exl::hook::InlineCtx* ctx) {
auto* highlightedActor = (engine::actor::ActorBase*)(ctx->X[8]);
lotuskit::ActorWatcher::resolveRecallHighlight(highlightedActor);
}
};
// then OnRecallUpdateHighlightActorHook::Install(), same ideaI'm not sure of the best way to handle these, just wanted to bring up these different patterns for symbol lookup, they're both useful :) |
Contributor
Author
|
Thanks for bringing this to my attention. I will update my code to use the exlaunch lookup. However, I'll stick to the principle of passing the target info inside the installation function to be consistent with the design. |
InstallAtSymbol when exlaunch is loaded as a moduleInstallAtSymbol with exlaunch's symbol lookup
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The obligatory usage:
A
static_assert(false)intype_traits.hppcaused the compilation to fail, since the compiler tried to substitute uintptr_t inFuncPtrTraitsto test the application of a templated function.