I tried it but it didn't work, I don't know if I did something wrongWhy don't you try/test before asking?
I will do that, thanks!Why dont you analyze the class to see if there are instances in other classes that have access to it?
GitHub - jbro129/Universal-Unity-NoClip: A universal way to create a noclip mod in Unity games (Mono/IIL2CPP)
A universal way to create a noclip mod in Unity games (Mono/IIL2CPP) - jbro129/Universal-Unity-NoClipgithub.com
This is a perfect example of this method being used.
Checked By yourself Personally or not?Yes .ctor can be used for hooking but the problem is most classes doesn't call it often and most of the time it only get called once when game start loading. Better look if another class is calling it or not if it does then access it from that class. If nothing is working you can try a dirty fix (not sure if it will work or not)
1. Hook .ctor and modify field.
2. Also create a function pointer for .ctor
[Ctor = (void(*)(void *))getAbsoluteAddress(targetLibName, 0x123456);]
3. Now call it from any update function.
Yes .ctor can be used for hooking but the problem is most classes doesn't call it often and most of the time it only get called once when game start loading. Better look if another class is calling it or not if it does then access it from that class. If nothing is working you can try a dirty fix (not sure if it will work or not)
1. Hook .ctor and modify field.
2. Also create a function pointer for .ctor
[Ctor = (void(*)(void *))getAbsoluteAddress(targetLibName, 0x123456);]
3. Now call it from any update function.
Yes checked by myself (1st & 2nd option) but 3rd one its totally an experimentalChecked By yourself Personally or not?
Yes checked by myself (1st & 2nd option) but 3rd one its totally an experimental
void* globalInstance;
void (*_ctor)(void* this);
void ctor(void* this){
if(this != NULL){
globalInstance = this;
}
_ctor(this);
}
void (*_update)(void* this);
void update(void* this){
if(this != NULL && globalInstance != NULL){
*(int *)((uint_64t)globalInstance + 0x24) = 0;
}
_update(this)
}
HOOK(.ctor//);
HOOK(update//);
Also discard this, it seems like .ctor is only responsible to run the code in the constructor. It's not responsible for the actual object creation in il2cpp. But the second point holdsWell among other things, that would create a new object on every frame. That's a high toll on memory
Also, .ctor might use a completely different object than the one actually being used in the game. So i am not sure how that would actually help in modifying those fields :)
C++:void* globalInstance; void (*_ctor)(void* this); void ctor(void* this){ if(este != NULL){ globalInstance = this; } _ctor(este); } void (*_update)(void* this); void update(void* this){ if(this != NULL && globalInstance != NULL){ *(int *)((uint_64t)globalInstance + 0x24) = 0; } _atualizar(este) } GANCHO(.ctor//); HOOK(atualizar //);
Aqui está um código que pode funcionar. A única limitação é que o ctor deve ser chamado pelo menos uma vez rs. Se for chamado mais de uma vez, você perderá o acesso aos objetos anteriores
[/CITAR]
Bgood, try to use it but it didn't work, there was no change in the value
Eu penso o mesmo, . ctor (Construtor) não pode ser usado para enganchar. Se o jogo chamar, então funcionará, senão não.
[/CITAR]
EIs there any way to change this code? I've tried everything
100%I think same, . ctor (Constructor) cant be used to hook. If the game calles it then it will work, else it wont.