#pragma once class PPUThread; namespace vm { template class _ptr_base { AT m_addr; public: typedef T type; _ptr_base operator++ (int) { AT result = m_addr; m_addr += sizeof(AT); return make(result); } _ptr_base& operator++ () { m_addr += sizeof(AT); return *this; } _ptr_base operator-- (int) { AT result = m_addr; m_addr -= sizeof(AT); return make(result); } _ptr_base& operator-- () { m_addr -= sizeof(AT); return *this; } _ptr_base& operator += (int count) { m_addr += count * sizeof(AT); return *this; } _ptr_base& operator -= (int count) { m_addr -= count * sizeof(AT); return *this; } _ptr_base operator + (int count) const { return make(m_addr + count * sizeof(AT)); } _ptr_base operator - (int count) const { return make(m_addr - count * sizeof(AT)); } __forceinline _ptr_base::value, typename to_be_t::type, AT>>& operator *() const { return vm::get_ref<_ptr_base::value, typename to_be_t::type, AT>>>(m_addr); } __forceinline _ptr_base::value, typename to_be_t::type, AT>>& operator [](int index) const { return vm::get_ref<_ptr_base::value, typename to_be_t::type, AT>>>(m_addr + sizeof(AT)* index); } operator bool() const { return m_addr != 0; } //typedef typename invert_be_t::type AT2; template operator const _ptr_base() const { typename std::remove_const::type addr; addr = m_addr; return (_ptr_base&)addr; } AT addr() const { return m_addr; } void set(const AT value) { m_addr = value; } static _ptr_base make(AT addr) { return (_ptr_base&)addr; } _ptr_base& operator = (const _ptr_base& right) = default; }; template class _ptr_base { AT m_addr; public: __forceinline T* const operator -> () const { return vm::get_ptr(m_addr); } _ptr_base operator++ (int) { AT result = m_addr; m_addr += sizeof(T); return make(result); } _ptr_base& operator++ () { m_addr += sizeof(T); return *this; } _ptr_base operator-- (int) { AT result = m_addr; m_addr -= sizeof(T); return make(result); } _ptr_base& operator-- () { m_addr -= sizeof(T); return *this; } _ptr_base& operator += (int count) { m_addr += count * sizeof(T); return *this; } _ptr_base& operator -= (int count) { m_addr -= count * sizeof(T); return *this; } _ptr_base operator + (int count) const { return make(m_addr + count * sizeof(T)); } _ptr_base operator - (int count) const { return make(m_addr - count * sizeof(T)); } __forceinline T& operator *() const { return get_ref(m_addr); } __forceinline T& operator [](int index) const { return get_ref(m_addr + sizeof(T) * index); } /* operator _ref_base() { return _ref_base::make(m_addr); } operator const _ref_base() const { return _ref_base::make(m_addr); } */ AT addr() const { return m_addr; } void set(const AT value) { m_addr = value; } operator bool() const { return m_addr != 0; } //typedef typename invert_be_t::type AT2; template operator const _ptr_base() const { typename std::remove_const::type addr; addr = m_addr; return (_ptr_base&)addr; } T* const get_ptr() const { return vm::get_ptr(m_addr); } static _ptr_base make(AT addr) { return (_ptr_base&)addr; } _ptr_base& operator = (const _ptr_base& right) = default; }; template class _ptr_base { AT m_addr; public: AT addr() const { return m_addr; } void set(const AT value) { m_addr = value; } void* const get_ptr() const { return vm::get_ptr(m_addr); } operator bool() const { return m_addr != 0; } //typedef typename invert_be_t::type AT2; template operator const _ptr_base() const { typename std::remove_const::type addr; addr = m_addr; return (_ptr_base&)addr; } template operator const _ptr_base() const { typename std::remove_const::type addr; addr = m_addr; return (_ptr_base&)addr; } static _ptr_base make(AT addr) { return (_ptr_base&)addr; } _ptr_base& operator = (const _ptr_base& right) = default; }; template class _ptr_base { AT m_addr; public: AT addr() const { return m_addr; } void set(const AT value) { m_addr = value; } const void* const get_ptr() const { return vm::get_ptr(m_addr); } operator bool() const { return m_addr != 0; } //typedef typename invert_be_t::type AT2; template operator const _ptr_base() const { typename std::remove_const::type addr; addr = m_addr; return (_ptr_base&)addr; } static _ptr_base make(AT addr) { return (_ptr_base&)addr; } _ptr_base& operator = (const _ptr_base& right) = default; }; template class _ptr_base { AT m_addr; public: typedef RT(*type)(T...); RT call(PPUThread& CPU, T... args) const; // call using specified PPU thread context, defined in Callback.h (CB_FUNC.h) RT operator()(T... args) const; // call using current PPU thread context, defined in Callback.h (CB_FUNC.h) AT addr() const { return m_addr; } void set(const AT value) { m_addr = value; } operator bool() const { return m_addr != 0; } //typedef typename invert_be_t::type AT2; template operator const _ptr_base() const { typename std::remove_const::type addr; addr = m_addr; return (_ptr_base&)addr; } static _ptr_base make(AT addr) { return (_ptr_base&)addr; } operator const std::function() const { typename std::remove_const::type addr; addr = m_addr; return [addr](T... args) -> RT { return make(addr)(args...); }; } _ptr_base& operator = (const _ptr_base& right) = default; }; //BE pointer to LE data template struct bptrl : public _ptr_base::type> { static bptrl make(typename to_be_t::type addr) { return (bptrl&)addr; } using _ptr_base::type>::operator=; //using _ptr_base::type>::operator const _ptr_base; }; //BE pointer to BE data template struct bptrb : public _ptr_base::type, lvl, typename to_be_t::type> { static bptrb make(typename to_be_t::type addr) { return (bptrb&)addr; } using _ptr_base::type, lvl, typename to_be_t::type>::operator=; //using _ptr_base::type, lvl, typename to_be_t::type>::operator const _ptr_base::type, lvl, AT>; }; //LE pointer to BE data template struct lptrb : public _ptr_base::type, lvl, AT> { static lptrb make(AT addr) { return (lptrb&)addr; } using _ptr_base::type, lvl, AT>::operator=; //using _ptr_base::type, lvl, AT>::operator const _ptr_base::type, lvl, typename to_be_t::type>; }; //LE pointer to LE data template struct lptrl : public _ptr_base { static lptrl make(AT addr) { return (lptrl&)addr; } using _ptr_base::operator=; //using _ptr_base::operator const _ptr_base::type>; }; namespace ps3 { //default pointer for HLE functions (LE ptrerence to BE data) template struct ptr : public lptrb { static ptr make(AT addr) { return (ptr&)addr; } using lptrb::operator=; //using lptrb::operator const _ptr_base::type, lvl, AT>; }; //default pointer for HLE structures (BE ptrerence to BE data) template struct bptr : public bptrb { static bptr make(typename to_be_t::type addr) { return (bptr&)addr; } using bptrb::operator=; //using bptrb::operator const _ptr_base::type, lvl, AT>; }; } namespace psv { //default pointer for HLE functions & structures (LE ptrerence to LE data) template struct ptr : public lptrl { static ptr make(AT addr) { return (ptr&)addr; } using lptrl::operator=; }; } //PS3 emulation is main now, so lets it be as default using namespace ps3; }