[core] Support riru24 (#329)

* Support riru24

* tmp aar for build

* Check riru version

* Rename libriru_lspd to liblspd

* Fix hiddenapi

* Use maven
This commit is contained in:
LoveSy 2021-03-11 18:57:06 +08:00 committed by GitHub
parent 696309af0b
commit c5bac3415c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 166 additions and 449 deletions

View File

@ -41,7 +41,7 @@ val commitCount = Git(repo).log().add(refId).call().count()
val defaultManagerPackageName by extra("org.lsposed.manager")
val verCode by extra(commitCount + 4200)
val verName by extra("v1.3.2")
val verName by extra("v1.3.3")
val androidTargetSdkVersion by extra(30)
val androidMinSdkVersion by extra(27)
val androidBuildToolsVersion by extra("30.0.3")

View File

@ -37,15 +37,14 @@ fun calcSha256(file: File): String {
}
val moduleName = "LSPosed"
val jarDestDir = "${projectDir}/template_override/system/framework/"
val isWindows = OperatingSystem.current().isWindows
val moduleId = "riru_lsposed"
val authors = "LSPosed Developers"
val riruModuleId = "lsposed"
val moduleMinRiruApiVersion = 10
val moduleMinRiruVersionName = "v23.0"
val moduleMaxRiruApiVersion = 10
val moduleMinRiruApiVersion = 24
val moduleMinRiruVersionName = "v24.0.0"
val moduleMaxRiruApiVersion = 24
val defaultManagerPackageName: String by rootProject.extra
val apiCode: Int by rootProject.extra
@ -64,7 +63,7 @@ val verCode: Int by rootProject.extra
val verName: String by rootProject.extra
dependencies {
implementation("dev.rikka.ndk:riru:10")
implementation("dev.rikka.ndk:riru:24.0.0")
implementation("com.android.tools.build:apksig:4.1.2")
compileOnly(project(":hiddenapi-stubs"))
compileOnly("androidx.annotation:annotation:1.1.0")
@ -183,7 +182,7 @@ afterEvaluate {
from(dexOutPath) {
rename("classes.dex", "lspd.dex")
}
into(file(zipPathMagiskReleasePath + "system/framework/"))
into(file(zipPathMagiskReleasePath + "framework/"))
}
copy {
from("${projectDir}/template_override")
@ -203,27 +202,27 @@ afterEvaluate {
}
copy {
include("riru_lspd")
rename("riru_lspd", "libriru_lspd.so")
rename("riru_lspd", "liblspd.so")
from("$libPathRelease/armeabi-v7a")
into("$zipPathMagiskReleasePath/system/lib")
into("$zipPathMagiskReleasePath/riru/lib")
}
copy {
include("riru_lspd")
rename("riru_lspd", "libriru_lspd.so")
rename("riru_lspd", "liblspd.so")
from("$libPathRelease/arm64-v8a")
into("$zipPathMagiskReleasePath/system/lib64")
into("$zipPathMagiskReleasePath/riru/lib64")
}
copy {
include("riru_lspd")
rename("riru_lspd", "libriru_lspd.so")
rename("riru_lspd", "liblspd.so")
from("$libPathRelease/x86")
into("$zipPathMagiskReleasePath/system_x86/lib")
into("$zipPathMagiskReleasePath/riru_x86/lib")
}
copy {
include("riru_lspd")
rename("riru_lspd", "libriru_lspd.so")
rename("riru_lspd", "liblspd.so")
from("$libPathRelease/x86_64")
into("$zipPathMagiskReleasePath/system_x86/lib64")
into("$zipPathMagiskReleasePath/riru_x86/lib64")
}
copy {
from("${project(":app").projectDir}/build/outputs/apk/${variantLowered}")

View File

@ -23,10 +23,10 @@ cmake_minimum_required(VERSION 3.4.1)
aux_source_directory(src SRC_LIST)
aux_source_directory(src/jni SRC_JNI_LIST)
include_directories(include src)
add_executable(riru_lspd ${SRC_LIST} ${SRC_JNI_LIST})
add_executable(lspd ${SRC_LIST} ${SRC_JNI_LIST})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--dynamic-list=${CMAKE_SOURCE_DIR}/dynamic_list")
find_package(riru REQUIRED CONFIG)
find_library(log-lib log)
target_link_libraries(riru_lspd yahfa riru::riru android dobby dex_builder ${log-lib})
target_link_libraries(lspd yahfa riru::riru android dobby dex_builder ${log-lib})

View File

@ -50,8 +50,8 @@ namespace art {
// Note: these identifiers should be consistent with those in Java layer
if (strstr(thisDesc, "LspHooker_") != nullptr
|| strstr(thatDesc, "LspHooker_") != nullptr
|| strstr(thisDesc, "io/github/lsposed/") != nullptr
|| strstr(thatDesc, "io/github/lsposed/") != nullptr) {
|| strstr(thisDesc, "org/lsposed/") != nullptr
|| strstr(thatDesc, "org/lsposed/") != nullptr) {
return true;
}
// for MIUI resources hooking

View File

@ -51,7 +51,7 @@ inline constexpr bool is64 = Is64();
static const auto kEntryClassName = "org.lsposed.lspd.core.Main"s;
static const auto kClassLinkerClassName = "org.lsposed.lspd.nativebridge.ClassLinker"s;
static const auto kBridgeServiceClassName = "org.lsposed.lspd.service.BridgeService"s;
static const auto kDexPath = "/data/adb/lspd/framework/lspd.dex"s;
static const auto kDexPath = "framework/lspd.dex"s;
static const auto kLibArtName = "libart.so"s;
static const auto kLibFwName = "libandroidfw.so"s;

View File

@ -33,7 +33,6 @@
#include "jni/logger.h"
#include "jni/native_api.h"
#include "service.h"
#include "rirud_socket.h"
namespace lspd {
constexpr int FIRST_ISOLATED_UID = 99000;
@ -60,14 +59,13 @@ namespace lspd {
void Context::PreLoadDex(const std::string &dex_path) {
if (LIKELY(!dex.empty())) return;
try {
RirudSocket socket;
auto dex_content = socket.ReadFile(dex_path);
dex.assign(dex_content.begin(), dex_content.end());
} catch (RirudSocket::RirudSocketException &e) {
LOGE("%s", e.what());
return;
std::ifstream is(dex_path);
if (!is.good()) {
LOGE("Failed to read dex");
return;
}
dex.assign(std::istreambuf_iterator<char>(is), std::istreambuf_iterator<char>());
LOGI("Loaded %s with size %zu", dex_path.c_str(), dex.size());
}
@ -126,9 +124,10 @@ namespace lspd {
jclass
Context::FindClassFromLoader(JNIEnv *env, jobject class_loader, std::string_view class_name) {
if (class_loader == nullptr) return nullptr;
static auto clz = (jclass)env->NewGlobalRef(env->FindClass( "dalvik/system/DexClassLoader"));
static auto clz = (jclass) env->NewGlobalRef(
env->FindClass("dalvik/system/DexClassLoader"));
static jmethodID mid = JNI_GetMethodID(env, clz, "loadClass",
"(Ljava/lang/String;)Ljava/lang/Class;");
"(Ljava/lang/String;)Ljava/lang/Class;");
jclass ret = nullptr;
if (!mid) {
mid = JNI_GetMethodID(env, clz, "findClass", "(Ljava/lang/String;)Ljava/lang/Class;");
@ -202,9 +201,9 @@ namespace lspd {
}
if (!skip_ && ((app_id >= FIRST_ISOLATED_UID && app_id <= LAST_ISOLATED_UID) ||
(app_id >= FIRST_APP_ZYGOTE_ISOLATED_UID &&
app_id <= LAST_APP_ZYGOTE_ISOLATED_UID) ||
app_id == SHARED_RELRO_UID)) {
(app_id >= FIRST_APP_ZYGOTE_ISOLATED_UID &&
app_id <= LAST_APP_ZYGOTE_ISOLATED_UID) ||
app_id == SHARED_RELRO_UID)) {
skip_ = true;
LOGI("skip injecting into %s because it's isolated", process_name.get());
}
@ -213,7 +212,7 @@ namespace lspd {
void
Context::OnNativeForkAndSpecializePost(JNIEnv *env) {
const JUTFString process_name(env, nice_name_);
auto binder = skip_? nullptr : Service::instance()->RequestBinder(env, nice_name_);
auto binder = skip_ ? nullptr : Service::instance()->RequestBinder(env, nice_name_);
if (binder) {
LoadDex(env);
InstallInlineHooks();

View File

@ -29,123 +29,98 @@
#include "symbol_cache.h"
namespace lspd {
static void onModuleLoaded() {
LOGI("onModuleLoaded: welcome to LSPosed!");
// rirud must be used in onModuleLoaded
Context::GetInstance()->PreLoadDex(kDexPath);
InitSymbolCache();
}
namespace {
std::string magiskPath;
static int shouldSkipUid(int) {
return 0;
}
void onModuleLoaded() {
LOGI("onModuleLoaded: welcome to LSPosed!");
// rirud must be used in onModuleLoaded
Context::GetInstance()->PreLoadDex(magiskPath + '/' + kDexPath);
InitSymbolCache();
}
static void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *,
jintArray *, jint *,
jobjectArray *, jint *,
jstring *, jstring *nice_name,
jintArray *, jintArray *,
jboolean *start_child_zygote, jstring *,
jstring *app_data_dir, jboolean *,
jobjectArray *,
jobjectArray *,
jboolean *,
jboolean *) {
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid,
*nice_name,
*start_child_zygote,
*app_data_dir);
}
int shouldSkipUid(int) {
return 0;
}
static void nativeForkAndSpecializePost(JNIEnv *env, jclass, jint res) {
if (res == 0)
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
}
static void nativeForkSystemServerPre(JNIEnv *env, jclass, uid_t *, gid_t *,
jintArray *, jint *,
jobjectArray *, jlong *,
jlong *) {
Context::GetInstance()->OnNativeForkSystemServerPre(env);
}
static void nativeForkSystemServerPost(JNIEnv *env, jclass, jint res) {
Context::GetInstance()->OnNativeForkSystemServerPost(env, res);
}
/* method added in Android Q */
static void specializeAppProcessPre(JNIEnv *env, jclass, jint *uid, jint *,
jintArray *, jint *, jobjectArray *,
jint *, jstring *, jstring *nice_name,
void nativeForkAndSpecializePre(JNIEnv *env, jclass, jint *_uid, jint *,
jintArray *, jint *,
jobjectArray *, jint *,
jstring *, jstring *nice_name,
jintArray *, jintArray *,
jboolean *start_child_zygote, jstring *,
jstring *app_data_dir, jboolean *,
jobjectArray *,
jobjectArray *,
jboolean *,
jboolean *) {
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *uid, *nice_name, *start_child_zygote,
*app_data_dir);
}
static void specializeAppProcessPost(JNIEnv *env, jclass) {
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
}
}
int riru_api_version;
RIRU_EXPORT __attribute__((noinline)) void *init(void *arg) {
static int step = 0;
step += 1;
static void *_module;
switch (step) {
case 1: {
auto core_max_api_version = *(int *) arg;
riru_api_version =
core_max_api_version <= RIRU_MODULE_API_VERSION ? core_max_api_version
: RIRU_MODULE_API_VERSION;
return &riru_api_version;
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *_uid,
*nice_name,
*start_child_zygote,
*app_data_dir);
}
case 2: {
switch (riru_api_version) {
case 10:
[[fallthrough]];
case 9: {
auto module = (RiruModuleInfoV10 *) malloc(sizeof(RiruModuleInfoV10));
memset(module, 0, sizeof(RiruModuleInfoV10));
_module = module;
module->supportHide = true;
void nativeForkAndSpecializePost(JNIEnv *env, jclass, jint res) {
if (res == 0)
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
}
module->version = RIRU_MODULE_VERSION;
module->versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME);
module->onModuleLoaded = lspd::onModuleLoaded;
module->shouldSkipUid = lspd::shouldSkipUid;
module->forkAndSpecializePre = lspd::nativeForkAndSpecializePre;
module->forkAndSpecializePost = lspd::nativeForkAndSpecializePost;
module->specializeAppProcessPre = lspd::specializeAppProcessPre;
module->specializeAppProcessPost = lspd::specializeAppProcessPost;
module->forkSystemServerPre = lspd::nativeForkSystemServerPre;
module->forkSystemServerPost = lspd::nativeForkSystemServerPost;
return module;
}
default: {
return nullptr;
}
void nativeForkSystemServerPre(JNIEnv *env, jclass, uid_t *, gid_t *,
jintArray *, jint *,
jobjectArray *, jlong *,
jlong *) {
Context::GetInstance()->OnNativeForkSystemServerPre(env);
}
void nativeForkSystemServerPost(JNIEnv *env, jclass, jint res) {
Context::GetInstance()->OnNativeForkSystemServerPost(env, res);
}
/* method added in Android Q */
void specializeAppProcessPre(JNIEnv *env, jclass, jint *uid, jint *,
jintArray *, jint *, jobjectArray *,
jint *, jstring *, jstring *nice_name,
jboolean *start_child_zygote, jstring *,
jstring *app_data_dir, jboolean *,
jobjectArray *,
jobjectArray *,
jboolean *,
jboolean *) {
Context::GetInstance()->OnNativeForkAndSpecializePre(env, *uid, *nice_name,
*start_child_zygote,
*app_data_dir);
}
void specializeAppProcessPost(JNIEnv *env, jclass) {
Context::GetInstance()->OnNativeForkAndSpecializePost(env);
}
}
RiruVersionedModuleInfo module{
.moduleApiVersion = RIRU_MODULE_API_VERSION,
.moduleInfo = RiruModuleInfo{
.supportHide = true,
.version = RIRU_MODULE_VERSION,
.versionName = STRINGIFY(RIRU_MODULE_VERSION_NAME),
.onModuleLoaded = lspd::onModuleLoaded,
.shouldSkipUid = lspd::shouldSkipUid,
.forkAndSpecializePre = lspd::nativeForkAndSpecializePre,
.forkAndSpecializePost = lspd::nativeForkAndSpecializePost,
.forkSystemServerPre = lspd::nativeForkSystemServerPre,
.forkSystemServerPost = lspd::nativeForkSystemServerPost,
.specializeAppProcessPre = lspd::specializeAppProcessPre,
.specializeAppProcessPost = lspd::specializeAppProcessPost,
}
}
case 3: {
free(_module);
return nullptr;
}
default: {
return nullptr;
}
}
};
}
int main(){
__attribute__((noinline)) RIRU_EXPORT RiruVersionedModuleInfo *init(Riru *riru) {
LOGD("Using riru %d", riru->riruApiVersion);
LOGD("module path: %s", riru->magiskModulePath);
lspd::magiskPath = riru->magiskModulePath;
return &lspd::module;
}
int main() {
init(nullptr);
}
}

View File

@ -1,121 +0,0 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
#include "rirud_socket.h"
#include <unistd.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <logging.h>
#include <cerrno>
template<>
void RirudSocket::Write<std::string>(const std::string &str) {
auto count = str.size();
auto *buf = str.data();
Write(buf, count);
}
template<typename T>
void RirudSocket::Write(const T &obj) {
auto len = sizeof(T);
auto *buf = &obj;
Write(reinterpret_cast<const char*>(buf), len);
}
template<>
void RirudSocket::Read<std::string>(std::string &str) {
auto count = str.size();
auto *buf = str.data();
Read(buf, count);
}
template<typename T>
void RirudSocket::Read(T &obj) {
auto len = sizeof(T);
auto *buf = &obj;
Read(reinterpret_cast<char*>(buf), len);
}
RirudSocket::RirudSocket() {
if ((fd_ = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0)) < 0) {
throw RirudSocketException(strerror(errno));
}
struct sockaddr_un addr{
.sun_family = AF_UNIX,
.sun_path={0}
};
strcpy(addr.sun_path + 1, "rirud");
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
if (connect(fd_, reinterpret_cast<struct sockaddr *>(&addr), socklen) == -1) {
close(fd_);
fd_ = -1;
throw RirudSocketException(strerror(errno));
}
}
RirudSocket::~RirudSocket() {
if (fd_ != -1)
close(fd_);
}
std::string RirudSocket::ReadFile(const std::string &path) {
Write(ACTION_READ_FILE);
Write(static_cast<uint32_t>(path.size()));
Write(path);
int32_t rirud_errno;
Read(rirud_errno);
if(rirud_errno != 0) {
throw RirudSocketException(strerror(rirud_errno));
}
uint32_t file_size;
Read(file_size);
std::string content;
content.resize(file_size);
Read(content);
return content;
}
void RirudSocket::Write(const char *buf, size_t len) const {
auto count = len;
while (count > 0) {
ssize_t size = write(fd_, buf, count < SSIZE_MAX ? count : SSIZE_MAX);
if (size == -1) {
if (errno == EINTR) continue;
else throw RirudSocketException(strerror(errno));
}
buf = buf + size;
count -= size;
}
}
void RirudSocket::Read(char *out, size_t len) const {
while (len > 0) {
ssize_t ret = read(fd_, out, len);
if (ret <= 0) {
if(errno == EINTR) continue;
else throw RirudSocketException(strerror(errno));
}
out = out + ret;
len -= ret;
}
}

View File

@ -1,64 +0,0 @@
/*
* This file is part of LSPosed.
*
* LSPosed is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* LSPosed is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with LSPosed. If not, see <https://www.gnu.org/licenses/>.
*
* Copyright (C) 2020 EdXposed Contributors
* Copyright (C) 2021 LSPosed Contributors
*/
#pragma once
#include <string>
#include <filesystem>
class RirudSocket {
public:
// class DirIter {};
class RirudSocketException : public std::runtime_error {
public:
RirudSocketException(const std::string &what) : std::runtime_error(what) {}
};
RirudSocket();
std::string ReadFile(const std::string &path);
// DirIter ReadDir(const std::filesystem::path &path);
// DirIter RecursiveReadDir(const std::filesystem::path &path);
~RirudSocket();
private:
RirudSocket(const RirudSocket &) = delete;
RirudSocket operator=(const RirudSocket &) = delete;
inline static const uint32_t ACTION_READ_FILE = 4;
template<typename T>
void Write(const T &);
template<typename T>
void Read(T &);
void Write(const char *buf, size_t len) const;
void Read(char *buf, size_t len) const;
int fd_ = -1;
};

View File

@ -22,45 +22,15 @@ SKIPUNZIP=1
abortC() {
rm -rf "${MODPATH}"
if [[ ! -f /data/adb/lspd/misc_path ]]; then
[[ -d "${MISC_PATH}" ]] && rm -rf "${MISC_PATH}"
if [ ! -f /data/adb/lspd/misc_path ]; then
[ -d "${MISC_PATH}" ] && rm -rf "${MISC_PATH}"
fi
abort "$1"
}
getRandomNameExist() {
RAND_PATH=$4
RAND_SUFFIX=$3
RAND_PREFIX=$2
RAND_DIGIT=$1
RAND_RAND="$(cat /proc/sys/kernel/random/uuid|md5sum|cut -c 1-"${RAND_DIGIT}")"
RAND_PATH_EXIST=false
for TARGET in ${RAND_PATH}; do
if [[ -e "${TARGET}/${RAND_PREFIX}${RAND_RAND}${RAND_SUFFIX}" ]]; then
RAND_PATH_EXIST=true
fi
done
if [[ "${RAND_PATH_EXIST}" == true ]]; then
getRandomNameExist "${RAND_DIGIT}" "${RAND_PREFIX}" "${RAND_SUFFIX}" "${RAND_PATH}"
else
echo "${RAND_RAND}"
fi
}
POUNDS="*********************************************************"
RIRU_PATH="/data/adb/riru"
RIRU_EDXP="$(getRandomNameExist 4 "libriru_" ".so" "
/system/lib
/system/lib64
")"
RIRU_MODULES="${RIRU_PATH}/modules"
RIRU_TARGET="${RIRU_MODULES}/${RIRU_EDXP}"
VERSION=$(grep_prop version "${TMPDIR}/module.prop")
RIRU_MIN_API_VERSION=$(grep_prop api "${TMPDIR}/module.prop")
LIB_RIRU_EDXP="libriru_${RIRU_EDXP}.so"
### lang start ###
# Default en_US
@ -76,8 +46,6 @@ LANG_CUST_INST_CONF_OLD="Use previous path"
LANG_CUST_DISABLE_EDXP="**WARNING**: This installation will disable edxposed because of incompatibility"
LANG_CUST_INST_CONF_NEW="Use new path"
LANG_CUST_INST_COPY_LIB="Copying framework libraries"
LANG_CUST_INST_REM_OLDCONF="Removing old configuration"
LANG_CUST_INST_COPT_EXTRA="Copying extra files"
LANG_CUST_INST_DONE="Welcome to"
LANG_CUST_ERR_VERIFY_FAIL="Unable to extract verify tool!"
@ -86,7 +54,6 @@ LANG_CUST_ERR_CONF_CREATE="Can't create configuration path"
LANG_CUST_ERR_CONF_STORE="Can't store configuration path"
LANG_CUST_ERR_CONF_FIRST="Can't create first install flag"
LANG_CUST_ERR_CONF_UNINST="Can't write uninstall script"
LANG_CUST_ERR_EXTRA_CREATE="Can't create"
# verify
LANG_VERIFY_SUCCESS="Verified"
@ -109,9 +76,9 @@ LANG_UTIL_ERR_PLATFORM_UNSUPPORT="Unsupported platform"
LANG_CUST_INST_MIGRATE_CONF="Migrating configuration"
# Load lang
if [[ ${BOOTMODE} == true ]]; then
if [ ${BOOTMODE} == true ]; then
locale=$(getprop persist.sys.locale|awk -F "-" '{print $1"_"$NF}')
[[ ${locale} == "" ]] && locale=$(settings get system system_locales|awk -F "," '{print $1}'|awk -F "-" '{print $1"_"$NF}')
[ ${locale} == "" ] && locale=$(settings get system system_locales|awk -F "," '{print $1}'|awk -F "-" '{print $1"_"$NF}')
file=${locale}.sh
unzip -o "$ZIPFILE" "${file}" -d "$TMPDIR" >&2
unzip -o "$ZIPFILE" "${file}.sha256" -d "$TMPDIR" >&2
@ -149,34 +116,32 @@ extract "${ZIPFILE}" 'post-fs-data.sh' "${MODPATH}"
extract "${ZIPFILE}" 'service.sh' "${MODPATH}"
extract "${ZIPFILE}" 'uninstall.sh' "${MODPATH}"
extract "${ZIPFILE}" 'system/framework/lspd.dex' "${MODPATH}"
extract "${ZIPFILE}" 'framework/lspd.dex' "${MODPATH}"
if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then
ui_print "- ${LANG_CUST_INST_EXT_LIB_X86}"
extract "$ZIPFILE" 'system_x86/lib/libriru_lspd.so' "${MODPATH}"
mv "${MODPATH}/system_x86/lib" "${MODPATH}/system/lib"
extract "$ZIPFILE" 'riru_x86/lib/liblspd.so' "${MODPATH}"
if [ "$IS64BIT" = true ]; then
ui_print "- ${LANG_CUST_INST_EXT_LIB_X64}"
extract "$ZIPFILE" 'system_x86/lib64/libriru_lspd.so' "${MODPATH}"
mv "${MODPATH}/system_x86/lib64" "${MODPATH}/system/lib64"
extract "$ZIPFILE" 'riru_x86/lib64/liblspd.so' "${MODPATH}"
fi
mv "${MODPATH}/riru_x86" "${MODPATH}/riru"
else
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM}"
extract "$ZIPFILE" 'system/lib/libriru_lspd.so' "${MODPATH}"
extract "$ZIPFILE" 'riru/lib/liblspd.so' "${MODPATH}"
if [ "$IS64BIT" = true ]; then
ui_print "- ${LANG_CUST_INST_EXT_LIB_ARM64}"
extract "$ZIPFILE" 'system/lib64/libriru_lspd.so' "${MODPATH}"
extract "$ZIPFILE" 'riru/lib64/liblspd.so' "${MODPATH}"
fi
fi
ui_print "- ${LANG_CUST_INST_CONF_CREATE}"
if [[ -f /data/adb/lspd/misc_path ]]; then
if [ -f /data/adb/lspd/misc_path ]; then
# read current MISC_PATH
MISC_PATH=$(cat /data/adb/lspd/misc_path)
ui_print " - ${LANG_CUST_INST_CONF_OLD} $MISC_PATH"
elif [[ -f /data/adb/edxp/misc_path ]]; then
elif [ -f /data/adb/edxp/misc_path ]; then
mkdir -p /data/adb/lspd || abortC "! ${LANG_CUST_ERR_CONF_CREATE}"
MISC_PATH=$(cat /data/adb/edxp/misc_path | sed "s/edxp/lspd/")
echo $MISC_PATH > /data/adb/lspd/misc_path
@ -195,55 +160,24 @@ else
fi
touch /data/adb/lspd/new_install || abortC "! ${LANG_CUST_ERR_CONF_FIRST}"
ui_print "- ${LANG_CUST_INST_COPY_LIB}"
rm -rf "/data/adb/lspd/framework"
mv "${MODPATH}/system/framework" "/data/adb/lspd/framework"
extract "${ZIPFILE}" 'manager.apk' "/data/adb/lspd/"
mkdir -p /data/misc/$MISC_PATH
set_perm /data/misc/$MISC_PATH 0 0 0771 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}"
if [[ ! -d /data/adb/lspd/config ]]; then
if [ ! -d /data/adb/lspd/config ]; then
mkdir -p /data/adb/lspd/config
ui_print "- ${LANG_CUST_INST_MIGRATE_CONF}"
cp -r /data/misc/$MISC_PATH/0/prefs /data/misc/$MISC_PATH/prefs
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd_config org.lsposed.lspd.service.ConfigManager
fi
echo "rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
echo "[[ -f /data/adb/lspd/new_install ]] || rm -rf /data/adb/lspd" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
if [[ ! -e /data/adb/lspd/config/verbose_log ]]; then
echo "rm -rf /data/misc/$MISC_PATH" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
echo "[ -f /data/adb/lspd/new_install ] || rm -rf /data/adb/lspd" >> "${MODPATH}/uninstall.sh" || abortC "! ${LANG_CUST_ERR_CONF_UNINST}"
if [ ! -e /data/adb/lspd/config/verbose_log ]; then
echo "0" > /data/adb/lspd/config/verbose_log
fi
mv "${MODPATH}/system/lib/libriru_lspd.so" "${MODPATH}/system/lib/${LIB_RIRU_EDXP}"
if [[ "${IS64BIT}" == true ]]; then
mv "${MODPATH}/system/lib64/libriru_lspd.so" "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}"
fi
ui_print "- ${LANG_CUST_INST_REM_OLDCONF}"
if [[ -f "${RIRU_MODULES}/lspd.prop" ]]; then
OLD_CONFIG=$(cat "${RIRU_MODULES}/lspd.prop")
rm -rf "${RIRU_MODULES}/${OLD_CONFIG}"
fi
if [[ -e "${RIRU_MODULES}/lspd" ]]; then
rm -rf "${RIRU_MODULES}/lspd"
fi
# extract Riru files
ui_print "- ${LANG_CUST_INST_COPT_EXTRA}"
[[ -d "${RIRU_TARGET}" ]] || mkdir -p "${RIRU_TARGET}" || abortC "! ${LANG_CUST_ERR_EXTRA_CREATE} ${RIRU_TARGET}"
echo "${RIRU_EDXP}">"${RIRU_MODULES}/lspd.prop"
rm -f "${RIRU_TARGET}/module.prop"
cp "${MODPATH}/module.prop" "${RIRU_TARGET}/module.prop" || abortC "! ${LANG_CUST_ERR_EXTRA_CREATE} ${RIRU_TARGET}/module.prop"
set_perm "$RIRU_TARGET/module.prop" 0 0 0600 $RIRU_SECONTEXT || abortC "! ${LANG_CUST_ERR_PERM}"
set_perm_recursive "${MODPATH}" 0 0 0755 0644
ui_print "- ${LANG_CUST_INST_DONE} LSPosed ${VERSION}!"

View File

@ -24,7 +24,7 @@ grep_prop() {
local REGEX="s/^$1=//p"
shift
local FILES="$@"
[[ -z "$FILES" ]] && FILES='/system/build.prop'
[ -z "$FILES" ] && FILES='/system/build.prop'
sed -n "$REGEX" ${FILES} 2>/dev/null | head -n 1
}
@ -75,7 +75,7 @@ loop_logcat() {
while true
do
logcat $*
if [[ $? -ne 1 ]]; then
if [ $? -ne 1 ]; then
break
fi
done
@ -114,12 +114,12 @@ start_log_catcher () {
LOG_FILE="${LOG_PATH}/${LOG_FILE_NAME}.log"
PID_FILE="${LOG_PATH}/${LOG_FILE_NAME}.pid"
mkdir -p ${LOG_PATH}
if [[ ${CLEAN_OLD} == true ]]; then
if [ ${CLEAN_OLD} == true ]; then
rm "${LOG_FILE}.old"
mv "${LOG_FILE}" "${LOG_FILE}.old"
fi
rm "${LOG_PATH}/${LOG_FILE_NAME}.pid"
if [[ ${START_NEW} == false ]]; then
if [ ${START_NEW} == false ]; then
return
fi
touch "${PID_FILE}"
@ -129,9 +129,9 @@ start_log_catcher () {
echo "${LOG_PID}">"${LOG_PATH}/${LOG_FILE_NAME}.pid"
}
if [[ -f "/data/adb/riru/modules/lspd.prop" ]]; then
if [ -f "/data/adb/riru/modules/lspd.prop" ]; then
CONFIG=$(cat "/data/adb/riru/modules/lspd.prop")
[[ -d "${TARGET}/${CONFIG}" ]] || mkdir -p "${TARGET}/${CONFIG}"
[ -d "${TARGET}/${CONFIG}" ] || mkdir -p "${TARGET}/${CONFIG}"
cp "${MODDIR}/module.prop" "${TARGET}/${CONFIG}/module.prop"
fi
@ -142,7 +142,7 @@ mv ${LOG_PATH} ${LOG_PATH}.old
mkdir -p ${LOG_PATH}
chcon -R u:object_r:magisk_file:s0 ${LOG_PATH}
if [[ ! -z "${MISC_PATH}" ]]; then
if [ ! -z "${MISC_PATH}" ]; then
chcon -R u:object_r:magisk_file:s0 "${BASE_PATH}"
chmod 771 "${BASE_PATH}"
print_log_head "${LOG_PATH}/modules.log"
@ -155,7 +155,7 @@ start_app_process() {
while true
do
if [ -S "/dev/socket/zygote" ]; then
/system/bin/app_process -Djava.class.path=/data/adb/lspd/framework/lspd.dex /system/bin --nice-name=lspd org.lsposed.lspd.core.Main
/system/bin/app_process -Djava.class.path=$(magisk --path)/.magisk/modules/riru_lsposed/framework/lspd.dex /system/bin --nice-name=lspd org.lsposed.lspd.core.Main
fi
done
}

View File

@ -24,22 +24,22 @@ MODDIR=${0%/*}
VARIANT="YAHFA"
REMOVE=false
[[ "$(echo ${MODDIR} | grep sandhook)" != "" ]] && VARIANT="SandHook"
[ "$(echo ${MODDIR} | grep sandhook)" != "" ] && VARIANT="SandHook"
if [[ "${VARIANT}" == "SandHook" ]]; then
[[ -f "${MODDIR}/../riru_lsposed/module.prop" ]] || REMOVE=true
if [ "${VARIANT}" == "SandHook" ]; then
[ -f "${MODDIR}/../riru_lsposed/module.prop" ] || REMOVE=true
else
[[ -f "${MODDIR}/../riru_lsposed_sandhook/module.prop" ]] || REMOVE=true
[ -f "${MODDIR}/../riru_lsposed_sandhook/module.prop" ] || REMOVE=true
fi
if [[ "${REMOVE}" == true ]]; then
if [ "${REMOVE}" == true ]; then
rm -rf /data/misc/riru/modules/lspd
if [[ -f "/data/adb/riru/modules/lspd.prop" ]]; then
if [ -f "/data/adb/riru/modules/lspd.prop" ]; then
OLD_CONFIG=$(cat "/data/adb/riru/modules/lspd.prop")
rm -rf "/data/adb/riru/modules/${OLD_CONFIG}"
rm "/data/adb/riru/modules/lspd.prop"
fi
if [[ -f "/data/misc/riru/modules/lspd.prop" ]]; then
if [ -f "/data/misc/riru/modules/lspd.prop" ]; then
OLD_CONFIG=$(cat "/data/misc/riru/modules/lspd.prop")
rm -rf "/data/misc/riru/modules/${OLD_CONFIG}"
rm "/data/misc/riru/modules/lspd.prop"

View File

@ -18,31 +18,29 @@
# Copyright (C) 2021 LSPosed Contributors
#
RIRU_PATH="/data/adb/riru"
RIRU_MODULE_ID="%%%RIRU_MODULE_ID%%%"
RIRU_MODULE_PATH="$RIRU_PATH/modules/$RIRU_MODULE_ID"
RIRU_SECONTEXT="u:object_r:magisk_file:s0"
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%%%"
check_riru_version() {
RIRU_MIN_API_VERSION=%%%RIRU_MIN_API_VERSION%%%
RIRU_MIN_VERSION_NAME="%%%RIRU_MIN_VERSION_NAME%%%"
if [ ! -f "$RIRU_PATH/api_version" ] && [ ! -f "$RIRU_PATH/api_version.new" ]; then
ui_print "${POUNDS}"
ui_print "! ${LANG_UTIL_ERR_RIRU_NOT_FOUND_1}"
ui_print "! ${LANG_UTIL_ERR_RIRU_NOT_FOUND_2}"
[[ ${BOOTMODE} == true ]] && am start -a android.intent.action.VIEW -d https://github.com/RikkaApps/Riru/releases
abortC "${POUNDS}"
RIRU_CORE_MODULES_PATH=/data/adb/modules/riru-core
RIRU_CORE_MODULES_UPDATE_PATH=/data/adb/modules_update/riru-core
if [ ! -f "$RIRU_CORE_MODULES_UPDATE_PATH/api_version" ] && [ ! -f "$RIRU_CORE_MODULES_PATH/api_version" ] && [ ! -f "/data/adb/riru/api_version" ] && [ ! -f "/data/adb/riru/api_version.new" ]; then
ui_print "*********************************************************"
ui_print "! Riru $RIRU_MODULE_MIN_RIRU_VERSION_NAME or above is required"
ui_print "! Please install Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
abort "*********************************************************"
fi
RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version.new") || RIRU_API_VERSION=$(cat "$RIRU_PATH/api_version") || RIRU_API_VERSION=0
[ "$RIRU_API_VERSION" -eq "$RIRU_API_VERSION" ] || RIRU_API_VERSION=0
ui_print "- Riru API ${LANG_CUST_INST_VERSION}: $RIRU_API_VERSION"
if [ "$RIRU_API_VERSION" -lt $RIRU_MIN_API_VERSION ]; then
ui_print "${POUNDS}"
ui_print "! Riru $RIRU_MIN_VERSION_NAME ${LANG_UTIL_ERR_RIRU_LOW_1}"
ui_print "! ${LANG_UTIL_ERR_RIRU_LOW_2}"
[[ ${BOOTMODE} == true ]] && am start -a android.intent.action.VIEW -d https://github.com/RikkaApps/Riru/releases
abortC "${POUNDS}"
RIRU_API=$(cat "$RIRU_CORE_MODULES_UPDATE_PATH/api_version") || RIRU_API=$(cat "$RIRU_CORE_MODULES_PATH/api_version") || RIRU_API=$(cat "/data/adb/riru/api_version.new") || RIRU_API=$(cat "/data/adb/riru/api_version") || RIRU_API=0
[ "$RIRU_API" -eq "$RIRU_API" ] || RIRU_API=0
ui_print "- Riru API version: $RIRU_API"
if [ "$RIRU_API" -lt $RIRU_MODULE_MIN_API_VERSION ]; then
ui_print "*********************************************************"
ui_print "! Riru $RIRU_MODULE_MIN_RIRU_VERSION_NAME or above is required"
ui_print "! Please upgrade Riru from Magisk Manager or https://github.com/RikkaApps/Riru/releases"
abort "*********************************************************"
fi
}
@ -54,12 +52,12 @@ require_new_android() {
ui_print "${POUNDS}"
ui_print "! ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_1} ${1} ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_2}"
ui_print "! ${LANG_UTIL_ERR_ANDROID_UNSUPPORT_3}"
[[ ${BOOTMODE} == true ]] && am start -a android.intent.action.VIEW -d https://github.com/LSPosed/LSPosed/wiki/Available-Android-versions
[ ${BOOTMODE} == true ] && am start -a android.intent.action.VIEW -d https://github.com/LSPosed/LSPosed/wiki/Available-Android-versions
abortC "${POUNDS}"
}
lspd_check_architecture() {
if [[ "${ARCH}" != "arm" && "${ARCH}" != "arm64" && "${ARCH}" != "x86" && "${ARCH}" != "x64" ]]; then
if [ "${ARCH}" != "arm" && "${ARCH}" != "arm64" && "${ARCH}" != "x86" && "${ARCH}" != "x64" ]; then
abortC "! ${LANG_UTIL_ERR_PLATFORM_UNSUPPORT}: ${ARCH}"
else
ui_print "- ${LANG_UTIL_PLATFORM}: ${ARCH}"
@ -67,9 +65,9 @@ lspd_check_architecture() {
}
check_android_version() {
if [[ ${API} -ge 27 ]]; then
if [ ${API} -ge 27 ]; then
ui_print "- Android SDK ${LANG_CUST_INST_VERSION}: ${API}"
else
require_new_android "${API}"
fi
}
}

View File

@ -34,8 +34,6 @@ LANG_CUST_INST_CONF_OLD="使用旧目录"
LANG_CUST_DISABLE_EDXP="**警告**: 由于不兼容此次安装会自动禁用EdXposed"
LANG_CUST_INST_CONF_NEW="使用新目录"
LANG_CUST_INST_COPY_LIB="正在复制框架运行库"
LANG_CUST_INST_REM_OLDCONF="正在移除老旧配置"
LANG_CUST_INST_COPT_EXTRA="正在复制文件"
LANG_CUST_INST_DONE="欢迎使用"
LANG_CUST_ERR_VERIFY_FAIL="无法解压校验工具!"
@ -45,7 +43,6 @@ LANG_CUST_ERR_CONF_CREATE="无法创建配置路径"
LANG_CUST_ERR_CONF_STORE="无法写入配置路径"
LANG_CUST_ERR_CONF_FIRST="无法创建首次安装标识"
LANG_CUST_ERR_CONF_UNINST="无法写入卸载脚本"
LANG_CUST_ERR_EXTRA_CREATE="无法创建"
# verify
LANG_VERIFY_SUCCESS="已验证"