2022-06-02 04:14:44 -04:00
|
|
|
#pragma once
|
|
|
|
|
2022-08-10 05:26:19 -04:00
|
|
|
#include "structs.hpp"
|
2022-06-02 04:14:44 -04:00
|
|
|
|
|
|
|
namespace game
|
|
|
|
{
|
2022-11-11 11:19:26 -05:00
|
|
|
size_t get_base();
|
2022-08-10 05:26:19 -04:00
|
|
|
|
2022-11-11 11:19:26 -05:00
|
|
|
inline size_t relocate(const size_t val)
|
|
|
|
{
|
|
|
|
const auto base = get_base();
|
|
|
|
return base + (val - 0x140000000);
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t derelocate(const size_t val)
|
|
|
|
{
|
|
|
|
const auto base = get_base();
|
|
|
|
return (val - base) + 0x140000000;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline size_t derelocate(const void* val)
|
|
|
|
{
|
|
|
|
return derelocate(reinterpret_cast<size_t>(val));
|
|
|
|
}
|
2022-06-02 07:49:43 -04:00
|
|
|
|
2022-06-02 04:14:44 -04:00
|
|
|
template <typename T>
|
|
|
|
class symbol
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
symbol(const size_t address)
|
2022-11-09 11:10:08 -05:00
|
|
|
: address_(address)
|
2022-06-02 04:14:44 -04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
T* get() const
|
|
|
|
{
|
2022-11-11 11:19:26 -05:00
|
|
|
return reinterpret_cast<T*>(relocate(this->address_));
|
2022-06-02 04:14:44 -04:00
|
|
|
}
|
|
|
|
|
2022-11-09 11:10:08 -05:00
|
|
|
operator T*() const
|
2022-06-02 04:14:44 -04:00
|
|
|
{
|
|
|
|
return this->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
T* operator->() const
|
|
|
|
{
|
|
|
|
return this->get();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-11-09 11:10:08 -05:00
|
|
|
size_t address_;
|
2022-06-02 04:14:44 -04:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-11-11 11:19:26 -05:00
|
|
|
inline size_t operator"" _g(const size_t val)
|
|
|
|
{
|
|
|
|
return game::relocate(val);
|
|
|
|
}
|
|
|
|
|
2022-06-02 04:14:44 -04:00
|
|
|
#include "symbols.hpp"
|