feat: added hooks to the api

This commit is contained in:
2025-11-18 22:01:37 +01:00
parent ce6c64d393
commit d341524e66
3 changed files with 59 additions and 13 deletions

View File

@@ -6,7 +6,8 @@ extern "C"
{
typedef bool (*native_hook_t)(fxn::NativeContext* context, bool& call_original);
__declspec(dllexport) void* fxn_native_invoker_get_handler(std::uint64_t hash);
__declspec(dllexport) void fxn_schedule_native(fxn::NativeContext* context, bool wait);
__declspec(dllexport) void fxn_register_native_hook(std::uint64_t hash, native_hook_t hook);
__declspec(dllexport) void* fxn_native_invoker_get_handler(std::uint64_t hash);
__declspec(dllexport) void fxn_schedule_native(fxn::NativeContext* context, bool wait);
__declspec(dllexport) size_t fxn_register_native_hook(std::uint64_t hash, native_hook_t hook);
__declspec(dllexport) void fxn_unregister_native_hook(std::uint64_t hash, size_t index);
}

View File

@@ -17,13 +17,17 @@ extern "C"
manager.Schedule(context, wait);
}
__declspec(dllexport) void fxn_register_native_hook(std::uint64_t hash, native_hook_t hook)
__declspec(dllexport) size_t fxn_register_native_hook(std::uint64_t hash, native_hook_t hook)
{
static auto& manager = fxn::FxnManager::GetInstance();
manager.RegisterNativeHook(hash, [hook](fxn::NativeContext* context, bool& call_original)
{
return hook(context, call_original);
});
return manager.RegisterNativeHook(hash, hook);
}
__declspec(dllexport) void fxn_unregister_native_hook(std::uint64_t hash, size_t index)
{
static auto& manager = fxn::FxnManager::GetInstance();
manager.UnregisterNativeHook(hash, index);
}
}