五、静态类和修复完整结构

一、认识静态类

  • 静态类

document_image_rId4

每一个对象都是从某一个静态类继承而来的,基类存在UObject的Class成员中。那么通过这个字段我们就可以判断当前对象是什么类。

document_image_rId5

知道什么什么类之后,我们就可以对应处理。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
auto obj = GetStaticClass();
switch(obj)
{
case CLASS:
//处理类
break;
case FUNCTION:
//处理函数
break;
case UPROPERTY:
//处理字段
break;
.......
};

其实我们修结构,就是在修这些静态类。(之所以从对象去修,是因为对象是已经实例化了这个类,类的每个字段已经存在了数据,这样更利于我们修结构,当我们把一些字段修完后,再去修一些基类固定的结构。

二、修复完整结构

  • 修复UStruct

上节课已经把UStruct修了个90%,这次直接把他修完整。在ObjectsDump.txt中找到基类。(基类都是Class CoreObject.xxxxxx命名

document_image_rId6

地址更新到我们上节课修复好的结构中。

document_image_rId7

可以看到基类的PropertiesSize是152的大小,但是我们现在的大小是104,所以我们需要把我们的类给完善。

document_image_rId8

然后因为我们上节课没有修复SuperField,现在来修复一下,通过结构可知,UStruct继承了UField类。

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;
}

由于当前我们查看的是UStruct的静态类,UStruct继承了UField的静态类,我们直接在周围查看UField的静态地址。

document_image_rId9

document_image_rId10

  • 修复UFunction

同样把UFunction基类地址扔进Reclass

document_image_rId11

document_image_rId12

可以看到PropertiesSize是200的大小,将当前类大小进行修复。

document_image_rId13

  • 修复UClass

由于UClass是继承UStruct,直接,按照同样的操作修复。

document_image_rId14

document_image_rId15

  • 修复UStructProperty

由于UStructProperty是继承UStruct,直接,按照同样的操作修复。

document_image_rId16

document_image_rId17

  • 修复UProperty

类似这种结构,需要找到一个对应类型的对象,扔到CE或者ReClass查看。

1
2
3
4
5
class UStructProperty : public UProperty
{
public:
UScriptStruct* Struct;
};

比如

document_image_rId18

修到下边这个。

document_image_rId19