diff -r e3d55ad50ba6 -r 08583103ba6f sourcehook/sourcehook.h --- a/sourcehook/sourcehook.h Sun Oct 07 22:45:51 2007 +0000 +++ b/sourcehook/sourcehook.h Sun Oct 07 23:00:38 2007 +0000 @@ -391,6 +391,14 @@ */ virtual void ResetIgnoreHooks(void *vfnptr) = 0; + /** + * @brief Finds the original entry of a virtual function pointer + * + * @param vfnptr The virtual function pointer + * @return The original entry if the virtual function pointer has been patched; NULL otherwise. + */ + virtual void *GetOrigVfnPtrEntry(void *vfnptr) = 0; + ////////////////////////////////////////////////////////////////////////// // For hook managers @@ -466,6 +474,20 @@ return &ref; } }; + + template + void *GetOrigVfnPtrEntry(X *pInstance, MFP mfp, ISourceHook *pSH) + { + SourceHook::MemFuncInfo info = {true, -1, 0, 0}; + SourceHook::GetFuncInfo(pInstance, mfp, info); + + void *vfnptr = reinterpret_cast( + *reinterpret_cast(reinterpret_cast(pInstance) + info.thisptroffs + info.vtbloffs) + info.vtblindex); + + void *origentry = pSH->GetOrigVfnPtrEntry(vfnptr); + + return origentry ? origentry : *reinterpret_cast(vfnptr); + } } /************************************************************************/ @@ -588,6 +610,8 @@ SH_MFHCls(hookname)::ms_MFI.vtbloffs = pvtbloffs; \ } while (0) +#define SH_GET_ORIG_VFNPTR_ENTRY(inst, mfp) (SourceHook::GetOrigVfnPtrEntry(inst, mfp, SH_GLOB_SHPTR)) + // New ADD / REMOVE macros. #define SH_STATIC(func) fastdelegate::MakeDelegate(func) #define SH_MEMBER(inst, func) fastdelegate::MakeDelegate(inst, func)