sourcehook/sourcehook.h
changeset 61 f9b4e9ded36d
parent 58 71016f952503
child 62 90513b7e3d99
     1.1 --- a/sourcehook/sourcehook.h	Thu May 05 14:00:08 2005 +0000
     1.2 +++ b/sourcehook/sourcehook.h	Thu May 05 14:43:40 2005 +0000
     1.3 @@ -63,6 +63,8 @@
     1.4  # define vsnprintf _vsnprintf
     1.5  #endif
     1.6  
     1.7 +#define SH_PTRSIZE sizeof(void*)
     1.8 +										
     1.9  #include "FastDelegate.h"
    1.10  #include "sh_memfuncinfo.h"
    1.11  #include "sh_memory.h"
    1.12 @@ -86,8 +88,8 @@
    1.13  
    1.14  namespace SourceHook
    1.15  {
    1.16 -	const int STRBUF_LEN=8192;		// In bytes, for "vafmt" functions
    1.17 -
    1.18 +	const int STRBUF_LEN=4096;		// In bytes, for "vafmt" functions
    1.19 +	
    1.20  	/**
    1.21  	*	@brief An empty class. No inheritance used. Used for original-function-call hacks
    1.22  	*/
    1.23 @@ -1491,8 +1493,9 @@
    1.24  //////////////////////////////////////////////////////////////////////////
    1.25  // SH_CALL
    1.26  
    1.27 +#if SH_COMP == SH_COMP_MSVC
    1.28  
    1.29 -#define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
    1.30 +# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
    1.31  { \
    1.32  	using namespace ::SourceHook; \
    1.33  	MemFuncInfo mfi; \
    1.34 @@ -1513,6 +1516,34 @@
    1.35  	return (reinterpret_cast<EmptyClass*>(adjustedthisptr)->*u.mfpnew)call; \
    1.36  }
    1.37  
    1.38 +#elif SH_COMP == SH_COMP_GCC
    1.39 +
    1.40 +# define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
    1.41 +{ \
    1.42 +	using namespace ::SourceHook; \
    1.43 +	MemFuncInfo mfi; \
    1.44 +	GetFuncInfo(m_CC->ptr, m_MFP, mfi); \
    1.45 +	OrigVTables::const_iterator iter = m_CC->vt.find(mfi.thisptroffs + mfi.vtbloffs); \
    1.46 +	if (iter == m_CC->vt.end() || mfi.vtblindex >= (int)iter->second.size() || iter->second[mfi.vtblindex] == NULL) \
    1.47 +		return (m_CC->ptr->*m_MFP)call; \
    1.48 +	\
    1.49 +	/* It's hooked. Call the original function. */ \
    1.50 +	union \
    1.51 +	{ \
    1.52 +		RetType(EmptyClass::*mfpnew)prms; \
    1.53 +		struct \
    1.54 +		{ \
    1.55 +			void *addr; \
    1.56 +			intptr_t adjustor; \
    1.57 +		} s; \
    1.58 +	} u; \
    1.59 +	u.s.addr = iter->second[mfi.vtblindex]; \
    1.60 +	u.s.adjustor = mfi.thisptroffs; \
    1.61 +	\
    1.62 +	return (reinterpret_cast<EmptyClass*>(m_CC->ptr)->*u.mfpnew)call; \
    1.63 +}
    1.64 +
    1.65 +#endif
    1.66  
    1.67  namespace SourceHook
    1.68  {