#ifndef COMMON_GAMEPTR_H #define COMMON_GAMEPTR_H #include #include #include namespace Memory { class GamePtr_Manager { public: GamePtr_Manager(); static uintptr_t s_baseAddress; }; template class GamePtr { public : GamePtr(uintptr_t offset) : offset(offset + Memory::GamePtr_Manager::s_baseAddress){} T * GetPtr() const { return reinterpret_cast (offset); } T * operator->() const { return GetPtr(); } operator T *() const { return GetPtr(); } bool operator!() const { return !GetPtr(); } const T * GetConstPtr() const { return reinterpret_cast (offset); } uintptr_t GetUIntPtr() const { return offset; } private: uintptr_t offset; GamePtr(); GamePtr(GamePtr & rhs); GamePtr & operator=(GamePtr & rhs); }; template class GameAddr{ public: GameAddr(uintptr_t offset) : offset(reinterpret_cast(offset + Memory::GamePtr_Manager::s_baseAddress)){} operator T() { return reinterpret_cast(offset); } uintptr_t GetUIntPtr(){ return reinterpret_cast(offset); } private: struct ConversionType {}; ConversionType * offset; GameAddr(); GameAddr(GameAddr & rhs); GameAddr & operator=(GameAddr & rhs); }; } #endif