Help! How to mod Struct member ?

hienngocloveyou

Solid & Active Platinian
Hi Everyone,

The forum is sharing how to acces method return int,float,bool,etc data but I don't know how to access member in struct return.
For example I have method return ZoomParams is a struct. So how to access it's member ?

1621553350982.png


1621553401041.png


Thank for your reading !
 
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*
 
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,
 
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;
 
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);
 
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.
 
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.
 
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.
 
Вот что я нашел на свалке



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

[КОД=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
}
 
Back
Top Bottom