Solved Help How to call void in lgl mod menu

Status
Not open for further replies.

asdsfasfasfafa

Rookie
Original poster
Sep 30, 2023
4
3
3
33
Note: I'm a beginner and I'm Japanese. I've only used C++ a little.
I looked at various sample codes and threads, But eventually it crashes
Target function
[Address(RVA = "0x18E60AC", Offset = "0x18E60AC", VA = "0x18E60AC")]
public void Jump(){}
the code I made

C++:
#include <And64InlineHook/And64InlineHook.hpp>

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

jobjectArray GetFeatureList(JNIEnv *env, jobject context) {
        do {
        sleep(1);
    } while (!isLibraryLoaded(targetLibName));
    A64HookFunction((void*)getAbsoluteAddress("libil2cpp.so", 0x18E60AC), (void*)alwaysjump, (void **)&old_alwaysjump);
    const char *features[] = {
            OBFUSCATE("Button_test1")
        };
    
void Changes(JNIEnv *env, jclass clazz, jobject obj,
                                        jint featNum, jstring featName, jint value,
                                        jboolean boolean, jstring str) {
        switch (featNum) {
        case 0:
            if (alwaysjump != NULL)
                old_alwaysjump(alwaysjumpbtn);
            break;
        }
Thread referenced
 
  • Like
Reactions: libModz

libModz

Awesome Active Platinian
Jun 2, 2022
169
30
28
UK
You need to hook void Jump through a void Update function. Look to see if there is Update, LateUpdate, or FixedUpdate in the same class then you can hook it like this...


C++:
bool AlwaysJump;

void (*Jump)(void *instance);
void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=NULL) {
        if(AlwaysJump) {
            Jump(instance);
        }
    }
    old_Update(instance);
}




case 0:
    AlwaysJump = !AlwaysJump;
    break;
 
  • Like
Reactions: asdsfasfasfafa

asdsfasfasfafa

Rookie
Original poster
Sep 30, 2023
4
3
3
33
Hmm... Excuse me, where do you insert the Update offset? FixedUpdate exists in the same class.
Or hook by function name?
Also, A64HookFunction is not necessary?
You need to hook void Jump through a void Update function. Look to see if there is Update, LateUpdate, or FixedUpdate in the same class then you can hook it like this...


C++:
bool AlwaysJump;

void (*Jump)(void *instance);
void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=NULL) {
        if(AlwaysJump) {
            Jump(instance);
        }
    }
    old_Update(instance);
}




case 0:
    AlwaysJump = !AlwaysJump;
    break;
 

RazerTexz

Platinian
May 17, 2020
36
5
8
the void
Hmm... Excuse me, where do you insert the Update offset? FixedUpdate exists in the same class.
Or hook by function name?
Also, A64HookFunction is not necessary?
Insert the Update offset on the hack_thread like this
C++:
// targetLibName can be replaced by a string of the lib name
A64HookFunction((void *)getAbsoluteAddress(targetLibName, 0xOFFSET), (void *)Update, (void **)&old_Update); // For arm64 only
// OR
MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0xOFFSET), (void *)Update, (void **)&old_Update); // For arm32 only
// OR
// HOOK function uses string for offset because it uses string2Offset (converts string to offset)
HOOK("0xOFFSET", Update, old_Update); // Will use MSHookFunction or A64HookFunction depending on what lib is being used
 
  • Like
Reactions: asdsfasfasfafa

asdsfasfasfafa

Rookie
Original poster
Sep 30, 2023
4
3
3
33
You need to hook void Jump through a void Update function. Look to see if there is Update, LateUpdate, or FixedUpdate in the same class then you can hook it like this...


C++:
bool AlwaysJump;

void (*Jump)(void *instance);
void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=NULL) {
        if(AlwaysJump) {
            Jump(instance);
        }
    }
    old_Update(instance);
}




case 0:
    AlwaysJump = !AlwaysJump;
    break;
Insert the Update offset on the hack_thread like this
C++:
// targetLibName can be replaced by a string of the lib name
A64HookFunction((void *)getAbsoluteAddress(targetLibName, 0xOFFSET), (void *)Update, (void **)&old_Update); // For arm64 only
// OR
MSHookFunction((void *)getAbsoluteAddress(targetLibName, 0xOFFSET), (void *)Update, (void **)&old_Update); // For arm32 only
// OR
// HOOK function uses string for offset because it uses string2Offset (converts string to offset)
HOOK("0xOFFSET", Update, old_Update); // Will use MSHookFunction or A64HookFunction depending on what lib is being used
It worked fine and I was able to call void.
Thanks to libModz and ZealZenS.
This will be my final code :
C++:
#define targetLibName OBFUSCATE("libil2cpp.so")
#include <And64InlineHook/And64InlineHook.hpp>

bool AlwaysJump;

void (*Jump)(void *instance);
void (*old_Update)(void *instance);
void Update(void *instance) {
    if(instance!=NULL) {
        if(AlwaysJump) {
            Jump(instance);
        }
    }
    old_Update(instance);
}

void *hack_thread(void *) {
    //Check if target lib is loaded
    do {
        sleep(1);
    } while (!isLibraryLoaded(targetLibName));
    A64HookFunction((void *)getAbsoluteAddress(targetLibName, 0x18E48B4), (void *)Update, (void **)&old_Update);
    A64HookFunction((void*)getAbsoluteAddress(targetLibName, 0x18E60AC), (void*)AlwaysJump, (void **)&Jump);
}

jobjectArray GetFeatureList(JNIEnv *env, jobject context) {
    jobjectArray ret;
    const char *features[] = {
        OBFUSCATE("Button_alwayjump"),
    };
}

void Changes(JNIEnv *env, jclass clazz, jobject obj,
                                        jint featNum, jstring featName, jint value,
                                        jboolean boolean, jstring str) {
    switch (featNum) {
        case 0:
            AlwaysJump = !AlwaysJump;
            break;
    }
}
 
  • Like
Reactions: RazerTexz

DaRealPanDa

Co-Administrator
Staff member
Supporting-Team
Global Moderator
Social Media
Mar 12, 2018
6,893
15,734
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.
 
  • Like
Reactions: asdsfasfasfafa
Status
Not open for further replies.