四、认识结构并手动解析

一、 认识结构

  • UObject
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
class UObject
{
/** virtual function table */
void* vtf;
/** Flags used to track and report various object states. This needs to be 8 byte aligned on 32-bit
platforms to reduce memory waste */
EObjectFlags ObjectFlags;

/** Index into GObjectArray...very private. */
int32 InternalIndex; //表明该对象在GObjectArray中的第几个

/** Class the object belongs to. */
UClass* ClassPrivate; //对象所属的基类

/** Name of this object */
FName NamePrivate; //类名

/** Object this object resides in. */
UObject* OuterPrivate; //这个对象是从哪个对象来的
}
  • UField
1
2
3
4
5
6
class UField : public UObject
{
public:
/** Next Field in the linked list */
UField* Next;
};
  • UEnum
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
class UEnum : public UField
{
public:
/** How this enum is declared in C++, affects the internal naming of enum values */
enum class ECppForm
{
Regular, //0
Namespaced, //1
EnumClass ///2
};

<br/>

/** 枚举类型的字符串, e.g. "ENamespacedEnum::InnerType" or "ERegularEnum" or "EEnumClass" */
FString CppType;

<br/>

/**枚举成员. */
TArray<TPair<FName, int64>> Names;

<br/>

/** 枚举的最初定义类型. */
ECppForm CppForm;

<br/>

/** pointer to function used to look up the enum's display name. Currently only assigned for UEnums generated for nativized blueprints */
FEnumDisplayNameFn EnumDisplayNameFn;

<br/>

/** global list of all value names used by all enums in memory, used for property text import */
static TMap<FName, UEnum*> AllEnumNames;
}
  • UStruct
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
class UStruct : public UField
{
/** 继承自的结构体,可以为空 */
UStruct* SuperStruct;
/** 指向下一个子对象的指针 */
UField* Children;

/** 该结构体的总大小 */
int32 PropertiesSize;
/** 结构体的对齐大小 */
int32 MinAlignment;

/** Script bytecode associated with this object */
TArray<uint8> Script;
/** In memory only: Linked list of properties from most-derived to base */
UProperty* PropertyLink;
/** In memory only: Linked list of object reference properties from most-derived to base */
UProperty* RefLink;
/** In memory only: Linked list of properties requiring destruction. Note this does not include things that will be destroyed byt he native destructor */
UProperty* DestructorLink;
/** In memory only: Linked list of properties requiring post constructor initialization */
UProperty* PostConstructLink;
/** Array of object references embedded in script code. Mirrored for easy access by realtime garbage collection code */
TArray<UObject*> ScriptObjectReferences;
}
  • UFunction
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
class UFunction : public UStruct
{
public:
// Persistent variables.

/** EFunctionFlags set defined for this function */
EFunctionFlags FunctionFlags;

// Variables in memory only.
/** 参数数量 */
uint8 NumParms;
/** 所有参数的总大小 */
uint16 ParmsSize;
/** 返回值的偏移 */
uint16 ReturnValueOffset;
/** Id of this RPC function call (must be FUNC_Net & (FUNC_NetService|FUNC_NetResponse)) */
uint16 RPCId;
/** Id of the corresponding response call (must be FUNC_Net & FUNC_NetService) */
uint16 RPCResponseId;
/** pointer to first local struct property in this UFunction that contains defaults */
UProperty* FirstPropertyToInit;

/** The event graph this function calls in to (persistent) */
UFunction* EventGraphFunction;

/** The state offset inside of the event graph (persistent) */
int32 EventGraphCallOffset;

/** 所指向的函数地址 */
FNativeFuncPtr Func;
}
  • UProperty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
class UProperty : public UField
{
/** 成员上限 **/
int32 ArrayDim;
/** 成员大小 **/
int32 ElementSize;
/** 成员标志 **/
EPropertyFlags PropertyFlags;
uint16 RepIndex;
/** 成员偏移 **/
int32 Offset_Internal;
FName RepNotifyFunc;
/** 下一个成员 **/
UProperty* PropertyLinkNext;
/** In memory only: Linked list of object reference properties from most-derived to base **/
UProperty* NextRef;
/** In memory only: Linked list of properties requiring destruction. Note this does not include things that will be destroyed byt he native destructor **/
UProperty* DestructorLinkNext;
/** In memory only: Linked list of properties requiring post constructor initialization.**/
UProperty* PostConstructLinkNext;
}

二、手动解析

  • UObject

document_image_rId4

  • UEnum

document_image_rId5

  • UStruct

document_image_rId6

  • UProperty

document_image_rId7

document_image_rId8

document_image_rId9

  • UFunction

document_image_rId10

document_image_rId11

实战:解析GameInstance类

  • LocalPlayers

document_image_rId12

document_image_rId13

  • OnlineSession

document_image_rId14

document_image_rId15

  • ReferencedObjects

document_image_rId16

document_image_rId17