From 80ca99c7c8974d215f00ad4ddd17f7c8ff796272 Mon Sep 17 00:00:00 2001 From: Chiheb Bacha Date: Wed, 25 Mar 2026 16:19:00 +0100 Subject: [PATCH 1/2] Add C export to fix Unresolved Symbol when linking against this library --- HookingLib/HookingLib.vcxproj | 6 ++++-- HookingLib/hooking_internal.h | 10 +++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/HookingLib/HookingLib.vcxproj b/HookingLib/HookingLib.vcxproj index 8204783..4b4243b 100644 --- a/HookingLib/HookingLib.vcxproj +++ b/HookingLib/HookingLib.vcxproj @@ -21,13 +21,13 @@ StaticLibrary true - v142 + v143 Unicode StaticLibrary false - v142 + v143 true Unicode @@ -57,6 +57,7 @@ true NotUsing pch.h + stdcpp23 @@ -78,6 +79,7 @@ NotUsing pch.h false + stdcpp23 diff --git a/HookingLib/hooking_internal.h b/HookingLib/hooking_internal.h index 1c654c6..630bac6 100644 --- a/HookingLib/hooking_internal.h +++ b/HookingLib/hooking_internal.h @@ -1,3 +1,11 @@ #pragma once #include -void* LhAllocateMemoryEx(void* InEntryPoint, ULONG* OutPageSize); \ No newline at end of file +#ifdef __cplusplus +extern "C" { +#endif + + void* LhAllocateMemoryEx(void* InEntryPoint, ULONG* OutPageSize); + +#ifdef __cplusplus +} +#endif \ No newline at end of file From 49a0c883347e584ca0bf30f80d0f7b0fc2b34972 Mon Sep 17 00:00:00 2001 From: Chiheb Bacha Date: Thu, 26 Mar 2026 07:27:31 +0100 Subject: [PATCH 2/2] Fix trampoline count not getting incremented, which causes old trampolines to be overwritten --- HookingLib/HookingLib.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/HookingLib/HookingLib.cpp b/HookingLib/HookingLib.cpp index fe16a5d..1f6a42d 100644 --- a/HookingLib/HookingLib.cpp +++ b/HookingLib/HookingLib.cpp @@ -384,7 +384,10 @@ bool InsertTrampoline(uintptr_t branchAddress, uintptr_t targetAddress) uint8_t jump[5] = { 0 }; jump[0] = 0xe9; memcpy(jump + 1, &offset, 4); - return WriteForeignMemory(branchAddress, jump, 5); + if (!WriteForeignMemory(branchAddress, jump, 5)) + return false; + trampolineCount++; + return true; } uintptr_t InsertNearHook(uintptr_t address, uintptr_t hook)