1.1 --- a/sourcehook/sourcehook.cpp Sun Jun 26 19:15:24 2005 +0000
1.2 +++ b/sourcehook/sourcehook.cpp Sat Jul 02 10:09:40 2005 +0000
1.3 @@ -71,12 +71,14 @@
1.4 {
1.5 // 1) Manually remove all hooks by this plugin
1.6 std::list<RemoveHookInfo> hookstoremove;
1.7 + HookManInfoList::iterator hmil_iter;
1.8 +
1.9 #define TMP_CHECK_LIST(name, ispost) \
1.10 for (hook_iter = iface_iter->name.begin(); hook_iter != iface_iter->name.end(); ++hook_iter) \
1.11 if (hook_iter->plug == plug) \
1.12 hookstoremove.push_back(RemoveHookInfo(hook_iter->plug, iface_iter->ptr, \
1.13 hook_iter->thisptr_offs, hmil_iter->func, hook_iter->handler, ispost))
1.14 - for (HookManInfoList::iterator hmil_iter = m_HookMans.begin(); hmil_iter != m_HookMans.end(); ++hmil_iter)
1.15 + for (hmil_iter = m_HookMans.begin(); hmil_iter != m_HookMans.end(); ++hmil_iter)
1.16 {
1.17 for (HookManagerInfo::VfnPtrListIter vfnptr_iter = hmil_iter->vfnptrs.begin();
1.18 vfnptr_iter != hmil_iter->vfnptrs.end(); ++vfnptr_iter)
1.19 @@ -101,7 +103,7 @@
1.20
1.21 HookManInfoList tmphookmans;
1.22 bool erase = false;
1.23 - for (HookManInfoList::iterator hmil_iter = m_HookMans.begin(); hmil_iter != m_HookMans.end();
1.24 + for (hmil_iter = m_HookMans.begin(); hmil_iter != m_HookMans.end();
1.25 erase ? hmil_iter=m_HookMans.erase(hmil_iter) : ++hmil_iter)
1.26 {
1.27 if (hmil_iter->plug == plug)
1.28 @@ -119,7 +121,7 @@
1.29 }
1.30
1.31 // For each hook manager:
1.32 - for (HookManInfoList::iterator hmil_iter = tmphookmans.begin(); hmil_iter != tmphookmans.end(); ++hmil_iter)
1.33 + for (hmil_iter = tmphookmans.begin(); hmil_iter != tmphookmans.end(); ++hmil_iter)
1.34 {
1.35 // Find a suitable hook manager in an other plugin
1.36 HookManInfoList::iterator newHookMan = FindHookMan(m_HookMans.begin(), m_HookMans.end(),
1.37 @@ -142,6 +144,20 @@
1.38 // Unregister the old one, register the new one
1.39 hmil_iter->func(HA_Unregister, NULL);
1.40 newHookMan->func(HA_Register, &(*newHookMan));
1.41 +
1.42 + // zOMG BAIL, here is part of what you wanted:
1.43 +
1.44 + // Go through all vfnptrs in this hookman and patch them to point to the new manager's handler!
1.45 + // or whatever
1.46 + for (HookManagerInfo::VfnPtrListIter vfnptr_iter = newHookMan->vfnptrs.begin();
1.47 + vfnptr_iter != newHookMan->vfnptrs.end(); ++vfnptr_iter)
1.48 + {
1.49 + // And DEREFERENCE newHookMan->hookfunc_vfnptr!
1.50 + // otherwise it will be executing the vtable... had to find out the hard way
1.51 + *reinterpret_cast<void**>(vfnptr_iter->vfnptr) = *reinterpret_cast<void**>(newHookMan->hookfunc_vfnptr);
1.52 + }
1.53 +
1.54 + // That should fix it, bail!
1.55 }
1.56 }
1.57