Hi !
I have a little function which is used to hook virtual functions under Windows x86.
I have to port it or linux x86, I know I have to use mprotect but this is abstract for me, I've searched all the night on google, here and on other site but ... wtf ... no answer at all ?? Linux doesn't exists or what ??
DWORD VirtualTableHook( DWORD* pdwNewInterface, int vtable, DWORD newInterface )
{
DWORD dwOld, dwStor = 0x0;
#ifdef WIN32
VirtualProtect( &pdwNewInterface[vtable], 4, PAGE_EXECUTE_READWRITE, &dwOld );
#else
#endif
dwStor = pdwNewInterface[vtable];
*(DWORD*)&pdwNewInterface[vtable] = newInterface;
#ifdef WIN32
VirtualProtect(&pdwNewInterface[vtable], 4, dwOld, &dwOld);
#else
#endif
return dwStor;
}
I don't know if I can use DWORD under Linux, I don't know how to use mprotect exactly, even if I take a look at man ... so if someone could help me it will be much appreciated. Thanks :o