sourcehook/generate/sourcehook.hxx
branchsourcemm-1.6.0
changeset 428 40a9d2f61121
parent 370 4dc28ab1c722
child 429 cadecde4b802
     1.1 --- a/sourcehook/generate/sourcehook.hxx	Thu Oct 04 19:46:28 2007 +0000
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,1503 +0,0 @@
     1.4 -/* ======== SourceHook ========
     1.5 -* Copyright (C) 2004-2007 Metamod:Source Development Team
     1.6 -* No warranties of any kind
     1.7 -*
     1.8 -* License: zlib/libpng
     1.9 -*
    1.10 -* Author(s): Pavol "PM OnoTo" Marko
    1.11 -* ============================
    1.12 -*/
    1.13 -
    1.14 -/**
    1.15 -*	@file sourcehook.h
    1.16 -*	@brief Contains the public SourceHook API
    1.17 -*/
    1.18 -
    1.19 -#ifndef __SOURCEHOOK_H__
    1.20 -#define __SOURCEHOOK_H__
    1.21 -
    1.22 -// Interface revisions:
    1.23 -//  1 - Initial revision
    1.24 -//  2 - Changed to virtual functions for iterators and all queries
    1.25 -//  3 - Added "hook loop status variable"
    1.26 -//  4 - Reentrant
    1.27 -#define SH_IFACE_VERSION 4
    1.28 -
    1.29 -// Impl versions:
    1.30 -// ???
    1.31 -// 4 - addition of hook ids and vp hooks (with them, AddHookNew and RemoveHookNew)
    1.32 -//     This is not a SH_IFACE_VERSION change so that old plugins continue working!
    1.33 -// 5 - addition of direct vp hooks (new hook mode; from now on AddHookNew checks for
    1.34 -//	   invalid hookmode -> impl version won't have to change because of things like this)
    1.35 -#define SH_IMPL_VERSION 5
    1.36 -
    1.37 -// Hookman version:
    1.38 -//  1 - Support for recalls, performance optimisations
    1.39 -#define SH_HOOKMAN_VERSION 1
    1.40 -
    1.41 -// The value of SH_GLOB_SHPTR has to be a pointer to SourceHook::ISourceHook
    1.42 -// It's used in various macros
    1.43 -#ifndef SH_GLOB_SHPTR
    1.44 -#define SH_GLOB_SHPTR g_SHPtr
    1.45 -#endif
    1.46 -
    1.47 -// Used to identify the current plugin
    1.48 -#ifndef SH_GLOB_PLUGPTR
    1.49 -#define SH_GLOB_PLUGPTR g_PLID
    1.50 -#endif
    1.51 -
    1.52 -#ifdef SH_DEBUG
    1.53 -# include <stdio.h>
    1.54 -# include <stdlib.h>
    1.55 -
    1.56 -# define SH_ASSERT(x, info) \
    1.57 -	do { \
    1.58 -		if (!(x)) \
    1.59 -		{ \
    1.60 -			printf("SOURCEHOOK DEBUG ASSERTION FAILED: %s:%u(%s): %s: ", __FILE__, __LINE__, __FUNCTION__, #x); \
    1.61 -			printf info; \
    1.62 -			putchar('\n'); \
    1.63 -			abort(); \
    1.64 -		} \
    1.65 -	} while(0)
    1.66 -
    1.67 -#else
    1.68 -# define SH_ASSERT(x, info)
    1.69 -#endif
    1.70 -
    1.71 -// System
    1.72 -#define SH_SYS_WIN32 1
    1.73 -#define SH_SYS_LINUX 2
    1.74 -
    1.75 -#ifdef _WIN32
    1.76 -# define SH_SYS SH_SYS_WIN32
    1.77 -#elif defined __linux__
    1.78 -# define SH_SYS SH_SYS_LINUX
    1.79 -#else
    1.80 -# error Unsupported system
    1.81 -#endif
    1.82 -
    1.83 -// Compiler
    1.84 -#define SH_COMP_GCC 1
    1.85 -#define SH_COMP_MSVC 2
    1.86 -
    1.87 -#ifdef _MSC_VER
    1.88 -# define SH_COMP SH_COMP_MSVC
    1.89 -#elif defined __GNUC__
    1.90 -# define SH_COMP SH_COMP_GCC
    1.91 -#else
    1.92 -# error Unsupported compiler
    1.93 -#endif
    1.94 -
    1.95 -#if SH_COMP==SH_COMP_MSVC
    1.96 -# define vsnprintf _vsnprintf
    1.97 -#endif
    1.98 -
    1.99 -#if SH_SYS != SH_SYS_WIN32
   1.100 -# include <unistd.h>
   1.101 -#endif
   1.102 -
   1.103 -#define SH_PTRSIZE sizeof(void*)
   1.104 -
   1.105 -#include "FastDelegate.h"
   1.106 -#include "sh_memfuncinfo.h"
   1.107 -
   1.108 -// Good old metamod!
   1.109 -
   1.110 -// Flags returned by a plugin's api function.
   1.111 -// NOTE: order is crucial, as greater/less comparisons are made.
   1.112 -enum META_RES
   1.113 -{
   1.114 -	MRES_IGNORED=0,		// plugin didn't take any action
   1.115 -	MRES_HANDLED,		// plugin did something, but real function should still be called
   1.116 -	MRES_OVERRIDE,		// call real function, but use my return value
   1.117 -	MRES_SUPERCEDE		// skip real function; use my return value
   1.118 -};
   1.119 -
   1.120 -
   1.121 -namespace SourceHook
   1.122 -{
   1.123 -	/**
   1.124 -	*	@brief	Specifies the size (in bytes) for the internal buffer of vafmt(printf-like) function handlers
   1.125 -	*/
   1.126 -	const int STRBUF_LEN=4096;
   1.127 -
   1.128 -	/**
   1.129 -	*	@brief	An empty class. No inheritance used. Used for original-function-call hacks
   1.130 -	*/
   1.131 -	class EmptyClass
   1.132 -	{
   1.133 -	};
   1.134 -
   1.135 -	/**
   1.136 -	*	@brief Implicit cast.
   1.137 -	*/
   1.138 -	template <class In, class Out>
   1.139 -		inline Out implicit_cast(In input)
   1.140 -		{
   1.141 -			return input;
   1.142 -		}
   1.143 -
   1.144 -	/**
   1.145 -	*	@brief A plugin typedef
   1.146 -	*
   1.147 -	*	SourceHook doesn't really care what this is. As long as the ==, != and = operators work on it and every
   1.148 -	*	plugin has a unique identifier, everything is ok.
   1.149 -	*	It should also be possible to set it to 0.
   1.150 -	*/
   1.151 -	typedef int Plugin;
   1.152 -
   1.153 -	struct ProtoInfo
   1.154 -	{
   1.155 -		ProtoInfo(int rtsz, int nop, const int *p) : beginningNull(0), retTypeSize(rtsz), numOfParams(nop), params(p)
   1.156 -		{
   1.157 -		}
   1.158 -		int beginningNull;		//!< To distinguish from old protos (which never begin with 0)
   1.159 -		int retTypeSize;		//!< 0 if void
   1.160 -		int numOfParams;		//!< number of parameters
   1.161 -		const int *params;		//!< params[0]=0 (or -1 for vararg), params[1]=size of first param, ...
   1.162 -	};
   1.163 -
   1.164 -	/**
   1.165 -	*	@brief Specifies the actions for hook managers
   1.166 -	*/
   1.167 -	enum HookManagerAction
   1.168 -	{
   1.169 -		HA_GetInfo = 0,			//!< Store info about the hook manager
   1.170 -		HA_Register,			//!< Save the IHookManagerInfo pointer for future reference
   1.171 -		HA_Unregister			//!< Clear the saved pointer
   1.172 -	};
   1.173 -
   1.174 -	struct IHookManagerInfo;
   1.175 -
   1.176 -	/**
   1.177 -	*	@brief Pointer to hook manager interface function
   1.178 -	*
   1.179 -	*	A "hook manager" is a the only thing that knows the actual protoype of the function at compile time.
   1.180 -	*
   1.181 -	*   @param ha What the hook manager should do
   1.182 -	*	@param hi A pointer to IHookManagerInfo
   1.183 -	*/
   1.184 -	typedef int (*HookManagerPubFunc)(HookManagerAction ha, IHookManagerInfo *hi);
   1.185 -
   1.186 -	class ISHDelegate
   1.187 -	{
   1.188 -	public:
   1.189 -		virtual void DeleteThis() = 0;				// Ugly, I know
   1.190 -		virtual bool IsEqual(ISHDelegate *other) = 0;
   1.191 -	};
   1.192 -
   1.193 -	template <class T> class CSHDelegate : public ISHDelegate
   1.194 -	{
   1.195 -		T m_Deleg;
   1.196 -	public:
   1.197 -		CSHDelegate(T deleg) : m_Deleg(deleg)
   1.198 -		{
   1.199 -		}
   1.200 -
   1.201 -		CSHDelegate(const CSHDelegate &other) : m_Deleg(other.m_Deleg)
   1.202 -		{
   1.203 -		}
   1.204 -
   1.205 -		void DeleteThis()
   1.206 -		{
   1.207 -			delete this;
   1.208 -		}
   1.209 -
   1.210 -		bool IsEqual(ISHDelegate *other)
   1.211 -		{
   1.212 -			return static_cast<CSHDelegate<T>* >(other)->GetDeleg() == GetDeleg();
   1.213 -		}
   1.214 -
   1.215 -		T &GetDeleg()
   1.216 -		{
   1.217 -			return m_Deleg;
   1.218 -		}
   1.219 -	};
   1.220 -
   1.221 -	struct IHookList
   1.222 -	{
   1.223 -		struct IIter
   1.224 -		{
   1.225 -			virtual bool End() = 0;
   1.226 -			virtual void Next() = 0;
   1.227 -			virtual ISHDelegate *Handler() = 0;
   1.228 -			virtual int ThisPtrOffs() = 0;
   1.229 -		};
   1.230 -		virtual IIter *GetIter() = 0;
   1.231 -		virtual void ReleaseIter(IIter *pIter) = 0;
   1.232 -	};
   1.233 -
   1.234 -	struct IIface
   1.235 -	{
   1.236 -		virtual void *GetPtr() = 0;
   1.237 -		virtual IHookList *GetPreHooks() = 0;
   1.238 -		virtual IHookList *GetPostHooks() = 0;
   1.239 -	};
   1.240 -
   1.241 -	struct IVfnPtr
   1.242 -	{
   1.243 -		virtual void *GetVfnPtr() = 0;
   1.244 -		virtual void *GetOrigEntry() = 0;
   1.245 -
   1.246 -		virtual IIface *FindIface(void *ptr) = 0;
   1.247 -	};
   1.248 -
   1.249 -	struct IHookManagerInfo
   1.250 -	{
   1.251 -		virtual IVfnPtr *FindVfnPtr(void *vfnptr) = 0;
   1.252 -
   1.253 -		virtual void SetInfo(int vtbloffs, int vtblidx, const char *proto) = 0;
   1.254 -		virtual void SetHookfuncVfnptr(void *hookfunc_vfnptr) = 0;
   1.255 -
   1.256 -		// Added 23.12.2005 (yup! I'm coding RIGHT BEFORE CHRISTMAS!)
   1.257 -		// If the hookman doesn't set this, it defaults 0
   1.258 -		// SourceHook prefers hookmans with higher version numbers
   1.259 -		virtual void SetVersion(int version) = 0;
   1.260 -	};
   1.261 -
   1.262 -	class AutoHookIter
   1.263 -	{
   1.264 -		IHookList *m_pList;
   1.265 -		IHookList::IIter *m_pIter;
   1.266 -	public:
   1.267 -		AutoHookIter(IHookList *pList)
   1.268 -			: m_pList(pList), m_pIter(pList->GetIter())
   1.269 -		{
   1.270 -		}
   1.271 -
   1.272 -		~AutoHookIter()
   1.273 -		{
   1.274 -			if (m_pList)
   1.275 -				m_pList->ReleaseIter(m_pIter);
   1.276 -		}
   1.277 -
   1.278 -		bool End()
   1.279 -		{
   1.280 -			return m_pIter->End();
   1.281 -		}
   1.282 -
   1.283 -		void Next()
   1.284 -		{
   1.285 -			m_pIter->Next();
   1.286 -		}
   1.287 -
   1.288 -		ISHDelegate *Handler()
   1.289 -		{
   1.290 -			return m_pIter->Handler();
   1.291 -		}
   1.292 -
   1.293 -		int ThisPtrOffs()
   1.294 -		{
   1.295 -			return m_pIter->ThisPtrOffs();
   1.296 -		}
   1.297 -
   1.298 -		void SetToZero()
   1.299 -		{
   1.300 -			m_pList = 0;
   1.301 -		}
   1.302 -	};
   1.303 -
   1.304 -	template<class B> struct DeprecatedCallClass
   1.305 -	{
   1.306 -		virtual B *GetThisPtr() = 0;
   1.307 -		virtual void *GetOrigFunc(int vtbloffs, int vtblidx) = 0;
   1.308 -	};
   1.309 -
   1.310 -	// 09.08.2008 (6 AM, I just woke up, the others are still sleeping so i finally can use this notebook !!)
   1.311 -	// - Today is an important day.
   1.312 -	// I'm adding support for functions which return references.
   1.313 -
   1.314 -	// How it works:
   1.315 -	//  SH_SETUPCALLS doesn't use plain rettype to store the temporary return values (plugin ret, orig ret,
   1.316 -	//  override ret) anymore; instead, it uses SourceHook::ReferenceCarrier<rettype>::type
   1.317 -	//  this is typedefed to the original rettype normally, but if the rettype is a reference, it's a special class
   1.318 -	//  which stores the reference as a pointer, and implements constructors, operator= and a conversion operator.
   1.319 -	//  special cases were needed for getoverrideret / getorigret; these are implemented through the
   1.320 -	//  SourceHook::MacroRefHelpers structs.
   1.321 -	//  Furthermore, SetOverrideRet had to be changed a bit; see SourceHook::OverrideFunctor somewhere down in this file.
   1.322 -	template <class T> struct ReferenceCarrier
   1.323 -	{
   1.324 -		typedef T type;
   1.325 -	};
   1.326 -
   1.327 -	template <class T> struct ReferenceCarrier<T&>
   1.328 -	{
   1.329 -		class type
   1.330 -		{
   1.331 -			T *m_StoredRef;
   1.332 -		public:
   1.333 -			type() : m_StoredRef(NULL)
   1.334 -			{
   1.335 -			}
   1.336 -			type(T& ref) : m_StoredRef(&ref)
   1.337 -			{
   1.338 -			}
   1.339 -
   1.340 -			T& operator= (T& ref)
   1.341 -			{
   1.342 -				m_StoredRef = &ref;
   1.343 -				return ref;
   1.344 -			}
   1.345 -
   1.346 -			operator T& () const
   1.347 -			{
   1.348 -				return *m_StoredRef;
   1.349 -			}
   1.350 -		};
   1.351 -	};
   1.352 -
   1.353 -	/**
   1.354 -	*	@brief The main SourceHook interface
   1.355 -	*/
   1.356 -	class ISourceHook
   1.357 -	{
   1.358 -	public:
   1.359 -		/**
   1.360 -		*	@brief Return interface version
   1.361 -		*/
   1.362 -		virtual int GetIfaceVersion() = 0;
   1.363 -
   1.364 -		/**
   1.365 -		*	@brief Return implementation version
   1.366 -		*/
   1.367 -		virtual int GetImplVersion() = 0;
   1.368 -
   1.369 -		/**
   1.370 -		*	@brief Add a hook.
   1.371 -		*
   1.372 -		*	@return True if the function succeeded, false otherwise
   1.373 -		*
   1.374 -		*	@param plug The unique identifier of the plugin that calls this function
   1.375 -		*	@param iface The interface pointer
   1.376 -		*	@param ifacesize The size of the class iface points to
   1.377 -		*	@param myHookMan A hook manager function that should be capable of handling the function
   1.378 -		*	@param handler A pointer to a FastDelegate containing the hook handler
   1.379 -		*	@param post Set to true if you want a post handler
   1.380 -		*/
   1.381 -		virtual bool AddHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.382 -			ISHDelegate *handler, bool post) = 0;
   1.383 -
   1.384 -		/**
   1.385 -		*	@brief Removes a hook.
   1.386 -		*
   1.387 -		*	@return True if the function succeeded, false otherwise
   1.388 -		*
   1.389 -		*	@param plug The unique identifier of the plugin that calls this function
   1.390 -		*	@param iface The interface pointer
   1.391 -		*	@param myHookMan A hook manager function that should be capable of handling the function
   1.392 -		*	@param handler A pointer to a FastDelegate containing the hook handler
   1.393 -		*	@param post Set to true if you want a post handler
   1.394 -		*/
   1.395 -		virtual bool RemoveHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.396 -			ISHDelegate *handler, bool post) = 0;
   1.397 -
   1.398 -		/**
   1.399 -		*	@brief Checks whether a plugin has (a) hook manager(s) that is/are currently used by other plugins
   1.400 -		*
   1.401 -		*	@param plug The unique identifier of the plugin in question
   1.402 -		*/
   1.403 -		virtual bool IsPluginInUse(Plugin plug) = 0;
   1.404 -
   1.405 -		/**
   1.406 -		*	@brief Return a pointer to a callclass. Generate a new one if required.
   1.407 -		*
   1.408 -		*	@param iface The interface pointer
   1.409 -		*	@param size Size of the class instance
   1.410 -		*/
   1.411 -		virtual DeprecatedCallClass<void> *GetCallClass(void *iface, size_t size) = 0;
   1.412 -
   1.413 -		/**
   1.414 -		*	@brief Release a callclass
   1.415 -		*
   1.416 -		*	@param ptr Pointer to the callclass
   1.417 -		*/
   1.418 -		virtual void ReleaseCallClass(DeprecatedCallClass<void> *ptr) = 0;
   1.419 -
   1.420 -		virtual void SetRes(META_RES res) = 0;				//!< Sets the meta result
   1.421 -		virtual META_RES GetPrevRes() = 0;					//!< Gets the meta result of the
   1.422 -															//!<  previously calledhandler
   1.423 -		virtual META_RES GetStatus() = 0;					//!< Gets the highest meta result
   1.424 -		virtual const void *GetOrigRet() = 0;				//!< Gets the original result.
   1.425 -															//!<  If not in post function, undefined
   1.426 -		virtual const void *GetOverrideRet() = 0;			//!< Gets the override result.
   1.427 -															//!<  If none is specified, NULL
   1.428 -		virtual void *GetIfacePtr() = 0;					//!< Gets the interface pointer
   1.429 -		//////////////////////////////////////////////////////////////////////////
   1.430 -		// For hook managers
   1.431 -		virtual void HookLoopBegin(IIface *pIface) = 0;			//!< Should be called when a hook loop begins
   1.432 -		virtual void HookLoopEnd() = 0;							//!< Should be called when a hook loop exits
   1.433 -		virtual void SetCurResPtr(META_RES *mres) = 0;			//!< Sets pointer to the current meta result
   1.434 -		virtual void SetPrevResPtr(META_RES *mres) = 0;			//!< Sets pointer to previous meta result
   1.435 -		virtual void SetStatusPtr(META_RES *mres) = 0;			//!< Sets pointer to the status variable
   1.436 -		virtual void SetIfacePtrPtr(void **pp) = 0;				//!< Sets pointer to the interface this pointer
   1.437 -		virtual void SetOrigRetPtr(const void *ptr) = 0;		//!< Sets the original return pointer
   1.438 -		virtual void SetOverrideRetPtr(void *ptr) = 0;			//!< Sets the override result pointer
   1.439 -		virtual bool ShouldContinue() = 0;						//!< Returns false if the hook loop should exit
   1.440 -
   1.441 -		/**
   1.442 -		*	@brief Remove a hook manager. Auto-removes all hooks attached to it from plugin plug.
   1.443 -		*
   1.444 -		*	@param plug The owner of the hook manager
   1.445 -		*   @param pubFunc The hook manager's info function
   1.446 -		*/
   1.447 -		virtual void RemoveHookManager(Plugin plug, HookManagerPubFunc pubFunc) = 0;
   1.448 -
   1.449 -		virtual void DoRecall() = 0;							//!< Initiates a recall sequence
   1.450 -		/*
   1.451 -			HOW RECALLS WORK:
   1.452 -			
   1.453 -			The problem:
   1.454 -				Users want the ability to change parameters of the called function
   1.455 -				from inside their handler.
   1.456 -			The solution:
   1.457 -				1) Mark as "recall"
   1.458 -				2) Recall the function
   1.459 -				3) => SH's hook func gets called:
   1.460 -				  4) The first iterator points at the first hook the last hookfunc didn't execute yet
   1.461 -				  5) does all iteration and returns normally
   1.462 -		        6) The user's handler returns immediately
   1.463 -				7) The hook func returns immediately as well
   1.464 -
   1.465 -				Also note that the recalled hookfunc starts with the status the recalling hookfunc
   1.466 -				ended with. The last handler (doing the recall) is also able to specify its own
   1.467 -				META_RES.
   1.468 -		*/
   1.469 -
   1.470 -		virtual void *GetOverrideRetPtr() = 0;		//!< Returns the pointer set by SetOverrideRetPtr
   1.471 -
   1.472 -		/**
   1.473 -		*	@brief Set up the hook loop. Equivalent to calling:
   1.474 -		*	SetStatusPtr, SetPrevResPtr, SetCurResPtr, SetIfacePtrPtr, SetOrigRetPtr, Get/SetOverrideRetPtr
   1.475 -		*
   1.476 -		*	@param statusPtr		pointer to status variable
   1.477 -		*	@param prevResPtr		pointer to previous result variable
   1.478 -		*	@param curResPtr		pointer to current result variable
   1.479 -		*	@param ifacePtrPtr		pointer to interface this pointer variable
   1.480 -		*	@param origRetPr		pointer to original return value variable. NULL for void funcs
   1.481 -		*	@param overrideRetPtr	pointer to override return value variable. NULL for void funcs
   1.482 -		*	
   1.483 -		*	@return Override Return Pointer the hookfunc should use (may differ from overrideRetPtr
   1.484 -		*		when the hook func is being called as part of a recall
   1.485 -		*/
   1.486 -		virtual void *SetupHookLoop(META_RES *statusPtr, META_RES *prevResPtr, META_RES *curResPtr,
   1.487 -			void **ifacePtrPtr, const void *origRetPtr, void *overrideRetPtr) = 0;
   1.488 -
   1.489 -		/**
   1.490 -		*	@brief Modes for the new AddHook
   1.491 -		*/
   1.492 -		enum AddHookMode
   1.493 -		{
   1.494 -			Hook_Normal,
   1.495 -			Hook_VP,
   1.496 -			Hook_DVP
   1.497 -		}; 
   1.498 -
   1.499 -		/**
   1.500 -		*	@brief Add a (VP) hook.
   1.501 -		*
   1.502 -		*	@return non-zero hook id on success, 0 otherwise
   1.503 -		*
   1.504 -		*	@param plug The unique identifier of the plugin that calls this function
   1.505 -		*	@param mode	Can be either Hook_Normal or Hook_VP (vtable-wide hook)
   1.506 -		*	@param iface The interface pointer
   1.507 -		*	@param ifacesize The size of the class iface points to
   1.508 -		*	@param myHookMan A hook manager function that should be capable of handling the function
   1.509 -		*	@param handler A pointer to a FastDelegate containing the hook handler
   1.510 -		*	@param post Set to true if you want a post handler
   1.511 -		*/
   1.512 -		virtual int AddHookNew(Plugin plug, AddHookMode mode, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.513 -			ISHDelegate *handler, bool post) = 0;
   1.514 -
   1.515 -		/**
   1.516 -		*	@brief Remove a VP hook by ID.
   1.517 -		*
   1.518 -		*	@return true on success, false otherwise
   1.519 -		*
   1.520 -		*	@param plug The unique identifier of the plugin that calls this function
   1.521 -		*	@param hookid The hook id (returned by AddHookNew)
   1.522 -		*/
   1.523 -		virtual bool RemoveHookByID(Plugin plug, int hookid) = 0;
   1.524 -
   1.525 -		/**
   1.526 -		*	@brief Makes sure that hooks are going to be ignored on the next call of vfnptr
   1.527 -		*
   1.528 -		*	@param plug The unique identifier of the plugin that calls this function
   1.529 -		*	@param vfnptr The virtual function pointer of the function in question
   1.530 -		*/
   1.531 -		virtual void SetIgnoreHooks(Plugin plug, void *vfnptr) = 0;
   1.532 -
   1.533 -		/**
   1.534 -		*	@brief Reverses SetIgnoreHooks' effect
   1.535 -		*
   1.536 -		*	@param plug The unique identifier of the plugin that calls this function
   1.537 -		*	@param vfnptr The virtual function pointer of the function in question
   1.538 -		*/
   1.539 -		virtual void ResetIgnoreHooks(Plugin plug, void *vfnptr) = 0;
   1.540 -
   1.541 -		/**
   1.542 -		*	@brief Finds the original entry of a virtual function pointer
   1.543 -		*
   1.544 -		*	@param vfnptr The virtual function pointer
   1.545 -		*	@return The original entry if the virtual function pointer has been patched; NULL otherwise.
   1.546 -		*/
   1.547 -		virtual void *GetOrigVfnPtrEntry(void *vfnptr) = 0;
   1.548 -	};
   1.549 -
   1.550 -	// For META_RESULT_ORIG_RET and META_RESULT_OVERRIDE_RET:
   1.551 -	//  These have to be able to return references. If T is a reference, the pointers returned
   1.552 -	//  from the SH_GLOB_SHPTR are pointers to instances of ReferenceCarrier<T>::type.
   1.553 -	template <class T> struct MacroRefHelpers
   1.554 -	{
   1.555 -		inline static const T* GetOrigRet(ISourceHook *shptr)
   1.556 -		{
   1.557 -			return reinterpret_cast<const T*>(shptr->GetOrigRet());
   1.558 -		}
   1.559 -		inline static const T* GetOverrideRet(ISourceHook *shptr)
   1.560 -		{
   1.561 -			return reinterpret_cast<const T*>(shptr->GetOverrideRet());
   1.562 -		}
   1.563 -	};
   1.564 -
   1.565 -	template <class T> struct MacroRefHelpers<T&>
   1.566 -	{
   1.567 -		inline static T* GetOrigRet(ISourceHook *shptr)
   1.568 -		{
   1.569 -			T &ref = *reinterpret_cast<const typename ReferenceCarrier<T&>::type *>(shptr->GetOrigRet());
   1.570 -			return &ref;
   1.571 -		}
   1.572 -		inline static T* GetOverrideRet(ISourceHook *shptr)
   1.573 -		{
   1.574 -			T &ref = *reinterpret_cast<const typename ReferenceCarrier<T&>::type *>(shptr->GetOverrideRet());
   1.575 -			return &ref;
   1.576 -		}
   1.577 -	};
   1.578 -
   1.579 -	// For source-level compatibility
   1.580 -	template <class T> struct CallClass
   1.581 -	{
   1.582 -		T *ptr;
   1.583 -
   1.584 -		CallClass(T *p) : ptr(p)
   1.585 -		{
   1.586 -		}
   1.587 -
   1.588 -		operator T*()
   1.589 -		{
   1.590 -			return ptr;
   1.591 -		}
   1.592 -	};
   1.593 -
   1.594 -	typedef CallClass<void> GenericCallClass;
   1.595 -	typedef CallClass<EmptyClass> ManualCallClass;
   1.596 -
   1.597 -	template <class T>
   1.598 -	CallClass<T> *GetCallClass(T *p)
   1.599 -	{
   1.600 -		return new CallClass<T>(p);
   1.601 -	}
   1.602 -
   1.603 -	template <class T>
   1.604 -	void ReleaseCallClass(CallClass<T> *p)
   1.605 -	{
   1.606 -		delete p;
   1.607 -	}
   1.608 -
   1.609 -	template <class X, class MFP>
   1.610 -	void *GetOrigVfnPtrEntry(X *pInstance, MFP mfp, ISourceHook *pSH)
   1.611 -	{
   1.612 -		SourceHook::MemFuncInfo info = {true, -1, 0, 0};
   1.613 -		SourceHook::GetFuncInfo(pInstance, mfp, info);
   1.614 -
   1.615 -		void *vfnptr = reinterpret_cast<void*>(
   1.616 -			*reinterpret_cast<void***>(reinterpret_cast<char*>(pInstance) + info.thisptroffs + info.vtbloffs) + info.vtblindex);
   1.617 -
   1.618 -		void *origentry = pSH->GetOrigVfnPtrEntry(vfnptr);
   1.619 -		
   1.620 -		return origentry ? origentry : *reinterpret_cast<void**>(vfnptr);
   1.621 -	}
   1.622 -}
   1.623 -
   1.624 -/************************************************************************/
   1.625 -/* High level interface                                                 */
   1.626 -/************************************************************************/
   1.627 -#define META_RESULT_STATUS					SH_GLOB_SHPTR->GetStatus()
   1.628 -#define META_RESULT_PREVIOUS				SH_GLOB_SHPTR->GetPrevRes()
   1.629 -#define META_RESULT_ORIG_RET(type)			*SourceHook::MacroRefHelpers<type>::GetOrigRet(SH_GLOB_SHPTR)
   1.630 -#define META_RESULT_OVERRIDE_RET(type)		*SourceHook::MacroRefHelpers<type>::GetOverrideRet(SH_GLOB_SHPTR)
   1.631 -#define META_IFACEPTR(type)					reinterpret_cast<type*>(SH_GLOB_SHPTR->GetIfacePtr())
   1.632 -
   1.633 -#define SET_META_RESULT(result)				SH_GLOB_SHPTR->SetRes(result)
   1.634 -#define RETURN_META(result)					do { SET_META_RESULT(result); return; } while(0)
   1.635 -#define RETURN_META_VALUE(result, value)	do { SET_META_RESULT(result); return (value); } while(0)
   1.636 -
   1.637 -// If a hook on a function which returns a reference does not want to specify a return value,
   1.638 -// it can use this macro.
   1.639 -//   ONLY USE THIS WITH MRES_IGNORED AND MRES_HANDLED !!!
   1.640 -#define RETURN_META_NOREF(result, rettype)	do { SET_META_RESULT(result); return reinterpret_cast<rettype>(*SH_GLOB_SHPTR); } while(0)
   1.641 -
   1.642 -// only call these from the hook handlers directly!
   1.643 -// :TODO: enforce it ?
   1.644 -
   1.645 -// Why take a memfuncptr instead of iface and func when we have to deduce the iface anyway now?
   1.646 -// Well, without it, there'd be no way to specify which overloaded version we want in _VALUE
   1.647 -
   1.648 -// SourceHook::SetOverrideRet is defined later.
   1.649 -#define RETURN_META_NEWPARAMS(result, memfuncptr, newparams) \
   1.650 -	do { \
   1.651 -		SET_META_RESULT(result); \
   1.652 -		SH_GLOB_SHPTR->DoRecall(); \
   1.653 -		(SourceHook::RecallGetIface(SH_GLOB_SHPTR, memfuncptr)->*(memfuncptr)) newparams; \
   1.654 -		RETURN_META(MRES_SUPERCEDE); \
   1.655 -	} while (0)
   1.656 -
   1.657 -#define RETURN_META_VALUE_NEWPARAMS(result, value, memfuncptr, newparams) \
   1.658 -	do { \
   1.659 -		SET_META_RESULT(result); \
   1.660 -		SH_GLOB_SHPTR->DoRecall(); \
   1.661 -		if ((result) >= MRES_OVERRIDE) \
   1.662 -		{ \
   1.663 -			/* meh, set the override result here because we don't get a chance to return */ \
   1.664 -			/* before continuing the hook loop through the recall */ \
   1.665 -			SourceHook::SetOverrideResult(memfuncptr)(SH_GLOB_SHPTR, value); \
   1.666 -		} \
   1.667 -		RETURN_META_VALUE(MRES_SUPERCEDE, \
   1.668 -			(SourceHook::RecallGetIface(SH_GLOB_SHPTR, memfuncptr)->*(memfuncptr)) newparams); \
   1.669 -	} while (0)
   1.670 -
   1.671 -// :TODO: thisptroffs in MNEWPARAMS ??
   1.672 -
   1.673 -#if SH_COMP == SH_COMP_MSVC
   1.674 -
   1.675 -#define SOUREHOOK__MNEWPARAMS_PREPAREMFP(hookname) \
   1.676 -	union \
   1.677 -	{ \
   1.678 -		SH_MFHCls(hookname)::ECMFP mfp; \
   1.679 -		void *addr; \
   1.680 -	} u; \
   1.681 -	SourceHook::EmptyClass *thisptr = reinterpret_cast<SourceHook::EmptyClass*>(SH_GLOB_SHPTR->GetIfacePtr()); \
   1.682 -	u.addr = (*reinterpret_cast<void***>(reinterpret_cast<char*>(thisptr) + SH_MFHCls(hookname)::ms_MFI.vtbloffs))[ \
   1.683 -		SH_MFHCls(hookname)::ms_MFI.vtblindex];
   1.684 -
   1.685 -#elif SH_COMP == SH_COMP_GCC
   1.686 -
   1.687 -#define SOUREHOOK__MNEWPARAMS_PREPAREMFP(hookname) \
   1.688 -	union \
   1.689 -	{ \
   1.690 -		SH_MFHCls(hookname)::ECMFP mfp; \
   1.691 -		struct \
   1.692 -		{ \
   1.693 -			void *addr; \
   1.694 -			intptr_t adjustor; \
   1.695 -		} s; \
   1.696 -	} u; \
   1.697 -	SourceHook::EmptyClass *thisptr = reinterpret_cast<SourceHook::EmptyClass*>(SH_GLOB_SHPTR->GetIfacePtr()); \
   1.698 -	u.s.addr = (*reinterpret_cast<void***>(reinterpret_cast<char*>(thisptr) + SH_MFHCls(hookname)::ms_MFI.vtbloffs))[ \
   1.699 -		SH_MFHCls(hookname)::ms_MFI.vtblindex]; \
   1.700 -	u.s.adjustor = 0;
   1.701 -
   1.702 -#endif
   1.703 -
   1.704 -#define RETURN_META_MNEWPARAMS(result, hookname, newparams) \
   1.705 -	do { \
   1.706 -		SET_META_RESULT(result); \
   1.707 -		SH_GLOB_SHPTR->DoRecall(); \
   1.708 -		SOUREHOOK__MNEWPARAMS_PREPAREMFP(hookname); \
   1.709 -		(thisptr->*(u.mfp)) newparams; \
   1.710 -		RETURN_META(MRES_SUPERCEDE); \
   1.711 -	} while (0)
   1.712 -
   1.713 -#define RETURN_META_VALUE_MNEWPARAMS(result, value, hookname, newparams) \
   1.714 -	do { \
   1.715 -		SET_META_RESULT(result); \
   1.716 -		SH_GLOB_SHPTR->DoRecall(); \
   1.717 -		if ((result) >= MRES_OVERRIDE) \
   1.718 -		{ \
   1.719 -			/* see RETURN_META_VALUE_NEWPARAMS */ \
   1.720 -			SourceHook::SetOverrideResult<SH_MFHCls(hookname)::RetType>(SH_GLOB_SHPTR, value); \
   1.721 -		} \
   1.722 -		SOUREHOOK__MNEWPARAMS_PREPAREMFP(hookname); \
   1.723 -		RETURN_META_VALUE(MRES_SUPERCEDE, (thisptr->*(u.mfp)) newparams); \
   1.724 -	} while (0)
   1.725 -
   1.726 -#define SH_MANUALHOOK_RECONFIGURE(hookname, pvtblindex, pvtbloffs, pthisptroffs) \
   1.727 -	do { \
   1.728 -		SH_GLOB_SHPTR->RemoveHookManager(SH_GLOB_PLUGPTR, SH_MFHCls(hookname)::HookManPubFunc); \
   1.729 -		SH_MFHCls(hookname)::ms_MFI.thisptroffs = pthisptroffs; \
   1.730 -		SH_MFHCls(hookname)::ms_MFI.vtblindex = pvtblindex; \
   1.731 -		SH_MFHCls(hookname)::ms_MFI.vtbloffs = pvtbloffs; \
   1.732 -	} while (0)
   1.733 -
   1.734 -
   1.735 -#define SH_GET_ORIG_VFNPTR_ENTRY(inst, mfp) (SourceHook::GetOrigVfnPtrEntry(inst, mfp, SH_GLOB_SHPTR))
   1.736 -
   1.737 -// For source-level compatibility
   1.738 -
   1.739 -#define SH_GET_CALLCLASS(ptr) SourceHook::GetCallClass(ptr)
   1.740 -#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
   1.741 -#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseCallClass(ptr)
   1.742 -
   1.743 -// New ADD / REMOVE macros.
   1.744 -#define SH_STATIC(func) fastdelegate::MakeDelegate(func)
   1.745 -#define SH_MEMBER(inst, func) fastdelegate::MakeDelegate(inst, func)
   1.746 -
   1.747 -#define SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.748 -	__SourceHook_FHAdd##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.749 -	post, handler)
   1.750 -
   1.751 -#define SH_REMOVE_HOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.752 -	__SourceHook_FHRemove##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.753 -	post, handler) 
   1.754 -
   1.755 -#define SH_ADD_MANUALHOOK(hookname, ifaceptr, handler, post) \
   1.756 -	__SourceHook_FHMAdd##hookname(reinterpret_cast<void*>(ifaceptr), post, handler)
   1.757 -
   1.758 -#define SH_REMOVE_MANUALHOOK(hookname, ifaceptr, handler, post) \
   1.759 -	__SourceHook_FHMRemove##hookname(reinterpret_cast<void*>(ifaceptr), post, handler) 
   1.760 -
   1.761 -#define SH_ADD_VPHOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.762 -	__SourceHook_FHVPAdd##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.763 -	post, handler, false)
   1.764 -
   1.765 -#define SH_ADD_DVPHOOK(ifacetype, ifacefunc, vtableptr, handler, post) \
   1.766 -	__SourceHook_FHVPAdd##ifacetype##ifacefunc(reinterpret_cast<void*>(vtableptr), \
   1.767 -	post, handler, true)
   1.768 -
   1.769 -#define SH_ADD_MANUALVPHOOK(hookname, ifaceptr, handler, post) \
   1.770 -	__SourceHook_FHMVPAdd##hookname(reinterpret_cast<void*>(ifaceptr), post, handler, false)
   1.771 -
   1.772 -#define SH_ADD_MANUALDVPHOOK(hookname, vtableptr, handler, post) \
   1.773 -	__SourceHook_FHMVPAdd##hookname(reinterpret_cast<void*>(vtableptr), post, handler, true)
   1.774 -
   1.775 -#define SH_REMOVE_HOOK_ID(hookid) \
   1.776 -	(SH_GLOB_SHPTR->RemoveHookByID(SH_GLOB_PLUGPTR, hookid))
   1.777 -
   1.778 -// Old macros
   1.779 -// !! These are now deprecated. Instead, use one of these:
   1.780 -//  SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, SH_STATIC(handler), post)
   1.781 -//  SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, SH_MEMBER(inst, func), post)
   1.782 -
   1.783 -#define SH_ADD_HOOK_STATICFUNC(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.784 -	SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, SH_STATIC(handler), post)
   1.785 -#define SH_ADD_HOOK_MEMFUNC(ifacetype, ifacefunc, ifaceptr, handler_inst, handler_func, post) \
   1.786 -	SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, SH_MEMBER(handler_inst, handler_func), post)
   1.787 -
   1.788 -//  SH_REMOVE_HOOK(ifacetype, ifacefunc, ifaceptr, SH_STATIC(handler), post)
   1.789 -//  SH_REMOVE_HOOK(ifacetype, ifacefunc, ifaceptr, SH_MEMBER(inst, func), post)
   1.790 -
   1.791 -#define SH_REMOVE_HOOK_STATICFUNC(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.792 -	SH_REMOVE_HOOK(ifacetype, ifacefunc, ifaceptr, SH_STATIC(handler), post)
   1.793 -#define SH_REMOVE_HOOK_MEMFUNC(ifacetype, ifacefunc, ifaceptr, handler_inst, handler_func, post) \
   1.794 -	SH_REMOVE_HOOK(ifacetype, ifacefunc, ifaceptr, SH_MEMBER(handler_inst, handler_func), post)
   1.795 -
   1.796 -//  SH_ADD_MANUALHOOK(hookname, ifaceptr, SH_STATIC(handler), post)
   1.797 -//  SH_ADD_MANUALHOOK(hookname, ifaceptr, SH_MEMBER(inst, func), post)
   1.798 -
   1.799 -#define SH_ADD_MANUALHOOK_STATICFUNC(hookname, ifaceptr, handler, post) \
   1.800 -	SH_ADD_MANUALHOOK(hookname, ifaceptr, SH_STATIC(handler), post)
   1.801 -#define SH_ADD_MANUALHOOK_MEMFUNC(hookname, ifaceptr, handler_inst, handler_func, post) \
   1.802 -	SH_ADD_MANUALHOOK(hookname, ifaceptr, SH_MEMBER(handler_inst, handler_func), post)
   1.803 -
   1.804 -//  SH_REMOVE_MANUALHOOK(hookname, ifaceptr, SH_STATIC(handler), post)
   1.805 -//  SH_REMOVE_MANUALHOOK(hookname, ifaceptr, SH_MEMBER(inst, func), post)
   1.806 -
   1.807 -#define SH_REMOVE_MANUALHOOK_STATICFUNC(hookname, ifaceptr, handler, post) \
   1.808 -	SH_REMOVE_MANUALHOOK(hookname, ifaceptr, SH_STATIC(handler), post)
   1.809 -#define SH_REMOVE_MANUALHOOK_MEMFUNC(hookname, ifaceptr, handler_inst, handler_func, post) \
   1.810 -	SH_REMOVE_MANUALHOOK(hookname, ifaceptr, SH_MEMBER(handler_inst, handler_func), post)  
   1.811 -
   1.812 -#define SH_NOATTRIB
   1.813 -
   1.814 -
   1.815 -
   1.816 -
   1.817 -#if SH_COMP == SH_COMP_MSVC
   1.818 -# define SH_SETUP_MFP(mfp) \
   1.819 -	reinterpret_cast<void**>(&mfp)[0] = vfnptr_origentry;
   1.820 -#elif SH_COMP == SH_COMP_GCC
   1.821 -# define SH_SETUP_MFP(mfp) \
   1.822 -	reinterpret_cast<void**>(&mfp)[0] = vfnptr_origentry; \
   1.823 -	reinterpret_cast<void**>(&mfp)[1] = 0;
   1.824 -#else
   1.825 -# error Not supported yet.
   1.826 -#endif
   1.827 -
   1.828 -//////////////////////////////////////////////////////////////////////////
   1.829 -#define SH_FHCls(ift, iff, ov) __SourceHook_FHCls_##ift##iff##ov
   1.830 -#define SH_MFHCls(hookname) __SourceHook_MFHCls_##hookname
   1.831 -
   1.832 -#define SHINT_MAKE_HOOKMANPUBFUNC(ifacetype, ifacefunc, overload, funcptr) \
   1.833 -	SH_FHCls(ifacetype,ifacefunc,overload)() \
   1.834 -	{ \
   1.835 -		GetFuncInfo(funcptr, ms_MFI); \
   1.836 -	} \
   1.837 -	\
   1.838 -	static int HookManPubFunc(::SourceHook::HookManagerAction action, ::SourceHook::IHookManagerInfo *param) \
   1.839 -	{ \
   1.840 -		using namespace ::SourceHook; \
   1.841 -		GetFuncInfo(funcptr, ms_MFI); \
   1.842 -		/* Verify interface version */ \
   1.843 -		if (SH_GLOB_SHPTR->GetIfaceVersion() != SH_IFACE_VERSION) \
   1.844 -			return 1; \
   1.845 -		if (SH_GLOB_SHPTR->GetImplVersion() < SH_IMPL_VERSION) \
   1.846 -			return 1; \
   1.847 -		\
   1.848 -		if (action == HA_GetInfo) \
   1.849 -		{ \
   1.850 -			param->SetVersion(SH_HOOKMAN_VERSION); \
   1.851 -			param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
   1.852 -				reinterpret_cast<const char*>(&ms_Proto)); \
   1.853 -			\
   1.854 -			MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.855 -			GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \
   1.856 -			param->SetHookfuncVfnptr( \
   1.857 -				reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
   1.858 -			return 0; \
   1.859 -		} \
   1.860 -		else if (action == HA_Register) \
   1.861 -		{ \
   1.862 -			ms_HI = param; \
   1.863 -			return 0; \
   1.864 -		} \
   1.865 -		else if (action == HA_Unregister) \
   1.866 -		{ \
   1.867 -			ms_HI = NULL; \
   1.868 -			return 0; \
   1.869 -		} \
   1.870 -		else \
   1.871 -			return 1; \
   1.872 -	}
   1.873 -
   1.874 -// It has to be possible to use the macros in namespaces
   1.875 -// -> So we need to access and extend the global SourceHook namespace
   1.876 -// We use a namespace alias for this
   1.877 -#define SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, funcptr) \
   1.878 -	struct SH_FHCls(ifacetype,ifacefunc,overload) \
   1.879 -	{ \
   1.880 -		static SH_FHCls(ifacetype,ifacefunc,overload) ms_Inst; \
   1.881 -		static ::SourceHook::MemFuncInfo ms_MFI; \
   1.882 -		static ::SourceHook::IHookManagerInfo *ms_HI; \
   1.883 -		static ::SourceHook::ProtoInfo ms_Proto; \
   1.884 -		SHINT_MAKE_HOOKMANPUBFUNC(ifacetype, ifacefunc, overload, funcptr)
   1.885 -
   1.886 -#define SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, funcptr) \
   1.887 -	}; \
   1.888 -	SH_FHCls(ifacetype,ifacefunc,overload) SH_FHCls(ifacetype,ifacefunc,overload)::ms_Inst; \
   1.889 -	::SourceHook::MemFuncInfo SH_FHCls(ifacetype,ifacefunc,overload)::ms_MFI; \
   1.890 -	::SourceHook::IHookManagerInfo *SH_FHCls(ifacetype,ifacefunc,overload)::ms_HI; \
   1.891 -	int __SourceHook_FHAdd##ifacetype##ifacefunc(void *iface, bool post, \
   1.892 -		SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
   1.893 -	{ \
   1.894 -		using namespace ::SourceHook; \
   1.895 -		MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.896 -		GetFuncInfo(funcptr, mfi); \
   1.897 -		if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
   1.898 -			return false; /* No non-virtual functions / virtual inheritance supported */ \
   1.899 -		\
   1.900 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, ::SourceHook::ISourceHook::Hook_Normal, iface, mfi.thisptroffs, \
   1.901 -			SH_FHCls(ifacetype,ifacefunc,overload)::HookManPubFunc, \
   1.902 -			new CSHDelegate<SH_FHCls(ifacetype,ifacefunc,overload)::FD>(handler), post); \
   1.903 -	} \
   1.904 -	int __SourceHook_FHVPAdd##ifacetype##ifacefunc(void *iface, bool post, \
   1.905 -		SH_FHCls(ifacetype,ifacefunc,overload)::FD handler, bool direct) \
   1.906 -	{ \
   1.907 -		using namespace ::SourceHook; \
   1.908 -		MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.909 -		GetFuncInfo(funcptr, mfi); \
   1.910 -		if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
   1.911 -			return false; /* No non-virtual functions / virtual inheritance supported */ \
   1.912 -		\
   1.913 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, \
   1.914 -			direct ? ::SourceHook::ISourceHook::Hook_DVP : ::SourceHook::ISourceHook::Hook_VP, \
   1.915 -			iface, mfi.thisptroffs, SH_FHCls(ifacetype,ifacefunc,overload)::HookManPubFunc, \
   1.916 -			new CSHDelegate<SH_FHCls(ifacetype,ifacefunc,overload)::FD>(handler), post); \
   1.917 -	} \
   1.918 -	bool __SourceHook_FHRemove##ifacetype##ifacefunc(void *iface, bool post, \
   1.919 -		SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
   1.920 -	{ \
   1.921 -		using namespace ::SourceHook; \
   1.922 -		MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.923 -		GetFuncInfo(funcptr, mfi); \
   1.924 -		if (mfi.thisptroffs < 0) \
   1.925 -			return false; /* No virtual inheritance supported */ \
   1.926 -		\
   1.927 -		CSHDelegate<SH_FHCls(ifacetype,ifacefunc,overload)::FD> tmp(handler); \
   1.928 -		return SH_GLOB_SHPTR->RemoveHook(SH_GLOB_PLUGPTR, iface, mfi.thisptroffs, \
   1.929 -			SH_FHCls(ifacetype,ifacefunc,overload)::HookManPubFunc, &tmp, post); \
   1.930 -	} \
   1.931 -
   1.932 -#define SHINT_MAKE_GENERICSTUFF_BEGIN_MANUAL(hookname, pvtbloffs, pvtblidx, pthisptroffs) \
   1.933 -	struct SH_MFHCls(hookname) \
   1.934 -	{ \
   1.935 -		static SH_MFHCls(hookname) ms_Inst; \
   1.936 -		static ::SourceHook::MemFuncInfo ms_MFI; \
   1.937 -		static ::SourceHook::IHookManagerInfo *ms_HI; \
   1.938 -		static ::SourceHook::ProtoInfo ms_Proto; \
   1.939 -		\
   1.940 -		SH_MFHCls(hookname)() \
   1.941 -		{ \
   1.942 -			ms_MFI.isVirtual = true; \
   1.943 -			ms_MFI.thisptroffs = pthisptroffs; \
   1.944 -			ms_MFI.vtblindex = pvtblidx; \
   1.945 -			ms_MFI.vtbloffs = pvtbloffs; \
   1.946 -		} \
   1.947 -		static int HookManPubFunc(::SourceHook::HookManagerAction action, ::SourceHook::IHookManagerInfo *param) \
   1.948 -		{ \
   1.949 -			using namespace ::SourceHook; \
   1.950 -			/* we don't set ms_MFI here because manual hookmans can be reconfigured */ \
   1.951 -			/* :FIXME: possible problem: someone adding a hook from a constructor of a global entity */ \
   1.952 -			/* which is construced before SH_MFHCls(hookname)() gets called? */ \
   1.953 -			/* Verify interface version */ \
   1.954 -			if (SH_GLOB_SHPTR->GetIfaceVersion() != SH_IFACE_VERSION) \
   1.955 -				return 1; \
   1.956 -			if (SH_GLOB_SHPTR->GetImplVersion() < SH_IMPL_VERSION) \
   1.957 -				return 1; \
   1.958 -			\
   1.959 -			if (action == HA_GetInfo) \
   1.960 -			{ \
   1.961 -				param->SetVersion(SH_HOOKMAN_VERSION); \
   1.962 -				param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
   1.963 -					reinterpret_cast<const char*>(&ms_Proto)); \
   1.964 -				\
   1.965 -				MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.966 -				GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \
   1.967 -				param->SetHookfuncVfnptr( \
   1.968 -					reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
   1.969 -				return 0; \
   1.970 -			} \
   1.971 -			else if (action == HA_Register) \
   1.972 -			{ \
   1.973 -				ms_HI = param; \
   1.974 -				return 0; \
   1.975 -			} \
   1.976 -			else if (action == HA_Unregister) \
   1.977 -			{ \
   1.978 -				ms_HI = NULL; \
   1.979 -				return 0; \
   1.980 -			} \
   1.981 -			else \
   1.982 -				return 1; \
   1.983 -		}
   1.984 -
   1.985 -#define SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, pvtbloffs, pvtblidx, pthisptroffs) \
   1.986 -	}; \
   1.987 -	SH_MFHCls(hookname) SH_MFHCls(hookname)::ms_Inst; \
   1.988 -	::SourceHook::MemFuncInfo SH_MFHCls(hookname)::ms_MFI; \
   1.989 -	::SourceHook::IHookManagerInfo *SH_MFHCls(hookname)::ms_HI; \
   1.990 -	int __SourceHook_FHMAdd##hookname(void *iface, bool post, \
   1.991 -		SH_MFHCls(hookname)::FD handler) \
   1.992 -	{ \
   1.993 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, ::SourceHook::ISourceHook::Hook_Normal, iface, pthisptroffs, \
   1.994 -			SH_MFHCls(hookname)::HookManPubFunc, \
   1.995 -			new ::SourceHook::CSHDelegate<SH_MFHCls(hookname)::FD>(handler), post); \
   1.996 -	} \
   1.997 -	int __SourceHook_FHMVPAdd##hookname(void *iface, bool post, \
   1.998 -		SH_MFHCls(hookname)::FD handler, bool direct) \
   1.999 -	{ \
  1.1000 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, \
  1.1001 -			direct ? ::SourceHook::ISourceHook::Hook_DVP : ::SourceHook::ISourceHook::Hook_VP, \
  1.1002 -			iface, pthisptroffs, SH_MFHCls(hookname)::HookManPubFunc, \
  1.1003 -			new ::SourceHook::CSHDelegate<SH_MFHCls(hookname)::FD>(handler), post); \
  1.1004 -	} \
  1.1005 -	bool __SourceHook_FHMRemove##hookname(void *iface, bool post, \
  1.1006 -		SH_MFHCls(hookname)::FD handler) \
  1.1007 -	{ \
  1.1008 -		::SourceHook::CSHDelegate<SH_MFHCls(hookname)::FD> tmp(handler); \
  1.1009 -		return SH_GLOB_SHPTR->RemoveHook(SH_GLOB_PLUGPTR, iface, pthisptroffs, \
  1.1010 -			SH_MFHCls(hookname)::HookManPubFunc, &tmp, post); \
  1.1011 -	} \
  1.1012 -
  1.1013 -
  1.1014 -#define SH_SETUPCALLS(rettype, paramtypes, params) \
  1.1015 -	/* 1) Find the vfnptr */ \
  1.1016 -	using namespace ::SourceHook; \
  1.1017 -	void *ourvfnptr = reinterpret_cast<void*>( \
  1.1018 -		*reinterpret_cast<void***>(reinterpret_cast<char*>(this) + ms_MFI.vtbloffs) + ms_MFI.vtblindex); \
  1.1019 -	IVfnPtr *vfnptr = ms_HI->FindVfnPtr(ourvfnptr); \
  1.1020 -	SH_ASSERT(vfnptr, ("Called with vfnptr 0x%p which couldn't be found in the list", ourvfnptr)); \
  1.1021 -	\
  1.1022 -	void *vfnptr_origentry = vfnptr->GetOrigEntry(); \
  1.1023 -	/* ... and the iface */ \
  1.1024 -	IIface *ifinfo = vfnptr->FindIface(reinterpret_cast<void*>(this)); \
  1.1025 -	if (!ifinfo) \
  1.1026 -	{ \
  1.1027 -		/* The iface info was not found. Redirect the call to the original function. */ \
  1.1028 -		rettype (EmptyClass::*mfp)paramtypes; \
  1.1029 -		SH_SETUP_MFP(mfp); \
  1.1030 -		return (reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
  1.1031 -	} \
  1.1032 -	/* 2) Declare some vars and set it up */ \
  1.1033 -	SH_GLOB_SHPTR->HookLoopBegin(ifinfo); \
  1.1034 -	IHookList *prelist = ifinfo->GetPreHooks(); \
  1.1035 -	IHookList *postlist = ifinfo->GetPostHooks(); \
  1.1036 -	META_RES status = MRES_IGNORED; \
  1.1037 -	META_RES prev_res; \
  1.1038 -	META_RES cur_res; \
  1.1039 -	typedef ReferenceCarrier<rettype>::type my_rettype; \
  1.1040 -	my_rettype orig_ret; \
  1.1041 -	my_rettype override_ret; \
  1.1042 -	my_rettype plugin_ret; \
  1.1043 -	void* ifptr; \
  1.1044 -	my_rettype *pOverrideRet = reinterpret_cast<my_rettype*>(SH_GLOB_SHPTR->SetupHookLoop( \
  1.1045 -		&status, &prev_res, &cur_res, &ifptr, &orig_ret, &override_ret));
  1.1046 -
  1.1047 -#define SH_CALL_HOOKS(post, params) \
  1.1048 -	if (SH_GLOB_SHPTR->ShouldContinue()) \
  1.1049 -	{ \
  1.1050 -		prev_res = MRES_IGNORED; \
  1.1051 -		for (AutoHookIter iter(post##list); !iter.End(); iter.Next()) \
  1.1052 -		{ \
  1.1053 -			cur_res = MRES_IGNORED; \
  1.1054 -			ifptr = reinterpret_cast<void*>(reinterpret_cast<char*>(this) - iter.ThisPtrOffs()); \
  1.1055 -			plugin_ret = reinterpret_cast<CSHDelegate<FD>*>(iter.Handler())->GetDeleg() params; \
  1.1056 -			prev_res = cur_res; \
  1.1057 -			if (cur_res > status) \
  1.1058 -				status = cur_res; \
  1.1059 -			if (cur_res >= MRES_OVERRIDE) \
  1.1060 -				*pOverrideRet = plugin_ret; \
  1.1061 -			if (!SH_GLOB_SHPTR->ShouldContinue()) \
  1.1062 -			{ \
  1.1063 -				iter.SetToZero(); \
  1.1064 -				break; \
  1.1065 -			} \
  1.1066 -		} \
  1.1067 -	}
  1.1068 -
  1.1069 -#define SH_CALL_ORIG(rettype, paramtypes, params) \
  1.1070 -	if (status != MRES_SUPERCEDE) \
  1.1071 -	{ \
  1.1072 -		rettype (EmptyClass::*mfp)paramtypes; \
  1.1073 -		SH_SETUP_MFP(mfp); \
  1.1074 -		orig_ret = (reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
  1.1075 -	} \
  1.1076 -	else \
  1.1077 -		orig_ret = override_ret; \
  1.1078 -
  1.1079 -#define SH_RETURN() \
  1.1080 -	SH_GLOB_SHPTR->HookLoopEnd(); \
  1.1081 -	return status >= MRES_OVERRIDE ? *pOverrideRet : orig_ret;
  1.1082 -
  1.1083 -#define SH_HANDLEFUNC(paramtypes, params, rettype) \
  1.1084 -	SH_SETUPCALLS(rettype, paramtypes, params) \
  1.1085 -	SH_CALL_HOOKS(pre, params) \
  1.1086 -	SH_CALL_ORIG(rettype, paramtypes, params) \
  1.1087 -	SH_CALL_HOOKS(post, params) \
  1.1088 -	SH_RETURN()
  1.1089 -
  1.1090 -//////////////////////////////////////////////////////////////////////////
  1.1091 -#define SH_SETUPCALLS_void(paramtypes, params) \
  1.1092 -	/* 1) Find the vfnptr */ \
  1.1093 -	using namespace ::SourceHook; \
  1.1094 -	void *ourvfnptr = reinterpret_cast<void*>( \
  1.1095 -		*reinterpret_cast<void***>(reinterpret_cast<char*>(this) + ms_MFI.vtbloffs) + ms_MFI.vtblindex); \
  1.1096 -	IVfnPtr *vfnptr = ms_HI->FindVfnPtr(ourvfnptr); \
  1.1097 -	SH_ASSERT(vfnptr, ("Called with vfnptr 0x%p which couldn't be found in the list", ourvfnptr)); \
  1.1098 -	\
  1.1099 -	void *vfnptr_origentry = vfnptr->GetOrigEntry(); \
  1.1100 -	/* ... and the iface */ \
  1.1101 -	IIface *ifinfo = vfnptr->FindIface(reinterpret_cast<void*>(this)); \
  1.1102 -	if (!ifinfo) \
  1.1103 -	{ \
  1.1104 -		/* The iface info was not found. Redirect the call to the original function. */ \
  1.1105 -		void (EmptyClass::*mfp)paramtypes; \
  1.1106 -		SH_SETUP_MFP(mfp); \
  1.1107 -		(reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
  1.1108 -		return; \
  1.1109 -	} \
  1.1110 -	/* 2) Declare some vars and set it up */ \
  1.1111 -	SH_GLOB_SHPTR->HookLoopBegin(ifinfo); \
  1.1112 -	IHookList *prelist = ifinfo->GetPreHooks(); \
  1.1113 -	IHookList *postlist = ifinfo->GetPostHooks(); \
  1.1114 -	META_RES status = MRES_IGNORED; \
  1.1115 -	META_RES prev_res; \
  1.1116 -	META_RES cur_res; \
  1.1117 -	void* ifptr; \
  1.1118 -	SH_GLOB_SHPTR->SetupHookLoop(&status, &prev_res, &cur_res, &ifptr, NULL, NULL); \
  1.1119 -
  1.1120 -#define SH_CALL_HOOKS_void(post, params) \
  1.1121 -	if (SH_GLOB_SHPTR->ShouldContinue()) \
  1.1122 -	{ \
  1.1123 -		prev_res = MRES_IGNORED; \
  1.1124 -		for (AutoHookIter iter(post##list); !iter.End(); iter.Next()) \
  1.1125 -		{ \
  1.1126 -			cur_res = MRES_IGNORED; \
  1.1127 -			ifptr = reinterpret_cast<void*>(reinterpret_cast<char*>(this) - iter.ThisPtrOffs()); \
  1.1128 -			reinterpret_cast<CSHDelegate<FD>*>(iter.Handler())->GetDeleg() params; \
  1.1129 -			prev_res = cur_res; \
  1.1130 -			if (cur_res > status) \
  1.1131 -				status = cur_res; \
  1.1132 -			if (!SH_GLOB_SHPTR->ShouldContinue()) \
  1.1133 -			{ \
  1.1134 -				iter.SetToZero(); \
  1.1135 -				break; \
  1.1136 -			} \
  1.1137 -		} \
  1.1138 -	}
  1.1139 -
  1.1140 -#define SH_CALL_ORIG_void(paramtypes, params) \
  1.1141 -	if (status != MRES_SUPERCEDE) \
  1.1142 -	{ \
  1.1143 -		void (EmptyClass::*mfp)paramtypes; \
  1.1144 -		SH_SETUP_MFP(mfp); \
  1.1145 -		(reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
  1.1146 -	}
  1.1147 -
  1.1148 -#define SH_RETURN_void() \
  1.1149 -	SH_GLOB_SHPTR->HookLoopEnd();
  1.1150 -
  1.1151 -#define SH_HANDLEFUNC_void(paramtypes, params) \
  1.1152 -	SH_SETUPCALLS_void(paramtypes, params) \
  1.1153 -	SH_CALL_HOOKS_void(pre, params) \
  1.1154 -	SH_CALL_ORIG_void(paramtypes, params) \
  1.1155 -	SH_CALL_HOOKS_void(post, params) \
  1.1156 -	SH_RETURN_void()
  1.1157 -
  1.1158 -
  1.1159 -// Special vafmt handlers
  1.1160 -// :TODO: what
  1.1161 -#define SH_HANDLEFUNC_vafmt(paramtypes, params_orig, params_plug, rettype) \
  1.1162 -	SH_SETUPCALLS(rettype, paramtypes, params_orig) \
  1.1163 -	SH_CALL_HOOKS(pre, params_plug) \
  1.1164 -	SH_CALL_ORIG(rettype, paramtypes, params_orig) \
  1.1165 -	SH_CALL_HOOKS(post, params_plug) \
  1.1166 -	SH_RETURN()
  1.1167 -
  1.1168 -#define SH_HANDLEFUNC_void_vafmt(paramtypes, params_orig, params_plug) \
  1.1169 -	SH_SETUPCALLS_void(paramtypes, params_orig) \
  1.1170 -	SH_CALL_HOOKS_void(pre, params_plug) \
  1.1171 -	SH_CALL_ORIG_void(paramtypes, params_orig) \
  1.1172 -	SH_CALL_HOOKS_void(post, params_plug) \
  1.1173 -	SH_RETURN_void()
  1.1174 -
  1.1175 -//////////////////////////////////////////////////////////////////////////
  1.1176 -
  1.1177 -// :FIXME:
  1.1178 -//  sizeof on references returns the size of the datatype, NOT the pointer size or something
  1.1179 -//  -> one should probably flag references in __SourceHook_ParamSizes_* !
  1.1180 -//		or simply assume that their size is sizeof(void*)=SH_PTRSIZE... could be doable through a simple template
  1.1181 -
  1.1182 -@[$1,0,$a:
  1.1183 -// ********* Support for $1 arguments *********
  1.1184 -#define SH_DECL_HOOK$1(ifacetype, ifacefunc, attr, overload, rettype@[$2,1,$1:, param$2@]) \
  1.1185 -	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr> \
  1.1186 -		(&ifacetype::ifacefunc))) \
  1.1187 -		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]@[$1!=0:, @]rettype> FD; \
  1.1188 -		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1189 -		{ SH_HANDLEFUNC((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@]), rettype); } \
  1.1190 -	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1191 -		(static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr>(&ifacetype::ifacefunc))) \
  1.1192 -	\
  1.1193 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1194 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(sizeof(rettype), \
  1.1195 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1196 -
  1.1197 -#define SH_DECL_HOOK$1_void(ifacetype, ifacefunc, attr, overload@[$2,1,$1:, param$2@]) \
  1.1198 -	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr> \
  1.1199 -		(&ifacetype::ifacefunc))) \
  1.1200 -		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]> FD; \
  1.1201 -		virtual void Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1202 -		{ SH_HANDLEFUNC_void((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@])); } \
  1.1203 -	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1204 -		(static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr>(&ifacetype::ifacefunc))) \
  1.1205 -	\
  1.1206 -	\
  1.1207 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1208 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(0, \
  1.1209 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1210 -
  1.1211 -#define SH_DECL_HOOK$1_vafmt(ifacetype, ifacefunc, attr, overload, rettype@[$2,1,$1:, param$2@]) \
  1.1212 -	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr> \
  1.1213 -		(&ifacetype::ifacefunc))) \
  1.1214 -		typedef fastdelegate::FastDelegate@($1+1)<@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, rettype> FD; \
  1.1215 -		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@]@[$1!=0:, @]const char *fmt, ...) \
  1.1216 -		{ \
  1.1217 -			char buf[::SourceHook::STRBUF_LEN]; \
  1.1218 -			va_list ap; \
  1.1219 -			va_start(ap, fmt); \
  1.1220 -			vsnprintf(buf, sizeof(buf), fmt, ap); \
  1.1221 -			va_end(ap); \
  1.1222 -			SH_HANDLEFUNC_vafmt((@[$2,1,$1|, :param$2@]@[$1!=0:, @]...), (@[$2,1,$1|, :p$2@]@[$1!=0:, @]"%s", buf), (@[$2,1,$1|, :p$2@]@[$1!=0:, @]buf), rettype); \
  1.1223 -		} \
  1.1224 -	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1225 -		(static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr>(&ifacetype::ifacefunc))) \
  1.1226 -	\
  1.1227 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { -1@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1228 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(sizeof(rettype), \
  1.1229 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1230 -
  1.1231 -#define SH_DECL_HOOK$1_void_vafmt(ifacetype, ifacefunc, attr, overload@[$2,1,$1:, param$2@]) \
  1.1232 -	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr> \
  1.1233 -		(&ifacetype::ifacefunc))) \
  1.1234 -		typedef fastdelegate::FastDelegate@($1+1)<@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *> FD; \
  1.1235 -		virtual void Func(@[$2,1,$1|, :param$2 p$2@]@[$1!=0:, @]const char *fmt, ...) \
  1.1236 -		{ \
  1.1237 -			char buf[::SourceHook::STRBUF_LEN]; \
  1.1238 -			va_list ap; \
  1.1239 -			va_start(ap, fmt); \
  1.1240 -			vsnprintf(buf, sizeof(buf), fmt, ap); \
  1.1241 -			va_end(ap); \
  1.1242 -			SH_HANDLEFUNC_void_vafmt((@[$2,1,$1|, :param$2@]@[$1!=0:, @]...), (@[$2,1,$1|, :p$2@]@[$1!=0:, @]"%s", buf), (@[$2,1,$1|, :p$2@]@[$1!=0:, @]buf)); \
  1.1243 -		} \
  1.1244 -	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1245 -		(static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr>(&ifacetype::ifacefunc))) \
  1.1246 -	\
  1.1247 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { -1@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1248 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(0, \
  1.1249 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1250 -
  1.1251 -#define SH_DECL_MANUALHOOK$1(hookname, vtblidx, vtbloffs, thisptroffs, rettype@[$2,1,$1:, param$2@]) \
  1.1252 -	SHINT_MAKE_GENERICSTUFF_BEGIN_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1253 -		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]@[$1!=0:, @]rettype> FD; \
  1.1254 -		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1255 -		{ SH_HANDLEFUNC((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@]), rettype); } \
  1.1256 -		typedef rettype(::SourceHook::EmptyClass::*ECMFP)(@[$2,1,$1|, :param$2@]); \
  1.1257 -		typedef rettype RetType; \
  1.1258 -	SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1259 -	\
  1.1260 -	const int __SourceHook_ParamSizesM_##hookname[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1261 -	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto(sizeof(rettype), \
  1.1262 -		$1, __SourceHook_ParamSizesM_##hookname); \
  1.1263 -
  1.1264 -#define SH_DECL_MANUALHOOK$1_void(hookname, vtblidx, vtbloffs, thisptroffs@[$2,1,$1:, param$2@]) \
  1.1265 -	SHINT_MAKE_GENERICSTUFF_BEGIN_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1266 -		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]> FD; \
  1.1267 -		virtual void Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1268 -		{ SH_HANDLEFUNC_void((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@])); } \
  1.1269 -		typedef void(::SourceHook::EmptyClass::*ECMFP)(@[$2,1,$1|, :param$2@]); \
  1.1270 -	SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1271 -	\
  1.1272 -	const int __SourceHook_ParamSizesM_##hookname[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1273 -	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto(0, \
  1.1274 -		$1, __SourceHook_ParamSizesM_##hookname); \
  1.1275 -
  1.1276 -@]
  1.1277 -
  1.1278 -
  1.1279 -//////////////////////////////////////////////////////////////////////////
  1.1280 -// SH_CALL
  1.1281 -
  1.1282 -#define SH_MAKE_EXECUTABLECLASS_OB(call, prms) \
  1.1283 -{ \
  1.1284 -	using namespace ::SourceHook; \
  1.1285 -	\
  1.1286 -	m_pSH->SetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1287 -	RetType tmpret = (m_ThisPtr->*m_MFP)call; \
  1.1288 -	m_pSH->ResetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1289 -	return tmpret; \
  1.1290 -}
  1.1291 -
  1.1292 -#define SH_MAKE_EXECUTABLECLASS_OB_void(call, prms) \
  1.1293 -{ \
  1.1294 -	using namespace ::SourceHook; \
  1.1295 -	\
  1.1296 -	m_pSH->SetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1297 -	(m_ThisPtr->*m_MFP)call; \
  1.1298 -	m_pSH->ResetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1299 -}
  1.1300 -
  1.1301 -namespace SourceHook
  1.1302 -{
  1.1303 -	// Call Class Wrapper!
  1.1304 -	template <class T> struct CCW
  1.1305 -	{
  1.1306 -		typedef T type;
  1.1307 -
  1.1308 -		// Get Real Pointer!
  1.1309 -		static inline T *GRP(T *p)
  1.1310 -		{
  1.1311 -			return p;
  1.1312 -		}
  1.1313 -	};
  1.1314 -
  1.1315 -	template <class T> struct CCW< CallClass<T> >
  1.1316 -	{
  1.1317 -		typedef T type;
  1.1318 -
  1.1319 -		// Get Real Pointer!
  1.1320 -		static inline T *GRP(CallClass<T> *p)
  1.1321 -		{
  1.1322 -			return p->ptr;
  1.1323 -		}
  1.1324 -	};
  1.1325 -
  1.1326 -@[$1,0,$a:
  1.1327 -	// Support for $1 arguments
  1.1328 -	template<class ObjType, class MFP, class RetType@[$2,1,$1:, class Param$2@]> class ExecutableClass$1
  1.1329 -	{
  1.1330 -		ObjType *m_ThisPtr;
  1.1331 -		void *m_VfnPtr;
  1.1332 -		MFP m_MFP;
  1.1333 -		ISourceHook *m_pSH;
  1.1334 -		Plugin m_Plug;
  1.1335 -	public:
  1.1336 -		ExecutableClass$1(ObjType *tp, MFP mfp, void *vp, ISourceHook *pSH, Plugin plug) : m_ThisPtr(tp),
  1.1337 -			m_VfnPtr(vp), m_MFP(mfp), m_pSH(pSH), m_Plug(plug) { }
  1.1338 -	
  1.1339 -		RetType operator()(@[$2,1,$1|, :Param$2 p$2@]) const
  1.1340 -			SH_MAKE_EXECUTABLECLASS_OB((@[$2,1,$1|, :p$2@]), (@[$2,1,$1|, :Param$2@]))
  1.1341 -	         
  1.1342 -		@[$2,$1+1,$a:
  1.1343 -		template <@[$3,$1+1,$2|, :class Param$3@]> RetType operator()(@[$3,1,$2|, :Param$3 p$3@]) const
  1.1344 -			SH_MAKE_EXECUTABLECLASS_OB((@[$3,1,$2|, :p$3@]), (@[$3,1,$2|, :Param$3@]))
  1.1345 -		@]
  1.1346 -	};
  1.1347 -
  1.1348 -	template<class ObjType, class MFP@[$2,1,$1:, class Param$2@]> class ExecutableClass$1<ObjType, MFP, void@[$2,1,$1:, Param$2@]>
  1.1349 -	{
  1.1350 -	   ObjType *m_ThisPtr;
  1.1351 -	   void *m_VfnPtr;
  1.1352 -	   MFP m_MFP;
  1.1353 -	   ISourceHook *m_pSH;
  1.1354 -	   Plugin m_Plug;
  1.1355 -	public:
  1.1356 -	   ExecutableClass$1(ObjType *tp, MFP mfp, void *vp, ISourceHook *pSH, Plugin plug) : m_ThisPtr(tp),
  1.1357 -		   m_VfnPtr(vp), m_MFP(mfp), m_pSH(pSH), m_Plug(plug) { }
  1.1358 -	
  1.1359 -	   void operator()(@[$2,1,$1|, :Param$2 p$2@]) const
  1.1360 -	      SH_MAKE_EXECUTABLECLASS_OB_void((@[$2,1,$1|, :p$2@]), (@[$2,1,$1|, :Param$2@]))
  1.1361 -	         
  1.1362 -	   @[$2,$1+1,$a:
  1.1363 -	   template <@[$3,$1+1,$2|, :class Param$3@]> void operator()(@[$3,1,$2|, :Param$3 p$3@]) const
  1.1364 -	      SH_MAKE_EXECUTABLECLASS_OB_void((@[$3,1,$2|, :p$3@]), (@[$3,1,$2|, :Param$3@]))
  1.1365 -	   @]
  1.1366 -	};
  1.1367 -@]
  1.1368 -
  1.1369 -}
  1.1370 -
  1.1371 -#define SH__CALL_GET_VFNPTR_NORMAL \
  1.1372 -	using namespace ::SourceHook; \
  1.1373 -	MemFuncInfo mfi = {true, -1, 0, 0}; \
  1.1374 -	GetFuncInfo(CCW<Y>::GRP(ptr), mfp, mfi); \
  1.1375 -	void *vfnptr = reinterpret_cast<void*>( \
  1.1376 -		*reinterpret_cast<void***>(reinterpret_cast<char*>(ptr) + mfi.thisptroffs + mfi.vtbloffs) + mfi.vtblindex);
  1.1377 -
  1.1378 -#define SH__CALL_GET_VFNPTR_MANUAL \
  1.1379 -	using namespace ::SourceHook; \
  1.1380 -	void *vfnptr = reinterpret_cast<void*>( \
  1.1381 -		*reinterpret_cast<void***>( (reinterpret_cast<char*>(CCW<Y>::GRP(ptr)) + thisptroffs + vtbloffs) ) + vtblidx); \
  1.1382 -	/* patch mfp */ \
  1.1383 -	*reinterpret_cast<void**>(&mfp) = *reinterpret_cast<void**>(vfnptr);
  1.1384 -
  1.1385 -// SH_CALL needs to deduce the return type -> it uses templates and function overloading
  1.1386 -// That's why SH_CALL takes two parameters: "mfp2" of type RetType(X::*mfp)(params), and "mfp" of type MFP
  1.1387 -// The only purpose of the mfp2 parameter is to extract the return type
  1.1388 -
  1.1389 -@[$1,0,$a:
  1.1390 -// Support for $1 arguments
  1.1391 -template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1392 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1393 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]), SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1394 -{
  1.1395 -	SH__CALL_GET_VFNPTR_NORMAL
  1.1396 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1397 -		mfp, vfnptr, shptr, plug);
  1.1398 -}
  1.1399 -
  1.1400 -template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1401 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1402 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@])const, SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1403 -{
  1.1404 -	SH__CALL_GET_VFNPTR_NORMAL
  1.1405 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1406 -		mfp, vfnptr, shptr, plug);
  1.1407 -}
  1.1408 -
  1.1409 -template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1410 -SourceHook::ExecutableClass$1<SourceHook::EmptyClass, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1411 -SH_MCALL3(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]), int vtblidx, int vtbloffs, int thisptroffs, SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1412 -{
  1.1413 -	SH__CALL_GET_VFNPTR_MANUAL
  1.1414 -	return SourceHook::ExecutableClass$1<EmptyClass, MFP, RetType@[$2,1,$1:, Param$2@]>(
  1.1415 -		reinterpret_cast<SourceHook::EmptyClass*>(CCW<Y>::GRP(ptr)), mfp, vfnptr, shptr, plug);
  1.1416 -}
  1.1417 -@]
  1.1418 -
  1.1419 -#if SH_COMP != SH_COMP_MSVC || _MSC_VER > 1300
  1.1420 -// GCC & MSVC 7.1 need this, MSVC 7.0 doesn't like it
  1.1421 -
  1.1422 -@[$1,0,$a:
  1.1423 -// Support for $1 arguments
  1.1424 -template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1425 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1426 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]@[$1!=0:, @]...), SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1427 -{
  1.1428 -	SH__CALL_GET_VFNPTR_NORMAL
  1.1429 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1430 -		mfp, vfnptr, shptr, plug);
  1.1431 -}
  1.1432 -
  1.1433 -template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1434 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1435 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]@[$1!=0:, @]...)const, SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1436 -{
  1.1437 -	SH__CALL_GET_VFNPTR_NORMAL
  1.1438 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1439 -		mfp, vfnptr, shptr, plug);
  1.1440 -}
  1.1441 -
  1.1442 -@]
  1.1443 -
  1.1444 -#endif
  1.1445 -
  1.1446 -#define SH_CALL(ptr, mfp) SH_CALL2((ptr), (mfp), (mfp), SH_GLOB_SHPTR, SH_GLOB_PLUGPTR)
  1.1447 -#define SH_MCALL2(ptr, mfp, vtblidx, vtbloffs, thisptroffs) SH_MCALL3((ptr), (mfp), (mfp), (vtblidx), (vtbloffs), (thisptroffs), SH_GLOB_SHPTR, SH_GLOB_PLUGPTR)
  1.1448 -#define SH_MCALL(ptr, mhookname) SH_MCALL2((ptr), SH_MFHCls(mhookname)::ECMFP(), SH_MFHCls(mhookname)::ms_MFI.vtblindex, \
  1.1449 -	SH_MFHCls(mhookname)::ms_MFI.vtbloffs, SH_MFHCls(mhookname)::ms_MFI.thisptroffs)
  1.1450 -
  1.1451 -#undef SH_MAKE_EXECUTABLECLASS_OB
  1.1452 -
  1.1453 -//////////////////////////////////////////////////////////////////////////
  1.1454 -// SetOverrideRet and RecallGetIface for recalls
  1.1455 -// These take a ISourceHook pointer instead of using SH_GLOB_SHPTR directly
  1.1456 -// The reason is that the user may want to redefine SH_GLOB_SHPTR - then the macros
  1.1457 -// (META_RETURN_VALUE_NEWPARAMS) should obey the new pointer.
  1.1458 -
  1.1459 -namespace SourceHook
  1.1460 -{
  1.1461 -	template <class RetType>
  1.1462 -	void SetOverrideResult(ISourceHook *shptr, const RetType res)
  1.1463 -	{
  1.1464 -		*reinterpret_cast<RetType*>(shptr->GetOverrideRetPtr()) = res;
  1.1465 -	}
  1.1466 -
  1.1467 -	// SetOverrideResult used to be implemented like this:
  1.1468 -	//  SetOverrideResult(shptr, memfuncptr, return);
  1.1469 -	//  normally the compiler can deduce the return type from memfuncptr, but (at least msvc8) failed when it was a reference
  1.1470 -	//  (it thought it was ambigous - the ref and non-ref type)
  1.1471 -	//  so now SetOverrideResult(memfuncptr) deduces the ret type, and returns a functor which does the work
  1.1472 -	//  new syntax: SetOverrideResult(memfuncptr)(shptr, return)
  1.1473 -	// This also allows us to create a special version for references which respects ReferenceCarrier.
  1.1474 -
  1.1475 -	template <class T> struct OverrideFunctor
  1.1476 -	{
  1.1477 -		void operator()(ISourceHook *shptr, T res)
  1.1478 -		{
  1.1479 -			*reinterpret_cast<T*>(shptr->GetOverrideRetPtr()) = res;
  1.1480 -		}
  1.1481 -	};
  1.1482 -	template <class T> struct OverrideFunctor<T&>
  1.1483 -	{
  1.1484 -		void operator()(ISourceHook *shptr, T &res)
  1.1485 -		{
  1.1486 -			// overrideretptr points to ReferenceCarrier<T&>
  1.1487 -			*reinterpret_cast<typename ReferenceCarrier<T&>::type *>(shptr->GetOverrideRetPtr()) = res;
  1.1488 -		}
  1.1489 -	};
  1.1490 -@[$1,0,$a:
  1.1491 -	template <class Iface, class RetType@[$2,1,$1:, class Param$2@]>
  1.1492 -	OverrideFunctor<RetType> SetOverrideResult(RetType (Iface::*mfp)(@[$2,1,$1|, :Param$2@]))
  1.1493 -	{
  1.1494 -		return OverrideFunctor<RetType>();
  1.1495 -	}
  1.1496 -
  1.1497 -	template <class Iface, class RetType@[$2,1,$1:, class Param$2@]>
  1.1498 -	Iface *RecallGetIface(ISourceHook *shptr, RetType (Iface::*mfp)(@[$2,1,$1|, :Param$2@]))
  1.1499 -	{
  1.1500 -		return reinterpret_cast<Iface*>(shptr->GetIfacePtr());
  1.1501 -	}
  1.1502 -@]
  1.1503 -}
  1.1504 -
  1.1505 -#endif
  1.1506 -	// The pope is dead. -> :(