From 69a3e04ede6059328b5a3ff1e21f83c2750f661c Mon Sep 17 00:00:00 2001 From: LoveSy Date: Tue, 6 Apr 2021 00:29:40 +0800 Subject: [PATCH] [core] Debug so should place under /system (#460) Otherwise, unwind will fail --- core/build.gradle.kts | 4 ++++ core/src/main/cpp/main/src/main.cpp | 9 ++++++--- core/src/main/cpp/main/src/symbol_cache.cpp | 2 +- core/template_override/customize.sh | 8 ++++++++ core/template_override/riru.sh | 3 ++- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 83265057..7496526d 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -279,6 +279,10 @@ afterEvaluate { "%%%RIRU_MODULE_MIN_RIRU_VERSION_NAME%%%", moduleMinRiruVersionName ) + .replace( + "%%RIRU_MODULE_DEBUG%%", + if (variantLowered == "debug") "true" else "false" + ) } filter( mapOf("eol" to FixCrLfFilter.CrLf.newInstance("lf")), diff --git a/core/src/main/cpp/main/src/main.cpp b/core/src/main/cpp/main/src/main.cpp index 83f79908..b269a30e 100644 --- a/core/src/main/cpp/main/src/main.cpp +++ b/core/src/main/cpp/main/src/main.cpp @@ -37,8 +37,11 @@ namespace lspd { void onModuleLoaded() { LOGI("onModuleLoaded: welcome to LSPosed!"); LOGI("onModuleLoaded: version %s (%d)", versionName, versionCode); - // rirud must be used in onModuleLoaded - Context::GetInstance()->PreLoadDex(magiskPath + '/' + kDexPath); + if constexpr (isDebug) { + Context::GetInstance()->PreLoadDex("/system/" + kDexPath); + } else { + Context::GetInstance()->PreLoadDex(magiskPath + '/' + kDexPath); + } InitSymbolCache(); } @@ -116,7 +119,7 @@ RIRU_EXPORT RiruVersionedModuleInfo *init(Riru *riru) { LOGD("using riru %d", riru->riruApiVersion); LOGD("module path: %s", riru->magiskModulePath); lspd::magiskPath = riru->magiskModulePath; - if (lspd::magiskPath.find(MODULE_NAME) == std::string::npos) { + if (!lspd::isDebug && lspd::magiskPath.find(MODULE_NAME) == std::string::npos) { LOGE("who am i"); return nullptr; } diff --git a/core/src/main/cpp/main/src/symbol_cache.cpp b/core/src/main/cpp/main/src/symbol_cache.cpp index 6f2f23cf..e940228a 100644 --- a/core/src/main/cpp/main/src/symbol_cache.cpp +++ b/core/src/main/cpp/main/src/symbol_cache.cpp @@ -91,7 +91,7 @@ namespace lspd { #ifdef __LP64__ inline static size_t solist_next_offset = 0x30; - constexpr static size_t solist_realpath_offset = 0x1a8; + constexpr static size_t solist_realpath_offset = 0x1a8; #else inline static size_t solist_next_offset = 0xa4; constexpr static size_t solist_realpath_offset = 0x174; diff --git a/core/template_override/customize.sh b/core/template_override/customize.sh index 5688e701..8996e7d3 100644 --- a/core/template_override/customize.sh +++ b/core/template_override/customize.sh @@ -137,5 +137,13 @@ if [ ! -e /data/adb/lspd/config/verbose_log ]; then echo "0" >/data/adb/lspd/config/verbose_log fi +if [ "$RIRU_MODULE_DEBUG" = true ]; then + mv ${MODPATH}/riru ${MODPATH}/system + mv ${MODPATH}/system/lib/liblspd.so ${MODPATH}/system/lib/libriru_lspd.so + mv ${MODPATH}/system/lib64/liblspd.so ${MODPATH}/system/lib64/libriru_lspd.so + cp -r ${MODPATH}/framework ${MODPATH}/system/framework + mkdir -p /data/adb/riru/modules/lspd +fi + set_perm_recursive "${MODPATH}" 0 0 0755 0644 ui_print "- Welcome to LSPosed!" diff --git a/core/template_override/riru.sh b/core/template_override/riru.sh index d85c62bc..113942ea 100644 --- a/core/template_override/riru.sh +++ b/core/template_override/riru.sh @@ -11,6 +11,7 @@ RIRU_VERSION_NAME="" RIRU_MODULE_API_VERSION=%%%RIRU_MODULE_API_VERSION%%% RIRU_MODULE_MIN_API_VERSION=%%%RIRU_MODULE_MIN_API_VERSION%%% RIRU_MODULE_MIN_RIRU_VERSION_NAME="%%%RIRU_MODULE_MIN_RIRU_VERSION_NAME%%%" +RIRU_MODULE_DEBUG=%%RIRU_MODULE_DEBUG%% if [ "$MAGISK_VER_CODE" -ge 21000 ]; then MAGISK_CURRENT_RIRU_MODULE_PATH=$(magisk --path)/.magisk/modules/riru-core @@ -61,4 +62,4 @@ else else ui_print "- Can't find /data/adb/riru/util_functions.sh" fi -fi \ No newline at end of file +fi