ds@658: /* ======== SourceHook ======== pavolmarko@733: * Copyright (C) 2004-2010 Metamod:Source Development Team ds@658: * No warranties of any kind ds@658: * ds@658: * License: zlib/libpng ds@658: * ds@658: * Author(s): Pavol "PM OnoTo" Marko ds@658: * ============================ ds@658: */ ds@658: ds@658: #ifndef __SOURCEHOOK_IMPL_CHOOKMANINFO_H__ ds@658: #define __SOURCEHOOK_IMPL_CHOOKMANINFO_H__ ds@658: ds@658: #include "sh_list.h" ds@658: #include "sourcehook_impl_cproto.h" ds@658: ds@658: namespace SourceHook ds@658: { ds@658: namespace Impl ds@658: { ds@658: class CVfnPtr; ds@658: ds@658: class CHookManager : public IHookManagerInfo ds@658: { ds@658: // *** Data *** ds@658: Plugin m_OwnerPlugin; ds@658: HookManagerPubFunc m_PubFunc; ds@658: int m_VtblOffs; ds@658: int m_VtblIdx; ds@658: CProto m_Proto; ds@658: int m_Version; ds@658: ds@658: void *m_HookfuncVfnptr; ds@658: ds@658: List m_VfnPtrs; ds@658: public: ds@658: // *** Descriptor *** ds@658: struct Descriptor ds@658: { ds@658: Plugin m_OwnerPlugin; ds@658: HookManagerPubFunc m_PubFunc; ds@658: Descriptor(Plugin ownerPlugin, HookManagerPubFunc pubFunc) ds@658: : m_OwnerPlugin(ownerPlugin), m_PubFunc(pubFunc) ds@658: { ds@658: } ds@658: }; ds@658: ds@658: // *** Interface *** pavolmarko@733: CHookManager(Plugin ownerPlugin, HookManagerPubFunc pubFunc); ds@658: ds@658: inline bool operator==(const Descriptor &other) const; ds@658: inline bool operator==(const CHookManager &other) const; ds@658: ds@658: inline operator bool() const; ds@658: inline Plugin GetOwnerPlugin() const; ds@658: inline int GetVtblOffs() const; ds@658: inline int GetVtblIdx() const; ds@658: inline const CProto &GetProto() const; ds@658: inline int GetVersion() const; ds@658: inline void *GetHookFunc() const; ds@658: inline HookManagerPubFunc GetPubFunc() const; ds@658: pavolmarko@733: void Register(); pavolmarko@733: void Unregister(); ds@658: pavolmarko@733: void IncrRef(CVfnPtr *pVfnPtr); pavolmarko@733: void DecrRef(CVfnPtr *pVfnPtr); ds@658: ds@658: List &GetVfnPtrList() ds@658: { ds@658: return m_VfnPtrs; ds@658: } ds@658: ds@658: // *** IHookManagerInfo interface *** pavolmarko@380: void SetInfo(int hookman_version, int vtbloffs, int vtblidx, ds@658: ProtoInfo *proto, void *hookfunc_vfnptr); ds@658: }; ds@658: ds@658: class CHookManList : public List ds@658: { ds@658: public: pavolmarko@733: CHookManager *GetHookMan(Plugin plug, HookManagerPubFunc pubFunc); pavolmarko@733: CHookManager *GetHookMan(CHookManager &hm); ds@658: }; ds@658: pavolmarko@733: // *** Implementation **/ ds@658: ds@658: inline CHookManager::operator bool() const ds@658: { ds@658: return m_Version != -1; ds@658: } ds@658: ds@658: inline bool CHookManager::operator==(const Descriptor &other) const ds@658: { ds@658: return m_OwnerPlugin == other.m_OwnerPlugin ds@658: && m_PubFunc == other.m_PubFunc; ds@658: } ds@658: ds@658: inline bool CHookManager::operator==(const CHookManager &other) const ds@658: { ds@658: return m_OwnerPlugin == other.m_OwnerPlugin ds@658: && m_PubFunc == other.m_PubFunc; ds@658: } ds@658: ds@658: inline Plugin CHookManager::GetOwnerPlugin() const ds@658: { ds@658: return m_OwnerPlugin; ds@658: } ds@658: ds@658: inline int CHookManager::GetVtblOffs() const ds@658: { ds@658: return m_VtblOffs; ds@658: } ds@658: ds@658: inline int CHookManager::GetVtblIdx() const ds@658: { ds@658: return m_VtblIdx; ds@658: } ds@658: ds@658: inline const CProto &CHookManager::GetProto() const ds@658: { ds@658: return m_Proto; ds@658: } ds@658: ds@658: inline int CHookManager::GetVersion() const ds@658: { ds@658: return m_Version; ds@658: } ds@658: ds@658: inline void *CHookManager::GetHookFunc() const ds@658: { ds@658: return *reinterpret_cast(m_HookfuncVfnptr); ds@658: } ds@658: ds@658: inline HookManagerPubFunc CHookManager::GetPubFunc() const ds@658: { ds@658: return m_PubFunc; ds@658: } ds@658: } ds@658: } ds@658: pavolmarko@381: #endif pavolmarko@381: