forked from CodeRedModding/CodeRed-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Member.hpp
115 lines (105 loc) · 3.23 KB
/
Member.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#pragma once
#include <string>
// Class Types
enum class EClassTypes : uint8_t
{
UNKNOWN,
STRUCT_FNAMEENTRY,
STRUCT_FNAME,
CLASS_UOBJECT,
CLASS_UFIELD,
CLASS_UENUM,
CLASS_UCONST,
CLASS_UPROPERTY,
CLASS_USTRUCT,
CLASS_UFUNCTION,
CLASS_USCRIPTSTRUCT,
CLASS_USTATE,
CLASS_UCLASS,
CLASS_USTRUCTPROPERTY,
CLASS_USTRPROPERTY,
CLASS_UQWORDPROPERTY,
CLASS_UOBJECTPROPERTY,
CLASS_UCOMPONENTPROPERTY,
CLASS_UCLASSPROPERTY,
CLASS_UNAMEPROPERTY,
CLASS_UMAPPROPERTY,
CLASS_UINTPROPERTY,
CLASS_UINTERFACEPROPERTY,
CLASS_UFLOATPROPERTY,
CLASS_UDELEGATEPROPERTY,
CLASS_UBYTEPROPERTY,
CLASS_UBOOLPROPERTY,
CLASS_UARRAYPROPERTY
};
// Class Member Types
enum class EMemberTypes : uint8_t
{
UNKNOWN,
FNAMEENTRY_FLAGS,
FNAMEENTRY_INDEX,
FNAMEENTRY_NAME,
UOBJECT_VFTABLE,
UOBJECT_INDEX,
UOBJECT_OUTER,
UOBJECT_NAME,
UOBJECT_CLASS,
UFIELD_NEXT,
UFIELD_SUPERFIELD, // Not needed if "SuperField" is in the "UStruct" class!
UENUM_NAMES,
UCONST_VALUE,
UPROPERTY_DIMENSION,
UPROPERTY_SIZE,
UPROPERTY_FLAGS,
UPROPERTY_OFFSET,
USTRUCT_SUPERFIELD, // Not needed if "SuperField" is in the "UField" class!
USTRUCT_CHILDREN,
USTRUCT_SIZE,
UFUNCTION_FLAGS,
UFUNCTION_NATIVE,
USTRUCTPROPERTY_STRUCT,
UOBJECTPROPERTY_PROPERTY,
UCLASSPROPERTY_METACLASS,
UMAPPROPERTY_KEY,
UMAPPROPERTY_VALUE,
UINTERFACEPROPERTY_CLASS,
UDELEGATEPROPERTY_FUNCTION,
UDELEGATEPROPERTY_NAME,
UBYTEPROPERTY_ENUM,
UBOOLPROPERTY_BITMASK,
UARRAYPROPERTY_INNTER
};
/*
# ========================================================================================= #
# Members
# ========================================================================================= #
*/
class Member
{
public:
EMemberTypes Type; // Internal id used to tell which member this class is.
std::string Label; // String label used for printing the member inside the class.
uintptr_t Offset; // Member offset from the base of the class.
size_t Size; // Size of the member at the given offset.
public:
Member();
Member(EMemberTypes type, size_t size);
Member(const Member& member);
~Member();
public: // Global Utils
static std::string GetLabel(EMemberTypes type); // Returns the string version of the member used for printing in the generated sdk.
static uintptr_t GetOffset(EMemberTypes type); // Returns the members offset in its defined class.
static size_t GetClassSize(EClassTypes type); // Returns the "sizeof" for the given class type.
static size_t GetClassOffset(EClassTypes type); // Returns the start offset of the given type, taking into account its inherited classes.
public:
static void Register(EMemberTypes type, size_t size); // This should only be called by the "REGISTER_MEMBER" macro!
static std::map<uintptr_t, Member> GetRegistered(EClassTypes type); // Returns registered members for the given class type, ordered by their offsets.
private:
static inline std::unordered_map<EMemberTypes, Member> RegisteredMembers;
};
#define REGISTER_MEMBER(memberVariable, memberName, memberType) static void Register_##memberName(){ Member::Register(memberType, sizeof(memberVariable)); }
/*
# ========================================================================================= #
#
# ========================================================================================= #
*/