Skip to content

Commit

Permalink
Add templated handler for manual hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
mixern6 committed Dec 4, 2023
1 parent 36b9858 commit 564a667
Show file tree
Hide file tree
Showing 7 changed files with 728 additions and 21 deletions.
36 changes: 36 additions & 0 deletions core/sourcehook/sourcehook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,18 @@ namespace SourceHook

int CSourceHookImpl::AddHook(Plugin plug, AddHookMode mode, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
ISHDelegate *handler, bool post)
{
return AddHook(plug, mode, iface, thisptr_offs, HookManagerPubFuncHandler(myHookMan), handler, post);
}

int CSourceHookImpl::AddHook(Plugin plug, AddHookMode mode, void *iface, int thisptr_offs, IHookManagerMemberFunc* myHookMan,
ISHDelegate *handler, bool post)
{
return AddHook(plug, mode, iface, thisptr_offs, HookManagerPubFuncHandler(myHookMan), handler, post);
}

int CSourceHookImpl::AddHook(Plugin plug, AddHookMode mode, void *iface, int thisptr_offs, const HookManagerPubFuncHandler &myHookMan,
ISHDelegate *handler, bool post)
{
if (mode != Hook_Normal && mode != Hook_VP && mode != Hook_DVP)
return 0;
Expand Down Expand Up @@ -172,6 +184,18 @@ namespace SourceHook

bool CSourceHookImpl::RemoveHook(Plugin plug, void *iface, int thisptr_offs, HookManagerPubFunc myHookMan,
ISHDelegate *handler, bool post)
{
return RemoveHook(plug, iface, thisptr_offs, HookManagerPubFuncHandler(myHookMan), handler, post);
}

bool CSourceHookImpl::RemoveHook(Plugin plug, void *iface, int thisptr_offs, IHookManagerMemberFunc* myHookMan,
ISHDelegate *handler, bool post)
{
return RemoveHook(plug, iface, thisptr_offs, HookManagerPubFuncHandler(myHookMan), handler, post);
}

bool CSourceHookImpl::RemoveHook(Plugin plug, void *iface, int thisptr_offs, const HookManagerPubFuncHandler &myHookMan,
ISHDelegate *handler, bool post)
{
// Get info about hook manager and compute adjustediface
CHookManager tmpHookMan(plug, myHookMan);
Expand Down Expand Up @@ -417,6 +441,18 @@ namespace SourceHook
}

void CSourceHookImpl::RemoveHookManager(Plugin plug, HookManagerPubFunc pubFunc)
{
// Find the hook manager
RemoveHookManager(plug, HookManagerPubFuncHandler(pubFunc));
}

void CSourceHookImpl::RemoveHookManager(Plugin plug, IHookManagerMemberFunc* pubFunc)
{
// Find the hook manager
RemoveHookManager(plug, HookManagerPubFuncHandler(pubFunc));
}

void CSourceHookImpl::RemoveHookManager(Plugin plug, const HookManagerPubFuncHandler &pubFunc)
{
// Find the hook manager
CHookManList::iterator hookman_iter = m_HookManList.find(CHookManager::Descriptor(plug, pubFunc));
Expand Down
Loading

0 comments on commit 564a667

Please sign in to comment.