forked from CodeRedModding/CodeRed-Generator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Member.cpp
348 lines (331 loc) · 13.5 KB
/
Member.cpp
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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
#include "Engine/Engine.hpp"
/*
# ========================================================================================= #
# Members
# ========================================================================================= #
*/
Member::Member() : Type(EMemberTypes::UNKNOWN), Label(GetLabel(Type)), Offset(0x0), Size(1) {}
Member::Member(EMemberTypes type, size_t size) : Type(type), Label(GetLabel(type)), Offset(GetOffset(type)), Size(size) {}
Member::Member(const Member& member) : Type(member.Type), Label(member.Label), Offset(member.Offset), Size(member.Size) {}
Member::~Member() {}
std::string Member::GetLabel(EMemberTypes type)
{
switch (type)
{
case EMemberTypes::FNAMEENTRY_FLAGS:
return "uint64_t Flags;";
case EMemberTypes::FNAMEENTRY_INDEX:
return "int32_t Index;";
case EMemberTypes::FNAMEENTRY_NAME:
#ifdef UTF16
return "wchar_t Name[0x400];";
#else
return "char Name[0x400];";
#endif
case EMemberTypes::UOBJECT_VFTABLE:
return "struct FPointer VfTableObject;";
case EMemberTypes::UOBJECT_INDEX:
return "int32_t ObjectInternalInteger;";
case EMemberTypes::UOBJECT_OUTER:
return "class UObject* Outer;";
case EMemberTypes::UOBJECT_NAME:
return "struct FName Name;";
case EMemberTypes::UOBJECT_CLASS:
return "class UClass* Class;";
case EMemberTypes::UFIELD_NEXT:
return "class UField* Next;";
case EMemberTypes::UFIELD_SUPERFIELD:
return "class UField* SuperField;";
case EMemberTypes::UENUM_NAMES:
return "TArray<struct FName> Names;";
case EMemberTypes::UCONST_VALUE:
return "class FString Value;";
case EMemberTypes::UPROPERTY_DIMENSION:
return "uint32_t ArrayDim;";
case EMemberTypes::UPROPERTY_SIZE:
return "uint32_t ElementSize;";
case EMemberTypes::UPROPERTY_FLAGS:
return "uint64_t PropertyFlags;";
case EMemberTypes::UPROPERTY_OFFSET:
return "uint32_t Offset;";
case EMemberTypes::USTRUCT_SUPERFIELD:
return "class UField* SuperField;";
case EMemberTypes::USTRUCT_CHILDREN:
return "class UField* Children;";
case EMemberTypes::USTRUCT_SIZE:
return "uint32_t PropertySize;";
case EMemberTypes::UFUNCTION_FLAGS:
return "uint64_t FunctionFlags;";
case EMemberTypes::UFUNCTION_NATIVE:
return "uint16_t iNative;";
case EMemberTypes::USTRUCTPROPERTY_STRUCT:
return "class UStruct* Struct;";
case EMemberTypes::UOBJECTPROPERTY_PROPERTY:
return "class UClass* PropertyClass;";
case EMemberTypes::UCLASSPROPERTY_METACLASS:
return "class UClass* MetaClass;";
case EMemberTypes::UMAPPROPERTY_KEY:
return "class UProperty* Key;";
case EMemberTypes::UMAPPROPERTY_VALUE:
return "class UProperty* Value;";
case EMemberTypes::UINTERFACEPROPERTY_CLASS:
return "class UClass* InterfaceClass;";
case EMemberTypes::UDELEGATEPROPERTY_FUNCTION:
return "class UFuncton* DelegateFunction;";
case EMemberTypes::UDELEGATEPROPERTY_NAME:
return "struct FName DelegateName;";
case EMemberTypes::UBYTEPROPERTY_ENUM:
return "class UEnum* Enum;";
case EMemberTypes::UBOOLPROPERTY_BITMASK:
return "uint64_t BitMask;";
case EMemberTypes::UARRAYPROPERTY_INNTER:
return "class UProperty* Inner;";
default:
return "uint8_t UnknownMemberType[0x1];";
}
}
uintptr_t Member::GetOffset(EMemberTypes type)
{
switch (type)
{
case EMemberTypes::FNAMEENTRY_FLAGS:
return offsetof(FNameEntry, Flags);
case EMemberTypes::FNAMEENTRY_INDEX:
return offsetof(FNameEntry, Index);
case EMemberTypes::FNAMEENTRY_NAME:
return offsetof(FNameEntry, Name);
case EMemberTypes::UOBJECT_VFTABLE:
return offsetof(UObject, VfTableObject);
case EMemberTypes::UOBJECT_INDEX:
return offsetof(UObject, ObjectInternalInteger);
case EMemberTypes::UOBJECT_OUTER:
return offsetof(UObject, Outer);
case EMemberTypes::UOBJECT_NAME:
return offsetof(UObject, Name);
case EMemberTypes::UOBJECT_CLASS:
return offsetof(UObject, Class);
case EMemberTypes::UFIELD_NEXT:
return offsetof(UField, Next);
case EMemberTypes::UFIELD_SUPERFIELD:
return offsetof(UStruct, SuperField);
case EMemberTypes::UENUM_NAMES:
return offsetof(UEnum, Names);
case EMemberTypes::UCONST_VALUE:
return offsetof(UConst, Value);
case EMemberTypes::UPROPERTY_DIMENSION:
return offsetof(UProperty, ArrayDim);
case EMemberTypes::UPROPERTY_SIZE:
return offsetof(UProperty, ElementSize);
case EMemberTypes::UPROPERTY_FLAGS:
return offsetof(UProperty, PropertyFlags);
case EMemberTypes::UPROPERTY_OFFSET:
return offsetof(UProperty, Offset);
case EMemberTypes::USTRUCT_SUPERFIELD:
return offsetof(UStruct, SuperField);
case EMemberTypes::USTRUCT_CHILDREN:
return offsetof(UStruct, Children);
case EMemberTypes::USTRUCT_SIZE:
return offsetof(UStruct, PropertySize);
case EMemberTypes::UFUNCTION_FLAGS:
return offsetof(UFunction, FunctionFlags);
case EMemberTypes::UFUNCTION_NATIVE:
return offsetof(UFunction, iNative);
case EMemberTypes::USTRUCTPROPERTY_STRUCT:
return offsetof(UStructProperty, Struct);
case EMemberTypes::UOBJECTPROPERTY_PROPERTY:
return offsetof(UObjectProperty, PropertyClass);
case EMemberTypes::UCLASSPROPERTY_METACLASS:
return offsetof(UClassProperty, MetaClass);
case EMemberTypes::UMAPPROPERTY_KEY:
return offsetof(UMapProperty, Key);
case EMemberTypes::UMAPPROPERTY_VALUE:
return offsetof(UMapProperty, Value);
case EMemberTypes::UINTERFACEPROPERTY_CLASS:
return offsetof(UInterfaceProperty, InterfaceClass);
case EMemberTypes::UDELEGATEPROPERTY_FUNCTION:
return offsetof(UDelegateProperty, DelegateFunction);
case EMemberTypes::UDELEGATEPROPERTY_NAME:
return offsetof(UDelegateProperty, DelegateName);
case EMemberTypes::UBYTEPROPERTY_ENUM:
return offsetof(UByteProperty, Enum);
case EMemberTypes::UBOOLPROPERTY_BITMASK:
return offsetof(UBoolProperty, BitMask);
case EMemberTypes::UARRAYPROPERTY_INNTER:
return offsetof(UArrayProperty, Inner);
default:
return 0x0;
}
}
size_t Member::GetClassSize(EClassTypes type)
{
switch (type)
{
case EClassTypes::STRUCT_FNAMEENTRY:
return sizeof(FNameEntry);
case EClassTypes::CLASS_UOBJECT:
return sizeof(UObject);
case EClassTypes::CLASS_UFIELD:
return sizeof(UField);
case EClassTypes::CLASS_UENUM:
return sizeof(UEnum);
case EClassTypes::CLASS_UCONST:
return sizeof(UConst);
case EClassTypes::CLASS_UPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_USTRUCT:
return sizeof(UStruct);
case EClassTypes::CLASS_UFUNCTION:
return sizeof(UFunction);
case EClassTypes::CLASS_USTRUCTPROPERTY:
return sizeof(UStructProperty);
case EClassTypes::CLASS_UOBJECTPROPERTY:
return sizeof(UObjectProperty);
case EClassTypes::CLASS_UCLASSPROPERTY:
return sizeof(UClassProperty);
case EClassTypes::CLASS_UMAPPROPERTY:
return sizeof(UMapProperty);
case EClassTypes::CLASS_UINTERFACEPROPERTY:
return sizeof(UInterfaceProperty);
case EClassTypes::CLASS_UDELEGATEPROPERTY:
return sizeof(UDelegateProperty);
case EClassTypes::CLASS_UBYTEPROPERTY:
return sizeof(UByteProperty);
case EClassTypes::CLASS_UBOOLPROPERTY:
return sizeof(UBoolProperty);
case EClassTypes::CLASS_UARRAYPROPERTY:
return sizeof(UArrayProperty);
default:
return 0;
}
}
size_t Member::GetClassOffset(EClassTypes type)
{
switch (type)
{
case EClassTypes::STRUCT_FNAMEENTRY:
return 0;
case EClassTypes::CLASS_UOBJECT:
return 0;
case EClassTypes::CLASS_UFIELD:
return sizeof(UObject);
case EClassTypes::CLASS_UENUM:
return sizeof(UField);
case EClassTypes::CLASS_UCONST:
return sizeof(UField);
case EClassTypes::CLASS_UPROPERTY:
return sizeof(UField);
case EClassTypes::CLASS_USTRUCT:
return sizeof(UField);
case EClassTypes::CLASS_UFUNCTION:
return sizeof(UStruct);
case EClassTypes::CLASS_USTRUCTPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UOBJECTPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UCLASSPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UMAPPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UINTERFACEPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UDELEGATEPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UBYTEPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UBOOLPROPERTY:
return sizeof(UProperty);
case EClassTypes::CLASS_UARRAYPROPERTY:
return sizeof(UProperty);
default:
return 0;
}
}
void Member::Register(EMemberTypes type, size_t size)
{
RegisteredMembers[type] = Member(type, size);
}
std::map<uintptr_t, Member> Member::GetRegistered(EClassTypes type)
{
std::map<uintptr_t, Member> returnMembers;
switch (type)
{
case EClassTypes::STRUCT_FNAMEENTRY:
returnMembers[RegisteredMembers[EMemberTypes::FNAMEENTRY_FLAGS].Offset] = RegisteredMembers[EMemberTypes::FNAMEENTRY_FLAGS];
returnMembers[RegisteredMembers[EMemberTypes::FNAMEENTRY_INDEX].Offset] = RegisteredMembers[EMemberTypes::FNAMEENTRY_INDEX];
returnMembers[RegisteredMembers[EMemberTypes::FNAMEENTRY_NAME].Offset] = RegisteredMembers[EMemberTypes::FNAMEENTRY_NAME];
break;
case EClassTypes::CLASS_UOBJECT:
returnMembers[RegisteredMembers[EMemberTypes::UOBJECT_VFTABLE].Offset] = RegisteredMembers[EMemberTypes::UOBJECT_VFTABLE];
returnMembers[RegisteredMembers[EMemberTypes::UOBJECT_INDEX].Offset] = RegisteredMembers[EMemberTypes::UOBJECT_INDEX];
returnMembers[RegisteredMembers[EMemberTypes::UOBJECT_OUTER].Offset] = RegisteredMembers[EMemberTypes::UOBJECT_OUTER];
returnMembers[RegisteredMembers[EMemberTypes::UOBJECT_NAME].Offset] = RegisteredMembers[EMemberTypes::UOBJECT_NAME];
returnMembers[RegisteredMembers[EMemberTypes::UOBJECT_CLASS].Offset] = RegisteredMembers[EMemberTypes::UOBJECT_CLASS];
break;
case EClassTypes::CLASS_UFIELD:
returnMembers[RegisteredMembers[EMemberTypes::UFIELD_NEXT].Offset] = RegisteredMembers[EMemberTypes::UFIELD_NEXT];
if (RegisteredMembers.find(EMemberTypes::UFIELD_SUPERFIELD) != RegisteredMembers.end())
{
returnMembers[RegisteredMembers[EMemberTypes::UFIELD_SUPERFIELD].Offset] = RegisteredMembers[EMemberTypes::UFIELD_SUPERFIELD];
}
break;
case EClassTypes::CLASS_UENUM:
returnMembers[RegisteredMembers[EMemberTypes::UENUM_NAMES].Offset] = RegisteredMembers[EMemberTypes::UENUM_NAMES];
break;
case EClassTypes::CLASS_UCONST:
returnMembers[RegisteredMembers[EMemberTypes::UCONST_VALUE].Offset] = RegisteredMembers[EMemberTypes::UCONST_VALUE];
break;
case EClassTypes::CLASS_UPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UPROPERTY_DIMENSION].Offset] = RegisteredMembers[EMemberTypes::UPROPERTY_DIMENSION];
returnMembers[RegisteredMembers[EMemberTypes::UPROPERTY_SIZE].Offset] = RegisteredMembers[EMemberTypes::UPROPERTY_SIZE];
returnMembers[RegisteredMembers[EMemberTypes::UPROPERTY_FLAGS].Offset] = RegisteredMembers[EMemberTypes::UPROPERTY_FLAGS];
returnMembers[RegisteredMembers[EMemberTypes::UPROPERTY_OFFSET].Offset] = RegisteredMembers[EMemberTypes::UPROPERTY_OFFSET];
break;
case EClassTypes::CLASS_USTRUCT:
if (RegisteredMembers.find(EMemberTypes::USTRUCT_SUPERFIELD) != RegisteredMembers.end())
{
returnMembers[RegisteredMembers[EMemberTypes::USTRUCT_SUPERFIELD].Offset] = RegisteredMembers[EMemberTypes::USTRUCT_SUPERFIELD];
}
returnMembers[RegisteredMembers[EMemberTypes::USTRUCT_CHILDREN].Offset] = RegisteredMembers[EMemberTypes::USTRUCT_CHILDREN];
returnMembers[RegisteredMembers[EMemberTypes::USTRUCT_SIZE].Offset] = RegisteredMembers[EMemberTypes::USTRUCT_SIZE];
break;
case EClassTypes::CLASS_UFUNCTION:
returnMembers[RegisteredMembers[EMemberTypes::UFUNCTION_FLAGS].Offset] = RegisteredMembers[EMemberTypes::UFUNCTION_FLAGS];
returnMembers[RegisteredMembers[EMemberTypes::UFUNCTION_NATIVE].Offset] = RegisteredMembers[EMemberTypes::UFUNCTION_NATIVE];
break;
case EClassTypes::CLASS_USTRUCTPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::USTRUCTPROPERTY_STRUCT].Offset] = RegisteredMembers[EMemberTypes::USTRUCTPROPERTY_STRUCT];
break;
case EClassTypes::CLASS_UOBJECTPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UOBJECTPROPERTY_PROPERTY].Offset] = RegisteredMembers[EMemberTypes::UOBJECTPROPERTY_PROPERTY];
break;
case EClassTypes::CLASS_UCLASSPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UCLASSPROPERTY_METACLASS].Offset] = RegisteredMembers[EMemberTypes::UCLASSPROPERTY_METACLASS];
break;
case EClassTypes::CLASS_UMAPPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UMAPPROPERTY_KEY].Offset] = RegisteredMembers[EMemberTypes::UMAPPROPERTY_KEY];
returnMembers[RegisteredMembers[EMemberTypes::UMAPPROPERTY_VALUE].Offset] = RegisteredMembers[EMemberTypes::UMAPPROPERTY_VALUE];
break;
case EClassTypes::CLASS_UINTERFACEPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UINTERFACEPROPERTY_CLASS].Offset] = RegisteredMembers[EMemberTypes::UINTERFACEPROPERTY_CLASS];
break;
case EClassTypes::CLASS_UDELEGATEPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UDELEGATEPROPERTY_FUNCTION].Offset] = RegisteredMembers[EMemberTypes::UDELEGATEPROPERTY_FUNCTION];
returnMembers[RegisteredMembers[EMemberTypes::UDELEGATEPROPERTY_NAME].Offset] = RegisteredMembers[EMemberTypes::UDELEGATEPROPERTY_NAME];
break;
case EClassTypes::CLASS_UBYTEPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UBYTEPROPERTY_ENUM].Offset] = RegisteredMembers[EMemberTypes::UBYTEPROPERTY_ENUM];
break;
case EClassTypes::CLASS_UBOOLPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UBOOLPROPERTY_BITMASK].Offset] = RegisteredMembers[EMemberTypes::UBOOLPROPERTY_BITMASK];
break;
case EClassTypes::CLASS_UARRAYPROPERTY:
returnMembers[RegisteredMembers[EMemberTypes::UARRAYPROPERTY_INNTER].Offset] = RegisteredMembers[EMemberTypes::UARRAYPROPERTY_INNTER];
break;
}
return returnMembers;
}
/*
# ========================================================================================= #
#
# ========================================================================================= #
*/