Skip to content

Commit

Permalink
Plugins: Defer hook creation
Browse files Browse the repository at this point in the history
  • Loading branch information
praydog committed Feb 18, 2025
1 parent f86f90d commit b3f9542
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/mods/PluginLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,21 @@ int register_inline_hook(void* target, void* dst, void** original) {
return -1;
}

auto hook = safetyhook::create_inline(target, dst);
auto hook = safetyhook::create_inline(target, dst, safetyhook::InlineHook::StartDisabled);

if (!hook) {
spdlog::error("Failed to create inline hook at {:x}", (uintptr_t)target);
return -1;
}

// Plugin needs to be aware of this before enabling the hook.
*original = hook.original<void*>();

if (auto enable_result = hook.enable(); !enable_result.has_value()) {
spdlog::error("Failed to enable inline hook at {:x}: {}", (uintptr_t)target, enable_result.error().type);
return -1;
}

return PluginLoader::get()->add_inline_hook(std::move(hook));
}

Expand Down

0 comments on commit b3f9542

Please sign in to comment.