Discussion How to hook fields variables using And64InlineHook ?

markitosx666

New User
12
01/05/22
4
Thread Author
Hello guys, I'm trying to hook and change the field value of a class like this:

1646057551898.png


I tried everything but when I press the skill button in the game, it crashes. I read in another forums that I need Update method, but here there isn't any method called Update or LateUpdate, so... How can I modify the value? There is the code I used which DON'T CRASH the game but doesn't work:

C++:
void(*old_skill)(void* instance);
void skill(void* instance) {
    *(float*)((uint64_t)instance + 0xF0) = 9999.0f;
    old_skill(instance);
}

A64HookFunction((void*)getAbsoluteAddress(targetLibName, offset), (void*)skill, (void**)&old_skill);

The offset I use is the class one, I think that's the problem but I don't know.
Someone can help me? Thanks ^^.
 
I solved it, the problem is the old_skill; the original code of the function xD. You must declare the original first like this:

C++:
void(*old_skill)(void* instance);
void skill(void* instance) {
    old_skill(instance);
    *(float*)((uint64_t)instance + 0xF0) = FLT_MAX;
}

A64HookFunction((void*)getAbsoluteAddress(targetLibName, offset), (void*)skill, (void**)&old_skill);

This worked for me, I'm stupid xD.
 
Hello guys, I'm trying to hook and change the field value of a class like this:

[Attachment removed from Quotes]

I tried everything but when I press the skill button in the game, it crashes. I read in another forums that I need Update method, but here there isn't any method called Update or LateUpdate, so... How can I modify the value? There is the code I used which DON'T CRASH the game but doesn't work:

C++:
void(*old_skill)(void* instance);
void skill(void* instance) {
    *(float*)((uint64_t)instance + 0xF0) = 9999.0f;
    old_skill(instance);
}

A64HookFunction((void*)getAbsoluteAddress(targetLibName, offset), (void*)skill, (void**)&old_skill);

The offset I use is the class one, I think that's the problem but I don't know.
Someone can help me? Thanks ^^.


how did you do it, i need to use the field offset but in the class there is no update and the update of other classes doesn't work


using System;
using Il2CppDummyDll;

// Token: 0x0200002C RID: 44
[Token(Token = "0x200002C")]
[Attribute(Name = "CreateAssetMenuAttribute", RVA = "0x776044", Offset = "0x776044")]
public class GunData : BaseData
{
// Token: 0x060002B4 RID: 692 RVA: 0x00002050 File Offset: 0x00000250
[Token(Token = "0x60002B4")]
[Address(RVA = "0x1A35F54", Offset = "0x1A35F54", VA = "0x1A35F54")]
public GunData()
{
}

// Token: 0x04000146 RID: 326
[Token(Token = "0x4000146")]
[FieldOffset(Offset = "0x20")]
public int gunID;

// Token: 0x04000147 RID: 327
[Token(Token = "0x4000147")]
[FieldOffset(Offset = "0x24")]
[Attribute(Name = "HeaderAttribute", RVA = "0x776DA4", Offset = "0x776DA4")]
[Attribute(Name = "RangeAttribute", RVA = "0x776DA4", Offset = "0x776DA4")]
public int dmg;

// Token: 0x04000148 RID: 328
[Token(Token = "0x4000148")]
[FieldOffset(Offset = "0x28")]
[Attribute(Name = "RangeAttribute", RVA = "0x776DF8", Offset = "0x776DF8")]
public int rateOfFire;

// Token: 0x04000149 RID: 329
[Token(Token = "0x4000149")]
[FieldOffset(Offset = "0x2C")]
[Attribute(Name = "RangeAttribute", RVA = "0x776E14", Offset = "0x776E14")]
public int accuracy;

// Token: 0x0400014A RID: 330
[Token(Token = "0x400014A")]
[FieldOffset(Offset = "0x30")]
public int capacity;

// Token: 0x0400014B RID: 331
[Token(Token = "0x400014B")]
[FieldOffset(Offset = "0x34")]
public int maximumBullets;

// Token: 0x0400014C RID: 332
[Token(Token = "0x400014C")]
[FieldOffset(Offset = "0x38")]
[Attribute(Name = "HeaderAttribute", RVA = "0x776E30", Offset = "0x776E30")]
public float shootDelay;

// Token: 0x0400014D RID: 333
[Token(Token = "0x400014D")]
[FieldOffset(Offset = "0x3C")]
[Attribute(Name = "RangeAttribute", RVA = "0x776E64", Offset = "0x776E64")]
public float dmgPower;

// Token: 0x0400014E RID: 334
[Token(Token = "0x400014E")]
[FieldOffset(Offset = "0x40")]
public float spread;
}
 
how did you do it, i need to use the field offset but in the class there is no update and the update of other classes doesn't work


using System;
using Il2CppDummyDll;

// Token: 0x0200002C RID: 44
[Token(Token = "0x200002C")]
[Attribute(Name = "CreateAssetMenuAttribute", RVA = "0x776044", Offset = "0x776044")]
public class GunData : BaseData
{
// Token: 0x060002B4 RID: 692 RVA: 0x00002050 File Offset: 0x00000250
[Token(Token = "0x60002B4")]
[Address(RVA = "0x1A35F54", Offset = "0x1A35F54", VA = "0x1A35F54")]
public GunData()
{
}

// Token: 0x04000146 RID: 326
[Token(Token = "0x4000146")]
[FieldOffset(Offset = "0x20")]
public int gunID;

// Token: 0x04000147 RID: 327
[Token(Token = "0x4000147")]
[FieldOffset(Offset = "0x24")]
[Attribute(Name = "HeaderAttribute", RVA = "0x776DA4", Offset = "0x776DA4")]
[Attribute(Name = "RangeAttribute", RVA = "0x776DA4", Offset = "0x776DA4")]
public int dmg;

// Token: 0x04000148 RID: 328
[Token(Token = "0x4000148")]
[FieldOffset(Offset = "0x28")]
[Attribute(Name = "RangeAttribute", RVA = "0x776DF8", Offset = "0x776DF8")]
public int rateOfFire;

// Token: 0x04000149 RID: 329
[Token(Token = "0x4000149")]
[FieldOffset(Offset = "0x2C")]
[Attribute(Name = "RangeAttribute", RVA = "0x776E14", Offset = "0x776E14")]
public int accuracy;

// Token: 0x0400014A RID: 330
[Token(Token = "0x400014A")]
[FieldOffset(Offset = "0x30")]
public int capacity;

// Token: 0x0400014B RID: 331
[Token(Token = "0x400014B")]
[FieldOffset(Offset = "0x34")]
public int maximumBullets;

// Token: 0x0400014C RID: 332
[Token(Token = "0x400014C")]
[FieldOffset(Offset = "0x38")]
[Attribute(Name = "HeaderAttribute", RVA = "0x776E30", Offset = "0x776E30")]
public float shootDelay;

// Token: 0x0400014D RID: 333
[Token(Token = "0x400014D")]
[FieldOffset(Offset = "0x3C")]
[Attribute(Name = "RangeAttribute", RVA = "0x776E64", Offset = "0x776E64")]
public float dmgPower;

// Token: 0x0400014E RID: 334
[Token(Token = "0x400014E")]
[FieldOffset(Offset = "0x40")]
public float spread;
}
if no update then you have to use any instance from that class that can be handy for it
 
Back
Top Bottom