#pragma once namespace vm { template class ptr { AT m_addr; public: ptr operator++ (int) { AT result = m_addr; m_addr += sizeof(AT); return { result }; } ptr& operator++ () { m_addr += sizeof(AT); return *this; } ptr operator-- (int) { AT result = m_addr; m_addr -= sizeof(AT); return { result }; } ptr& operator-- () { m_addr -= sizeof(AT); return *this; } ptr& operator += (int count) { m_addr += count * sizeof(AT); return *this; } ptr& operator -= (int count) { m_addr -= count * sizeof(AT); return *this; } ptr operator + (int count) const { return { m_addr + count * sizeof(AT) }; } ptr operator - (int count) const { return { m_addr - count * sizeof(AT) }; } __forceinline ptr& operator *() { return get_ref>(m_addr); } __forceinline const ptr& operator *() const { return get_ref>(m_addr); } __forceinline ptr& operator [](int index) { return get_ref>(m_addr + sizeof(AT) * index); } __forceinline const ptr& operator [](int index) const { return get_ref>(m_addr + sizeof(AT) * index); } operator bool() const { return m_addr != 0; } AT addr() const { return m_addr; } bool check() const { return Memory.IsGoodAddr(m_addr, sizeof(AT)); } static ptr make(u32 addr) { return (ptr&)addr; } }; template class ptr { AT m_addr; public: __forceinline T* operator -> () { return get_ptr(m_addr); } __forceinline const T* operator -> () const { return get_ptr(m_addr); } ptr operator++ (int) { AT result = m_addr; m_addr += sizeof(T); return { result }; } ptr& operator++ () { m_addr += sizeof(T); return *this; } ptr operator-- (int) { AT result = m_addr; m_addr -= sizeof(T); return { result }; } ptr& operator-- () { m_addr -= sizeof(T); return *this; } ptr& operator += (int count) { m_addr += count * sizeof(T); return *this; } ptr& operator -= (int count) { m_addr -= count * sizeof(T); return *this; } ptr operator + (int count) const { return { m_addr + count * sizeof(T) }; } ptr operator - (int count) const { return { m_addr - count * sizeof(T) }; } __forceinline T& operator *() { return get_ref(m_addr); } __forceinline const T& operator *() const { return get_ref(m_addr); } __forceinline T& operator [](int index) { return get_ref(m_addr + sizeof(T) * index); } __forceinline const T& operator [](int index) const { return get_ref(m_addr + sizeof(T) * index); } /* operator ref() { return { m_addr }; } operator const ref() const { return { m_addr }; } */ AT addr() const { return m_addr; } operator bool() const { return m_addr != 0; } T* get_ptr() const { return vm::get_ptr(m_addr); } bool check() const { return Memory.IsGoodAddr(m_addr, sizeof(T)); } static ptr make(u32 addr) { return (ptr&)addr; } }; template class ptr { AT m_addr; public: AT addr() const { return m_addr; } void* get_ptr() const { return vm::get_ptr(m_addr); } bool check() const { return Memory.IsGoodAddr(m_addr); } operator bool() const { return m_addr != 0; } static ptr make(u32 addr) { return (ptr&)addr; } }; template class ptr { AT m_addr; __forceinline RT call_func(bool is_async) const { Callback cb; cb.SetAddr(m_addr); return (RT)cb.Branch(!is_async); } public: typedef RT(*type)(); __forceinline RT operator()() const { return call_func(false); } __forceinline void async() const { call_func(true); } AT addr() const { return m_addr; } type get_ptr() const { return *((type*)vm::get_ptr(m_addr)); } bool check() const { return Memory.IsGoodAddr(m_addr); } operator bool() const { return m_addr != 0; } static ptr make(u32 addr) { return (ptr&)addr; } }; template class ptr { AT m_addr; __forceinline RT call_func(bool is_async, T... args) const { template struct _func_arg { __forceinline static u64 get_value(const T& arg) { return arg; } }; template struct _func_arg> { __forceinline static u64 get_value(const ptr arg) { return arg.addr(); } }; template struct _func_arg> { __forceinline static u64 get_value(const ref arg) { return arg.addr(); } }; Callback cb; cb.SetAddr(m_addr); cb.Handle(_func_arg::get_value(args)...); return (RT)cb.Branch(!is_async); } public: typedef RT(*type)(T...); __forceinline RT operator()(T... args) const { return call_func(false, args...); } __forceinline void async(T... args) const { call_func(true, args...); } AT addr() const { return m_addr; } type get_ptr() const { return *((type*)vm::get_ptr(m_addr)); } bool check() const { return Memory.IsGoodAddr(m_addr); } operator bool() const { return m_addr != 0; } static ptr make(u32 addr) { return (ptr&)addr; } }; template class beptr : public ptr> {}; }