Solved How can I unlink enemy-shared functions in IDA Pro? (not il2cpp game)

Status
Not open for further replies.

Sami1980

Solid & Active Platinian
Original poster
May 15, 2021
64
11
8
43
Europe
Hi there,

I am modding a non-unity Android game and I gave myself infinite health but the enemy got it too. How can I fix this? Unfortunately this tutorial wouldn't help as it's not a IL2CPP game :(

I am using IDA pro. Any help would be truly appreciated.
 

CodeJutsu

Platinian
Oct 1, 2023
47
25
18
30
Street Fighter IV CE - Apps on Google Play << Game link just in case someone else was curious

Here is a comprehensive info:

This game has exported functions in libGltest2jni.so, In the 64 bit binary in IDA you can search the exports list for DamageCalc which is at offset 0x629278 in current version.

Params look like this
DamageCalc(GENERAL_TASK* Attacker, GENERAL_TASK* Victim, _ATK_DATA const* AttackData, CHECK_WORK* CheckWork, int Unknown_a5)

the health for victim is at: Victim + 0x164
there are a few potential offsets that could be a team value, one of them is offset: Victim + 0x12C

Victim + 0x12C is 1 if player is being hit and 0 if enemy is being hit. This can be used to split.
Damage is in AttackData param, Normal damage is at AttackData + 0x10, if you set this to 0 you wont take damage but other attacks like throws are at different offsets.

These values and offsets were found using Cheat Engine, setting a breakpoint on DamageCalc() then analyzing the Victim and AttackData params.

There is no global method to find this though, you need to be able to debug and analyze the game using IDA and in memory yourself.



i've attached 2 files contains frida script ready to be used and debug further if needed as well as some results i've got when that game been debugged
 

Attachments

Sami1980

Solid & Active Platinian
Original poster
May 15, 2021
64
11
8
43
Europe
A quick question, how can I use the script? Should i copy and paste the contents into main.cpp in LGLMod menu?
 

CodeJutsu

Platinian
Oct 1, 2023
47
25
18
30
That script is javascript code, you use it with frida.re (really good for rapid testing etc).
To use in native you need to convert that code to c++ equivalent, simple example:
C++:
class AttackData
{
public:
    char pad_0000[16]; //0x0000
    int32_t normalDamage; //0x0010
    char pad_0014[4]; //0x0014
};

class GeneralTask
{
public:
    char pad_0000[300]; //0x0000
    int32_t team; //0x012C - COULD BE WRONG, SHOULD TEST MORE!!
    char pad_0130[52]; //0x0130
    int32_t Health; //0x0164
};


void* (orig_DamageCalc)(GeneralTask* Attacker, GeneralTask* Victim, AttackData* AttackData, void* CheckWork, int Unknown_a5);
void* hook_DamageCalc(GeneralTask* Attacker, GeneralTask* Victim, AttackData* AttackData, void* CheckWork, int Unknown_a5)
{
    if (Victim->team == 1)
    {
        AttackData->normalDamage = 0;
    }
    else
    {
        AttackData->normalDamage *= 10;
    }

    orig_DamageCalc(Attacker, Victim, AttackData, CheckWork, Unknown_a5);
}
Please keep in mind il2cpp is very easy to mod due to il2cpp dumpers, It seems you are relatively new to modding, it is definately worth sticking to il2cpp before diving into pure native games.
 
  • Like
Reactions: Sami1980

Sami1980

Solid & Active Platinian
Original poster
May 15, 2021
64
11
8
43
Europe
That script is javascript code, you use it with frida.re (really good for rapid testing etc).
To use in native you need to convert that code to c++ equivalent, simple example:
C++:
class AttackData
{
public:
    char pad_0000[16]; //0x0000
    int32_t normalDamage; //0x0010
    char pad_0014[4]; //0x0014
};

class GeneralTask
{
public:
    char pad_0000[300]; //0x0000
    int32_t team; //0x012C - COULD BE WRONG, SHOULD TEST MORE!!
    char pad_0130[52]; //0x0130
    int32_t Health; //0x0164
};


void* (orig_DamageCalc)(GeneralTask* Attacker, GeneralTask* Victim, AttackData* AttackData, void* CheckWork, int Unknown_a5);
void* hook_DamageCalc(GeneralTask* Attacker, GeneralTask* Victim, AttackData* AttackData, void* CheckWork, int Unknown_a5)
{
    if (Victim->team == 1)
    {
        AttackData->normalDamage = 0;
    }
    else
    {
        AttackData->normalDamage *= 10;
    }

    orig_DamageCalc(Attacker, Victim, AttackData, CheckWork, Unknown_a5);
}
Please keep in mind il2cpp is very easy to mod due to il2cpp dumpers, It seems you are relatively new to modding, it is definately worth sticking to il2cpp before diving into pure native games.
Yeah I am kinda new and I know what you mean. I've already modded a few il2cpp games and now I really wanted to mod this game which unfortunately isn't il2cpp.

Thank you so much for the script conversion!
 

CodeJutsu

Platinian
Oct 1, 2023
47
25
18
30
Yeah I am kinda new and I know what you mean. I've already modded a few il2cpp games and now I really wanted to mod this game which unfortunately isn't il2cpp.

Thank you so much for the script conversion!
to be honest i only posted this plain code to learn from it not a ready made solution , it's always better to share source code especially when it comes to plain games without any AC this supposed to help modding community to grow. but people seems to forget the real goal behind learning how to mod. I get it, everyone's excited about modding that one particular game, but there is so much more you can learn from modding. You should be looking at the logic behind it, not just copying and pasting stuff. Modding is a journey and you should enjoy every bit of it and learn from it . So, take a step back, understand what's happening in that code. it's better to learn how to mod instead of modding game. because that will help you in the long run. salam , and happy modding
 

Sami1980

Solid & Active Platinian
Original poster
May 15, 2021
64
11
8
43
Europe
to be honest i only posted this plain code to learn from it not a ready made solution , it's always better to share source code especially when it comes to plain games without any AC this supposed to help modding community to grow. but people seems to forget the real goal behind learning how to mod. I get it, everyone's excited about modding that one particular game, but there is so much more you can learn from modding. You should be looking at the logic behind it, not just copying and pasting stuff. Modding is a journey and you should enjoy every bit of it and learn from it . So, take a step back, understand what's happening in that code. it's better to learn how to mod instead of modding game. because that will help you in the long run. salam , and happy modding
Ok no worries and thanks again. I sent you a private message. Have you seen it?
 

TERROR

Platinian
Jun 11, 2018
8
1
3
some place
to be honest i only posted this plain code to learn from it not a ready made solution , it's always better to share source code especially when it comes to plain games without any AC this supposed to help modding community to grow. but people seems to forget the real goal behind learning how to mod. I get it, everyone's excited about modding that one particular game, but there is so much more you can learn from modding. You should be looking at the logic behind it, not just copying and pasting stuff. Modding is a journey and you should enjoy every bit of it and learn from it . So, take a step back, understand what's happening in that code. it's better to learn how to mod instead of modding game. because that will help you in the long run. salam , and happy modding
Hello, what Android emulator do you recommend to be able to learn about modding in Unity, as well as what advice would you give to be able to use the CE, I tried it with ceserver and it does not attach, the CE breaks. Do I need to open the AndroidManifest file and add android:debuggable="true" ?
 

CodeJutsu

Platinian
Oct 1, 2023
47
25
18
30
Hello, what Android emulator do you recommend to be able to learn about modding in Unity, as well as what advice would you give to be able to use the CE, I tried it with ceserver and it does not attach, the CE breaks. Do I need to open the AndroidManifest file and add android:debuggable="true" ?
I don't use emu i use real device to avoid any unnecessary issues with emu, my suggestion is to use pixel devices they're known to be good for debugging, as for CE not being able to attach it could be many things , AC , your device , conflict in CE versions , connectivity issues
without further info i can't really tell or help. just a peace of advice whenever asking for any help more info would always help us help you
Game name
has AC or not
device models / android version
what did you try so far
Logs maybe ?
 

CodeJutsu

Platinian
Oct 1, 2023
47
25
18
30
I did respond with this

" You won't achieve this by hex patching... That's the whole reason i sent a plain c++ code, it looks like it's too much for tbh no offense but I'd start learning c++ first "

why i said that is hex patching will be more tedious task to split it , that DamageCalc is also shared and you still need to split it , but doing it with hex patching is a hassle you would hook that DamageCalc and use the code above as an example of hook.

if what i said didn't answer the question then i can't help anymore. i hope someone else does things in different and better way


Edit: looks like you edited your answer.. anyways i tried to provide as much as possible info. sorry i don't give mods on golden plates. in my prospective It is better to teach people how to do something themselves than to just do it for them
 

Sami1980

Solid & Active Platinian
Original poster
May 15, 2021
64
11
8
43
Europe
I did respond with this

" You won't achieve this by hex patching... That's the whole reason i sent a plain c++ code, it looks like it's too much for tbh no offense but I'd start learning c++ first "

why i said that is hex patching will be more tedious task to split it , that DamageCalc is also shared and you still need to split it , but doing it with hex patching is a hassle you would hook that DamageCalc and use the code above as an example of hook.

if what i said didn't answer the question then i can't help anymore. i hope someone else does things in different and better way


Edit: looks like you edited your answer.. anyways i tried to provide as much as possible info. sorry i don't give mods on golden plates. in my prospective It is better to teach people how to do something themselves than to just do it for them
I didn't ask you to give it to me on a golden plate.
 

CodeJutsu

Platinian
Oct 1, 2023
47
25
18
30
Throwing one more info in case it helps AttackData is read only you would need to make it writable first you can read up on mprotect
function for linux to change the memory page to writeable
 
  • Like
Reactions: Sami1980

Sami1980

Solid & Active Platinian
Original poster
May 15, 2021
64
11
8
43
Europe
Throwing one more info in case it helps AttackData is read only you would need to make it writable first you can read up on mprotect
function for linux to change the memory page to writeable
Thank you again for everything. You have been wonderful!

@DaRealPanDa .
We can mark this as solved please!
 

Del4073188

Platinian
Feb 20, 2024
6
0
1
23
@Sami1980

Im sorry but if you think codejutsu saying you need to learn C++ to be able to mod native properly is condescending then you are kidding yourself, its just a fact of what cheat making is... you want to modify code you need to know how to code, same way as if you want to modify a car you need to know how a car works....

if you arent interested in learning C++ then dont try modifying C++ code unless its basic il2cpp dumped games where you dont need to read C++.

You say I didn't ask you to give it to me on a golden plate. and yet even when it was handed to you this way you still didnt understand it at all.

To be honest you along with most of the help threads makers in this section need a reality check on what cheating is... modifying code... to do that effectivly you need to know how to code.
 
Status
Not open for further replies.