Fixed hamsandwich vtable patching on Linux for newer GCC binaries.
This commit is contained in:
parent
ad960a64e2
commit
944f608f09
@ -35,6 +35,8 @@
|
||||
// This is just a simple container for data so I only have to add 1 extra
|
||||
// parameter to calls that get trampolined
|
||||
|
||||
#define ALIGN(ar) ((intptr_t)ar & ~(sysconf(_SC_PAGESIZE)-1))
|
||||
|
||||
class Hook
|
||||
{
|
||||
public:
|
||||
@ -66,7 +68,8 @@ public:
|
||||
DWORD OldFlags;
|
||||
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
|
||||
#elif defined __linux__
|
||||
mprotect(&ivtable[entry],sizeof(int*),PROT_READ|PROT_WRITE);
|
||||
void *addr = (void *)ALIGN(&ivtable[entry]);
|
||||
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
|
||||
#endif
|
||||
ivtable[entry]=(int*)tramp;
|
||||
|
||||
@ -84,8 +87,9 @@ public:
|
||||
#if defined _WIN32
|
||||
DWORD OldFlags;
|
||||
VirtualProtect(&ivtable[entry],sizeof(int*),PAGE_READWRITE,&OldFlags);
|
||||
#elif defined __linux__
|
||||
mprotect(&ivtable[entry],sizeof(int*),PROT_READ|PROT_WRITE);
|
||||
#elif defined __linux_
|
||||
void *addr = (void *)ALIGN(&ivtable[entry]);
|
||||
mprotect(addr,sysconf(_SC_PAGESIZE),PROT_READ|PROT_WRITE);
|
||||
#endif
|
||||
|
||||
ivtable[entry]=(int *)func;
|
||||
|
Loading…
Reference in New Issue
Block a user