Help! Hooking VOID multiplier function

DeeNastyle

Platinian
Hi guys,

I took my first steps at modding a few days ago but I can't manage to make my function work.
I'm using LGL Model Menu template 3.2 to mod a unity libil2cpp game on android.

I want to do a damage multiplier function with a slider.
Here the offset I've found with dnSpy:

1659130421668.png



On Main.cpp I've tried the following:


1659130627555.png


1659130539485.png


1659130680334.png


1659130744483.png


1659130795700.png



Any clue how to make the function work ?

Thanks guys,
 

Attachments

  • 1659130517153.png
    1659130517153.png
    4.9 KB · Views: 68
  • 1659130578286.png
    1659130578286.png
    90.4 KB · Views: 81
Last edited:
C++:
if (instance && DamageMultiplier > 1) {
    hpDamage *= DamageMultiplier;
    shieldDamage *= DamageMultiplier;
}

It must be so, you haven't provided all the necessary arguments to the ApplyAttackDamage method yet.

In the switch construction, value has an integer type, which means that it would be more correct to specify the type not float (real) but int (integer), It's certainly not a bug, but still.
 
It's an online game yes but battle calculation are client-sided, there is a lot of working mod menu out there with damage multiplier & defence multiplier functions..just trying to make my own :)

I will try to change the switch construction, thank you guys.
 
C++:
if (instance && DamageMultiplier > 1) {
    hpDamage *= DamageMultiplier;
    shieldDamage *= DamageMultiplier;
}

It must be so, you haven't provided all the necessary arguments to the ApplyAttackDamage method yet.

In the switch construction, value has an integer type, which means that it would be more correct to specify the type not float (real) but int (integer), It's certainly not a bug, but still.
try this
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;
 
Thank you for the answers.

try this
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;

I can't even build LGL Mod Menu with this code, it does not understand "BattleUnitController", "attacker", "UnitMoveType", "moveType" etc.
"BattleUnitController" and so on are lib classes
"attacker" and so on are lib parameters

C++:
if (instance && DamageMultiplier > 1) {
    hpDamage *= DamageMultiplier;
    shieldDamage *= DamageMultiplier;
}

It must be so, you haven't provided all the necessary arguments to the ApplyAttackDamage method yet.

In the switch construction, value has an integer type, which means that it would be more correct to specify the type not float (real) but int (integer), It's certainly not a bug, but still.

It didn't worked neither but I guess it also about void calling..

So I've tryied the following:

C++:
int DamageMultiplier = 1;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* BattleUnitController,void* UnitMoveType,void* DamageTypeEnum,bool showUiMessaging,bool canCounterAttack,void* BattleEffectDO,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* BattleUnitController,void* UnitMoveType,void* DamageTypeEnum,bool showUiMessaging,bool canCounterAttack,void* BattleEffectDO,bool fromDestroyModule)
 {
    if (instance != NULL && DamageMultiplier > 1)
    {
        return old_ApplyAttackDamage(instance, hpDamage * DamageMultiplier , shieldDamage * DamageMultiplier, isCrit, BattleUnitController, UnitMoveType, DamageTypeEnum, showUiMessaging, canCounterAttack, BattleEffectDO, fromDestroyModule);
    }
    return old_ApplyAttackDamage(instance, hpDamage, shieldDamage, isCrit, BattleUnitController, UnitMoveType, DamageTypeEnum, showUiMessaging, canCounterAttack, BattleEffectDO, fromDestroyModule);

 }

HOOK("0xd92288", ApplyAttackDamage, old_ApplyAttackDamage);

    switch (featNum) {
        
        case 11:
            if (value >= 1) {
                DamageMultiplier = value;
            }
            break;

I can build the Mod Menu and recompile the apk with this one but it's not working, any other clue ?
 
Thank you for the answers.



I can't even build LGL Mod Menu with this code, it does not understand "BattleUnitController", "attacker", "UnitMoveType", "moveType" etc.
"BattleUnitController" and so on are lib classes
"attacker" and so on are lib parameters



It didn't worked neither but I guess it also about void calling..

So I've tryied the following:

C++:
int DamageMultiplier = 1;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* BattleUnitController,void* UnitMoveType,void* DamageTypeEnum,bool showUiMessaging,bool canCounterAttack,void* BattleEffectDO,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* BattleUnitController,void* UnitMoveType,void* DamageTypeEnum,bool showUiMessaging,bool canCounterAttack,void* BattleEffectDO,bool fromDestroyModule)
{
    if (instance != NULL && DamageMultiplier > 1)
    {
        return old_ApplyAttackDamage(instance, hpDamage * DamageMultiplier , shieldDamage * DamageMultiplier, isCrit, BattleUnitController, UnitMoveType, DamageTypeEnum, showUiMessaging, canCounterAttack, BattleEffectDO, fromDestroyModule);
    }
    return old_ApplyAttackDamage(instance, hpDamage, shieldDamage, isCrit, BattleUnitController, UnitMoveType, DamageTypeEnum, showUiMessaging, canCounterAttack, BattleEffectDO, fromDestroyModule);

}

HOOK("0xd92288", ApplyAttackDamage, old_ApplyAttackDamage);

    switch (featNum) {
       
        case 11:
            if (value >= 1) {
                DamageMultiplier = value;
            }
            break;

I can build the Mod Menu and recompile the apk with this one but it's not working, any other clue ?
you need to make a function pointer
 
try this
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,int hpDamage,int shieldDamage,bool isCrit,BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType,bool showUiMessaging,bool canCounterAttack,[Optional] BattleEffectDO sourceEffect,bool fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;

this is not recommended
 
He said that bcs the sample u give wont be able to compile it is bcs this
C++:
BattleUnitController attacker,BattleUnitController target,UnitMoveType moveType,DamageTypeEnum damageType

Enum is usually Int, If u not sure just put void
yea i mean , its work for me because most of my mod was have somethink like that in the dump , so yea need to cast all the think into hook variable
 
try this , this is was improved version
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* attacker,void* target,void* moveType,int damageType,bool showUiMessaging,bool canCounterAttack,[Optional] void* sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* attacker,void* target,void* moveType,int damageType,bool showUiMessaging,bool canCounterAttack,[Optional] void* sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,isCrit,attacker,target,damageType,showUiMessaging,canCounterAttack,[Optional] sourceEffect,fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,hpDamage,shieldDamage,isCrit,attacker,target,moveType,damageType,showUiMessaging,canCounterAttack,[Optional] sourceEffect,fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;
[/QUOTE]
 
try this , this is was improved version
C++:
float DamageMultiplier;

void (*old_ApplyAttackDamage)(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* attacker,void* target,void* moveType,int damageType,bool showUiMessaging,bool canCounterAttack,[Optional] void* sourceEffect,bool fromDestroyModule);
void ApplyAttackDamage(void *instance,int hpDamage,int shieldDamage,bool isCrit,void* attacker,void* target,void* moveType,int damageType,bool showUiMessaging,bool canCounterAttack,[Optional] void* sourceEffect,bool fromDestroyModule){
     if (instance != NULL && DamageMultiplier > 1){
          return old_ApplyAttackDamage(instance,int hpDamage * DamageMultiplier ,int shieldDamage * DamageMultiplier,isCrit,attacker,target,damageType,showUiMessaging,canCounterAttack,[Optional] sourceEffect,fromDestroyModule);
     }
     return old_ApplyAttackDamage(instance,hpDamage,shieldDamage,isCrit,attacker,target,moveType,damageType,showUiMessaging,canCounterAttack,[Optional] sourceEffect,fromDestroyModule);
}

HOOK("OFFSETS",ApplyAttackDamage,old_ApplyAttackDamage);


switch(featNum):
case 10:
          if (value >= 1){
               DamageMultiplier = value;
          }
break;
[/QUOTE]
this is not recommended, why should type void return? and consuming too much space should be easy, just replace the parameter with a damagemultiplier.
 
Back
Top Bottom