Help! Help!, How to call a void with button ?

babydoll69

Platinian
Original poster
Nov 25, 2022
6
2
1
30
Indonesia
do you know how to call a void with button ?
i tried many ways but it didnt work,

i want to spawn a monster if i press the spawnbutton

public void SpawnMonster()

this is my code :
C++:
void *spawnmonsterbtn;

void (*_SpawnMonster)(void *instance);
void SpawnMonster(void* instance) {
    if (instance != NULL) {
        spawnmonsterbtn = instance;
    }
    _SpawnMonster(instance);
}

MSHookFunction((void*)getAbsoluteAddress("libil2cpp.so", 0x1A3E7F0), (void*)SpawnMonster, (void **)&_SpawnMonster);

OBFUSCATE("1_Button_Spawn Monster"),

case 1:
            if (spawnmonsterbtn != NULL)
             _SpawnMonster(spawnmonsterbtn);
            Toast(env,obj,OBFUSCATE("Spawn Monster"),ToastLength::LENGTH_LONG);
            break;
 

babydoll69

Platinian
Original poster
Nov 25, 2022
6
2
1
30
Indonesia
Does it crash or anything? Does it show the toast? I don't see mistakes here.
no crash, the toast is show up but the mod doesnt work.

i tried change the mshook to this

C++:
SpawnMonster = (void(*)(void *))getAbsoluteAddress("libil2cpp.so", 0x1A3E7F0);
but still doesnt work at all.
 

CM_OfficialYT

1/3 Games Approved
Jun 16, 2023
16
1
3
16
Philippines
Same happening in this situation but the code seems to be good and no errors.

You can try to test the Offset or RVA first in toggle, because toggle is one of the most easiest function to deal with. If the offset works there then try the button. If the button seems to be not working, then you must find a help through online.

I haven't used button function since my first modding, but now I might be.
 
  • Like
Reactions: priyanshu88064

CM_OfficialYT

1/3 Games Approved
Jun 16, 2023
16
1
3
16
Philippines
I think I saw something missing in the code:


C++:
void *spawnmonsterbtn;

void (*old_SpawnMonster)(void *instance);
void SpawnMonster(void* instance) {
    if (instance != NULL) {
        spawnmonsterbtn = instance; // It could be some functions are missing in this line.
    }
    return old_SpawnMonster(instance); // *return* is missing here.
}

MSHookFunction((void*) getAbsoluteAddress(targetLibName /*I just changed this, there is no serious error here.*/, string2Offset(OBFUSCATE("0x1A3E7F0"))), (void*)SpawnMonster, (void **)&old_SpawnMonster);

OBFUSCATE("1_Button_Spawn Monster"),

case 1:
    if (spawnmonsterbtn != NULL)
        old_SpawnMonster(spawnmonsterbtn, 1 /*There is a missing function here*/);
    MakeToast(env, obj, OBFUSCATE("Monster Has Spawned"), Toast::LENGTH_LONG);
break;