吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 4276|回复: 2
收起左侧

[游戏安全] UE4逆向笔记之GObjectArray

  [复制链接]
XiaoTouM1ng 发表于 2023-1-11 15:49

GObjectArray逆向:

首先查看源代码:

01.png

此处上面存在字符串特征:

Cannot Cancel Async Loading while async loading is suspended.

直接搜索该字符串就可以定位到GUObjectArray.GetObjectArrayNum():

02.png

然后查看GetObjectArrayNum的源代码:

    FORCEINLINE int32 GetObjectArrayNum() const 
    { 
        return ObjObjects.Num();
    }

跟进ObjObjects发现定义如下:

TUObjectArray ObjObjects;

继续跟进:

typedef FChunkedFixedUObjectArray TUObjectArray;

得到如下类:

class FChunkedFixedUObjectArray
{
    enum
    {
        NumElementsPerChunk = 64 * 1024,
    };

    /** Master table to chunks of pointers **/
    FUObjectItem** Objects;
    /** If requested, a contiguous memory where all objects are allocated **/
    FUObjectItem* PreAllocatedObjects;
    /** Maximum number of elements **/
    int32 MaxElements;
    /** Number of elements we currently have **/
    int32 NumElements;
    /** Maximum number of chunks **/
    int32 MaxChunks;
    /** Number of chunks we currently have **/
    int32 NumChunks;

找到方法的定义如下:

    FORCEINLINE int32 Num() const
    {
        return NumElements;
    }

发现返回的就是NumElements这个,所以7FF78E0D11A4该地址其实就是ObjObjects.NumElements,而上面存在5个元素,5*4=0x14,所以该地址-0x14就可以得到GObjectArray:

03.png

此时的第一个元素为:

class FUObjectItem
{
// Pointer to the allocated object
class UObjectBase* Object;
// Internal flags
int32 Flags;
// UObject Owner Cluster Index
int32 ClusterRootIndex;
// Weak Object Pointer Serial number associated with the object
int32 SerialNumber;
}

04.png

继续查看第一个元素就是UObject:

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

05.png

通过UObject就可以遍历出UE4引擎的所有对象了

使用代码遍历:

通过观察代码我们知道Objct是一个二级指针:

FUObjectItem** Objects;

也就是说他和Gname一样是以表的形式存在的,所以我们想要遍历他就需要知道当前需要遍历的对象在哪张表中,算法如下:

UObject* UobjectArray::GetObjectPtr(int id) {

    if (id >= NumElements) return 0;
    DWORD64 chunkIndex = id / 65536; //chunkIndex = 0
    if (chunkIndex >= NumChunks) return 0;
    auto chunk = Process::ReadProcess<void*>(Objects+(chunkIndex * 8));//
    if (!chunk) return 0;
    DWORD withinChunkIndex = id % 65536 * 32; //这里的32是根据游戏实际结构体大小决定了,默认情况下为32
    auto item = Process::ReadProcess<PVOID>((PVOID)((DWORD64)chunk + withinChunkIndex));
    return (DWORD64)item;

}

官方给出的SDK代码中就有,可以复制过来直接用:

code。png.png

遍历代码如下:

    GobjectArray = Process::ReadProcess<UobjectArray>((PVOID)((DWORD64)Process::GetProcessMoudleBase() + 0x8031190));

    //int NumElements = Process::ReadProcess<int>((PVOID)(GobjectArray + 0x14));

    cout << "NumElements: " << hex << GobjectArray.NumElements << endl;

    for (int i = 0; i < GobjectArray.NumElements; i++) {

        cout <<"ID:" << i << "       Uobject Address: " << GobjectArray.GetObjectPtr(i) << endl;

    }

测试结果:

06.png

当能够遍历出Object后还需要使用到Gname遍历Object的名称,具体可以查看我之前的文章,部分代码如下:

string GetObjectName(DWORD64 Address) {

    string Name;

    DWORD64 UobjectOuter = Process::ReadProcess<DWORD64>((PVOID)(Address + 0x20)); //获取UObject->OuterPrivate
    if (UobjectOuter != 0)
    {

        for (DWORD64 Outer = UobjectOuter; Outer; Outer = Process::ReadProcess<DWORD64>((PVOID)(Outer + 0x20)))
        {
            Name = GetName_New(GetFName(Outer).ComparisonIndex) + "." + Name;
        }

        Name = GetKlassName(Address) + " " + Name + GetName_New(GetFName(Address).ComparisonIndex);
        return Name;
    }

    Name = GetKlassName(Address) + " " + GetName_New(GetFName(Address).ComparisonIndex);
    return Name;
}

遍历结果如下:

07.png

08.png

参考代码:

https://github.com/guttir14/CheatIt

https://github.com/XiaoTouMingyo/UE4ForeachClass

免费评分

参与人数 5威望 +1 吾爱币 +25 热心值 +5 收起 理由
King1993 + 1 + 1 谢谢@Thanks!
忆魂丶天雷 + 2 + 1 我很赞同!
supercilious + 1 + 1 鼓励转贴优秀软件安全工具和文档!
Hmily + 1 + 20 + 1 感谢发布原创作品,吾爱破解论坛因你更精彩!
这是追求不是梦 + 1 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

zhangting2022 发表于 2023-1-12 08:01
UE4逆向笔记之GObjectArray
King1993 发表于 2023-1-13 08:57
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-25 04:48

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表