Help! how to use a BackingField pointer?

CHEATS GAMES

Solid & Active Platinian
Original poster
Aug 9, 2019
64
18
8
39
Brazil
I have a pointer that I add to my cheat but it crashes the game and doesn't work, how to use this type of function?
how to add bankfield in mod menu?

C++:
[Token(Token = "0x40052CA")]
[FieldOffset(Offset = "0x20")]
[Attribute(Name = "CompilerGeneratedAttribute", RVA = "0x5EE0E4", Offset = "0x5EE0E4")]
private int <MovesLeft>k__BackingField;
1648561963766.png


I already tried to use get_MovesLeft and set_MovesLeft(int value) linking the two but it didn't work.


I did it using private int <Moves Left>k__BackingField; in game guardian and it worked, but how to assemble this script in mod menu

C++:
void (*orig_Update)(void *instance);
void Update(void *instance)
{
    if(instance != NULL)
    {
        *(int*)((uint64_t)instance + 0x20) = 99; // Declare a variable to isEnemy to access it
              
        }

   orig_Update(instance);
}
 
  • Like
Reactions: Rookie1062 and Ze6

NullCoder

Inactive Approved Modder
Jun 8, 2020
110
900
93
21
None
Stop asking such embarrassing easy questions, how do you want to do and learn something if you expect to be taught something you don't even want to learn? I think they don’t answer you just because the error is immediately visible, there are examples, there are trainings. Before asking a question, learn what MSHookFunction is and how to use it.
Those who do not learn will always stand still.
 

CHEATS GAMES

Solid & Active Platinian
Original poster
Aug 9, 2019
64
18
8
39
Brazil
Pare de fazer perguntas tão fáceis e embaraçosas, como você quer fazer e aprender algo se espera ser ensinado algo que nem quer aprender? Acho que não te respondem só porque o erro é logo visível, tem exemplos, tem treinamentos. Antes de fazer uma pergunta, saiba o que é MSHookFunction e como usá-lo.
Quem não aprende sempre fica parado.
[/CITAR]
:face26:
 

CHEATS GAMES

Solid & Active Platinian
Original poster
Aug 9, 2019
64
18
8
39
Brazil
Stop asking such embarrassing easy questions, how do you want to do and learn something if you expect to be taught something you don't even want to learn? I think they don’t answer you just because the error is immediately visible, there are examples, there are trainings. Before asking a question, learn what MSHookFunction is and how to use it.
Those who do not learn will always stand still.

I already tried all the ways I saw here and it didn't work, sorry
 

DieckyAwsm

Platinian
Feb 23, 2022
22
3
3
27
Indonesia
Stop asking such embarrassing easy questions, how do you want to do and learn something if you expect to be taught something you don't even want to learn? I think they don’t answer you just because the error is immediately visible, there are examples, there are trainings. Before asking a question, learn what MSHookFunction is and how to use it.
Those who do not learn will always stand still.
Can this type of offset field be used?
private int _maxHP; // 0x2C
private int _curHP; // 0x30
private int _regHP; // 0x34
 

CHEATS GAMES

Solid & Active Platinian
Original poster
Aug 9, 2019
64
18
8
39
Brazil
Stop asking such embarrassing easy questions, how do you want to do and learn something if you expect to be taught something you don't even want to learn? I think they don’t answer you just because the error is immediately visible, there are examples, there are trainings. Before asking a question, learn what MSHookFunction is and how to use it.
Those who do not learn will always stand still.

it was really easy, i'm so dumb, but i've never done it using set method :face31:thanks anyway, i'll try to improve
 

Tiahh

Solid & Active Platinian
Jan 12, 2018
75
45
18
37
Instead of hooking an update and changing that field, why don't you just hook get_MovesLeft()?
 

Sbyky

Approved Modder
Approved Modder
Oct 4, 2022
72
2,213
183
Pakistan
for hooking fields and k__backingfields

Code:
struct {
    bool Update = false;
} MyMod;



void (*old_NameOfYourChoice)(void *instance);
void NameOfYourChoice(void *instance) {
    if (instance != NULL) {
        if (MyMod.Update) {
            *(int *) ((uint64_t) instance + 0x20) = 99;
        }
    }
    return old_NameOfYourChoice(instance);
}



    HOOK_LIB("libil2cpp.so", "0x764500", NameOfYourChoice, old_NameOfYourChoice);



            OBFUSCATE("Toggle_Whatever Your Hook Does"),



        case 0: // use your case number
            MyMod.Update = boolean;
            break;
you just gotta find the right method to hook, Update() works most of the times but in rare cases when it doesn't work for you or when the class doesn't have an Update() method, try hooking another method from the same class as the field that's getting called, and keep on trying, i hope this helps
 
Last edited: