Help! Loading IL2CPP/Library Crash based on Device Speed (LGL Mod Menu)

Sunghera

Platinian
Original poster
Jan 4, 2024
11
1
3
26
Currently I'm facing an issue where it occurs on different devices.

For my mod menu, I usually would use this section of code to initialise:
C++:
void *hack_thread(void *) {
    LOGI(OBFUSCATE("pthread created"));
    do {
        sleep(1);
    } while (!isLibraryLoaded(targetLibName));
    BNM::AddOnLoadedEvent(OnLoaded_Hooks);
    LOGI(OBFUSCATE("%s has been loaded"), (const char *) targetLibName);
    return nullptr;
}
Using the above code, I can simply open the game/App on my emulator without issues and the Mod Menu along with its features will work just fine.
However, when I use it on my phone (Redmi K60) it would crash almost instantly. To bypass the crash on my phone I would need to tap on the app icon and IMMEDIATELY tap the home button to just hold app in place for a few moments before tapping on the app icon again to allow it to fully launch.
I've experimented with the above section of code for a little bit, and eventually the code below will allow me to launch the app on my phone without the technique and crash:
C++:
void *hack_thread(void *) {
    LOGI(OBFUSCATE("pthread created"));
    do {
        usleep(10000);
    } while (!isLibraryLoaded(targetLibName));
    BNM::AddOnLoadedEvent(OnLoaded_Hooks);
    LOGI(OBFUSCATE("%s has been loaded"), (const char *) targetLibName);
    return nullptr;
}
At first I thought this was a perfect fix, however when I installed this version on my emulator, the emulator version would crash on launch.

I've installed modded games that have worked on my phone and my emulator at the same time. What is it that I'm missing here that prevents the crash on both type of devices?
 
  • Like
Reactions: naharsona