correct version now... i guess i'm just tired :)
1 /* ======== SourceHook ========
2 * Copyright (C) 2004-2007 Metamod:Source Development Team
3 * No warranties of any kind
7 * Author(s): Pavol "PM OnoTo" Marko
8 * ============================
11 #ifndef __SOURCEHOOK_IMPL_CHOOKMANINFO_H__
12 #define __SOURCEHOOK_IMPL_CHOOKMANINFO_H__
15 #include "sourcehook_impl_cproto.h"
21 class CHookManager : public IHookManagerInfo
25 HookManagerPubFunc m_PubFunc;
31 void *m_HookfuncVfnptr;
32 List<CVfnPtr> m_VfnPtrList;
38 HookManagerPubFunc m_PubFunc;
39 Descriptor(Plugin ownerPlugin, HookManagerPubFunc pubFunc)
40 : m_OwnerPlugin(ownerPlugin), m_PubFunc(pubFunc)
46 inline CHookManager(Plugin ownerPlugin, HookManagerPubFunc pubFunc);
48 inline bool operator==(const Descriptor &other) const;
49 inline bool operator==(const CHookManager &other) const;
51 inline operator bool() const;
52 inline Plugin GetOwnerPlugin() const;
53 inline int GetVtblOffs() const;
54 inline int GetVtblIdx() const;
55 inline const CProto &GetProto() const;
56 inline int GetVersion() const;
57 inline void *GetHookFunc() const;
58 inline HookManagerPubFunc GetPubFunc() const;
60 inline List<CVfnPtr> &GetVfnPtrList();
61 inline const List<CVfnPtr> &GetVfnPtrList() const;
63 inline void Register();
64 inline void Unregister();
66 CVfnPtr &GetVfnPtr(void *vfnptr);
68 // *** IHookManagerInfo interface ***
69 void SetInfo(int hookman_version, int vtbloffs, int vtblidx,
70 ProtoInfo *proto, void *hookfunc_vfnptr);
73 // *** Implementation ***
74 inline CHookManager::CHookManager(Plugin ownerPlugin, HookManagerPubFunc pubFunc)
75 : m_OwnerPlugin(ownerPlugin), m_PubFunc(pubFunc), m_Version(-1)
78 // -> Should call SetInfo and set all the other variables!
79 if (m_PubFunc(false, this) != 0)
86 inline CHookManager::operator bool() const
88 return m_Version != -1;
91 inline bool CHookManager::operator==(const Descriptor &other) const
93 return m_OwnerPlugin == other.m_OwnerPlugin
94 && m_PubFunc == other.m_PubFunc;
97 inline bool CHookManager::operator==(const CHookManager &other) const
99 return m_OwnerPlugin == other.m_OwnerPlugin
100 && m_PubFunc == other.m_PubFunc;
103 inline Plugin CHookManager::GetOwnerPlugin() const
105 return m_OwnerPlugin;
108 inline int CHookManager::GetVtblOffs() const
113 inline int CHookManager::GetVtblIdx() const
118 inline const CProto &CHookManager::GetProto() const
123 inline int CHookManager::GetVersion() const
128 inline void *CHookManager::GetHookFunc() const
130 return *reinterpret_cast<void**>(m_HookfuncVfnptr);
133 inline HookManagerPubFunc CHookManager::GetPubFunc() const
138 inline List<CVfnPtr> &CHookManager::GetVfnPtrList()
143 inline const List<CVfnPtr> &CHookManager::GetVfnPtrList() const
148 inline void CHookManager::Register()
150 m_PubFunc(true, this);
153 inline void CHookManager::Unregister()
155 m_PubFunc(true, NULL);