ByNameModding / BNM-Android

Modding il2cpp games by classes, methods, field names on Android.
MIT License
173 stars 37 forks source link

Zygisk crashing -> Can not start Zygisk while having ByNameModding included as lib #15

Closed PeteSpencer closed 7 months ago

PeteSpencer commented 8 months ago

I am running Magisk 26.1 on a Samsung Galaxy S10+ (SM-g975f).

I've a the ByNameMod in my cmake list Zygisk failed to start. There are no helpfull logs..

add_library(${MODULE_NAME}
        SHARED
        ByNameModding/BNM.cpp
        ImGui/imgui.cpp
        ImGui/imgui_draw.cpp
        ImGui/imgui_demo.cpp
        ImGui/imgui_widgets.cpp
        ImGui/imgui_tables.cpp
        ImGui/backends/imgui_impl_opengl3.cpp
        ImGui/backends/imgui_impl_android.cpp
        KittyMemory/KittyArm64.cpp
        KittyMemory/KittyMemory.cpp
        KittyMemory/KittyScanner.cpp
        KittyMemory/KittyUtils.cpp
        KittyMemory/MemoryBackup.cpp
        KittyMemory/MemoryPatch.cpp
        main.cpp
        hook.cpp
        )

my settings

/********** USER AREA **************/

//#define UNITY_VER 171 // 2017.1.x
//#define UNITY_VER 172 // From 2017.2.x to 2017.4.x
//#define UNITY_VER 181 // 2018.1.x
//#define UNITY_VER 182 // 2018.2.x
//#define UNITY_VER 183 // From 2018.3.x to 2018.4.x
//#define UNITY_VER 191 // From 2019.1.x to 2019.2.x
//#define UNITY_VER 193 // 2019.3.x
//#define UNITY_VER 194 // 2019.4.x
//#define UNITY_VER 201 // 2020.1.x
//#define UNITY_VER 202 // From 2020.2.x to 2020.3.19 (They are probably same because BNM don't use things like Il2CppCodeGen)
//#define UNITY_VER 203 // From 2020.3.20 to 2020.3.xx
//#define UNITY_VER 211 // 2021.1.x (You need set UNITY_PATCH_VER to 24 if build 24 and upper)
//#define UNITY_VER 212 // 2021.2.x
#define UNITY_VER 213 // 2021.3.x
//#define UNITY_VER 221 // 2022.1.x
//#define UNITY_VER 222 // 2022.2.x - 2022.3.x
//#define UNITY_VER 231 // 2023.1.x+

#ifndef NDEBUG

//! DEBUG LOGS
#define BNM_DEBUG

//! INFO LOGS
#define BNM_INFO

//! ERROR LOGS
#define BNM_ERROR

//! WARNING LOGS
#define BNM_WARNING

#endif

//! Include your string obfuscator
#define OBFUSCATE_BNM(str) str // const char *
#define OBFUSCATES_BNM(str) std::string(str) // std::string
#define BNMTAG OBFUSCATE_BNM("ByNameModding")

//! DobbyHook
//!!!!!!!! Recommended !!!!!!!!
#include "../Includes/Dobby/dobby.h"

template<typename PTR_T, typename NEW_T, typename OLD_T>
inline void HOOK(PTR_T ptr, NEW_T newMethod, OLD_T&& oldBytes) {
    if (((void *)ptr) != nullptr)
        DobbyHook((void *)ptr, (void *) newMethod, (void **) &oldBytes);
}

// If you need hide dl calls or use custom dl for external BNM initialization
#define BNM_dlopen dlopen
#define BNM_dlsym dlsym
#define BNM_dlclose dlclose
#define BNM_dladdr dladdr

#include <thread>
#define BNM_thread std::thread

// Disabling BNM automatic loading when your lib loaded
// Define it when you using BNM::HardBypass to speed up loading or when you externally loading BNM
// #define BNM_DISABLE_AUTO_LOAD
#define BNM_DISABLE_NEW_CLASSES 0

// Can make game crashes on arm64
// #define BNM_USE_APPDOMAIN // Use System.AppDomain to find il2cpp::vm::Assembly::GetAllAssemblies

// Enable zero-padding of new il2cpp objects
// #define BNM_IL2CPP_ZERO_PTR

/********** USER AREA **************/

#include <android/log.h>

#ifdef BNM_INFO
#define LOGIBNM(...) ((void)__android_log_print(4,  BNMTAG, __VA_ARGS__))
#else
#define LOGIBNM(...) ((void)0)
#endif

#ifdef BNM_DEBUG
#define LOGDBNM(...) ((void)__android_log_print(3,  BNMTAG, __VA_ARGS__))
#else
#define LOGDBNM(...) ((void)0)
#endif

#ifdef BNM_ERROR
#define LOGEBNM(...) ((void)__android_log_print(6,  BNMTAG, __VA_ARGS__))
#else
#define LOGEBNM(...) ((void)0)
#endif

#ifdef BNM_WARNING
#define LOGWBNM(...) ((void)__android_log_print(5,  BNMTAG, __VA_ARGS__))
#else
#define LOGWBNM(...) ((void)0)
#endif

If I just remove the line including the ByNameModding/BNM.cpp it start normaly.

PeteSpencer commented 8 months ago

No way, didn't get it started anyway :(

BNM-Dev commented 7 months ago

Try use BNM 1.0