Zeex / subhook

Simple hooking library for C/C++ (x86 only, 32/64-bit, no dependencies)
BSD 2-Clause "Simplified" License
801 stars 124 forks source link

add SUBHOOK_TRY_ALLOCATE_TRAMPOLINE_NEAR_SOURCE flag #58

Open santazhang opened 3 years ago

santazhang commented 3 years ago

On 64-bit Linux systems, this flag will let subhook call mmap() with MAP_FIXED_NOREPLACE to allocate trampoline code near the source function. This helps avoid relocation overflow when generating trampoline code.

The exact allocation address will be determined by going through /proc//maps file and locating the nearest unmapped address near the source function.

santazhang commented 3 years ago

This should help address issues like #53

bottiger1 commented 3 years ago

This should help address issues like #53

I tried your patch on x64 linux and it doesn't seem to work. I still get overflow errors with SUBHOOK_TRY_ALLOCATE_TRAMPOLINE_NEAR_SOURCE and I get null trampolines with SUBHOOK_64BIT_OFFSET|SUBHOOK_TRY_ALLOCATE_TRAMPOLINE_NEAR_SOURCE.

I'm using funchook now, they don't have any of these issues.

UchiyhaMozi commented 3 years ago

hallo sir, can u help me?