From e1ee08d5120c32e16154b4b90ae44854899f84d2 Mon Sep 17 00:00:00 2001 From: RimuruChan Date: Mon, 13 Jan 2025 15:53:35 +0800 Subject: [PATCH] feat(hook): add uncheck hook option and fix test --- src-test/server/HookTest.cpp | 4 ++-- src/ll/api/memory/Hook.h | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src-test/server/HookTest.cpp b/src-test/server/HookTest.cpp index 81c157c724..f1ef70dc84 100644 --- a/src-test/server/HookTest.cpp +++ b/src-test/server/HookTest.cpp @@ -29,12 +29,12 @@ class TestPtrClass { int test(int a, int b) { return a + b; } }; -// they will choose non-const version if possible +// test unchecked function pointer LL_TYPE_INSTANCE_HOOK( TestPtrHook, HookPriority::Normal, TestPtrClass, - ll::memory::toFuncPtr(&TestPtrClass::test), + ll::memory::unchecked(&TestPtrClass::test), int, __int64 a, __int64 b diff --git a/src/ll/api/memory/Hook.h b/src/ll/api/memory/Hook.h index 11f9f144fe..49c2e15677 100644 --- a/src/ll/api/memory/Hook.h +++ b/src/ll/api/memory/Hook.h @@ -80,6 +80,11 @@ constexpr FuncPtr resolveIdentifier(uintptr_t address) { return toFuncPtr(address); } +template +constexpr uintptr_t unchecked(T identifier) { + return reinterpret_cast(toFuncPtr(identifier)); +} + template requires(!std::is_member_function_pointer_v) consteval bool virtualDetector() noexcept {