Solved Hook void (float)

Status
Not open for further replies.

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
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);
 

Zen0ns

Solid & Active Platinian
Sep 10, 2019
70
1,828
183
Indonesia
RVA: 0x604820 VA: 0xc0204820
private Void NormalDamage(Int32 newDamage, EnemyInfo enemy, Single multiplier) { }

you need to hook the parameter
 

Smiley3rd

Platinian
Oct 4, 2020
28
66
13
23
Indonesia
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);

}
 
  • Like
Reactions: AZFernandez

libModz

Awesome Active Platinian
Jun 2, 2022
163
29
28
UK
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);
}
 
  • Like
Reactions: AZFernandez

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
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
 

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
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);
 

libModz

Awesome Active Platinian
Jun 2, 2022
163
29
28
UK
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);
}
 

libModz

Awesome Active Platinian
Jun 2, 2022
163
29
28
UK
Your game is likely crashing because the ememy offset you entered is incorrect. Look for a field offset called enemy in the same class
 

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
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);
 

libModz

Awesome Active Platinian
Jun 2, 2022
163
29
28
UK
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
 

AZFernandez

Platinian
Original poster
Dec 8, 2023
19
3
3
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
It doesn't matter anymore, I just reduced the enemies' health. Thanks again for your help
 
  • Like
Reactions: RazerTexz

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,771
15,628
2,120
27
Skyrim
Thread will be set to "solved" and closed.
When you're not happy with that just send me a message and i will re-open the thread for you.

Thanks.
 
Status
Not open for further replies.