From 4ce4e008cceb18e7f09a3cc62c3103df676f7aab Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Sat, 10 Nov 2007 11:01:42 +0000 Subject: [PATCH] Fixed potential crashbug in SH_MCALL on GCC --HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%40554 --- sourcehook/generate/sourcehook.h | 2 ++ sourcehook/generate/sourcehook.hxx | 2 ++ sourcehook/sourcehook.h | 2 ++ 3 files changed, 6 insertions(+) diff --git a/sourcehook/generate/sourcehook.h b/sourcehook/generate/sourcehook.h index 282a4a4..35dbb5f 100644 --- a/sourcehook/generate/sourcehook.h +++ b/sourcehook/generate/sourcehook.h @@ -852,6 +852,8 @@ SourceHook::CallClass *SH_GET_CALLCLASS(T *p) *reinterpret_cast( (reinterpret_cast(ptr) + SH_MFHCls(hookname)::ms_MFI.thisptroffs + SH_MFHCls(hookname)::ms_MFI.vtbloffs) ) + SH_MFHCls(hookname)::ms_MFI.vtblindex); \ /* patch mfp */ \ *reinterpret_cast(&mfp) = *reinterpret_cast(vfnptr); \ + if (sizeof(mfp) == 2*sizeof(void*)) /* gcc */ \ + *(reinterpret_cast(&mfp) + 1) = 0; \ return SH_MFHCls(hookname)::CallEC(reinterpret_cast< ::SourceHook::EmptyClass* >(ptr), mfp, vfnptr, SH_GLOB_SHPTR); \ } \ void __SourceHook_FHM_Reconfigure##hookname(int p_vtblindex, int p_vtbloffs, int p_thisptroffs) \ diff --git a/sourcehook/generate/sourcehook.hxx b/sourcehook/generate/sourcehook.hxx index 6d934b7..8b8b6fc 100755 --- a/sourcehook/generate/sourcehook.hxx +++ b/sourcehook/generate/sourcehook.hxx @@ -852,6 +852,8 @@ SourceHook::CallClass *SH_GET_CALLCLASS(T *p) *reinterpret_cast( (reinterpret_cast(ptr) + SH_MFHCls(hookname)::ms_MFI.thisptroffs + SH_MFHCls(hookname)::ms_MFI.vtbloffs) ) + SH_MFHCls(hookname)::ms_MFI.vtblindex); \ /* patch mfp */ \ *reinterpret_cast(&mfp) = *reinterpret_cast(vfnptr); \ + if (sizeof(mfp) == 2*sizeof(void*)) /* gcc */ \ + *(reinterpret_cast(&mfp) + 1) = 0; \ return SH_MFHCls(hookname)::CallEC(reinterpret_cast< ::SourceHook::EmptyClass* >(ptr), mfp, vfnptr, SH_GLOB_SHPTR); \ } \ void __SourceHook_FHM_Reconfigure##hookname(int p_vtblindex, int p_vtbloffs, int p_thisptroffs) \ diff --git a/sourcehook/sourcehook.h b/sourcehook/sourcehook.h index 282a4a4..35dbb5f 100644 --- a/sourcehook/sourcehook.h +++ b/sourcehook/sourcehook.h @@ -852,6 +852,8 @@ SourceHook::CallClass *SH_GET_CALLCLASS(T *p) *reinterpret_cast( (reinterpret_cast(ptr) + SH_MFHCls(hookname)::ms_MFI.thisptroffs + SH_MFHCls(hookname)::ms_MFI.vtbloffs) ) + SH_MFHCls(hookname)::ms_MFI.vtblindex); \ /* patch mfp */ \ *reinterpret_cast(&mfp) = *reinterpret_cast(vfnptr); \ + if (sizeof(mfp) == 2*sizeof(void*)) /* gcc */ \ + *(reinterpret_cast(&mfp) + 1) = 0; \ return SH_MFHCls(hookname)::CallEC(reinterpret_cast< ::SourceHook::EmptyClass* >(ptr), mfp, vfnptr, SH_GLOB_SHPTR); \ } \ void __SourceHook_FHM_Reconfigure##hookname(int p_vtblindex, int p_vtbloffs, int p_thisptroffs) \