Help! How to mod Struct member ?

Galaxy169

Approved Modder
Approved Modder
Apr 28, 2020
29
934
78
Home
I know we can use pointer to access that struct and modify it's member but I don't know how to do it by code ?
Can you send me an example ?
This is what I found in the dump

public sealed class GameCamera : MonoBehaviour // TypeDefIndex: 11111
private GameCamera.ZoomParams _defaultZoomParams; // 0x48

-------

public abstract class Controllable : FastMonoBehaviour // TypeDefIndex: 11056
private GameCamera.ZoomParams _cameraZoomParams; // 0x6C
You can use these field as instance to access the struct,

C++:
*rest of the hooking code*

    void *ZoomParams = *(void**)((uint64_t)instance + 0x48); // Pointer to ZoomParams

    if(ZoomParams){ // Check if it's not null

        *(float*)((uint64_t)ZoomParams + 0x4) = 25.0f; // public float heigth; // 0x4
    }

*rest of the hooking code*
 
  • Like
Reactions: hienngocloveyou

hienngocloveyou

Solid & Active Platinian
Original poster
May 16, 2021
61
7
8
38
VN
This is what I found in the dump



You can use these field as instance to access the struct,

C++:
*rest of the hooking code*

    void *ZoomParams = *(void**)((uint64_t)instance + 0x48); // Pointer to ZoomParams

    if(ZoomParams){ // Check if it's not null

        *(float*)((uint64_t)ZoomParams + 0x4) = 25.0f; // public float heigth; // 0x4
    }

*rest of the hooking code*
Hi,

Thank for your reply. I will test and let you know the result :)

Regards,
 

Tiahh

Solid & Active Platinian
Jan 12, 2018
75
45
18
37
Just set a function pointer.
And then modify the value
Ex:


C++:
void *(*FuncPoint)(void *instance) = (void *(*)(void*))getRelativeAddress(offset);
//we set the function pointer

//we set the value in the structure
*(int*)((uintptr_t)FuncPoint+fieldOffset) = 9999;
 
  • Like
Reactions: asdf101 and Sevol

ranfan06

Platinian
May 21, 2021
5
0
13
32
Malaysia
I have similar issues. Tried setting this->fields.maxHealth = 100; but the health became zero instead.

This is the pseudocode from il2cpp.so.

C++:
    LODWORD(this->fields.maxHealth) = ((int (__fastcall *)(LocalData_BaseUnitData_o *, int32_t, int32_t, int32_t, const MethodInfo *))data->klass->vtable._5_GetTotalHealth.methodPtr)(
                                        data,
                                        v9,
                                        levelUpgrade,
                                        levelUpgradeStarPurple,
                                        data->klass->vtable._5_GetTotalHealth.method);
 

Tiahh

Solid & Active Platinian
Jan 12, 2018
75
45
18
37
I have similar issues. Tried setting this->fields.maxHealth = 100; but the health became zero instead.

This is the pseudocode from il2cpp.so.

C++:
    LODWORD(this->fields.maxHealth) = ((int (__fastcall *)(LocalData_BaseUnitData_o *, int32_t, int32_t, int32_t, const MethodInfo *))data->klass->vtable._5_GetTotalHealth.methodPtr)(
                                        data,
                                        v9,
                                        levelUpgrade,
                                        levelUpgradeStarPurple,
                                        data->klass->vtable._5_GetTotalHealth.method);
is the health obscured? please use Il2cppDumper instead of ida if you have the possibility. Ida decompiler could have some mistakes.
 

ranfan06

Platinian
May 21, 2021
5
0
13
32
Malaysia
C++:
    // RVA: 0x9CEA24 Offset: 0x9CEA24 VA: 0x9CEA24
    public void InitBaseTowerData(BaseUnitData data, int levelUpgrade, int levelUpgradeStarPurple) { }
This is from the dump.cs. Following it into IDA got me to that point. First they get the soldier's ID, then assign their attributes by taking the value from GetTotalMoveSpeed. Below is the pseudocode and the dump.cs

C++:
    v9 = data->fields._Id_k__BackingField;
    this->fields.id = v9;
    LODWORD(this->fields.maxHealth) = ((int (__fastcall *)(LocalData_BaseUnitData_o *, int32_t, int32_t, int32_t, const MethodInfo *))data->klass->vtable._5_GetTotalHealth.methodPtr)(
                                        data,
                                        v9,
                                        levelUpgrade,
                                        levelUpgradeStarPurple,
                                        data->klass->vtable._5_GetTotalHealth.method);
C++:
    // RVA: 0x6CFB10 Offset: 0x6CFB10 VA: 0x6CFB10 Slot: 5
    public virtual float GetTotalHealth(int levelUnit = 0, int levelUpgrade = 0, int levelUpgradeStarPurple = 0) { }
The InitBaseTowerData is from my character class, while the GetTotalHealth is from BaseUnitData (see in pseudocode) shared with enemy.

I tried to find player's ID to unlink, but this might be the only way to differentiate player and enemy. I'm noob tho, so who knows.
 

hienngocloveyou

Solid & Active Platinian
Original poster
May 16, 2021
61
7
8
38
VN
This is what I found in the dump



You can use these field as instance to access the struct,

C++:
*rest of the hooking code*

    void *ZoomParams = *(void**)((uint64_t)instance + 0x48); // Pointer to ZoomParams

    if(ZoomParams){ // Check if it's not null

        *(float*)((uint64_t)ZoomParams + 0x4) = 25.0f; // public float heigth; // 0x4
    }

*rest of the hooking code*
It work in my case. Thank you very much.
 

KeqziCheats

Rookie
Apr 9, 2024
1
0
1
24
Вот что я нашел на свалке



Вы можете использовать это поле как экземпляр для доступа к структуре,

[КОД=cpp]

*остальная часть кода подключения*

void *ZoomParams = *(void**)((uint64_t)instance + 0x48); // Указатель на ZoomParams

if(ZoomParams){ // Проверяем, не равно ли значение нулю

*(float*)((uint64_t)ZoomParams + 0x4) = 25.0f; // публичная высота плавающей точки; // 0x4
}

*остальная часть кода перехвата*[/CODE]
[/ЦИТИРОВАТЬ]
This is what I found in the dump



You can use these field as instance to access the struct,

C++:
*rest of the hooking code*

    void *ZoomParams = *(void**)((uint64_t)instance + 0x48); // Pointer to ZoomParams

    if(ZoomParams){ // Check if it's not null

        *(float*)((uint64_t)ZoomParams + 0x4) = 25.0f; // public float heigth; // 0x4
    }

*rest of the hooking code*
Help me please to hook this

// Namespace: ClientCommons.Game.Rpc
public struct RemoteZonePassage // TypeDefIndex: 15795
{
// Fields
public int ZoneControllerId; // 0x0
public bool Entered; // 0x4
}