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

Help! public void .ctor can be used as update method?

Master TK

Platinian
public void .ctor Can be used as update method for hook field?

public float maxFallSpeed; // 0x24
// Methods

// RVA: 0x46E418 Offset: 0x46E418 VA: 0x46E418
public void .ctor() { }
}
 
BTW, FOR YOUR INFORMATION .ctor is not defined method, its full form is constructor, it os automatically added by the Compiler, so i don't think .ctor can Be hooked

You can do Multi class Hooking,
Like:
class:

class a {
int money; // 0x3
}

class b {
public a UserMoney; // 0x10

//0x11111111
public void update()
}

So, Now:
Hooking:

void(_Update)(void *thiz);
void UPDATE(void *thiz) {
if(thiz != NULL) {
void *aClass = *(void**)((uint64_t)thiz + 0x3);
if(a != NULL) {
*(int *) ((uint64_t) aClass + 0x10) = 999;
}
}
}
HOOK_LIB("LIBNAME", "0x11111111", UPDATE, _Update);
 
Tbh theres some games that i used ctor as update method, it does work but its a lil buggy. You need to try yourself, try and error is the key thats how u learn. Not just hoping ppl to spoonfeed you
 
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.
 
Checked By yourself Personally or not?
 

Well 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 :)
 
Last edited:
Yes checked by myself (1st & 2nd option) but 3rd one its totally an experimental


C++:
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//);

Here is a code that might work. The only limitation is that the ctor must be called at least once lol. If it's called more than once, you will lose access to previous objects
 
Last edited:
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 holds