This is the AMP version of this page.
If you want to load the real page instead, click this text.

Help! How to mod Struct member ?

Galaxy169

Approved Modder
Approved Modder
Apr 28, 2020
29
1,097
178
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

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*
 
Reactions: hienngocloveyou

hienngocloveyou

Solid & Active Platinian
Original poster
May 16, 2021
61
7
8
38
VN
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;
 
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
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
It work in my case. Thank you very much.
 

KeqziCheats

Rookie
Apr 9, 2024
1
0
1
24
Help me please to hook this

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