sourcehook/generate/sourcehook.hxx
changeset 384 264cab8ff2cc
parent 382 8b06ecc6e76d
child 386 08583103ba6f
     1.1 --- a/sourcehook/generate/sourcehook.hxx	Sun Oct 07 22:35:57 2007 +0000
     1.2 +++ b/sourcehook/generate/sourcehook.hxx	Sun Oct 07 22:45:22 2007 +0000
     1.3 @@ -6,7 +6,7 @@
     1.4  *
     1.5  * Author(s): Pavol "PM OnoTo" Marko
     1.6  * ============================
     1.7 -*/ 
     1.8 +*/
     1.9  
    1.10  /**
    1.11  *	@file sourcehook.h
    1.12 @@ -21,18 +21,18 @@
    1.13  //  2 - Changed to virtual functions for iterators and all queries
    1.14  //  3 - Added "hook loop status variable"
    1.15  //  4 - Reentrant
    1.16 -#define SH_IFACE_VERSION 4
    1.17 +//  5 - New "V2" interface
    1.18 +#define SH_IFACE_VERSION 5
    1.19  
    1.20  // Impl versions:
    1.21  // ???
    1.22  // 4 - addition of hook ids and vp hooks (with them, AddHookNew and RemoveHookNew)
    1.23  //     This is not a SH_IFACE_VERSION change so that old plugins continue working!
    1.24 -// 5 - addition of direct vp hooks (new hook mode; from now on AddHookNew checks for
    1.25 -//	   invalid hookmode -> impl version won't have to change because of things like this)
    1.26 +// 5 - implementation of the new "V2" interface
    1.27  #define SH_IMPL_VERSION 5
    1.28  
    1.29  // Hookman version:
    1.30 -//  1 - Support for recalls, performance optimisations
    1.31 +// 1 - standard
    1.32  #define SH_HOOKMAN_VERSION 1
    1.33  
    1.34  // The value of SH_GLOB_SHPTR has to be a pointer to SourceHook::ISourceHook
    1.35 @@ -99,8 +99,8 @@
    1.36  
    1.37  #define SH_PTRSIZE sizeof(void*)
    1.38  
    1.39 +#include "sh_memfuncinfo.h"
    1.40  #include "FastDelegate.h"
    1.41 -#include "sh_memfuncinfo.h"
    1.42  
    1.43  // Good old metamod!
    1.44  
    1.45 @@ -147,25 +147,57 @@
    1.46  	*/
    1.47  	typedef int Plugin;
    1.48  
    1.49 +
    1.50 +	template <class T> class CallClass : public T
    1.51 +	{
    1.52 +	};
    1.53 +	typedef void ManualCallClass;
    1.54 +
    1.55 +	/**
    1.56 +	*	@brief Describes the way a parameter/retval is passed.
    1.57 +	*/
    1.58 +	struct PassInfo
    1.59 +	{
    1.60 +		enum PassType
    1.61 +		{
    1.62 +			PassType_Unknown=0,		/**< Unknown -- no extra info available */
    1.63 +			PassType_Basic,			/**< Plain old register data (pointers, integers) */
    1.64 +			PassType_Float,			/**< Floating point data */
    1.65 +			PassType_Object,		/**< Object or structure */
    1.66 +		};
    1.67 +
    1.68 +		enum PassFlags
    1.69 +		{
    1.70 +			PassFlag_ByVal		= (1<<0),		/**< Passing by value */
    1.71 +			PassFlag_ByRef		= (1<<1),		/**< Passing by reference */
    1.72 +			PassFlag_ODtor		= (1<<2),		/**< Object has a destructor */
    1.73 +			PassFlag_OCtor		= (1<<3),		/**< Object has a constructor */
    1.74 +			PassFlag_AssignOp	= (1<<4)		/**< Object has an assignment operator */
    1.75 +		};
    1.76 +
    1.77 +		size_t size;			//!< Size of the data being passed
    1.78 +
    1.79 +		// Extra info:
    1.80 +		//  (might be used in future versions for automatic hookfunc generation)
    1.81 +		int type;				//!< PassType value
    1.82 +		unsigned int flags;		//!< Pass/return flags
    1.83 +	};
    1.84 +
    1.85  	struct ProtoInfo
    1.86  	{
    1.87 -		ProtoInfo(int rtsz, int nop, const int *p) : beginningNull(0), retTypeSize(rtsz), numOfParams(nop), params(p)
    1.88 +		enum CallConvention
    1.89  		{
    1.90 -		}
    1.91 -		int beginningNull;		//!< To distinguish from old protos (which never begin with 0)
    1.92 -		int retTypeSize;		//!< 0 if void
    1.93 -		int numOfParams;		//!< number of parameters
    1.94 -		const int *params;		//!< params[0]=0 (or -1 for vararg), params[1]=size of first param, ...
    1.95 -	};
    1.96 +			CallConv_Unknown,		/**< Unknown  -- no extra info available */
    1.97 +			CallConv_ThisCall,		/**< This call (object pointer required) */
    1.98 +			CallConv_Cdecl,			/**< Standard C call */
    1.99 +		};
   1.100  
   1.101 -	/**
   1.102 -	*	@brief Specifies the actions for hook managers
   1.103 -	*/
   1.104 -	enum HookManagerAction
   1.105 -	{
   1.106 -		HA_GetInfo = 0,			//!< Store info about the hook manager
   1.107 -		HA_Register,			//!< Save the IHookManagerInfo pointer for future reference
   1.108 -		HA_Unregister			//!< Clear the saved pointer
   1.109 +		int numOfParams;			//!< number of parameters
   1.110 +		PassInfo retPassInfo;		//!< PassInfo for the return value. size=0 -> no retval
   1.111 +		const PassInfo *paramsPassInfo;	//!< PassInfos for the parameters
   1.112 +
   1.113 +		// Extra info:
   1.114 +		int convention;
   1.115  	};
   1.116  
   1.117  	struct IHookManagerInfo;
   1.118 @@ -173,139 +205,26 @@
   1.119  	/**
   1.120  	*	@brief Pointer to hook manager interface function
   1.121  	*
   1.122 -	*	A "hook manager" is a the only thing that knows the actual protoype of the function at compile time.
   1.123 +	*	The hook manager should store hi for later use if store==true. It should then call hi->SetInfo(...) if hi
   1.124 +	*   is non-null. The hook manager can return 0 for success or a non-zero value if it doesn't want to be used.
   1.125  	*
   1.126 -	*   @param ha What the hook manager should do
   1.127  	*	@param hi A pointer to IHookManagerInfo
   1.128  	*/
   1.129 -	typedef int (*HookManagerPubFunc)(HookManagerAction ha, IHookManagerInfo *hi);
   1.130 +	typedef int (*HookManagerPubFunc)(bool store, IHookManagerInfo *hi);
   1.131  
   1.132  	class ISHDelegate
   1.133  	{
   1.134  	public:
   1.135 -		virtual void DeleteThis() = 0;				// Ugly, I know
   1.136 -		virtual bool IsEqual(ISHDelegate *other) = 0;
   1.137 -	};
   1.138 -
   1.139 -	template <class T> class CSHDelegate : public ISHDelegate
   1.140 -	{
   1.141 -		T m_Deleg;
   1.142 -	public:
   1.143 -		CSHDelegate(T deleg) : m_Deleg(deleg)
   1.144 -		{
   1.145 -		}
   1.146 -
   1.147 -		CSHDelegate(const CSHDelegate &other) : m_Deleg(other.m_Deleg)
   1.148 -		{
   1.149 -		}
   1.150 -
   1.151 -		void DeleteThis()
   1.152 -		{
   1.153 -			delete this;
   1.154 -		}
   1.155 -
   1.156 -		bool IsEqual(ISHDelegate *other)
   1.157 -		{
   1.158 -			return static_cast<CSHDelegate<T>* >(other)->GetDeleg() == GetDeleg();
   1.159 -		}
   1.160 -
   1.161 -		T &GetDeleg()
   1.162 -		{
   1.163 -			return m_Deleg;
   1.164 -		}
   1.165 -	};
   1.166 -
   1.167 -	struct IHookList
   1.168 -	{
   1.169 -		struct IIter
   1.170 -		{
   1.171 -			virtual bool End() = 0;
   1.172 -			virtual void Next() = 0;
   1.173 -			virtual ISHDelegate *Handler() = 0;
   1.174 -			virtual int ThisPtrOffs() = 0;
   1.175 -		};
   1.176 -		virtual IIter *GetIter() = 0;
   1.177 -		virtual void ReleaseIter(IIter *pIter) = 0;
   1.178 -	};
   1.179 -
   1.180 -	struct IIface
   1.181 -	{
   1.182 -		virtual void *GetPtr() = 0;
   1.183 -		virtual IHookList *GetPreHooks() = 0;
   1.184 -		virtual IHookList *GetPostHooks() = 0;
   1.185 -	};
   1.186 -
   1.187 -	struct IVfnPtr
   1.188 -	{
   1.189 -		virtual void *GetVfnPtr() = 0;
   1.190 -		virtual void *GetOrigEntry() = 0;
   1.191 -
   1.192 -		virtual IIface *FindIface(void *ptr) = 0;
   1.193 +		virtual bool IsEqual(ISHDelegate *pOtherDeleg) = 0;		// pOtherDeleg is from the same plugin and hookman
   1.194 +		virtual void DeleteThis() = 0;
   1.195  	};
   1.196  
   1.197  	struct IHookManagerInfo
   1.198  	{
   1.199 -		virtual IVfnPtr *FindVfnPtr(void *vfnptr) = 0;
   1.200 -
   1.201 -		virtual void SetInfo(int vtbloffs, int vtblidx, const char *proto) = 0;
   1.202 -		virtual void SetHookfuncVfnptr(void *hookfunc_vfnptr) = 0;
   1.203 -
   1.204 -		// Added 23.12.2005 (yup! I'm coding RIGHT BEFORE CHRISTMAS!)
   1.205 -		// If the hookman doesn't set this, it defaults 0
   1.206 -		// SourceHook prefers hookmans with higher version numbers
   1.207 -		virtual void SetVersion(int version) = 0;
   1.208 +		virtual void SetInfo(int hookman_version, int vtbloffs, int vtblidx,
   1.209 +			ProtoInfo *proto, void *hookfunc_vfnptr) = 0;
   1.210  	};
   1.211  
   1.212 -	class AutoHookIter
   1.213 -	{
   1.214 -		IHookList *m_pList;
   1.215 -		IHookList::IIter *m_pIter;
   1.216 -	public:
   1.217 -		AutoHookIter(IHookList *pList)
   1.218 -			: m_pList(pList), m_pIter(pList->GetIter())
   1.219 -		{
   1.220 -		}
   1.221 -
   1.222 -		~AutoHookIter()
   1.223 -		{
   1.224 -			if (m_pList)
   1.225 -				m_pList->ReleaseIter(m_pIter);
   1.226 -		}
   1.227 -
   1.228 -		bool End()
   1.229 -		{
   1.230 -			return m_pIter->End();
   1.231 -		}
   1.232 -
   1.233 -		void Next()
   1.234 -		{
   1.235 -			m_pIter->Next();
   1.236 -		}
   1.237 -
   1.238 -		ISHDelegate *Handler()
   1.239 -		{
   1.240 -			return m_pIter->Handler();
   1.241 -		}
   1.242 -
   1.243 -		int ThisPtrOffs()
   1.244 -		{
   1.245 -			return m_pIter->ThisPtrOffs();
   1.246 -		}
   1.247 -
   1.248 -		void SetToZero()
   1.249 -		{
   1.250 -			m_pList = 0;
   1.251 -		}
   1.252 -	};
   1.253 -
   1.254 -	template<class B> struct DeprecatedCallClass
   1.255 -	{
   1.256 -		virtual B *GetThisPtr() = 0;
   1.257 -		virtual void *GetOrigFunc(int vtbloffs, int vtblidx) = 0;
   1.258 -	};
   1.259 -
   1.260 -	// 09.08.2008 (6 AM, I just woke up, the others are still sleeping so i finally can use this notebook !!)
   1.261 -	// - Today is an important day.
   1.262  	// I'm adding support for functions which return references.
   1.263  
   1.264  	// How it works:
   1.265 @@ -347,6 +266,14 @@
   1.266  		};
   1.267  	};
   1.268  
   1.269 +	struct IHookContext
   1.270 +	{
   1.271 +		virtual ISHDelegate *GetNext() = 0;
   1.272 +		virtual void *GetOverrideRetPtr() = 0;
   1.273 +		virtual const void *GetOrigRetPtr() = 0;
   1.274 +		virtual bool ShouldCallOrig() = 0;
   1.275 +	};
   1.276 +
   1.277  	/**
   1.278  	*	@brief The main SourceHook interface
   1.279  	*/
   1.280 @@ -364,126 +291,6 @@
   1.281  		virtual int GetImplVersion() = 0;
   1.282  
   1.283  		/**
   1.284 -		*	@brief Add a hook.
   1.285 -		*
   1.286 -		*	@return True if the function succeeded, false otherwise
   1.287 -		*
   1.288 -		*	@param plug The unique identifier of the plugin that calls this function
   1.289 -		*	@param iface The interface pointer
   1.290 -		*	@param ifacesize The size of the class iface points to
   1.291 -		*	@param myHookMan A hook manager function that should be capable of handling the function
   1.292 -		*	@param handler A pointer to a FastDelegate containing the hook handler
   1.293 -		*	@param post Set to true if you want a post handler
   1.294 -		*/
   1.295 -		virtual bool AddHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.296 -			ISHDelegate *handler, bool post) = 0;
   1.297 -
   1.298 -		/**
   1.299 -		*	@brief Removes a hook.
   1.300 -		*
   1.301 -		*	@return True if the function succeeded, false otherwise
   1.302 -		*
   1.303 -		*	@param plug The unique identifier of the plugin that calls this function
   1.304 -		*	@param iface The interface pointer
   1.305 -		*	@param myHookMan A hook manager function that should be capable of handling the function
   1.306 -		*	@param handler A pointer to a FastDelegate containing the hook handler
   1.307 -		*	@param post Set to true if you want a post handler
   1.308 -		*/
   1.309 -		virtual bool RemoveHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.310 -			ISHDelegate *handler, bool post) = 0;
   1.311 -
   1.312 -		/**
   1.313 -		*	@brief Checks whether a plugin has (a) hook manager(s) that is/are currently used by other plugins
   1.314 -		*
   1.315 -		*	@param plug The unique identifier of the plugin in question
   1.316 -		*/
   1.317 -		virtual bool IsPluginInUse(Plugin plug) = 0;
   1.318 -
   1.319 -		/**
   1.320 -		*	@brief Return a pointer to a callclass. Generate a new one if required.
   1.321 -		*
   1.322 -		*	@param iface The interface pointer
   1.323 -		*	@param size Size of the class instance
   1.324 -		*/
   1.325 -		virtual DeprecatedCallClass<void> *GetCallClass(void *iface, size_t size) = 0;
   1.326 -
   1.327 -		/**
   1.328 -		*	@brief Release a callclass
   1.329 -		*
   1.330 -		*	@param ptr Pointer to the callclass
   1.331 -		*/
   1.332 -		virtual void ReleaseCallClass(DeprecatedCallClass<void> *ptr) = 0;
   1.333 -
   1.334 -		virtual void SetRes(META_RES res) = 0;				//!< Sets the meta result
   1.335 -		virtual META_RES GetPrevRes() = 0;					//!< Gets the meta result of the
   1.336 -															//!<  previously calledhandler
   1.337 -		virtual META_RES GetStatus() = 0;					//!< Gets the highest meta result
   1.338 -		virtual const void *GetOrigRet() = 0;				//!< Gets the original result.
   1.339 -															//!<  If not in post function, undefined
   1.340 -		virtual const void *GetOverrideRet() = 0;			//!< Gets the override result.
   1.341 -															//!<  If none is specified, NULL
   1.342 -		virtual void *GetIfacePtr() = 0;					//!< Gets the interface pointer
   1.343 -		//////////////////////////////////////////////////////////////////////////
   1.344 -		// For hook managers
   1.345 -		virtual void HookLoopBegin(IIface *pIface) = 0;			//!< Should be called when a hook loop begins
   1.346 -		virtual void HookLoopEnd() = 0;							//!< Should be called when a hook loop exits
   1.347 -		virtual void SetCurResPtr(META_RES *mres) = 0;			//!< Sets pointer to the current meta result
   1.348 -		virtual void SetPrevResPtr(META_RES *mres) = 0;			//!< Sets pointer to previous meta result
   1.349 -		virtual void SetStatusPtr(META_RES *mres) = 0;			//!< Sets pointer to the status variable
   1.350 -		virtual void SetIfacePtrPtr(void **pp) = 0;				//!< Sets pointer to the interface this pointer
   1.351 -		virtual void SetOrigRetPtr(const void *ptr) = 0;		//!< Sets the original return pointer
   1.352 -		virtual void SetOverrideRetPtr(void *ptr) = 0;			//!< Sets the override result pointer
   1.353 -		virtual bool ShouldContinue() = 0;						//!< Returns false if the hook loop should exit
   1.354 -
   1.355 -		/**
   1.356 -		*	@brief Remove a hook manager. Auto-removes all hooks attached to it from plugin plug.
   1.357 -		*
   1.358 -		*	@param plug The owner of the hook manager
   1.359 -		*   @param pubFunc The hook manager's info function
   1.360 -		*/
   1.361 -		virtual void RemoveHookManager(Plugin plug, HookManagerPubFunc pubFunc) = 0;
   1.362 -
   1.363 -		virtual void DoRecall() = 0;							//!< Initiates a recall sequence
   1.364 -		/*
   1.365 -			HOW RECALLS WORK:
   1.366 -			
   1.367 -			The problem:
   1.368 -				Users want the ability to change parameters of the called function
   1.369 -				from inside their handler.
   1.370 -			The solution:
   1.371 -				1) Mark as "recall"
   1.372 -				2) Recall the function
   1.373 -				3) => SH's hook func gets called:
   1.374 -				  4) The first iterator points at the first hook the last hookfunc didn't execute yet
   1.375 -				  5) does all iteration and returns normally
   1.376 -		        6) The user's handler returns immediately
   1.377 -				7) The hook func returns immediately as well
   1.378 -
   1.379 -				Also note that the recalled hookfunc starts with the status the recalling hookfunc
   1.380 -				ended with. The last handler (doing the recall) is also able to specify its own
   1.381 -				META_RES.
   1.382 -		*/
   1.383 -
   1.384 -		virtual void *GetOverrideRetPtr() = 0;		//!< Returns the pointer set by SetOverrideRetPtr
   1.385 -
   1.386 -		/**
   1.387 -		*	@brief Set up the hook loop. Equivalent to calling:
   1.388 -		*	SetStatusPtr, SetPrevResPtr, SetCurResPtr, SetIfacePtrPtr, SetOrigRetPtr, Get/SetOverrideRetPtr
   1.389 -		*
   1.390 -		*	@param statusPtr		pointer to status variable
   1.391 -		*	@param prevResPtr		pointer to previous result variable
   1.392 -		*	@param curResPtr		pointer to current result variable
   1.393 -		*	@param ifacePtrPtr		pointer to interface this pointer variable
   1.394 -		*	@param origRetPr		pointer to original return value variable. NULL for void funcs
   1.395 -		*	@param overrideRetPtr	pointer to override return value variable. NULL for void funcs
   1.396 -		*	
   1.397 -		*	@return Override Return Pointer the hookfunc should use (may differ from overrideRetPtr
   1.398 -		*		when the hook func is being called as part of a recall
   1.399 -		*/
   1.400 -		virtual void *SetupHookLoop(META_RES *statusPtr, META_RES *prevResPtr, META_RES *curResPtr,
   1.401 -			void **ifacePtrPtr, const void *origRetPtr, void *overrideRetPtr) = 0;
   1.402 -
   1.403 -		/**
   1.404  		*	@brief Modes for the new AddHook
   1.405  		*/
   1.406  		enum AddHookMode
   1.407 @@ -503,21 +310,70 @@
   1.408  		*	@param iface The interface pointer
   1.409  		*	@param ifacesize The size of the class iface points to
   1.410  		*	@param myHookMan A hook manager function that should be capable of handling the function
   1.411 -		*	@param handler A pointer to a FastDelegate containing the hook handler
   1.412 +		*	@param handler A pointer to the hook handler something
   1.413  		*	@param post Set to true if you want a post handler
   1.414  		*/
   1.415 -		virtual int AddHookNew(Plugin plug, AddHookMode mode, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.416 +		virtual int AddHook(Plugin plug, AddHookMode mode, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.417 +			ISHDelegate *handler, bool post) = 0;
   1.418 +
   1.419 +		// Source backwarts compat (only for normal hooks)
   1.420 +		virtual bool RemoveHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
   1.421  			ISHDelegate *handler, bool post) = 0;
   1.422  
   1.423  		/**
   1.424 -		*	@brief Remove a VP hook by ID.
   1.425 +		*	@brief Remove a hook by ID.
   1.426 +		*
   1.427 +		*	@return true on success, false otherwise
   1.428 +		*
   1.429 +		*	@param hookid The hook id (returned by AddHook)
   1.430 +		*/
   1.431 +		virtual bool RemoveHookByID(int hookid) = 0;
   1.432 +
   1.433 +		/**
   1.434 +		*	@brief Pause a hook by ID.
   1.435 +		*
   1.436 +		*	@return true on success, false otherwise
   1.437 +		*
   1.438 +		*	@param hookid The hook id (returned by AddHook)
   1.439 +		*/
   1.440 +		virtual bool PauseHookByID(int hookid) = 0;
   1.441 +
   1.442 +		/**
   1.443 +		*	@brief Unpause a hook by ID.
   1.444  		*
   1.445  		*	@return true on success, false otherwise
   1.446  		*
   1.447 -		*	@param plug The unique identifier of the plugin that calls this function
   1.448 -		*	@param hookid The hook id (returned by AddHookNew)
   1.449 +		*	@param hookid The hook id (returned by AddHook)
   1.450 +		*/
   1.451 +		virtual bool UnpauseHookByID(int hookid) = 0;
   1.452 +
   1.453 +		/**
   1.454 +		*	@brief Checks whether a plugin has (a) hook manager(s) that is/are currently used by other plugins
   1.455 +		*
   1.456 +		*	@param plug The unique identifier of the plugin in question
   1.457  		*/
   1.458 -		virtual bool RemoveHookByID(Plugin plug, int hookid) = 0;
   1.459 +
   1.460 +		virtual void SetRes(META_RES res) = 0;				//!< Sets the meta result
   1.461 +		virtual META_RES GetPrevRes() = 0;					//!< Gets the meta result of the
   1.462 +															//!<  previously calledhandler
   1.463 +		virtual META_RES GetStatus() = 0;					//!< Gets the highest meta result
   1.464 +		virtual const void *GetOrigRet() = 0;				//!< Gets the original result.
   1.465 +															//!<  If not in post function, undefined
   1.466 +		virtual const void *GetOverrideRet() = 0;			//!< Gets the override result.
   1.467 +															//!<  If none is specified, NULL
   1.468 +		virtual void *GetIfacePtr() = 0;					//!< Gets the interface pointer
   1.469 +
   1.470 +		virtual void *GetOverrideRetPtr() = 0;				//!< Used for setting the override return value
   1.471 +
   1.472 +		/**
   1.473 +		*	@brief Remove a hook manager. Auto-removes all hooks attached to it from plugin plug.
   1.474 +		*
   1.475 +		*	@param plug The owner of the hook manager
   1.476 +		*   @param pubFunc The hook manager's info function
   1.477 +		*/
   1.478 +		virtual void RemoveHookManager(Plugin plug, HookManagerPubFunc pubFunc) = 0;
   1.479 +
   1.480 +		// For SH_CALL:
   1.481  
   1.482  		/**
   1.483  		*	@brief Makes sure that hooks are going to be ignored on the next call of vfnptr
   1.484 @@ -525,7 +381,7 @@
   1.485  		*	@param plug The unique identifier of the plugin that calls this function
   1.486  		*	@param vfnptr The virtual function pointer of the function in question
   1.487  		*/
   1.488 -		virtual void SetIgnoreHooks(Plugin plug, void *vfnptr) = 0;
   1.489 +		virtual void SetIgnoreHooks(void *vfnptr) = 0;
   1.490  
   1.491  		/**
   1.492  		*	@brief Reverses SetIgnoreHooks' effect
   1.493 @@ -533,15 +389,53 @@
   1.494  		*	@param plug The unique identifier of the plugin that calls this function
   1.495  		*	@param vfnptr The virtual function pointer of the function in question
   1.496  		*/
   1.497 -		virtual void ResetIgnoreHooks(Plugin plug, void *vfnptr) = 0;
   1.498 +		virtual void ResetIgnoreHooks(void *vfnptr) = 0;
   1.499 +
   1.500 +		//////////////////////////////////////////////////////////////////////////
   1.501 +
   1.502 +		// For hook managers	
   1.503 +
   1.504 +		// Returns the current iface ptr
   1.505 +		virtual void DoRecall() = 0;							//!< Initiates a recall sequence
   1.506 +
   1.507 +		/*
   1.508 +			HOW RECALLS WORK:
   1.509 +			
   1.510 +			The problem:
   1.511 +				Users want the ability to change parameters of the called function
   1.512 +				from inside their handler.
   1.513 +			The solution:
   1.514 +				1) Mark as "recall"
   1.515 +				2) Recall the function
   1.516 +				3) => SH's hook func gets called:
   1.517 +				  4) The first iterator points at the first hook the last hookfunc didn't execute yet
   1.518 +				  5) does all iteration and returns normally
   1.519 +		        6) The user's handler returns immediately
   1.520 +				7) The hook func returns immediately as well
   1.521 +
   1.522 +				Also note that the recalled hookfunc starts with the status the recalling hookfunc
   1.523 +				ended with. The last handler (doing the recall) is also able to specify its own
   1.524 +				META_RES.
   1.525 +		*/
   1.526  
   1.527  		/**
   1.528 -		*	@brief Finds the original entry of a virtual function pointer
   1.529 +		*	@brief Set up the hook loop.
   1.530  		*
   1.531 -		*	@param vfnptr The virtual function pointer
   1.532 -		*	@return The original entry if the virtual function pointer has been patched; NULL otherwise.
   1.533 +		*	@param statusPtr		pointer to status variable
   1.534 +		*	@param prevResPtr		pointer to previous result variable
   1.535 +		*	@param curResPtr		pointer to current result variable
   1.536 +		*	@param ifacePtrPtr		pointer to interface this pointer variable
   1.537 +		*	@param origRetPr		pointer to original return value variable. NULL for void funcs
   1.538 +		*	@param overrideRetPtr	pointer to override return value variable. NULL for void funcs
   1.539 +		*	
   1.540 +		*	@return Override Return Pointer the hookfunc should use (may differ from overrideRetPtr
   1.541 +		*		when the hook func is being called as part of a recall
   1.542  		*/
   1.543 -		virtual void *GetOrigVfnPtrEntry(void *vfnptr) = 0;
   1.544 +		virtual IHookContext *SetupHookLoop(IHookManagerInfo *hi, void *vfnptr, void *thisptr, void **origentry,
   1.545 +			META_RES *statusPtr, META_RES *prevResPtr, META_RES *curResPtr,
   1.546 +			const void *origRetPtr, void *overrideRetPtr) = 0;
   1.547 +
   1.548 +		virtual void EndContext(IHookContext *pCtx) = 0;
   1.549  	};
   1.550  
   1.551  	// For META_RESULT_ORIG_RET and META_RESULT_OVERRIDE_RET:
   1.552 @@ -572,50 +466,6 @@
   1.553  			return &ref;
   1.554  		}
   1.555  	};
   1.556 -
   1.557 -	// For source-level compatibility
   1.558 -	template <class T> struct CallClass
   1.559 -	{
   1.560 -		T *ptr;
   1.561 -
   1.562 -		CallClass(T *p) : ptr(p)
   1.563 -		{
   1.564 -		}
   1.565 -
   1.566 -		operator T*()
   1.567 -		{
   1.568 -			return ptr;
   1.569 -		}
   1.570 -	};
   1.571 -
   1.572 -	typedef CallClass<void> GenericCallClass;
   1.573 -	typedef CallClass<EmptyClass> ManualCallClass;
   1.574 -
   1.575 -	template <class T>
   1.576 -	CallClass<T> *GetCallClass(T *p)
   1.577 -	{
   1.578 -		return new CallClass<T>(p);
   1.579 -	}
   1.580 -
   1.581 -	template <class T>
   1.582 -	void ReleaseCallClass(CallClass<T> *p)
   1.583 -	{
   1.584 -		delete p;
   1.585 -	}
   1.586 -
   1.587 -	template <class X, class MFP>
   1.588 -	void *GetOrigVfnPtrEntry(X *pInstance, MFP mfp, ISourceHook *pSH)
   1.589 -	{
   1.590 -		SourceHook::MemFuncInfo info = {true, -1, 0, 0};
   1.591 -		SourceHook::GetFuncInfo(pInstance, mfp, info);
   1.592 -
   1.593 -		void *vfnptr = reinterpret_cast<void*>(
   1.594 -			*reinterpret_cast<void***>(reinterpret_cast<char*>(pInstance) + info.thisptroffs + info.vtbloffs) + info.vtblindex);
   1.595 -
   1.596 -		void *origentry = pSH->GetOrigVfnPtrEntry(vfnptr);
   1.597 -		
   1.598 -		return origentry ? origentry : *reinterpret_cast<void**>(vfnptr);
   1.599 -	}
   1.600  }
   1.601  
   1.602  /************************************************************************/
   1.603 @@ -631,14 +481,23 @@
   1.604  #define RETURN_META(result)					do { SET_META_RESULT(result); return; } while(0)
   1.605  #define RETURN_META_VALUE(result, value)	do { SET_META_RESULT(result); return (value); } while(0)
   1.606  
   1.607 +
   1.608 +template<class T>
   1.609 +SourceHook::CallClass<T> *SH_GET_CALLCLASS(T *p)
   1.610 +{
   1.611 +	return static_cast< SourceHook::CallClass<T> *>(p);
   1.612 +}
   1.613 +#define SH_RELEASE_CALLCLASS(p)
   1.614 +
   1.615 +#define SH_GET_MCALLCLASS(p, size) reinterpret_cast<void*>(p)
   1.616 +
   1.617 +// only call these from the hook handlers directly!
   1.618 +
   1.619  // If a hook on a function which returns a reference does not want to specify a return value,
   1.620  // it can use this macro.
   1.621  //   ONLY USE THIS WITH MRES_IGNORED AND MRES_HANDLED !!!
   1.622  #define RETURN_META_NOREF(result, rettype)	do { SET_META_RESULT(result); return reinterpret_cast<rettype>(*SH_GLOB_SHPTR); } while(0)
   1.623  
   1.624 -// only call these from the hook handlers directly!
   1.625 -// :TODO: enforce it ?
   1.626 -
   1.627  // Why take a memfuncptr instead of iface and func when we have to deduce the iface anyway now?
   1.628  // Well, without it, there'd be no way to specify which overloaded version we want in _VALUE
   1.629  
   1.630 @@ -720,6 +579,7 @@
   1.631  		RETURN_META_VALUE(MRES_SUPERCEDE, (thisptr->*(u.mfp)) newparams); \
   1.632  	} while (0)
   1.633  
   1.634 +
   1.635  #define SH_MANUALHOOK_RECONFIGURE(hookname, pvtblindex, pvtbloffs, pthisptroffs) \
   1.636  	do { \
   1.637  		SH_GLOB_SHPTR->RemoveHookManager(SH_GLOB_PLUGPTR, SH_MFHCls(hookname)::HookManPubFunc); \
   1.638 @@ -728,49 +588,41 @@
   1.639  		SH_MFHCls(hookname)::ms_MFI.vtbloffs = pvtbloffs; \
   1.640  	} while (0)
   1.641  
   1.642 -
   1.643 -#define SH_GET_ORIG_VFNPTR_ENTRY(inst, mfp) (SourceHook::GetOrigVfnPtrEntry(inst, mfp, SH_GLOB_SHPTR))
   1.644 -
   1.645 -// For source-level compatibility
   1.646 -
   1.647 -#define SH_GET_CALLCLASS(ptr) SourceHook::GetCallClass(ptr)
   1.648 -#define SH_GET_MCALLCLASS(ptr, size) SourceHook::GetCallClass(reinterpret_cast<SourceHook::EmptyClass*>(ptr))
   1.649 -#define SH_RELEASE_CALLCLASS(ptr) SourceHook::ReleaseCallClass(ptr)
   1.650 -
   1.651  // New ADD / REMOVE macros.
   1.652  #define SH_STATIC(func) fastdelegate::MakeDelegate(func)
   1.653  #define SH_MEMBER(inst, func) fastdelegate::MakeDelegate(inst, func)
   1.654  
   1.655  #define SH_ADD_HOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.656  	__SourceHook_FHAdd##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.657 -	post, handler)
   1.658 +	SourceHook::ISourceHook::Hook_Normal, post, handler)
   1.659  
   1.660  #define SH_REMOVE_HOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.661  	__SourceHook_FHRemove##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.662  	post, handler) 
   1.663  
   1.664  #define SH_ADD_MANUALHOOK(hookname, ifaceptr, handler, post) \
   1.665 -	__SourceHook_FHMAdd##hookname(reinterpret_cast<void*>(ifaceptr), post, handler)
   1.666 +	__SourceHook_FHMAdd##hookname(reinterpret_cast<void*>(ifaceptr), \
   1.667 +	SourceHook::ISourceHook::Hook_Normal, post, handler)
   1.668  
   1.669  #define SH_REMOVE_MANUALHOOK(hookname, ifaceptr, handler, post) \
   1.670  	__SourceHook_FHMRemove##hookname(reinterpret_cast<void*>(ifaceptr), post, handler) 
   1.671  
   1.672  #define SH_ADD_VPHOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.673 -	__SourceHook_FHVPAdd##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.674 -	post, handler, false)
   1.675 +	__SourceHook_FHAdd##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.676 +	SourceHook::ISourceHook::Hook_VP, post, handler)
   1.677  
   1.678 -#define SH_ADD_DVPHOOK(ifacetype, ifacefunc, vtableptr, handler, post) \
   1.679 -	__SourceHook_FHVPAdd##ifacetype##ifacefunc(reinterpret_cast<void*>(vtableptr), \
   1.680 -	post, handler, true)
   1.681 +#define SH_ADD_DVPHOOK(ifacetype, ifacefunc, ifaceptr, handler, post) \
   1.682 +	__SourceHook_FHAdd##ifacetype##ifacefunc((void*)SourceHook::implicit_cast<ifacetype*>(ifaceptr), \
   1.683 +	SourceHook::ISourceHook::Hook_DVP, post, handler)
   1.684  
   1.685  #define SH_ADD_MANUALVPHOOK(hookname, ifaceptr, handler, post) \
   1.686 -	__SourceHook_FHMVPAdd##hookname(reinterpret_cast<void*>(ifaceptr), post, handler, false)
   1.687 +	__SourceHook_FHMAdd##hookname(reinterpret_cast<void*>(ifaceptr), SourceHook::ISourceHook::Hook_VP, post, handler) 
   1.688  
   1.689 -#define SH_ADD_MANUALDVPHOOK(hookname, vtableptr, handler, post) \
   1.690 -	__SourceHook_FHMVPAdd##hookname(reinterpret_cast<void*>(vtableptr), post, handler, true)
   1.691 +#define SH_ADD_MANUALDVPHOOK(hookname, ifaceptr, handler, post) \
   1.692 +	__SourceHook_FHMAdd##hookname(reinterpret_cast<void*>(ifaceptr), SourceHook::ISourceHook::Hook_DVP, post, handler) 
   1.693  
   1.694  #define SH_REMOVE_HOOK_ID(hookid) \
   1.695 -	(SH_GLOB_SHPTR->RemoveHookByID(SH_GLOB_PLUGPTR, hookid))
   1.696 +	(SH_GLOB_SHPTR->RemoveHookByID(hookid))
   1.697  
   1.698  // Old macros
   1.699  // !! These are now deprecated. Instead, use one of these:
   1.700 @@ -827,12 +679,7 @@
   1.701  #define SH_MFHCls(hookname) __SourceHook_MFHCls_##hookname
   1.702  
   1.703  #define SHINT_MAKE_HOOKMANPUBFUNC(ifacetype, ifacefunc, overload, funcptr) \
   1.704 -	SH_FHCls(ifacetype,ifacefunc,overload)() \
   1.705 -	{ \
   1.706 -		GetFuncInfo(funcptr, ms_MFI); \
   1.707 -	} \
   1.708 -	\
   1.709 -	static int HookManPubFunc(::SourceHook::HookManagerAction action, ::SourceHook::IHookManagerInfo *param) \
   1.710 +	static int HookManPubFunc(bool store, ::SourceHook::IHookManagerInfo *hi) \
   1.711  	{ \
   1.712  		using namespace ::SourceHook; \
   1.713  		GetFuncInfo(funcptr, ms_MFI); \
   1.714 @@ -841,31 +688,16 @@
   1.715  			return 1; \
   1.716  		if (SH_GLOB_SHPTR->GetImplVersion() < SH_IMPL_VERSION) \
   1.717  			return 1; \
   1.718 -		\
   1.719 -		if (action == HA_GetInfo) \
   1.720 +		if (store) \
   1.721 +			ms_HI = hi; \
   1.722 +		if (hi) \
   1.723  		{ \
   1.724 -			param->SetVersion(SH_HOOKMAN_VERSION); \
   1.725 -			param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
   1.726 -				reinterpret_cast<const char*>(&ms_Proto)); \
   1.727 -			\
   1.728  			MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.729  			GetFuncInfo(&SH_FHCls(ifacetype,ifacefunc,overload)::Func, mfi); \
   1.730 -			param->SetHookfuncVfnptr( \
   1.731 -				reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
   1.732 -			return 0; \
   1.733 +			hi->SetInfo(SH_HOOKMAN_VERSION, ms_MFI.vtbloffs, ms_MFI.vtblindex, &ms_Proto, \
   1.734 +				reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex] ); \
   1.735  		} \
   1.736 -		else if (action == HA_Register) \
   1.737 -		{ \
   1.738 -			ms_HI = param; \
   1.739 -			return 0; \
   1.740 -		} \
   1.741 -		else if (action == HA_Unregister) \
   1.742 -		{ \
   1.743 -			ms_HI = NULL; \
   1.744 -			return 0; \
   1.745 -		} \
   1.746 -		else \
   1.747 -			return 1; \
   1.748 +		return 0; \
   1.749  	}
   1.750  
   1.751  // It has to be possible to use the macros in namespaces
   1.752 @@ -885,7 +717,7 @@
   1.753  	SH_FHCls(ifacetype,ifacefunc,overload) SH_FHCls(ifacetype,ifacefunc,overload)::ms_Inst; \
   1.754  	::SourceHook::MemFuncInfo SH_FHCls(ifacetype,ifacefunc,overload)::ms_MFI; \
   1.755  	::SourceHook::IHookManagerInfo *SH_FHCls(ifacetype,ifacefunc,overload)::ms_HI; \
   1.756 -	int __SourceHook_FHAdd##ifacetype##ifacefunc(void *iface, bool post, \
   1.757 +	int __SourceHook_FHAdd##ifacetype##ifacefunc(void *iface, ::SourceHook::ISourceHook::AddHookMode mode, bool post, \
   1.758  		SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
   1.759  	{ \
   1.760  		using namespace ::SourceHook; \
   1.761 @@ -894,23 +726,9 @@
   1.762  		if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
   1.763  			return false; /* No non-virtual functions / virtual inheritance supported */ \
   1.764  		\
   1.765 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, ::SourceHook::ISourceHook::Hook_Normal, iface, mfi.thisptroffs, \
   1.766 -			SH_FHCls(ifacetype,ifacefunc,overload)::HookManPubFunc, \
   1.767 -			new CSHDelegate<SH_FHCls(ifacetype,ifacefunc,overload)::FD>(handler), post); \
   1.768 -	} \
   1.769 -	int __SourceHook_FHVPAdd##ifacetype##ifacefunc(void *iface, bool post, \
   1.770 -		SH_FHCls(ifacetype,ifacefunc,overload)::FD handler, bool direct) \
   1.771 -	{ \
   1.772 -		using namespace ::SourceHook; \
   1.773 -		MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.774 -		GetFuncInfo(funcptr, mfi); \
   1.775 -		if (mfi.thisptroffs < 0 || !mfi.isVirtual) \
   1.776 -			return false; /* No non-virtual functions / virtual inheritance supported */ \
   1.777 -		\
   1.778 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, \
   1.779 -			direct ? ::SourceHook::ISourceHook::Hook_DVP : ::SourceHook::ISourceHook::Hook_VP, \
   1.780 +		return SH_GLOB_SHPTR->AddHook(SH_GLOB_PLUGPTR, mode, \
   1.781  			iface, mfi.thisptroffs, SH_FHCls(ifacetype,ifacefunc,overload)::HookManPubFunc, \
   1.782 -			new CSHDelegate<SH_FHCls(ifacetype,ifacefunc,overload)::FD>(handler), post); \
   1.783 +			new SH_FHCls(ifacetype,ifacefunc,overload)::CMyDelegateImpl(handler), post); \
   1.784  	} \
   1.785  	bool __SourceHook_FHRemove##ifacetype##ifacefunc(void *iface, bool post, \
   1.786  		SH_FHCls(ifacetype,ifacefunc,overload)::FD handler) \
   1.787 @@ -918,10 +736,7 @@
   1.788  		using namespace ::SourceHook; \
   1.789  		MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.790  		GetFuncInfo(funcptr, mfi); \
   1.791 -		if (mfi.thisptroffs < 0) \
   1.792 -			return false; /* No virtual inheritance supported */ \
   1.793 -		\
   1.794 -		CSHDelegate<SH_FHCls(ifacetype,ifacefunc,overload)::FD> tmp(handler); \
   1.795 +		SH_FHCls(ifacetype,ifacefunc,overload)::CMyDelegateImpl tmp(handler); \
   1.796  		return SH_GLOB_SHPTR->RemoveHook(SH_GLOB_PLUGPTR, iface, mfi.thisptroffs, \
   1.797  			SH_FHCls(ifacetype,ifacefunc,overload)::HookManPubFunc, &tmp, post); \
   1.798  	} \
   1.799 @@ -941,42 +756,24 @@
   1.800  			ms_MFI.vtblindex = pvtblidx; \
   1.801  			ms_MFI.vtbloffs = pvtbloffs; \
   1.802  		} \
   1.803 -		static int HookManPubFunc(::SourceHook::HookManagerAction action, ::SourceHook::IHookManagerInfo *param) \
   1.804 +		static int HookManPubFunc(bool store, ::SourceHook::IHookManagerInfo *hi) \
   1.805  		{ \
   1.806  			using namespace ::SourceHook; \
   1.807 -			/* we don't set ms_MFI here because manual hookmans can be reconfigured */ \
   1.808 -			/* :FIXME: possible problem: someone adding a hook from a constructor of a global entity */ \
   1.809 -			/* which is construced before SH_MFHCls(hookname)() gets called? */ \
   1.810  			/* Verify interface version */ \
   1.811  			if (SH_GLOB_SHPTR->GetIfaceVersion() != SH_IFACE_VERSION) \
   1.812  				return 1; \
   1.813  			if (SH_GLOB_SHPTR->GetImplVersion() < SH_IMPL_VERSION) \
   1.814  				return 1; \
   1.815 -			\
   1.816 -			if (action == HA_GetInfo) \
   1.817 +			if (store) \
   1.818 +				ms_HI = hi; \
   1.819 +			if (hi) \
   1.820  			{ \
   1.821 -				param->SetVersion(SH_HOOKMAN_VERSION); \
   1.822 -				param->SetInfo(ms_MFI.vtbloffs, ms_MFI.vtblindex, \
   1.823 -					reinterpret_cast<const char*>(&ms_Proto)); \
   1.824 -				\
   1.825  				MemFuncInfo mfi = {true, -1, 0, 0}; \
   1.826  				GetFuncInfo(&SH_MFHCls(hookname)::Func, mfi); \
   1.827 -				param->SetHookfuncVfnptr( \
   1.828 -					reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex]); \
   1.829 -				return 0; \
   1.830 +				hi->SetInfo(SH_HOOKMAN_VERSION, ms_MFI.vtbloffs, ms_MFI.vtblindex, &ms_Proto, \
   1.831 +					reinterpret_cast<void**>(reinterpret_cast<char*>(&ms_Inst) + mfi.vtbloffs)[mfi.vtblindex] ); \
   1.832  			} \
   1.833 -			else if (action == HA_Register) \
   1.834 -			{ \
   1.835 -				ms_HI = param; \
   1.836 -				return 0; \
   1.837 -			} \
   1.838 -			else if (action == HA_Unregister) \
   1.839 -			{ \
   1.840 -				ms_HI = NULL; \
   1.841 -				return 0; \
   1.842 -			} \
   1.843 -			else \
   1.844 -				return 1; \
   1.845 +			return 0; \
   1.846  		}
   1.847  
   1.848  #define SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, pvtbloffs, pvtblidx, pthisptroffs) \
   1.849 @@ -984,98 +781,68 @@
   1.850  	SH_MFHCls(hookname) SH_MFHCls(hookname)::ms_Inst; \
   1.851  	::SourceHook::MemFuncInfo SH_MFHCls(hookname)::ms_MFI; \
   1.852  	::SourceHook::IHookManagerInfo *SH_MFHCls(hookname)::ms_HI; \
   1.853 -	int __SourceHook_FHMAdd##hookname(void *iface, bool post, \
   1.854 +	int __SourceHook_FHMAdd##hookname(void *iface, ::SourceHook::ISourceHook::AddHookMode mode, bool post, \
   1.855  		SH_MFHCls(hookname)::FD handler) \
   1.856  	{ \
   1.857 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, ::SourceHook::ISourceHook::Hook_Normal, iface, pthisptroffs, \
   1.858 -			SH_MFHCls(hookname)::HookManPubFunc, \
   1.859 -			new ::SourceHook::CSHDelegate<SH_MFHCls(hookname)::FD>(handler), post); \
   1.860 -	} \
   1.861 -	int __SourceHook_FHMVPAdd##hookname(void *iface, bool post, \
   1.862 -		SH_MFHCls(hookname)::FD handler, bool direct) \
   1.863 -	{ \
   1.864 -		return SH_GLOB_SHPTR->AddHookNew(SH_GLOB_PLUGPTR, \
   1.865 -			direct ? ::SourceHook::ISourceHook::Hook_DVP : ::SourceHook::ISourceHook::Hook_VP, \
   1.866 +		return SH_GLOB_SHPTR->AddHook(SH_GLOB_PLUGPTR, mode, \
   1.867  			iface, pthisptroffs, SH_MFHCls(hookname)::HookManPubFunc, \
   1.868 -			new ::SourceHook::CSHDelegate<SH_MFHCls(hookname)::FD>(handler), post); \
   1.869 +			new SH_MFHCls(hookname)::CMyDelegateImpl(handler), post); \
   1.870  	} \
   1.871  	bool __SourceHook_FHMRemove##hookname(void *iface, bool post, \
   1.872  		SH_MFHCls(hookname)::FD handler) \
   1.873  	{ \
   1.874 -		::SourceHook::CSHDelegate<SH_MFHCls(hookname)::FD> tmp(handler); \
   1.875 +		SH_MFHCls(hookname)::CMyDelegateImpl tmp(handler); \
   1.876  		return SH_GLOB_SHPTR->RemoveHook(SH_GLOB_PLUGPTR, iface, pthisptroffs, \
   1.877  			SH_MFHCls(hookname)::HookManPubFunc, &tmp, post); \
   1.878  	} \
   1.879  
   1.880 -
   1.881  #define SH_SETUPCALLS(rettype, paramtypes, params) \
   1.882 -	/* 1) Find the vfnptr */ \
   1.883 +	/* 1) Set up */ \
   1.884  	using namespace ::SourceHook; \
   1.885  	void *ourvfnptr = reinterpret_cast<void*>( \
   1.886  		*reinterpret_cast<void***>(reinterpret_cast<char*>(this) + ms_MFI.vtbloffs) + ms_MFI.vtblindex); \
   1.887 -	IVfnPtr *vfnptr = ms_HI->FindVfnPtr(ourvfnptr); \
   1.888 -	SH_ASSERT(vfnptr, ("Called with vfnptr 0x%p which couldn't be found in the list", ourvfnptr)); \
   1.889 +	void *vfnptr_origentry; \
   1.890  	\
   1.891 -	void *vfnptr_origentry = vfnptr->GetOrigEntry(); \
   1.892 -	/* ... and the iface */ \
   1.893 -	IIface *ifinfo = vfnptr->FindIface(reinterpret_cast<void*>(this)); \
   1.894 -	if (!ifinfo) \
   1.895 -	{ \
   1.896 -		/* The iface info was not found. Redirect the call to the original function. */ \
   1.897 -		rettype (EmptyClass::*mfp)paramtypes; \
   1.898 -		SH_SETUP_MFP(mfp); \
   1.899 -		return (reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
   1.900 -	} \
   1.901 -	/* 2) Declare some vars and set it up */ \
   1.902 -	SH_GLOB_SHPTR->HookLoopBegin(ifinfo); \
   1.903 -	IHookList *prelist = ifinfo->GetPreHooks(); \
   1.904 -	IHookList *postlist = ifinfo->GetPostHooks(); \
   1.905  	META_RES status = MRES_IGNORED; \
   1.906  	META_RES prev_res; \
   1.907  	META_RES cur_res; \
   1.908 +	\
   1.909  	typedef ReferenceCarrier<rettype>::type my_rettype; \
   1.910  	my_rettype orig_ret; \
   1.911  	my_rettype override_ret; \
   1.912  	my_rettype plugin_ret; \
   1.913 -	void* ifptr; \
   1.914 -	my_rettype *pOverrideRet = reinterpret_cast<my_rettype*>(SH_GLOB_SHPTR->SetupHookLoop( \
   1.915 -		&status, &prev_res, &cur_res, &ifptr, &orig_ret, &override_ret));
   1.916 +	IMyDelegate *iter; \
   1.917 +	IHookContext *pContext = SH_GLOB_SHPTR->SetupHookLoop(ms_HI, ourvfnptr, reinterpret_cast<void*>(this), \
   1.918 +		&vfnptr_origentry, &status, &prev_res, &cur_res, &orig_ret, &override_ret);
   1.919  
   1.920  #define SH_CALL_HOOKS(post, params) \
   1.921 -	if (SH_GLOB_SHPTR->ShouldContinue()) \
   1.922 +	prev_res = MRES_IGNORED; \
   1.923 +	while ( iter = static_cast<IMyDelegate*>(pContext->GetNext()) ) \
   1.924  	{ \
   1.925 -		prev_res = MRES_IGNORED; \
   1.926 -		for (AutoHookIter iter(post##list); !iter.End(); iter.Next()) \
   1.927 -		{ \
   1.928 -			cur_res = MRES_IGNORED; \
   1.929 -			ifptr = reinterpret_cast<void*>(reinterpret_cast<char*>(this) - iter.ThisPtrOffs()); \
   1.930 -			plugin_ret = reinterpret_cast<CSHDelegate<FD>*>(iter.Handler())->GetDeleg() params; \
   1.931 -			prev_res = cur_res; \
   1.932 -			if (cur_res > status) \
   1.933 -				status = cur_res; \
   1.934 -			if (cur_res >= MRES_OVERRIDE) \
   1.935 -				*pOverrideRet = plugin_ret; \
   1.936 -			if (!SH_GLOB_SHPTR->ShouldContinue()) \
   1.937 -			{ \
   1.938 -				iter.SetToZero(); \
   1.939 -				break; \
   1.940 -			} \
   1.941 -		} \
   1.942 +		cur_res = MRES_IGNORED; \
   1.943 +		plugin_ret = iter->Call params; \
   1.944 +		prev_res = cur_res; \
   1.945 +		if (cur_res > status) \
   1.946 +			status = cur_res; \
   1.947 +		if (cur_res >= MRES_OVERRIDE) \
   1.948 +			*reinterpret_cast<my_rettype*>(pContext->GetOverrideRetPtr()) = plugin_ret; \
   1.949  	}
   1.950  
   1.951  #define SH_CALL_ORIG(rettype, paramtypes, params) \
   1.952 -	if (status != MRES_SUPERCEDE) \
   1.953 +	if (status != MRES_SUPERCEDE && pContext->ShouldCallOrig()) \
   1.954  	{ \
   1.955  		rettype (EmptyClass::*mfp)paramtypes; \
   1.956  		SH_SETUP_MFP(mfp); \
   1.957  		orig_ret = (reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
   1.958  	} \
   1.959  	else \
   1.960 -		orig_ret = override_ret; \
   1.961 +		orig_ret = override_ret; /* :TODO: ??? : use pContext->GetOverrideRetPtr() or not? */
   1.962  
   1.963  #define SH_RETURN() \
   1.964 -	SH_GLOB_SHPTR->HookLoopEnd(); \
   1.965 -	return status >= MRES_OVERRIDE ? *pOverrideRet : orig_ret;
   1.966 +	const my_rettype *retptr = reinterpret_cast<const my_rettype*>( \
   1.967 +		(status >= MRES_OVERRIDE) ? pContext->GetOverrideRetPtr() : pContext->GetOrigRetPtr()); \
   1.968 +	SH_GLOB_SHPTR->EndContext(pContext); \
   1.969 +	return *retptr;
   1.970  
   1.971  #define SH_HANDLEFUNC(paramtypes, params, rettype) \
   1.972  	SH_SETUPCALLS(rettype, paramtypes, params) \
   1.973 @@ -1086,56 +853,33 @@
   1.974  
   1.975  //////////////////////////////////////////////////////////////////////////
   1.976  #define SH_SETUPCALLS_void(paramtypes, params) \
   1.977 -	/* 1) Find the vfnptr */ \
   1.978 +	/* 1) Set up */ \
   1.979  	using namespace ::SourceHook; \
   1.980  	void *ourvfnptr = reinterpret_cast<void*>( \
   1.981  		*reinterpret_cast<void***>(reinterpret_cast<char*>(this) + ms_MFI.vtbloffs) + ms_MFI.vtblindex); \
   1.982 -	IVfnPtr *vfnptr = ms_HI->FindVfnPtr(ourvfnptr); \
   1.983 -	SH_ASSERT(vfnptr, ("Called with vfnptr 0x%p which couldn't be found in the list", ourvfnptr)); \
   1.984 +	void *vfnptr_origentry; \
   1.985  	\
   1.986 -	void *vfnptr_origentry = vfnptr->GetOrigEntry(); \
   1.987 -	/* ... and the iface */ \
   1.988 -	IIface *ifinfo = vfnptr->FindIface(reinterpret_cast<void*>(this)); \
   1.989 -	if (!ifinfo) \
   1.990 -	{ \
   1.991 -		/* The iface info was not found. Redirect the call to the original function. */ \
   1.992 -		void (EmptyClass::*mfp)paramtypes; \
   1.993 -		SH_SETUP_MFP(mfp); \
   1.994 -		(reinterpret_cast<EmptyClass*>(this)->*mfp)params; \
   1.995 -		return; \
   1.996 -	} \
   1.997 -	/* 2) Declare some vars and set it up */ \
   1.998 -	SH_GLOB_SHPTR->HookLoopBegin(ifinfo); \
   1.999 -	IHookList *prelist = ifinfo->GetPreHooks(); \
  1.1000 -	IHookList *postlist = ifinfo->GetPostHooks(); \
  1.1001  	META_RES status = MRES_IGNORED; \
  1.1002  	META_RES prev_res; \
  1.1003  	META_RES cur_res; \
  1.1004 -	void* ifptr; \
  1.1005 -	SH_GLOB_SHPTR->SetupHookLoop(&status, &prev_res, &cur_res, &ifptr, NULL, NULL); \
  1.1006 +	\
  1.1007 +	IMyDelegate *iter; \
  1.1008 +	IHookContext *pContext = SH_GLOB_SHPTR->SetupHookLoop(ms_HI, ourvfnptr, reinterpret_cast<void*>(this), \
  1.1009 +		&vfnptr_origentry, &status, &prev_res, &cur_res, NULL, NULL);
  1.1010  
  1.1011  #define SH_CALL_HOOKS_void(post, params) \
  1.1012 -	if (SH_GLOB_SHPTR->ShouldContinue()) \
  1.1013 +	prev_res = MRES_IGNORED; \
  1.1014 +	while ( iter = static_cast<IMyDelegate*>(pContext->GetNext()) ) \
  1.1015  	{ \
  1.1016 -		prev_res = MRES_IGNORED; \
  1.1017 -		for (AutoHookIter iter(post##list); !iter.End(); iter.Next()) \
  1.1018 -		{ \
  1.1019 -			cur_res = MRES_IGNORED; \
  1.1020 -			ifptr = reinterpret_cast<void*>(reinterpret_cast<char*>(this) - iter.ThisPtrOffs()); \
  1.1021 -			reinterpret_cast<CSHDelegate<FD>*>(iter.Handler())->GetDeleg() params; \
  1.1022 -			prev_res = cur_res; \
  1.1023 -			if (cur_res > status) \
  1.1024 -				status = cur_res; \
  1.1025 -			if (!SH_GLOB_SHPTR->ShouldContinue()) \
  1.1026 -			{ \
  1.1027 -				iter.SetToZero(); \
  1.1028 -				break; \
  1.1029 -			} \
  1.1030 -		} \
  1.1031 +		cur_res = MRES_IGNORED; \
  1.1032 +		iter->Call params; \
  1.1033 +		prev_res = cur_res; \
  1.1034 +		if (cur_res > status) \
  1.1035 +			status = cur_res; \
  1.1036  	}
  1.1037  
  1.1038  #define SH_CALL_ORIG_void(paramtypes, params) \
  1.1039 -	if (status != MRES_SUPERCEDE) \
  1.1040 +	if (status != MRES_SUPERCEDE && pContext->ShouldCallOrig()) \
  1.1041  	{ \
  1.1042  		void (EmptyClass::*mfp)paramtypes; \
  1.1043  		SH_SETUP_MFP(mfp); \
  1.1044 @@ -1143,7 +887,7 @@
  1.1045  	}
  1.1046  
  1.1047  #define SH_RETURN_void() \
  1.1048 -	SH_GLOB_SHPTR->HookLoopEnd();
  1.1049 +	SH_GLOB_SHPTR->EndContext(pContext);
  1.1050  
  1.1051  #define SH_HANDLEFUNC_void(paramtypes, params) \
  1.1052  	SH_SETUPCALLS_void(paramtypes, params) \
  1.1053 @@ -1171,6 +915,28 @@
  1.1054  
  1.1055  //////////////////////////////////////////////////////////////////////////
  1.1056  
  1.1057 +#define MAKE_DELEG(ret_type, params_decl, params_pass) \
  1.1058 +	struct IMyDelegate : ::SourceHook::ISHDelegate { virtual ret_type Call params_decl = 0; }; \
  1.1059 +	struct CMyDelegateImpl : IMyDelegate \
  1.1060 +	{ \
  1.1061 +		FD m_Deleg; \
  1.1062 +		CMyDelegateImpl(FD deleg) : m_Deleg(deleg) {} \
  1.1063 +		ret_type Call params_decl { return m_Deleg params_pass; } \
  1.1064 +		void DeleteThis() { delete this; } \
  1.1065 +		bool IsEqual(ISHDelegate *pOtherDeleg) { return m_Deleg == static_cast<CMyDelegateImpl*>(pOtherDeleg)->m_Deleg; } \
  1.1066 +	};
  1.1067 +
  1.1068 +#define MAKE_DELEG_void(params_decl, params_pass) \
  1.1069 +	struct IMyDelegate : ::SourceHook::ISHDelegate { virtual void  Call params_decl = 0; }; \
  1.1070 +	struct CMyDelegateImpl : IMyDelegate \
  1.1071 +	{ \
  1.1072 +		FD m_Deleg; \
  1.1073 +		CMyDelegateImpl(FD deleg) : m_Deleg(deleg) {} \
  1.1074 +		void Call params_decl { m_Deleg params_pass; } \
  1.1075 +		void DeleteThis() { delete this; } \
  1.1076 +		bool IsEqual(ISHDelegate *pOtherDeleg) { return m_Deleg == static_cast<CMyDelegateImpl*>(pOtherDeleg)->m_Deleg; } \
  1.1077 +	};
  1.1078 +
  1.1079  // :FIXME:
  1.1080  //  sizeof on references returns the size of the datatype, NOT the pointer size or something
  1.1081  //  -> one should probably flag references in __SourceHook_ParamSizes_* !
  1.1082 @@ -1182,34 +948,37 @@
  1.1083  	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr> \
  1.1084  		(&ifacetype::ifacefunc))) \
  1.1085  		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]@[$1!=0:, @]rettype> FD; \
  1.1086 +		MAKE_DELEG(rettype, (@[$2,1,$1|, :param$2 p$2@]), (@[$2,1,$1|, :p$2@])); \
  1.1087  		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1088  		{ SH_HANDLEFUNC((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@]), rettype); } \
  1.1089  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1090  		(static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr>(&ifacetype::ifacefunc))) \
  1.1091  	\
  1.1092 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1093 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(sizeof(rettype), \
  1.1094 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1095 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
  1.1096 +	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { sizeof(rettype), 0, 0 }, \
  1.1097 +		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
  1.1098 +
  1.1099  
  1.1100  #define SH_DECL_HOOK$1_void(ifacetype, ifacefunc, attr, overload@[$2,1,$1:, param$2@]) \
  1.1101  	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr> \
  1.1102  		(&ifacetype::ifacefunc))) \
  1.1103  		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]> FD; \
  1.1104 +		MAKE_DELEG_void((@[$2,1,$1|, :param$2 p$2@]), (@[$2,1,$1|, :p$2@])); \
  1.1105  		virtual void Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1106  		{ SH_HANDLEFUNC_void((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@])); } \
  1.1107  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1108  		(static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]) attr>(&ifacetype::ifacefunc))) \
  1.1109  	\
  1.1110 -	\
  1.1111 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1112 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(0, \
  1.1113 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1114 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
  1.1115 +	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { 0, 0, 0 }, \
  1.1116 +		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
  1.1117  
  1.1118  #define SH_DECL_HOOK$1_vafmt(ifacetype, ifacefunc, attr, overload, rettype@[$2,1,$1:, param$2@]) \
  1.1119  	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr> \
  1.1120  		(&ifacetype::ifacefunc))) \
  1.1121  		typedef fastdelegate::FastDelegate@($1+1)<@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, rettype> FD; \
  1.1122 -		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@]@[$1!=0:, @]const char *fmt, ...) \
  1.1123 +		MAKE_DELEG(rettype, (@[$2,1,$1|, :param$2 p$2@]@[$1!=0:, @]const char *px), (@[$2,1,$1|, :p$2@]@[$1!=0:, @]px)); \
  1.1124 +		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@] @[$1!=0:, @]const char *fmt, ...) \
  1.1125  		{ \
  1.1126  			char buf[::SourceHook::STRBUF_LEN]; \
  1.1127  			va_list ap; \
  1.1128 @@ -1221,14 +990,15 @@
  1.1129  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1130  		(static_cast<rettype (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr>(&ifacetype::ifacefunc))) \
  1.1131  	\
  1.1132 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { -1@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1133 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(sizeof(rettype), \
  1.1134 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1135 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
  1.1136 +	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { sizeof(rettype), 0, 0 }, \
  1.1137 +		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
  1.1138  
  1.1139  #define SH_DECL_HOOK$1_void_vafmt(ifacetype, ifacefunc, attr, overload@[$2,1,$1:, param$2@]) \
  1.1140  	SHINT_MAKE_GENERICSTUFF_BEGIN(ifacetype, ifacefunc, overload, (static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr> \
  1.1141  		(&ifacetype::ifacefunc))) \
  1.1142  		typedef fastdelegate::FastDelegate@($1+1)<@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *> FD; \
  1.1143 +		MAKE_DELEG_void((@[$2,1,$1|, :param$2 p$2@]@[$1!=0:, @]const char *px), (@[$2,1,$1|, :p$2@]@[$1!=0:, @]px)); \
  1.1144  		virtual void Func(@[$2,1,$1|, :param$2 p$2@]@[$1!=0:, @]const char *fmt, ...) \
  1.1145  		{ \
  1.1146  			char buf[::SourceHook::STRBUF_LEN]; \
  1.1147 @@ -1241,34 +1011,36 @@
  1.1148  	SHINT_MAKE_GENERICSTUFF_END(ifacetype, ifacefunc, overload, \
  1.1149  		(static_cast<void (ifacetype::*)(@[$2,1,$1|, :param$2@]@[$1!=0:, @]const char *, ...) attr>(&ifacetype::ifacefunc))) \
  1.1150  	\
  1.1151 -	const int __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload[] = { -1@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1152 -	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto(0, \
  1.1153 -		$1, __SourceHook_ParamSizes_##ifacetype##ifacefunc##overload);
  1.1154 +	const ::SourceHook::PassInfo __SourceHook_ParamInfos_##ifacetype##ifacefunc##overload[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
  1.1155 +	::SourceHook::ProtoInfo SH_FHCls(ifacetype, ifacefunc, overload)::ms_Proto = { $1, { 0, 0, 0 }, \
  1.1156 +		__SourceHook_ParamInfos_##ifacetype##ifacefunc##overload, 0 };
  1.1157  
  1.1158  #define SH_DECL_MANUALHOOK$1(hookname, vtblidx, vtbloffs, thisptroffs, rettype@[$2,1,$1:, param$2@]) \
  1.1159  	SHINT_MAKE_GENERICSTUFF_BEGIN_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1160  		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]@[$1!=0:, @]rettype> FD; \
  1.1161 +		MAKE_DELEG(rettype, (@[$2,1,$1|, :param$2 p$2@]), (@[$2,1,$1|, :p$2@])); \
  1.1162  		virtual rettype Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1163  		{ SH_HANDLEFUNC((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@]), rettype); } \
  1.1164  		typedef rettype(::SourceHook::EmptyClass::*ECMFP)(@[$2,1,$1|, :param$2@]); \
  1.1165  		typedef rettype RetType; \
  1.1166  	SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1167  	\
  1.1168 -	const int __SourceHook_ParamSizesM_##hookname[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1169 -	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto(sizeof(rettype), \
  1.1170 -		$1, __SourceHook_ParamSizesM_##hookname); \
  1.1171 +	const ::SourceHook::PassInfo __SourceHook_ParamInfosM_##hookname[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
  1.1172 +	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto = { $1, { sizeof(rettype), 0, 0 }, \
  1.1173 +		__SourceHook_ParamInfosM_##hookname, 0 };
  1.1174  
  1.1175  #define SH_DECL_MANUALHOOK$1_void(hookname, vtblidx, vtbloffs, thisptroffs@[$2,1,$1:, param$2@]) \
  1.1176  	SHINT_MAKE_GENERICSTUFF_BEGIN_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1177  		typedef fastdelegate::FastDelegate$1<@[$2,1,$1|, :param$2@]> FD; \
  1.1178 +		MAKE_DELEG_void((@[$2,1,$1|, :param$2 p$2@]), (@[$2,1,$1|, :p$2@])); \
  1.1179  		virtual void Func(@[$2,1,$1|, :param$2 p$2@]) \
  1.1180  		{ SH_HANDLEFUNC_void((@[$2,1,$1|, :param$2@]), (@[$2,1,$1|, :p$2@])); } \
  1.1181  		typedef void(::SourceHook::EmptyClass::*ECMFP)(@[$2,1,$1|, :param$2@]); \
  1.1182  	SHINT_MAKE_GENERICSTUFF_END_MANUAL(hookname, vtbloffs, vtblidx, thisptroffs) \
  1.1183  	\
  1.1184 -	const int __SourceHook_ParamSizesM_##hookname[] = { 0@[$2,1,$1:, sizeof(param$2)@] }; \
  1.1185 -	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto(0, \
  1.1186 -		$1, __SourceHook_ParamSizesM_##hookname); \
  1.1187 +	const ::SourceHook::PassInfo __SourceHook_ParamInfosM_##hookname[] = { {0, 0, 0}@[$2,1,$1:, {sizeof(param$2), 0, 0}@] }; \
  1.1188 +	::SourceHook::ProtoInfo SH_MFHCls(hookname)::ms_Proto = { $1, { 0, 0, 0 }, \
  1.1189 +		__SourceHook_ParamInfosM_##hookname	, 0 };
  1.1190  
  1.1191  @]
  1.1192  
  1.1193 @@ -1280,9 +1052,9 @@
  1.1194  { \
  1.1195  	using namespace ::SourceHook; \
  1.1196  	\
  1.1197 -	m_pSH->SetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1198 +	m_pSH->SetIgnoreHooks(m_VfnPtr); \
  1.1199  	RetType tmpret = (m_ThisPtr->*m_MFP)call; \
  1.1200 -	m_pSH->ResetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1201 +	m_pSH->ResetIgnoreHooks(m_VfnPtr); \
  1.1202  	return tmpret; \
  1.1203  }
  1.1204  
  1.1205 @@ -1290,48 +1062,24 @@
  1.1206  { \
  1.1207  	using namespace ::SourceHook; \
  1.1208  	\
  1.1209 -	m_pSH->SetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1210 +	m_pSH->SetIgnoreHooks(m_VfnPtr); \
  1.1211  	(m_ThisPtr->*m_MFP)call; \
  1.1212 -	m_pSH->ResetIgnoreHooks(m_Plug, m_VfnPtr); \
  1.1213 +	m_pSH->ResetIgnoreHooks(m_VfnPtr); \
  1.1214  }
  1.1215  
  1.1216  namespace SourceHook
  1.1217  {
  1.1218 -	// Call Class Wrapper!
  1.1219 -	template <class T> struct CCW
  1.1220 -	{
  1.1221 -		typedef T type;
  1.1222 -
  1.1223 -		// Get Real Pointer!
  1.1224 -		static inline T *GRP(T *p)
  1.1225 -		{
  1.1226 -			return p;
  1.1227 -		}
  1.1228 -	};
  1.1229 -
  1.1230 -	template <class T> struct CCW< CallClass<T> >
  1.1231 -	{
  1.1232 -		typedef T type;
  1.1233 -
  1.1234 -		// Get Real Pointer!
  1.1235 -		static inline T *GRP(CallClass<T> *p)
  1.1236 -		{
  1.1237 -			return p->ptr;
  1.1238 -		}
  1.1239 -	};
  1.1240 -
  1.1241  @[$1,0,$a:
  1.1242  	// Support for $1 arguments
  1.1243 -	template<class ObjType, class MFP, class RetType@[$2,1,$1:, class Param$2@]> class ExecutableClass$1
  1.1244 +	template<class ObjType, class MFPType, class RetType@[$2,1,$1:, class Param$2@]> class ExecutableClass$1
  1.1245  	{
  1.1246  		ObjType *m_ThisPtr;
  1.1247  		void *m_VfnPtr;
  1.1248 -		MFP m_MFP;
  1.1249 +		MFPType m_MFP;
  1.1250  		ISourceHook *m_pSH;
  1.1251 -		Plugin m_Plug;
  1.1252  	public:
  1.1253 -		ExecutableClass$1(ObjType *tp, MFP mfp, void *vp, ISourceHook *pSH, Plugin plug) : m_ThisPtr(tp),
  1.1254 -			m_VfnPtr(vp), m_MFP(mfp), m_pSH(pSH), m_Plug(plug) { }
  1.1255 +		ExecutableClass$1(ObjType *tp, MFPType mfp, void *vp, ISourceHook *pSH) : m_ThisPtr(tp),
  1.1256 +			m_VfnPtr(vp), m_MFP(mfp), m_pSH(pSH) { }
  1.1257  	
  1.1258  		RetType operator()(@[$2,1,$1|, :Param$2 p$2@]) const
  1.1259  			SH_MAKE_EXECUTABLECLASS_OB((@[$2,1,$1|, :p$2@]), (@[$2,1,$1|, :Param$2@]))
  1.1260 @@ -1342,16 +1090,15 @@
  1.1261  		@]
  1.1262  	};
  1.1263  
  1.1264 -	template<class ObjType, class MFP@[$2,1,$1:, class Param$2@]> class ExecutableClass$1<ObjType, MFP, void@[$2,1,$1:, Param$2@]>
  1.1265 +	template<class ObjType, class MFPType@[$2,1,$1:, class Param$2@]> class ExecutableClass$1<ObjType, MFPType, void@[$2,1,$1:, Param$2@]>
  1.1266  	{
  1.1267 -	   ObjType *m_ThisPtr;
  1.1268 -	   void *m_VfnPtr;
  1.1269 -	   MFP m_MFP;
  1.1270 -	   ISourceHook *m_pSH;
  1.1271 -	   Plugin m_Plug;
  1.1272 +		ObjType *m_ThisPtr;
  1.1273 +		void *m_VfnPtr;
  1.1274 +		MFPType m_MFP;
  1.1275 +		ISourceHook *m_pSH;
  1.1276  	public:
  1.1277 -	   ExecutableClass$1(ObjType *tp, MFP mfp, void *vp, ISourceHook *pSH, Plugin plug) : m_ThisPtr(tp),
  1.1278 -		   m_VfnPtr(vp), m_MFP(mfp), m_pSH(pSH), m_Plug(plug) { }
  1.1279 +		ExecutableClass$1(ObjType *tp, MFPType mfp, void *vp, ISourceHook *pSH) : m_ThisPtr(tp),
  1.1280 +			m_VfnPtr(vp), m_MFP(mfp), m_pSH(pSH) { }
  1.1281  	
  1.1282  	   void operator()(@[$2,1,$1|, :Param$2 p$2@]) const
  1.1283  	      SH_MAKE_EXECUTABLECLASS_OB_void((@[$2,1,$1|, :p$2@]), (@[$2,1,$1|, :Param$2@]))
  1.1284 @@ -1368,14 +1115,14 @@
  1.1285  #define SH__CALL_GET_VFNPTR_NORMAL \
  1.1286  	using namespace ::SourceHook; \
  1.1287  	MemFuncInfo mfi = {true, -1, 0, 0}; \
  1.1288 -	GetFuncInfo(CCW<Y>::GRP(ptr), mfp, mfi); \
  1.1289 +	GetFuncInfo(ptr, mfp, mfi); \
  1.1290  	void *vfnptr = reinterpret_cast<void*>( \
  1.1291  		*reinterpret_cast<void***>(reinterpret_cast<char*>(ptr) + mfi.thisptroffs + mfi.vtbloffs) + mfi.vtblindex);
  1.1292  
  1.1293  #define SH__CALL_GET_VFNPTR_MANUAL \
  1.1294  	using namespace ::SourceHook; \
  1.1295  	void *vfnptr = reinterpret_cast<void*>( \
  1.1296 -		*reinterpret_cast<void***>( (reinterpret_cast<char*>(CCW<Y>::GRP(ptr)) + thisptroffs + vtbloffs) ) + vtblidx); \
  1.1297 +		*reinterpret_cast<void***>( (reinterpret_cast<char*>(ptr) + thisptroffs + vtbloffs) ) + vtblidx); \
  1.1298  	/* patch mfp */ \
  1.1299  	*reinterpret_cast<void**>(&mfp) = *reinterpret_cast<void**>(vfnptr);
  1.1300  
  1.1301 @@ -1386,30 +1133,28 @@
  1.1302  @[$1,0,$a:
  1.1303  // Support for $1 arguments
  1.1304  template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1305 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1306 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]), SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1307 +SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1308 +SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]), SourceHook::ISourceHook *shptr)
  1.1309  {
  1.1310  	SH__CALL_GET_VFNPTR_NORMAL
  1.1311 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1312 -		mfp, vfnptr, shptr, plug);
  1.1313 +	return SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>(ptr, mfp, vfnptr, shptr);
  1.1314  }
  1.1315  
  1.1316  template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1317 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1318 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@])const, SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1319 +SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1320 +SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@])const, SourceHook::ISourceHook *shptr)
  1.1321  {
  1.1322  	SH__CALL_GET_VFNPTR_NORMAL
  1.1323 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1324 -		mfp, vfnptr, shptr, plug);
  1.1325 +	return SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>(ptr, mfp, vfnptr, shptr);
  1.1326  }
  1.1327  
  1.1328  template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1329  SourceHook::ExecutableClass$1<SourceHook::EmptyClass, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1330 -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.1331 +SH_MCALL3(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]), int vtblidx, int vtbloffs, int thisptroffs, SourceHook::ISourceHook *shptr)
  1.1332  {
  1.1333  	SH__CALL_GET_VFNPTR_MANUAL
  1.1334  	return SourceHook::ExecutableClass$1<EmptyClass, MFP, RetType@[$2,1,$1:, Param$2@]>(
  1.1335 -		reinterpret_cast<SourceHook::EmptyClass*>(CCW<Y>::GRP(ptr)), mfp, vfnptr, shptr, plug);
  1.1336 +		reinterpret_cast<SourceHook::EmptyClass*>(ptr), mfp, vfnptr, shptr);
  1.1337  }
  1.1338  @]
  1.1339  
  1.1340 @@ -1419,33 +1164,32 @@
  1.1341  @[$1,0,$a:
  1.1342  // Support for $1 arguments
  1.1343  template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1344 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1345 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]@[$1!=0:, @]...), SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1346 +SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1347 +SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]@[$1!=0:, @]...), SourceHook::ISourceHook *shptr)
  1.1348  {
  1.1349  	SH__CALL_GET_VFNPTR_NORMAL
  1.1350 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1351 -		mfp, vfnptr, shptr, plug);
  1.1352 +	return SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>(ptr, mfp, vfnptr, shptr);
  1.1353  }
  1.1354  
  1.1355  template <class X, class Y, class MFP, class RetType@[$2,1,$1:, class Param$2@]>
  1.1356 -SourceHook::ExecutableClass$1<typename SourceHook::CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1357 -SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]@[$1!=0:, @]...)const, SourceHook::ISourceHook *shptr, SourceHook::Plugin plug)
  1.1358 +SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>
  1.1359 +SH_CALL2(Y *ptr, MFP mfp, RetType(X::*mfp2)(@[$2,1,$1|, :Param$2@]@[$1!=0:, @]...)const, SourceHook::ISourceHook *shptr)
  1.1360  {
  1.1361  	SH__CALL_GET_VFNPTR_NORMAL
  1.1362 -	return SourceHook::ExecutableClass$1<typename CCW<Y>::type, MFP, RetType@[$2,1,$1:, Param$2@]>(CCW<Y>::GRP(ptr),
  1.1363 -		mfp, vfnptr, shptr, plug);
  1.1364 +	return SourceHook::ExecutableClass$1<Y, MFP, RetType@[$2,1,$1:, Param$2@]>(ptr, mfp, vfnptr, shptr);
  1.1365  }
  1.1366  
  1.1367  @]
  1.1368  
  1.1369  #endif
  1.1370  
  1.1371 -#define SH_CALL(ptr, mfp) SH_CALL2((ptr), (mfp), (mfp), SH_GLOB_SHPTR, SH_GLOB_PLUGPTR)
  1.1372 -#define SH_MCALL2(ptr, mfp, vtblidx, vtbloffs, thisptroffs) SH_MCALL3((ptr), (mfp), (mfp), (vtblidx), (vtbloffs), (thisptroffs), SH_GLOB_SHPTR, SH_GLOB_PLUGPTR)
  1.1373 +#define SH_CALL(ptr, mfp) SH_CALL2((ptr), (mfp), (mfp), SH_GLOB_SHPTR)
  1.1374 +#define SH_MCALL2(ptr, mfp, vtblidx, vtbloffs, thisptroffs) SH_MCALL3((ptr), (mfp), (mfp), (vtblidx), (vtbloffs), (thisptroffs), SH_GLOB_SHPTR)
  1.1375  #define SH_MCALL(ptr, mhookname) SH_MCALL2((ptr), SH_MFHCls(mhookname)::ECMFP(), SH_MFHCls(mhookname)::ms_MFI.vtblindex, \
  1.1376  	SH_MFHCls(mhookname)::ms_MFI.vtbloffs, SH_MFHCls(mhookname)::ms_MFI.thisptroffs)
  1.1377  
  1.1378  #undef SH_MAKE_EXECUTABLECLASS_OB
  1.1379 +#undef SH_MAKE_EXECUTABLECLASS_OB_void
  1.1380  
  1.1381  //////////////////////////////////////////////////////////////////////////
  1.1382  // SetOverrideRet and RecallGetIface for recalls