Solved Hook void (float)

Status
Not open for further replies.

AZFernandez

Platinian
Hi all. Is it possible to somehow hook this:
Code:
RVA: 0x604820 VA: 0xc0204820
    private Void NormalDamage(Int32 newDamage, EnemyInfo enemy, Single multiplier) { }

// RVA: 0x5e8008 VA: 0xc01e8008
private Void Update() { }
I'm trying to change the damage multiplier, but either nothing changes, or the character simply stops attacking.

All I've tried:
Code:
void (*old_Damage)(void *instance, float value);
void Damage(void *instance, float value) {
    if (instance != NULL) {
            old_Damage(instance, 9999.0f);
            return;
    }
    return old_Damage(instance,value);
}

MSHookFunction((void *)getAbsoluteAddress("libil2cpp.so", 0x604820), (void *) Damage, (void **) &old_Damage);
Code:
void (*isDamage)(void *instance,float value);
void (*old_Damage)(void *instance);
void Damage(void *instance) {
    if (instance != NULL) {
            isDamage(instance, 9999.0f);
    }
    return old_Damage(instance);
}

isDamage = (void (*)(void *, int))getAbsoluteAddress("libil2cpp.so",0x604820);
MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0x5e8008), (void *) Damage, (void **) &old_Damage);

Code:
void (*old_Damage)(void *instance, float value);
void Damage(void *instance, float value) {
    if (instance == nullptr)return;
   
               value == 9999.0f;
         
     old_Damage(instance,value);
}

HOOK_LIB("libil2cpp.so", "0x604820", Damage, old_Damage);
 
What do you mean by this? I'm not very good with modding terminology

void NormalDamage(void * instance, int newDamage, void *enemy, void *multiplier) ;

void _NormalDamage(void * instance, int newDamage, void *enemy, void *multiplier) {

if (instance != nullptr) {
//do whatever you want here
newDamage = 999999; //example for changing the param value
}
NormalDamage(instance, newDamage, enemy, multiplier);

}
 
void (*NormalDamage)(void *instance, int newDamage, void *enemy, float multiplier);

void (*old_Update)(void *instance);
void Update(void *instance) {
if(instance!=NULL) {
void *enemy = *(void **) ((uint64_t) instance + 0xOFFSET);
NormalDamage(instance, 9999, enemy, 1.0);
}
}
old_Update(instance);
}
 
void NormalDamage(void * instance, int newDamage, void *enemy, void *multiplier) ;

void _NormalDamage(void * instance, int newDamage, void *enemy, void *multiplier) {

if (instance != nullptr) {
//do whatever you want here
newDamage = 999999; //example for changing the param value
}
NormalDamage(instance, newDamage, enemy, multiplier);

}
Thank you for your answer, but unfortunately I was unable to compile the project
 
void (*NormalDamage)(void *instance, int newDamage, void *enemy, float multiplier);

void (*old_Update)(void *instance);
void Update(void *instance) {
if(instance!=NULL) {
void *enemy = *(void **) ((uint64_t) instance + 0xOFFSET);
NormalDamage(instance, 9999, enemy, 1.0);
}
}
old_Update(instance);
}
Thank you.
It was possible to compile the project only by bringing the code to this form, but unfortunately the game crashes
Code:
void (*NormalDamage)(void *instance, int newDamage, void *enemy, float multiplier);

void (*old_Update)(void *instance);
void Update(void *instance) {
if(instance!=NULL) {
void *enemy = *(void **) ((uint64_t) instance + 0x604820);
NormalDamage(instance, 9999, enemy, 1.0);
//}
}
old_Update(instance);
}


HOOK_LIB("libil2cpp.so", "0x5e8008", Update, old_Update);
 
Try this

C++:
void (*NormalDamage)(void *instance, int newDamage, void *enemy, float multiplier);
void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=NULL) {
        void *enemy = *(void **) ((uint64_t) instance + 0xOFFSET);
        NormalDamage(instance, 9999, enemy, 1.0);
    }
    old_Update(instance);
}
 
Your game is likely crashing because the ememy offset you entered is incorrect. Look for a field offset called enemy in the same class
In this case, I also get a crash, I will try to use other offsets, but for some reason it seems to me that we did not quite understand each other and that is why the result is negative. Could you explain why this fragment is used in your code? :
Code:
void *enemy = *(void **) ((uint64_t) instance + 0x604820);
NormalDamage(instance, 9999, enemy, 1.0);
It seems to me that I need to use something like this, but in this case I get a compilation error
Code:
float multiplier = *(float **) ((uint64_t) instance + 0x604820);
NormalDamage(instance, 9999, multiplier, 1.0);
 
The 3rd parameter in the method you're hooking (NormalDamage) is enemy, you need to define the enemy class there, the 4th parameter (1.0) is the multiplier, I've just put 1.0 but you can change it to whatever you want.

What game are you modding
 
Status
Not open for further replies.
Back
Top Bottom