diff --git a/sourcehook/smm_list.h b/sourcehook/smm_list.h new file mode 100644 index 0000000..0a6c5a7 --- /dev/null +++ b/sourcehook/smm_list.h @@ -0,0 +1,244 @@ +/* ======== SourceMM ======== +* Copyright (C) 2004-2005 Metamod:Source Development Team +* No warranties of any kind +* +* License: zlib/libpng +* +* Author(s): David "BAILOPAN" Anderson +* ============================ +*/ + +#ifndef _INCLUDE_SMM_LIST_H +#define _INCLUDE_SMM_LIST_H + +//This class is from CSDM_amxx by BAILOPAN +// +template +class List +{ +public: + class iterator; + friend class iterator; + class ListNode + { + public: + ListNode(const T & o) : obj(o) { }; + ListNode() { }; + T obj; + ListNode *next; + ListNode *prev; + }; +private: + ListNode *_Initialize() + { + ListNode *n = (ListNode *)malloc(sizeof(ListNode)); + n->next = NULL; + n->prev = NULL; + return n; + } +public: + List() : m_Head(_Initialize()), m_Size(0) + { + } + List(const List &src) : m_Head(_Initialize()), m_Size(0) + { + iterator iter; + for (iter=src.begin(); iter!=src.end(); iter++) + push_back( (*iter) ); + } + ~List() + { + clear(); + if (m_Head) + { + free(m_Head); + m_Head = NULL; + } + } + void push_back(const T &obj) + { + ListNode *node = new ListNode(obj); + + if (!m_Head->prev) + { + //link in the node as the first item + node->next = m_Head; + node->prev = m_Head; + m_Head->prev = node; + m_Head->next = node; + } else { + node->prev = m_Head->prev; + node->next = m_Head; + m_Head->prev->next = node; + m_Head->prev = node; + } + m_Size++; + } + size_t size() + { + return m_Size; + } + void clear() + { + ListNode *node = m_Head->next; + ListNode *temp; + m_Head->next = NULL; + m_Head->prev = NULL; + while (node && node != m_Head) + { + temp = node->next; + delete node; + node = temp; + } + m_Size = 0; + } + bool empty() + { + return (m_Head->next == NULL); + } + T & back() + { + return m_Head->prev->obj; + } +private: + ListNode *m_Head; + size_t m_Size; +public: + class iterator + { + friend class List; + public: + iterator() + { + m_This = NULL; + } + iterator(const List &src) + { + m_This = src.m_Head; + } + iterator(ListNode *n) : m_This(n) + { + } + iterator(const iterator &where) + { + m_This = where.m_This; + } + iterator & operator--() + { + if (m_This) + m_This = m_This->prev; + return *this; + } + //pre increment + iterator & operator++() + { + if (m_This) + m_This = m_This->next; + return *this; + } + iterator operator++(int) + { + iterator old(*this); + if (m_This) + m_This = m_This->next; + return old; + } + T & operator * () const + { + return m_This->obj; + } + T & operator * () + { + return m_This->obj; + } + T * operator -> () const + { + return &(m_This->obj); + } + bool operator != (iterator &where) + { + return (m_This != where.m_This); + } + bool operator ==(iterator &where) + { + return (m_This == where.m_This); + } + private: + ListNode *m_This; + }; +public: + iterator begin() const + { + if (m_Size) + return iterator(m_Head->next); + else + return iterator(m_Head); + } + iterator end() const + { + return iterator(m_Head); + } + iterator erase(iterator &where) + { + ListNode *pNode = where.m_This; + iterator iter(where); + iter++; + + //If we are both the head and tail... + if (m_Head->next == pNode && m_Head->prev == pNode) + { + m_Head->next = NULL; + m_Head->prev = NULL; + } else if (m_Head->next == pNode) { + //we are only the first + pNode->next->prev = m_Head; + m_Head->next = pNode->next; + } else if (m_Head->prev == pNode) { + //we are the tail + pNode->prev->next = m_Head; + m_Head->prev = pNode->prev; + } else { + //middle unlink + pNode->prev->next = pNode->next; + pNode->next->prev = pNode->prev; + } + + delete pNode; + m_Size--; + + return iter; + } +public: + void remove(const T & obj) + { + iterator b; + for (b=begin(); b!=end(); b++) + { + if ( (*b) == obj ) + { + erase( b ); + break; + } + } + } + template + iterator find(const U & equ) + { + iterator iter; + for (iter=begin(); iter!=end(); iter++) + { + if ( (*iter) == equ ) + return iter; + } + return end(); + } + List & operator =(List &src) + { + iterator iter; + for (iter=src.begin(); iter!=src.end(); iter++) + push_back( (*iter) ); + return *this; + } +}; + +#endif //_INCLUDE_CSDM_LIST_H diff --git a/sourcehook/smm_string.h b/sourcehook/smm_string.h new file mode 100755 index 0000000..2d19502 --- /dev/null +++ b/sourcehook/smm_string.h @@ -0,0 +1,364 @@ +/* ======== SourceMM ======== +* Copyright (C) 2004-2005 Metamod:Source Development Team +* No warranties of any kind +* +* License: zlib/libpng +* +* Author(s): David "BAILOPAN" Anderson +* ============================ +*/ + +/* AMX Mod X + * + * by the AMX Mod X Development Team + * originally developed by OLO + */ + +#ifndef _INCLUDE_CSTRING_H +#define _INCLUDE_CSTRING_H + +#include +#include + +class String +{ +public: + String() + { + v = NULL; + a_size = 0; + //assign(""); + } + + ~String() + { + if (v) + delete [] v; + } + + String(const char *src) + { + v = NULL; + a_size = 0; + assign(src); + } + + String(String &src) + { + v = NULL; + a_size = 0; + assign(src.c_str()); + } + + const char *c_str() { return v?v:""; } + + const char *c_str() const { return v?v:""; } + + void append(const char *t) + { + Grow(size() + strlen(t) + 1); + strcat(v, t); + } + + void append(const char c) + { + size_t len = size(); + Grow(len + 2); + v[len] = c; + v[len + 1] = '\0'; + } + + void append(String &d) + { + append(d.c_str()); + } + + void assign(const String &src) + { + assign(src.c_str()); + } + + void assign(const char *d) + { + if (!d) + { + clear(); + } else { + Grow(strlen(d) + 1, false); + strcpy(v, d); + } + } + + void clear() + { + if (v) + v[0] = '\0'; + } + + int compare (const char *d) + { + if (!v) + return strcmp("", d); + else + return strcmp(v, d); + } + + //Added this for amxx inclusion + bool empty() + { + if (!v) + return true; + + if (v[0] == '\0') + return true; + + return false; + } + + size_t size() + { + if (v) + return strlen(v); + else + return 0; + } + + int find(const char c, int index = 0) + { + size_t len = size(); + if (len < 1) + return npos; + if (index >= (int)len || index < 0) + return npos; + unsigned int i = 0; + for (i=index; i<(int)len; i++) + { + if (v[i] == c) + { + return i; + } + } + + return npos; + } + + bool is_space(int c) + { + if (c == '\f' || c == '\n' || + c == '\t' || c == '\r' || + c == '\v' || c == ' ') + { + return true; + } + + return false; + } + + void trim() + { + if (!v) + return; + + unsigned int i = 0; + unsigned int j = 0; + size_t len = strlen(v); + + if (len == 1) + { + if (is_space(v[i])) + { + clear(); + return; + } + } + + unsigned char c0 = v[0]; + + if (is_space(c0)) + { + for (i=0; i=0; i--) + { + if (!is_space(v[i]) + || (is_space(v[i]) && i==0)) + { + erase(i+1, j); + break; + } + j++; + } + } + + if (len == 1) + { + if (is_space(v[0])) + { + clear(); + return; + } + } + } + + void erase(unsigned int start, int num = npos) + { + if (!v) + return; + unsigned int i = 0; + size_t len = size(); + //check for bounds + if (num == npos || start+num > len-num+1) + num = len - start; + //do the erasing + bool copyflag = false; + for (i=0; i=start && i= len || !v) + return ns; + + if (num == npos) + { + num = len - index; + } else if (index+num >= len) { + num = len - index; + } + + unsigned int i = 0, j=0; + unsigned int nslen = num + 2; + + ns.Grow(nslen); + + for (i=index; i= 65 && v[i] <= 90) + v[i] &= ~(1<<5); + } + } + + String & operator = (const String &src) + { + assign(src); + return *this; + } + + String & operator = (const char *src) + { + assign(src); + return *this; + + } + + char operator [] (unsigned int index) + { + if (index > size() || !v) + { + return -1; + } else { + return v[index]; + } + } + + int at(int a) + { + if (a < 0 || a >= (int)size() || !v) + return -1; + + return v[a]; + } + + bool at(int at, char c) + { + if (at < 0 || at >= (int)size() || !v) + return false; + + v[at] = c; + + return true; + } + +private: + void Grow(unsigned int d, bool copy=true) + { + if (d <= a_size) + return; + char *n = new char[d + 1]; + if (copy && v) + strcpy(n, v); + if (v) + delete [] v; + else + strcpy(n, ""); + v = n; + a_size = d + 1; + } + + char *v; + unsigned int a_size; +public: + static const int npos = -1; +}; + +#endif //_INCLUDE_CSTRING_H diff --git a/sourcehook/smm_vector.h b/sourcehook/smm_vector.h new file mode 100644 index 0000000..bd97fd8 --- /dev/null +++ b/sourcehook/smm_vector.h @@ -0,0 +1,97 @@ +/* ======== SourceMM ======== +* Copyright (C) 2004-2005 Metamod:Source Development Team +* No warranties of any kind +* +* License: zlib/libpng +* +* Author(s): David "BAILOPAN" Anderson +* ============================ +*/ + +#ifndef _INCLUDE_SMMVECTOR_H +#define _INCLUDE_SMMVECTOR_H + +template +class DynVector +{ +public: + DynVector() + { + m_Data = NULL; + m_CurrentSize = 0; + m_UsedSize = 0; + } + ~DynVector() + { + clear(); + } + void clear() + { + if (m_Data) + { + delete [] m_Data; + m_Data = NULL; + } + m_UsedSize = 0; + m_CurrentSize = 0; + } + void resize(size_t size) + { + if (!size) + clear(); + else + Grow(size); + m_UsedSize = size; + } + DynVector & operator =(DynVector &src) + { + Grow(src.m_UsedSize + 1); + for (size_t i=0; i size) ? size : m_UsedSize; + for (size_t i=0; i m_CurrentSize) + Grow((m_UsedSize+1) * 2); + m_UsedSize++; + } +private: + T * m_Data; + size_t m_CurrentSize; + size_t m_UsedSize; +}; + +#endif //_INCLUDE_SMMVECTOR_H diff --git a/sourcehook/sourcehook.cpp b/sourcehook/sourcehook.cpp index e76a60c..9da6e12 100644 --- a/sourcehook/sourcehook.cpp +++ b/sourcehook/sourcehook.cpp @@ -14,7 +14,6 @@ * @brief Contains the implementation of the SourceHook API */ -#include #include "sourcehook_impl.h" namespace SourceHook @@ -58,7 +57,7 @@ namespace SourceHook for (HookManagerInfo::VfnPtr::IfaceListIter iface_iter = vfnptr_iter->ifaces.begin(); iface_iter != vfnptr_iter->ifaces.end(); ++iface_iter) { - std::list::iterator hook_iter; + List::iterator hook_iter; TMP_CHECK_LIST(hooks_pre); TMP_CHECK_LIST(hooks_post); } @@ -71,7 +70,7 @@ namespace SourceHook void CSourceHookImpl::UnloadPlugin(Plugin plug) { // 1) Manually remove all hooks by this plugin - std::list hookstoremove; + List hookstoremove; HookManInfoList::iterator hmil_iter; #define TMP_CHECK_LIST(name, ispost) \ @@ -87,7 +86,7 @@ namespace SourceHook for (HookManagerInfo::VfnPtr::IfaceListIter iface_iter = vfnptr_iter->ifaces.begin(); iface_iter != vfnptr_iter->ifaces.end(); ++iface_iter) { - std::list::iterator hook_iter; + List::iterator hook_iter; TMP_CHECK_LIST(hooks_pre, false); TMP_CHECK_LIST(hooks_post, true); } @@ -95,7 +94,7 @@ namespace SourceHook } #undef TMP_CHECK_LIST - for (std::list::iterator rmiter = hookstoremove.begin(); rmiter != hookstoremove.end(); ++rmiter) + for (List::iterator rmiter = hookstoremove.begin(); rmiter != hookstoremove.end(); ++rmiter) RemoveHook(*rmiter); // 2) Other plugins may use hook managers in this plugin. @@ -164,7 +163,7 @@ namespace SourceHook void CSourceHookImpl::CompleteShutdown() { - std::list hookstoremove; + List hookstoremove; #define TMP_CHECK_LIST(name, ispost) \ for (hook_iter = iface_iter->name.begin(); hook_iter != iface_iter->name.end(); ++hook_iter) \ hookstoremove.push_back(RemoveHookInfo(hook_iter->plug, iface_iter->ptr, \ @@ -177,7 +176,7 @@ namespace SourceHook for (HookManagerInfo::VfnPtr::IfaceListIter iface_iter = vfnptr_iter->ifaces.begin(); iface_iter != vfnptr_iter->ifaces.end(); ++iface_iter) { - std::list::iterator hook_iter; + List::iterator hook_iter; TMP_CHECK_LIST(hooks_pre, false); TMP_CHECK_LIST(hooks_post, true); } @@ -185,7 +184,7 @@ namespace SourceHook } #undef TMP_CHECK_LIST - for (std::list::iterator rmiter = hookstoremove.begin(); rmiter != hookstoremove.end(); ++rmiter) + for (List::iterator rmiter = hookstoremove.begin(); rmiter != hookstoremove.end(); ++rmiter) RemoveHook(*rmiter); m_HookMans.clear(); @@ -227,8 +226,7 @@ namespace SourceHook reinterpret_cast(adjustediface) + tmp.vtbl_offs); void *cur_vfnptr = reinterpret_cast(cur_vtptr + tmp.vtbl_idx); - HookManagerInfo::VfnPtrListIter vfnptr_iter = std::find( - hookman->vfnptrs.begin(), hookman->vfnptrs.end(), cur_vfnptr); + HookManagerInfo::VfnPtrListIter vfnptr_iter = hookman->vfnptrs.find(cur_vfnptr); if (vfnptr_iter == hookman->vfnptrs.end()) { @@ -253,8 +251,7 @@ namespace SourceHook ApplyCallClassPatches(adjustediface, tmp.vtbl_offs, tmp.vtbl_idx, vfp.orig_entry); } - HookManagerInfo::VfnPtr::IfaceListIter iface_iter = std::find( - vfnptr_iter->ifaces.begin(), vfnptr_iter->ifaces.end(), adjustediface); + HookManagerInfo::VfnPtr::IfaceListIter iface_iter = vfnptr_iter->ifaces.find(adjustediface); if (iface_iter == vfnptr_iter->ifaces.end()) { // Add a new one @@ -311,18 +308,19 @@ namespace SourceHook reinterpret_cast(adjustediface) + tmp.vtbl_offs); void *cur_vfnptr = reinterpret_cast(cur_vtptr + tmp.vtbl_idx); - HookManagerInfo::VfnPtrListIter vfnptr_iter = std::find(hookman->vfnptrs.begin(), hookman->vfnptrs.end(), cur_vfnptr); + HookManagerInfo::VfnPtrListIter vfnptr_iter = hookman->vfnptrs.find(cur_vfnptr); + if (vfnptr_iter == hookman->vfnptrs.end()) return false; for (HookManagerInfo::VfnPtr::IfaceListIter iface_iter = vfnptr_iter->ifaces.begin(); iface_iter != vfnptr_iter->ifaces.end();) { - std::list &hooks = + List &hooks = post ? iface_iter->hooks_post : iface_iter->hooks_pre; bool erase; - for (std::list::iterator hookiter = hooks.begin(); + for (List::iterator hookiter = hooks.begin(); hookiter != hooks.end(); erase ? hookiter = hooks.erase(hookiter) : ++hookiter) { erase = hookiter->plug == plug && hookiter->handler->IsEqual(handler) && @@ -386,7 +384,7 @@ namespace SourceHook void CSourceHookImpl::ReleaseCallClass(GenericCallClass *ptr) { - Impl_CallClassList::iterator iter = std::find(m_CallClasses.begin(), m_CallClasses.end(), ptr); + Impl_CallClassList::iterator iter = m_CallClasses.find(ptr); if (iter == m_CallClasses.end()) return; --iter->refcounter; @@ -495,12 +493,12 @@ namespace SourceHook for (HookManagerInfo::VfnPtr::IfaceListIter ifaceiter = vfnptr_iter->ifaces.begin(); ifaceiter != vfnptr_iter->ifaces.end(); ++ifaceiter) { - for (std::list::iterator hookiter = ifaceiter->hooks_pre.begin(); + for (List::iterator hookiter = ifaceiter->hooks_pre.begin(); hookiter != ifaceiter->hooks_pre.end(); ++hookiter) if (plug == hookiter->plug) hookiter->paused = true; - for (std::list::iterator hookiter = ifaceiter->hooks_post.begin(); + for (List::iterator hookiter = ifaceiter->hooks_post.begin(); hookiter != ifaceiter->hooks_post.end(); ++hookiter) if (plug == hookiter->plug) hookiter->paused = true; @@ -516,12 +514,12 @@ namespace SourceHook for (HookManagerInfo::VfnPtr::IfaceListIter ifaceiter = vfnptr_iter->ifaces.begin(); ifaceiter != vfnptr_iter->ifaces.end(); ++ifaceiter) { - for (std::list::iterator hookiter = ifaceiter->hooks_pre.begin(); + for (List::iterator hookiter = ifaceiter->hooks_pre.begin(); hookiter != ifaceiter->hooks_pre.end(); ++hookiter) if (plug == hookiter->plug) hookiter->paused = false; - for (std::list::iterator hookiter = ifaceiter->hooks_post.begin(); + for (List::iterator hookiter = ifaceiter->hooks_post.begin(); hookiter != ifaceiter->hooks_post.end(); ++hookiter) if (plug == hookiter->plug) hookiter->paused = false; diff --git a/sourcehook/sourcehook.h b/sourcehook/sourcehook.h index d8cd856..d20242e 100644 --- a/sourcehook/sourcehook.h +++ b/sourcehook/sourcehook.h @@ -68,10 +68,9 @@ #include "FastDelegate.h" #include "sh_memfuncinfo.h" #include "sh_memory.h" -#include +#include "smm_list.h" #include #include -#include // Good old metamod! @@ -185,8 +184,8 @@ namespace SourceHook int thisptr_offs; //!< This pointer offset }; void *ptr; //!< Pointer to the interface instance - std::list hooks_pre; //!< A list of pre-hooks - std::list hooks_post; //!< A list of post-hooks + List hooks_pre; //!< A list of pre-hooks + List hooks_post; //!< A list of post-hooks bool operator ==(void *other) const { return ptr == other; @@ -196,7 +195,7 @@ namespace SourceHook void *vfnptr; //!< Pointer to the function void *orig_entry; //!< The original vtable entry - typedef std::list IfaceList; + typedef List IfaceList; typedef IfaceList::iterator IfaceListIter; IfaceList ifaces; //!< List of interface pointers @@ -214,7 +213,7 @@ namespace SourceHook void *hookfunc_vfnptr; //!< Pointer to the hookfunc impl - typedef std::list VfnPtrList; + typedef List VfnPtrList; typedef VfnPtrList::iterator VfnPtrListIter; VfnPtrList vfnptrs; //!< List of hooked interfaces }; @@ -467,8 +466,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C void *ourvfnptr = reinterpret_cast( \ *reinterpret_cast(reinterpret_cast(this) + ms_HI->vtbl_offs) + ms_HI->vtbl_idx); \ \ - HookManagerInfo::VfnPtrListIter vfptriter = std::find(ms_HI->vfnptrs.begin(), \ - ms_HI->vfnptrs.end(), ourvfnptr); \ + HookManagerInfo::VfnPtrListIter vfptriter = ms_HI->vfnptrs.find(ourvfnptr); \ if (vfptriter == ms_HI->vfnptrs.end()) \ { \ /* Bleh? Should be impossible! */ \ @@ -476,7 +474,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C } \ HookManagerInfo::VfnPtr &vfnptr = *vfptriter; \ /* 2) Find the iface */ \ - HookManagerInfo::VfnPtr::IfaceListIter ifiter = std::find(vfnptr.ifaces.begin(), vfnptr.ifaces.end(), this); \ + HookManagerInfo::VfnPtr::IfaceListIter ifiter = vfnptr.ifaces.find(this); \ if (ifiter == vfnptr.ifaces.end()) \ { \ /* The iface info was not found. Redirect the call to the original function. */ \ @@ -486,8 +484,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C } \ HookManagerInfo::VfnPtr::Iface &ci = *ifiter; \ /* 2) Declare some vars and set it up */ \ - std::list &prelist = ci.hooks_pre; \ - std::list &postlist = ci.hooks_post; \ + List &prelist = ci.hooks_pre; \ + List &postlist = ci.hooks_post; \ rettype orig_ret; \ rettype override_ret; \ rettype plugin_ret; \ @@ -501,7 +499,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C #define SH_CALL_HOOKS(post, params) \ prev_res = MRES_IGNORED; \ - for (std::list::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \ + for (List::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \ { \ if (hiter->paused) continue; \ cur_res = MRES_IGNORED; \ @@ -544,8 +542,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C void *ourvfnptr = reinterpret_cast( \ *reinterpret_cast(reinterpret_cast(this) + ms_HI->vtbl_offs) + ms_HI->vtbl_idx); \ \ - HookManagerInfo::VfnPtrListIter vfptriter = std::find(ms_HI->vfnptrs.begin(), \ - ms_HI->vfnptrs.end(), ourvfnptr); \ + HookManagerInfo::VfnPtrListIter vfptriter = ms_HI->vfnptrs.find(ourvfnptr); \ if (vfptriter == ms_HI->vfnptrs.end()) \ { \ /* Bleh? Should be impossible! */ \ @@ -553,7 +550,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C } \ HookManagerInfo::VfnPtr &vfnptr = *vfptriter; \ /* 2) Find the iface */ \ - HookManagerInfo::VfnPtr::IfaceListIter ifiter = std::find(vfnptr.ifaces.begin(), vfnptr.ifaces.end(), this); \ + HookManagerInfo::VfnPtr::IfaceListIter ifiter = vfnptr.ifaces.find(this); \ if (ifiter == vfnptr.ifaces.end()) \ { \ /* The iface info was not found. Redirect the call to the original function. */ \ @@ -564,8 +561,8 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C } \ HookManagerInfo::VfnPtr::Iface &ci = *ifiter; \ /* 2) Declare some vars and set it up */ \ - std::list &prelist = ci.hooks_pre; \ - std::list &postlist = ci.hooks_post; \ + List &prelist = ci.hooks_pre; \ + List &postlist = ci.hooks_post; \ META_RES &cur_res = SH_GLOB_SHPTR->GetCurResRef(); \ META_RES &prev_res = SH_GLOB_SHPTR->GetPrevResRef(); \ META_RES &status = SH_GLOB_SHPTR->GetStatusRef(); \ @@ -575,7 +572,7 @@ inline void SH_RELEASE_CALLCLASS_R(SourceHook::ISourceHook *shptr, SourceHook::C #define SH_CALL_HOOKS_void(post, params) \ prev_res = MRES_IGNORED; \ - for (std::list::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \ + for (List::iterator hiter = post##list.begin(); hiter != post##list.end(); ++hiter) \ { \ if (hiter->paused) continue; \ cur_res = MRES_IGNORED; \ diff --git a/sourcehook/sourcehook_impl.h b/sourcehook/sourcehook_impl.h index b3a6c71..9de0ed6 100644 --- a/sourcehook/sourcehook_impl.h +++ b/sourcehook/sourcehook_impl.h @@ -51,7 +51,7 @@ namespace SourceHook /** * @brief A list of HookManagerInfo structures */ - typedef std::list HookManInfoList; + typedef List HookManInfoList; struct CallClassInfo { @@ -65,7 +65,7 @@ namespace SourceHook /** * @brief A list of CallClass structures */ - typedef std::list Impl_CallClassList; + typedef List Impl_CallClassList; Impl_CallClassList m_CallClasses; //!< A list of already generated callclasses HookManInfoList m_HookMans; //!< A list of hook managers diff --git a/sourcehook/test/main.cpp b/sourcehook/test/main.cpp index 742d5c9..bfc22ad 100644 --- a/sourcehook/test/main.cpp +++ b/sourcehook/test/main.cpp @@ -5,6 +5,8 @@ #include #include #include +#include "sourcehook_impl.h" +#include "smm_list.h" using namespace std; diff --git a/sourcehook/test/test.vcproj b/sourcehook/test/test.vcproj index 89edb39..9b79a98 100644 --- a/sourcehook/test/test.vcproj +++ b/sourcehook/test/test.vcproj @@ -1,7 +1,7 @@ - + @@ -54,8 +54,14 @@ Name="VCResourceCompilerTool"/> + + + + + + + + + + + + + + + + + + + + diff --git a/sourcehook/test/test1.cpp b/sourcehook/test/test1.cpp index d16383f..f5813d0 100644 --- a/sourcehook/test/test1.cpp +++ b/sourcehook/test/test1.cpp @@ -395,6 +395,7 @@ bool TestBasic(std::string &error) // 1) Get a call class and call the member through it and normally SourceHook::CallClass *cc = SH_GET_CALLCLASS(pTest); + ADD_STATE(State_F1_CallClassGenerated); SH_CALL(cc, &Test::F1)(); @@ -445,6 +446,7 @@ bool TestBasic(std::string &error) // 4) Rerequest the callclass SH_RELEASE_CALLCLASS(cc); + ADD_STATE(State_F1_CallClassReleased); cc2 = SH_GET_CALLCLASS(pTest); ADD_STATE(State_F1_CallClassGenerated); diff --git a/sourcehook/test/testbail.h b/sourcehook/test/testbail.h index 0ed80fc..3551e39 100644 --- a/sourcehook/test/testbail.h +++ b/sourcehook/test/testbail.h @@ -5,6 +5,8 @@ #include "sourcehook_impl.h" #include "testevents.h" #include +#include +#include void ___TestBail2(); diff --git a/sourcehook/test/testevents.h b/sourcehook/test/testevents.h index 7485ccb..d66c183 100644 --- a/sourcehook/test/testevents.h +++ b/sourcehook/test/testevents.h @@ -14,6 +14,7 @@ #include #include #include +#include #include extern bool g_Verbose;