1.1 --- a/sourcehook/sourcehook_impl.h Fri May 11 19:21:14 2007 +0000
1.2 +++ b/sourcehook/sourcehook_impl.h Sat May 12 08:08:01 2007 +0000
1.3 @@ -90,6 +90,9 @@
1.4
1.5 ---------------------------------------
1.6 Call classes
1.7 +
1.8 + !! deprecated !! - see below (new SH_CALL)
1.9 +
1.10 Call classes are identified by a this pointer and an instance size
1.11
1.12 We use the instance size because a derived class instance and a base class instance could
1.13 @@ -152,8 +155,25 @@
1.14
1.15 I'm afraid that with the addition of Recalls and VP Hooks, SourceHook is now a pretty complex and hacked-together
1.16 binary compatible beast which is pretty hard to maintain unless you've written it :)
1.17 +
1.18 +New SH_CALL
1.19 + The addition of VP hooks messed up the Call Classes concept (see above) - call classes are bound to an
1.20 + instance pointer; they only work on one of the hooked instances. But VP hooks are called on all instances.
1.21 +
1.22 + That's why now, SH_CALL takes an instance pointer instead of a callclass pointer. It basically does this:
1.23 + 1) call SH_GLOB_PTR->SetIgnoreHooks(vfnptr)
1.24 + 2) call this->*mfp
1.25 + 3) call SH_GLOB_PTR->ResetIgnoreHooks(vfnptr)
1.26 +
1.27 + SourceHook stroes the "ignored vfnptr" and makes CVfnPtr::FindIface return NULL if the CVfnPtr instance
1.28 + corresponds to the ignored vfnptr. This way the hook manager thinks that the instance isn't hooked, and calls
1.29 + the original function. Everything works fine. This works even for VP hooks.
1.30 */
1.31
1.32 +// See sourcehook.hxx :)
1.33 +#undef CallClass
1.34 +#undef ManualCallClass
1.35 +
1.36 namespace SourceHook
1.37 {
1.38 /**
1.39 @@ -416,8 +436,9 @@
1.40
1.41 IfaceList m_Ifaces;
1.42
1.43 + void **m_pOneIgnore;
1.44 public:
1.45 - CVfnPtr(void *ptr);
1.46 + CVfnPtr(void *ptr, void **pOneIgnore);
1.47 virtual ~CVfnPtr();
1.48
1.49 void *GetVfnPtr();
1.50 @@ -609,6 +630,9 @@
1.51
1.52 HookLoopInfoStack m_HLIStack;
1.53 CHookIDManager m_HookIDMan;
1.54 +
1.55 + void *m_OneIgnore; //:TODO:
1.56 + bool m_IgnoreActive;
1.57 public:
1.58 CSourceHookImpl();
1.59 virtual ~CSourceHookImpl();
1.60 @@ -748,6 +772,8 @@
1.61 * @param plug The unique identifier of the plugin that calls this function
1.62 * @param mode Can be either Hook_Normal or Hook_VP (vtable-wide hook)
1.63 * @param iface The interface pointer
1.64 + * The representative interface pointer for VP hooks
1.65 + * The vtable pointer for direct VP hooks !!!
1.66 * @param ifacesize The size of the class iface points to
1.67 * @param myHookMan A hook manager function that should be capable of handling the function
1.68 * @param handler A pointer to a FastDelegate containing the hook handler
1.69 @@ -765,6 +791,22 @@
1.70 * @param hookid The hook id (returned by AddHookNew)
1.71 */
1.72 virtual bool RemoveHookByID(Plugin plug, int hookid);
1.73 +
1.74 + /**
1.75 + * @brief Makes sure that hooks are going to be ignored on the next call of vfnptr
1.76 + *
1.77 + * @param plug The unique identifier of the plugin that calls this function
1.78 + * @param vfnptr The virtual function pointer of the function in question
1.79 + */
1.80 + virtual void SetIgnoreHooks(Plugin plug, void *vfnptr);
1.81 +
1.82 + /**
1.83 + * @brief Reverses SetIgnoreHooks' effect
1.84 + *
1.85 + * @param plug The unique identifier of the plugin that calls this function
1.86 + * @param vfnptr The virtual function pointer of the function in question
1.87 + */
1.88 + virtual void ResetIgnoreHooks(Plugin plug, void *vfnptr);
1.89 };
1.90 }
1.91