sourcehook/sourcehook_impl.h
changeset 41 534eac4c53ef
parent 34 11e62a912700
child 42 390a2aec00e4
     1.1 --- a/sourcehook/sourcehook_impl.h	Thu Apr 28 17:24:39 2005 +0000
     1.2 +++ b/sourcehook/sourcehook_impl.h	Fri Apr 29 20:29:46 2005 +0000
     1.3 @@ -28,14 +28,15 @@
     1.4  		*/
     1.5  		struct RemoveHookInfo
     1.6  		{
     1.7 -			RemoveHookInfo(Plugin p, void *i, HookManagerPubFunc h, ISHDelegate *hd, bool ps)
     1.8 -				: plug(p), iface(i), hpf(h), handler(hd), post(ps)
     1.9 +			RemoveHookInfo(Plugin pplug, void *piface, HookManagerPubFunc phookman,
    1.10 +				ISHDelegate *phandler, bool ppost)
    1.11 +				: plug(pplug), iface(piface), hookman(phookman), handler(phandler), post(ppost)
    1.12  			{
    1.13  			}
    1.14  
    1.15  			Plugin plug;
    1.16  			void *iface;
    1.17 -			HookManagerPubFunc hpf;
    1.18 +			HookManagerPubFunc hookman;
    1.19  			ISHDelegate *handler;
    1.20  			bool post;
    1.21  		};
    1.22 @@ -45,27 +46,30 @@
    1.23  		*/
    1.24  		typedef std::list<HookManagerInfo> HookManInfoList;
    1.25  
    1.26 -
    1.27 +		struct CallClassInfo
    1.28 +		{
    1.29 +			GenericCallClass cc;
    1.30 +			int refcounter;
    1.31 +			bool operator==(void *other)
    1.32 +			{
    1.33 +				return cc.ptr == other;
    1.34 +			}
    1.35 +		};
    1.36  		/**
    1.37 -		*	@brief A list of Impl_CallClass structures
    1.38 +		*	@brief A list of CallClass structures
    1.39  		*/
    1.40 -		typedef std::list<CallClass> Impl_CallClassList;
    1.41 +		typedef std::list<CallClassInfo> Impl_CallClassList;
    1.42  
    1.43  		Impl_CallClassList m_CallClasses;			//!< A list of already generated callclasses
    1.44  		HookManInfoList m_HookMans;					//!< A list of hook managers
    1.45  
    1.46 -		int m_PageSize;								//!< Stores the system's page size
    1.47 -
    1.48  		/**
    1.49  		*	@brief Finds a hook manager for a function based on a text-prototype, a vtable offset and a vtable index
    1.50  		*/
    1.51  		HookManInfoList::iterator FindHookMan(HookManInfoList::iterator begin, HookManInfoList::iterator end, 
    1.52 -			const char *proto, int vtblofs, int vtblidx, int thisptrofs);
    1.53 +			const char *proto, int vtblofs, int vtblidx);
    1.54  
    1.55 -		void FreeCallClass(CallClass &cc);
    1.56 -		bool ApplyCallClassPatch(CallClass &cc, int vtbl_offs, int vtbl_idx, void *orig_entry);
    1.57 -
    1.58 -		static const int MAX_VTABLE_LEN = 4096;		//!< Maximal vtable length in bytes
    1.59 +		void ApplyCallClassPatch(CallClassInfo &cc, int vtbl_offs, int vtbl_idx, void *orig_entry);
    1.60  
    1.61  		META_RES m_Status, m_PrevRes, m_CurRes;
    1.62  		const void *m_OrigRet;
    1.63 @@ -97,7 +101,7 @@
    1.64  		*	@param handler A pointer to a FastDelegate containing the hook handler
    1.65  		*	@param post Set to true if you want a post handler
    1.66  		*/
    1.67 -		bool AddHook(Plugin plug, void *iface, int ifacesize, HookManagerPubFunc myHookMan, ISHDelegate *handler, bool post);
    1.68 +		bool AddHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan, ISHDelegate *handler, bool post);
    1.69  
    1.70  		/**
    1.71  		*	@brief Removes a hook.
    1.72 @@ -106,6 +110,20 @@
    1.73  		*
    1.74  		*	@param plug The unique identifier of the plugin that calls this function
    1.75  		*	@param iface The interface pointer
    1.76 +		*	@param thisptr_offs This pointer adjuster
    1.77 +		*	@param myHookMan A hook manager function that should be capable of handling the function
    1.78 +		*	@param handler A pointer to a FastDelegate containing the hook handler
    1.79 +		*	@param post Set to true if you want a post handler
    1.80 +		*/
    1.81 +		bool RemoveHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan, ISHDelegate *handler, bool post);
    1.82 +
    1.83 +		/**
    1.84 +		*	@brief Removes a hook.
    1.85 +		*
    1.86 +		*	@return True if the function succeeded, false otherwise
    1.87 +		*
    1.88 +		*	@param plug The unique identifier of the plugin that calls this function
    1.89 +		*	@param iface Already adjusted interface pointer
    1.90  		*	@param myHookMan A hook manager function that should be capable of handling the function
    1.91  		*	@param handler A pointer to a FastDelegate containing the hook handler
    1.92  		*	@param post Set to true if you want a post handler
    1.93 @@ -113,6 +131,15 @@
    1.94  		bool RemoveHook(Plugin plug, void *iface, HookManagerPubFunc myHookMan, ISHDelegate *handler, bool post);
    1.95  
    1.96  		/**
    1.97 +		*	@brief Removes a hook.
    1.98 +		*
    1.99 +		*	@ return True if the function succeeded, false otherwise
   1.100 +		*
   1.101 +		*	@param info A RemoveHookInfo structure, describing the hook
   1.102 +		*/
   1.103 +		bool RemoveHook(RemoveHookInfo info);
   1.104 +
   1.105 +		/**
   1.106  		*	@brief Checks whether a plugin has (a) hook manager(s) that is/are currently used by other plugins
   1.107  		*
   1.108  		*	@param plug The unique identifier of the plugin in question
   1.109 @@ -138,14 +165,14 @@
   1.110  		*
   1.111  		*	@param iface The interface pointer
   1.112  		*/
   1.113 -		void *GetCallClass(void *iface, size_t size);
   1.114 +		GenericCallClass *GetCallClass(void *iface);
   1.115  
   1.116  		/**
   1.117  		*	@brief Release a callclass
   1.118  		*
   1.119  		*	@param ptr Pointer to the callclass
   1.120  		*/
   1.121 -		virtual void ReleaseCallClass(void *ptr);
   1.122 +		virtual void ReleaseCallClass(GenericCallClass *ptr);
   1.123  
   1.124  		virtual void SetRes(META_RES res);				//!< Sets the meta result
   1.125  		virtual META_RES GetPrevRes();					//!< Gets the meta result of the previously called handler