From: Vincent Nolin-H. <vh...@gm...> - 2005-07-04 23:13:04
|
Hi guys, I'm currently coding a plugin which needs to hook a virtual function in CBasePlayer. The thing is, it works perfectly without any issue under windows, but when I try the same code under linux all hooking/callclass related macros cause a protection fault. I traced the crash to the following lines in this function: bool CSourceHookImpl::AddHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan, ISHDelegate *handler, bool post) // Tell it to store the pointer if it's not already activ= e if (hookman->vfnptrs.empty()) hookman->func(HA_Register, &(*hookman)); XXX Crash here! XXX void **cur_vtptr =3D *reinterpret_cast<void***>( reinterpret_cast<char*>(adjustediface) + tmp.vtbl_offs); void *cur_vfnptr =3D reinterpret_cast<void*>(cur_vtptr + tmp.vtbl_idx); Here are the flags I use during compilating/linking: ARCH_CFLAGS=3D-O3 -fno-rtti -funroll-loops -s -pipe BASE_CFLAGS=3D-fpermissive -D_LINUX -DNDEBUG -Dstricmp=3Dstrcasecmp -D_stricmp=3Dstrcasecmp -D_strnicmp=3Dstrncasecmp -Dstrnicmp=3Dstrncasecmp -D_snprintf=3Dsnprintf -D_vsnprintf=3Dvsnprintf -D_alloca=3Dalloca -Dstrcmpi=3Dstrcasecmp -fPIC Any ideas ? Remember that the whole thing works fine under windows.= .. Thanks in advance, Vincent Nolin-Hudon |