rdbo / libmem

Advanced Game Hacking Library for C, Modern C++, Rust and Python (Windows/Linux/FreeBSD) (Process/Memory Hacking) (Hooking/Detouring) (Cross Platform) (x86/x64) (DLL/SO Injection) (Internal/External) (Assembler/Disassembler)
GNU Affero General Public License v3.0
807 stars 98 forks source link

Fix FreeBSD memory problems (???) #56

Open rdbo opened 1 year ago

rdbo commented 1 year ago

The tests on FreeBSD are failing during the hooking of some_function in test1.c. The reason for that is not clear yet.

rdbo commented 1 year ago

It seems to be allocating the trampoline memory as write only:

[*] Some Function Trampoline: 0x801038000

proc maps:
         0x801038000        0x801039000     0x1000    0x20000  -w- ---- 

This doesn't make sense, because it is being allocated with PROT_EXEC | PROT_READ | PROT_WRITE, which is what LM_PROT_XRW is set as.

rdbo commented 1 year ago

I just recompiled libmem on FreeBSD with the warning fixes and things got even wilder. It is crashing on LM_CALLOC, even though both parameters are valid:

LM_CALLOC(len + 1, sizeof(lm_byte_t));

And it is also crashing on mmap:

mmap(NULL, size, prot, MAP_PRIVATE | MAP_ANON, -1, 0)

Error:

Program received signal SIGSEGV, Segmentation fault.
Invalid permissions for mapped object.

Again, no clue what this is.