Help! How to executed function

Meepoooo

Platinian
Original poster
May 9, 2022
12
2
3
39
Viet Nam
C++:
protected ObscuredInt _currentRoomID; // 0x18
// RVA: 0x1113008 Offset: 0x1113008 VA: 0x1113008
private void room_update() { }
// RVA: 0x1113518 Offset: 0x1113518 VA: 0x1113518 Slot: 25
protected override void OnEnterDoorAfter() { }
bool istele;
int teleValue;
void(* old_UpdateRoom)(void * instance);
void UpdateRoom(void*instance) {
if(instance != NULL) {
if(istele) {
istele = false;
*(int *)((uint32_t ) instance + 0x18, teleValue);
}
}
old_UpdateRoom(instance);
}
MSHookFunction((void *) getAbsoluteAddress("libil2cpp.so", 0x1113008), (void*)UpdateRoom, (void**)&old_UpdateRoom);

the problem is: the update function will update when the openDoorAfter function is executed.
help me How to call openDoorAfter function so that update hook can work.
 

Meepoooo

Platinian
Original poster
May 9, 2022
12
2
3
39
Viet Nam
Make a function pointer to openafterdoor then call your pointer in the update.
i was try like this but did work!
C++:
protected ObscuredInt _currentRoomID; // 0x18
// RVA: 0x1113008 Offset: 0x1113008 VA: 0x1113008
private void room_update() { }
// RVA: 0x1113518 Offset: 0x1113518 VA: 0x1113518 Slot: 25
protected override void OnEnterDoorAfter() { }
bool istele;
int teleValue;
void( * onEnterDoorAfter)(void * instance);
void(* old_UpdateRoom)(void * instance);
void UpdateRoom(void*instance) {
if(instance != NULL) {
if(istele) {
istele = false;
*(int *)((uint32_t ) instance + 0x18, teleValue);
onEnterDoorAfter(instance);   
}
}
old_UpdateRoom(instance);
}
MSHookFunction((void *) getAbsoluteAddress("libil2cpp.so", 0x1113008), (void*)UpdateRoom, (void**)&old_UpdateRoom);
onEnterDoorAfter = (void (*) (void *))getAbsoluteAddress(targetLibName, 0x1113518);
 

alsya

Solid & Active Platinian
Oct 21, 2021
80
19
8
unknown
i was try like this but did work!
C++:
protected ObscuredInt _currentRoomID; // 0x18
// RVA: 0x1113008 Offset: 0x1113008 VA: 0x1113008
private void room_update() { }
// RVA: 0x1113518 Offset: 0x1113518 VA: 0x1113518 Slot: 25
protected override void OnEnterDoorAfter() { }
bool istele;
int teleValue;
void( * onEnterDoorAfter)(void * instance);
void(* old_UpdateRoom)(void * instance);
void UpdateRoom(void*instance) {
if(instance != NULL) {
if(istele) {
istele = false;
*(int *)((uint32_t ) instance + 0x18, teleValue);
onEnterDoorAfter(instance);  
}
}
old_UpdateRoom(instance);
}
MSHookFunction((void *) getAbsoluteAddress("libil2cpp.so", 0x1113008), (void*)UpdateRoom, (void**)&old_UpdateRoom);
onEnterDoorAfter = (void (*) (void *))getAbsoluteAddress(targetLibName, 0x1113518);
looks like it's wrong
C++:
void(*old_onEnterDoorAfter)(void *instance);
void _OnEnterDoorAfter(void*instance) {

if(instance != NULL) {

if(teleValue > 1) {

*(int *)((uint32_t ) instance + 0x18) = teleValue;
 

}

}

old_onEnterDoorAfter(instance);

}
 
  • Like
Reactions: Meepoooo

SleepyCatto

Rookie
Jun 9, 2023
3
0
1
Germany
Make a function pointer to openafterdoor then call your pointer in the update.
Hey, i also have a question about calling functions.
When im trying to call a function called DeleteAllBloons() from an update function, the game crashes. (i am advanced in c++)

This is how my code snippet looks like :



// The function inside dump.cs/Assembly-CSharp.dll
C#:
// Assets.Scripts.Unity.UI_New.InGame.InGame
// Token: 0x06007061 RID: 28769 RVA: 0x00002053 File Offset: 0x00000253
[Token(Token = "0x6007061")]
[Address(RVA = "0x1132848", Offset = "0x1132848", VA = "0x1132848")]
public void DeleteAllBloons()
{
}

//the update function im using
C#:
// Assets.Scripts.Unity.Game
// Token: 0x06004A9B RID: 19099 RVA: 0x00002053 File Offset: 0x00000253
[Token(Token = "0x6004A9B")]
[Address(RVA = "0xDCA4A0", Offset = "0xDCA4A0", VA = "0xDCA4A0")]
private void Update()
{
}
//offsets for funcs
C++:
enum Offsets {

    GameUpdateOffset = 0xDCA4A0,

};
//game update func and function pointer
C++:
void (*DeleteAllBloons)(void *instance);

void *gameUpdateInst;

void (*old_GameUpdate)(void *instance);
void GameUpdate(void *instance) {

    if(instance != NULL) {

        gameUpdateInst = instance;

    }

    old_GameUpdate(instance);

}


//inside the button
C++:
if (gameUpdateInst != NULL) {
    DeleteAllBloons(gameUpdateInst);
}
// inside of hack_thread pointer after the lib is loaded
C++:
DeleteAllBloons = (void (*)(void*))getAbsoluteAddress(targetLibName, 0x1132848);



MSHookFunction((void*)getAbsoluteAddress(targetLibName, Offsets::GameUpdateOffset), (void*) GameUpdate, (void **)&old_GameUpdate);

Sorry, forgot to mention the game's name : Bloons TD6

Im still unable to create threads, because i forgot which requirements i had to meet.