Remodel
Remodel.hpp File Reference

Contains the core classes of the library. More...

#include <functional>
#include <stdint.h>
#include <cstddef>
#include "zycore/Operators.hpp"
#include "zycore/Utils.hpp"
#include "zycore/Optional.hpp"
#include "Platform.hpp"

Go to the source code of this file.

Classes

class  remodel::ClassWrapper
 Base class for class wrappers. More...
 
struct  remodel::internal::InstantiableWrapperCtorCaller< WrapperT, useCustomCtorT, ArgsT >
 
struct  remodel::internal::InstantiableWrapperCtorCaller< WrapperT, true, ArgsT... >
 
struct  remodel::internal::InstantiableWrapperDtorCaller< WrapperT, useCustomDtorT >
 TMP helper type implementation that does nothing when called. More...
 
struct  remodel::internal::InstantiableWrapperDtorCaller< WrapperT, true >
 TMP helper type implementation that calls the custom destructor. More...
 
class  remodel::internal::InstantiableWrapper< WrapperT >
 Template making wrapper types instantiable. More...
 
class  remodel::AdvancedClassWrapper< objSizeT >
 Advanced version of the base class for wrappers. More...
 
class  remodel::OffsGetter
 PtrGetter functor adding an offset to the passed raw address. More...
 
class  remodel::AbsGetter
 PtrGetter functor ignoring the passed raw address, always returning a fixed address. More...
 
class  remodel::VfTableGetter
 PtrGetter functor obtaining a function address using the virtual function table. More...
 
class  remodel::internal::WeakWrapperImpl< WrapperT, typename >
 
class  remodel::internal::WeakWrapperImpl< WrapperT, typename WrapperT::IsAdvWrapper >
 
struct  remodel::WeakWrapper< WrapperT >
 Weak wrapper helper type. More...
 
class  remodel::internal::FieldBase
 
class  remodel::internal::FieldImpl< T, typename >
 
class  remodel::internal::FieldImpl< T, std::enable_if_t< std::is_arithmetic< T >::value||(std::is_enum< T >::value &&std::is_convertible< T, int >::value) > >
 
class  remodel::internal::FieldImpl< T, std::enable_if_t< std::is_array< T >::value > >
 
class  remodel::internal::FieldImpl< T, std::enable_if_t< std::is_class< T >::value > >
 
class  remodel::internal::FieldImpl< T, std::enable_if_t< std::is_enum< T >::value &&!std::is_convertible< T, int >::value > >
 
class  remodel::internal::FieldImpl< T, std::enable_if_t< std::is_pointer< T >::value > >
 
class  remodel::internal::FieldImpl< T && >
 
struct  remodel::internal::RewriteWrappersStep3< BaseTypeT, QualifierStackT, typename >
 
struct  remodel::internal::RewriteWrappersStep3< BaseTypeT, QualifierStackT, typename BaseTypeT::IsAdvWrapper >
 
struct  remodel::internal::RewriteWrappersStep2< BaseTypeT, QualifierStackT, typename >
 
struct  remodel::internal::value >>< BaseTypeT, QualifierStackT >
 
class  remodel::Field< T >
 Class representing a field (attribute, member variable) of a wrapper class. More...
 
class  remodel::internal::FunctionImpl< T >
 
struct  remodel::Function< T >
 Function wrapper template. More...
 
class  remodel::internal::MemberFunctionImpl< T >
 
struct  remodel::MemberFunction< T >
 Member function wrapper template. More...
 
struct  remodel::VirtualFunction< T >
 Convenience wrapper around MemberFunction constructing from a vftable index. More...
 
class  remodel::Global
 Allows declaration of global variables as fields using absolute addresses. More...
 
class  remodel::Module
 Allows declaration of global variables as fields using module relative addresses. More...
 

Namespaces

 remodel
 
 remodel::internal
 

Macros

#define REMODEL_WRAPPER_IMPL(classname, base)
 
#define REMODEL_WRAPPER(classname)   REMODEL_WRAPPER_IMPL(classname, ClassWrapper)
 Macro forwarding constructors and implementing other wrapper logic required. More...
 
#define REMODEL_ADV_WRAPPER(classname)
 Macro forwarding constructors and implementing other wrapper logic required. More...
 
#define REMODEL_FIELDIMPL_FORWARD_CTORS
 
#define REMODEL_DEF_FUNCTION(callingConv)
 
#define REMODEL_DEF_VARARG_FUNCTION(callingConv)
 
#define REMODEL_DEF_MEMBER_FUNCTION(callingConv)
 
#define REMODEL_DEF_VARARG_MEMBER_FUNCTION(callingConv)
 

Typedefs

template<typename T >
using remodel::internal::RewriteWrappers = typename RewriteWrappersStep2< typename AnalyzeQualifiers< T >::BaseType, typename AnalyzeQualifiers< T >::QualifierStack >::Type
 

Functions

template<typename WrapperT >
WrapperT remodel::wrapper_cast (void *raw)
 Creates a wrapper from a "raw" void pointer. More...
 
template<typename WrapperT >
WrapperT remodel::wrapper_cast (uintptr_t raw)
 Creates a wrapper from a "raw" pointer in uintptr_t representation. More...
 
template<typename WrapperT >
zycore::CloneConst< WrapperT, void > * remodel::addressOfObj (WrapperT &wrapper)
 Obtains the address of an object wrapped by this field/wrapper. More...
 
template<typename WrapperT >
WrapperT * remodel::addressOfWrapper (WrapperT &wrapper)
 Obtains the address of a field/wrapper (NOT of the wrapped object). More...
 

Detailed Description

Contains the core classes of the library.

This file is part of the remodel library (zyantific.com).

The MIT License (MIT)

Copyright (c) 2015 Joel Höner (athre0z)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Definition in file Remodel.hpp.

Macro Definition Documentation

◆ REMODEL_ADV_WRAPPER

#define REMODEL_ADV_WRAPPER (   classname)
Value:
REMODEL_WRAPPER_IMPL(classname, AdvancedClassWrapper) \
public: \
using Instantiable = internal::InstantiableWrapper<classname>; \
using Weak = WeakWrapper<classname>; \
public: \
Weak* weakPtr() { return reinterpret_cast<Weak*>(this->addressOfObj()); } \
private:
#define REMODEL_WRAPPER_IMPL(classname, base)
Definition: Remodel.hpp:549
zycore::CloneConst< WrapperT, void > * addressOfObj(WrapperT &wrapper)
Obtains the address of an object wrapped by this field/wrapper.
Definition: Remodel.hpp:624

Macro forwarding constructors and implementing other wrapper logic required.

Parameters
classnameThe class name of the wrapper.
See also
AdvancedClassWrapper

Definition at line 579 of file Remodel.hpp.

◆ REMODEL_DEF_FUNCTION

#define REMODEL_DEF_FUNCTION (   callingConv)
Value:
template<typename RetT, typename... ArgsT> \
class FunctionImpl<RetT (callingConv*)(ArgsT...)> \
: public internal::FieldBase \
{ \
protected: \
using FunctionPtr = RetT(callingConv*)(ArgsT...); \
public: \
explicit FunctionImpl(PtrGetter ptrGetter) \
: FieldBase{nullptr, ptrGetter} \
{} \
\
FunctionPtr get() const \
{ \
return (FunctionPtr)this->crawPtr(); \
} \
\
RetT operator () (ArgsT... args) const \
{ \
return get()(args...); \
} \
}

Definition at line 1325 of file Remodel.hpp.

◆ REMODEL_DEF_MEMBER_FUNCTION

#define REMODEL_DEF_MEMBER_FUNCTION (   callingConv)
Value:
template<typename RetT, typename... ArgsT> \
class MemberFunctionImpl<RetT (callingConv*)(ArgsT...)> \
: public internal::FieldBase \
{ \
protected: \
using FunctionPtr = RetT(callingConv*)(void* thiz, ArgsT... args); \
public: \
MemberFunctionImpl(ClassWrapper* parent, PtrGetter ptrGetter) \
: FieldBase{parent, ptrGetter} \
{} \
\
FunctionPtr get() const \
{ \
return (FunctionPtr)this->crawPtr(); \
} \
\
RetT operator () (ArgsT... args) const \
{ \
return get()(addressOfObj(*this->m_parent), args...); \
} \
}
zycore::CloneConst< WrapperT, void > * addressOfObj(WrapperT &wrapper)
Obtains the address of an object wrapped by this field/wrapper.
Definition: Remodel.hpp:624

Definition at line 1457 of file Remodel.hpp.

◆ REMODEL_DEF_VARARG_FUNCTION

#define REMODEL_DEF_VARARG_FUNCTION (   callingConv)
Value:
template<typename RetT, typename... ArgsT> \
class FunctionImpl<RetT (callingConv*)(ArgsT..., ...)> \
: public internal::FieldBase \
{ \
protected: \
using FunctionPtr = RetT(callingConv*)(ArgsT..., ...); \
public: \
explicit FunctionImpl(PtrGetter ptrGetter) \
: FieldBase{nullptr, ptrGetter} \
{} \
\
FunctionPtr get() const \
{ \
return (FunctionPtr)this->crawPtr(); \
} \
\
template<typename... VarArgsT> \
RetT operator () (ArgsT... args, VarArgsT... va) const \
{ \
return get()(args..., va...); \
} \
}

Definition at line 1353 of file Remodel.hpp.

◆ REMODEL_DEF_VARARG_MEMBER_FUNCTION

#define REMODEL_DEF_VARARG_MEMBER_FUNCTION (   callingConv)
Value:
template<typename RetT, typename... ArgsT> \
class MemberFunctionImpl<RetT (callingConv*)(ArgsT..., ...)> \
: public internal::FieldBase \
{ \
protected: \
using FunctionPtr = RetT(callingConv*)(void* thiz, ArgsT... args, ...); \
public: \
MemberFunctionImpl(ClassWrapper* parent, PtrGetter ptrGetter) \
: FieldBase{parent, ptrGetter} \
{} \
\
FunctionPtr get() const \
{ \
return (FunctionPtr)this->crawPtr(); \
} \
\
template<typename... VarArgsT> \
RetT operator () (ArgsT... args, VarArgsT... va) const \
{ \
return get()(addressOfObj(*this->m_parent), args..., va...); \
} \
}
zycore::CloneConst< WrapperT, void > * addressOfObj(WrapperT &wrapper)
Obtains the address of an object wrapped by this field/wrapper.
Definition: Remodel.hpp:624

Definition at line 1486 of file Remodel.hpp.

◆ REMODEL_FIELDIMPL_FORWARD_CTORS

#define REMODEL_FIELDIMPL_FORWARD_CTORS
Value:
public: \
FieldImpl(ClassWrapper *parent, PtrGetter ptrGetter) \
: FieldBase{parent, ptrGetter} \
{} \
\
explicit FieldImpl(const FieldImpl& other) \
: FieldBase{other} \
{} \
private:

Definition at line 945 of file Remodel.hpp.

◆ REMODEL_WRAPPER

#define REMODEL_WRAPPER (   classname)    REMODEL_WRAPPER_IMPL(classname, ClassWrapper)

Macro forwarding constructors and implementing other wrapper logic required.

Parameters
classnameThe class name of the wrapper.
See also
ClassWrapper

Definition at line 571 of file Remodel.hpp.

◆ REMODEL_WRAPPER_IMPL

#define REMODEL_WRAPPER_IMPL (   classname,
  base 
)
Value:
protected: \
template<typename WrapperT> \
friend WrapperT remodel::wrapper_cast(void *raw); \
explicit classname(void* raw) \
: base(raw) /* MSVC12 requires parentheses here */ {} \
public: \
classname(const classname& other) \
: base(other) /* MSVC12 requires parentheses here */ {} \
classname& operator = (const classname& other) \
{ this->base::operator = (other); return *this; } \
/* allow field access via -> (required to allow -> on wrapped struct fields) */ \
classname* operator -> () { return this; } \
classname* addressOfWrapper() { return this; } \
const classname* addressOfWrapper() const { return this; } \
private:
WrapperT wrapper_cast(void *raw)
Creates a wrapper from a "raw" void pointer.
Definition: Remodel.hpp:600
WrapperT * addressOfWrapper(WrapperT &wrapper)
Obtains the address of a field/wrapper (NOT of the wrapped object).
Definition: Remodel.hpp:640

Definition at line 549 of file Remodel.hpp.