-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathMember.hpp
136 lines (124 loc) · 3.58 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#pragma once
#include <map>
#include <vector>
#include <string>
// Class Types
enum class EClassTypes : uint8_t
{
Unknown,
FNameEntry,
UObject,
UClass,
UField,
UEnum,
UConst,
UProperty,
UStruct,
UFunction,
UStructProperty,
UObjectProperty,
UClassProperty,
UMapProperty,
UInterfaceProperty,
UByteProperty,
UBoolProperty,
UArrayProperty
};
// Member Types
enum class EMemberTypes : uint8_t
{
Unknown,
FNameEntry_Index,
FNameEntry_Flags,
FNameEntry_HashNext,
FNameEntry_Name,
UObject_VfTable,
UObject_Integer,
UObject_Outer,
UObject_Name,
UObject_Class,
UField_Next,
UField_SuperField, // Not needed if SuperField is in the UStruct class, leave "SUPERFIELDS_IN_UFIELD" in your "GameDefines.hpp" file!
UEnum_Names,
UConst_Value,
UProperty_Dim,
UProperty_Size,
UProperty_Flags,
UProperty_Offset,
UStruct_SuperField, // Not needed if SuperField is in the UField class, comment out "SUPERFIELDS_IN_UFIELD" in your "GameDefines.hpp" file!
UStruct_Children,
UStruct_Size,
UStruct_Alignment,
UFunction_Flags,
UFunction_Native,
UFunction_Func,
UStructProperty_Struct,
UObjectProperty_Class,
UClassProperty_Meta,
UMapProperty_Key,
UMapProperty_Value,
UInterfaceProperty_Class,
UByteProperty_Enum,
UBoolProperty_BitMask,
UArrayProperty_Inner
};
// Property Types
enum class EPropertyTypes : uint8_t
{
Unknown,
Int32,
UInt8,
UInt32,
UInt64,
Double,
Float,
Bool,
FName,
FString,
FScriptDelegate,
FStruct,
UObject,
UClass,
UInterface,
TArray,
TMap
};
/*
# ========================================================================================= #
# 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.
size_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 GetName(EClassTypes type); // Returns the string name of the enum used for logging and messageboxes.
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<size_t, Member*> GetRegistered(EClassTypes type); // Returns registered members for the given class type, sorted by their offsets.
private:
static void AddRegistered(std::map<size_t, Member*>& members, EMemberTypes type);
static std::map<EClassTypes, std::vector<EMemberTypes>> m_classMembers;
static inline std::map<EMemberTypes, Member> m_registeredMembers;
public:
Member& operator=(const Member& member);
};
#define REGISTER_MEMBER(memberVariable, memberName, memberType) static void Register_##memberName(){ Member::Register(memberType, sizeof(memberVariable)); }
/*
# ========================================================================================= #
#
# ========================================================================================= #
*/