Update to work with Riru-core v19
Add support for Android Q beta3
This commit is contained in:
parent
50444072b0
commit
560733396c
|
|
@ -22,9 +22,9 @@ and zip binaries can be downloaded from [here](http://gnuwin32.sourceforge.net/p
|
|||
|
||||
## Install
|
||||
|
||||
1. Make sure Magisk v17.0 or higher is installed.
|
||||
2. Download [Riru-core](https://github.com/RikkaApps/Riru/releases) v10 or higher and install it in Magisk Manager or recovery.
|
||||
3. Download [EdXposed](https://github.com/solohsu/EdXposed/releases) and install it in Magisk Manager or recovery.
|
||||
1. Install Magisk v19.0+.
|
||||
2. Install [Riru-Core](https://github.com/RikkaApps/Riru/releases) v19+ from Magisk repo.
|
||||
3. Download [EdXposed](https://github.com/solohsu/EdXposed/releases) and install it in Magisk Manager or recovery mode.
|
||||
4. Install companion application.
|
||||
4. Reboot.
|
||||
5. Have fun! :)
|
||||
|
|
|
|||
78
build.sh
78
build.sh
|
|
@ -1,78 +0,0 @@
|
|||
#!/bin/bash
|
||||
MODULE_NAME=$1
|
||||
if [ "$MODULE_NAME" == "" ]; then
|
||||
echo "Usage: sh build.sh <module name> [<version name>]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d "$MODULE_NAME" ]; then
|
||||
echo "$MODULE_NAME not exists"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
VERSION=$2
|
||||
[[ "$VERSION" == "" ]] && VERSION=v1
|
||||
|
||||
ZIP_NAME_PREFIX=$3
|
||||
|
||||
LIBS_OUTPUT=$MODULE_NAME/build/ndkBuild/libs
|
||||
NDK_OUT=$MODULE_NAME/build/ndkBuild/obj
|
||||
|
||||
# build
|
||||
NDK_BUILD=ndk-build
|
||||
[[ "$OSTYPE" == "msys" ]] && NDK_BUILD=ndk-build.cmd
|
||||
[[ "$OSTYPE" == "cygwin" ]] && NDK_BUILD=ndk-build.cmd
|
||||
|
||||
(cd $MODULE_NAME; $NDK_BUILD NDK_LIBS_OUT=build/ndkBuild/libs NDK_OUT=build/ndkBuild/obj)
|
||||
|
||||
# elf cleaner
|
||||
function run_elf_cleaner {
|
||||
for file in $1/*
|
||||
do
|
||||
if [ -f $file ]; then
|
||||
clean_elf $file > /dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
if [ -f elf-cleaner.sh ]; then
|
||||
source elf-cleaner.sh
|
||||
run_elf_cleaner $LIBS_OUTPUT/arm64-v8a
|
||||
run_elf_cleaner $LIBS_OUTPUT/armeabi-v7a
|
||||
run_elf_cleaner $LIBS_OUTPUT/x86
|
||||
run_elf_cleaner $LIBS_OUTPUT/x86-64
|
||||
fi
|
||||
|
||||
# create tmp dir
|
||||
TMP_DIR=build/zip
|
||||
TMP_DIR_MAGISK=$TMP_DIR/magisk
|
||||
|
||||
rm -rf $TMP_DIR
|
||||
mkdir -p $TMP_DIR
|
||||
|
||||
# copy files
|
||||
mkdir -p $TMP_DIR_MAGISK/system/lib64
|
||||
mkdir -p $TMP_DIR_MAGISK/system/lib
|
||||
mkdir -p $TMP_DIR_MAGISK/system_x86/lib64
|
||||
mkdir -p $TMP_DIR_MAGISK/system_x86/lib
|
||||
cp -a $LIBS_OUTPUT/arm64-v8a/. $TMP_DIR_MAGISK/system/lib64
|
||||
cp -a $LIBS_OUTPUT/armeabi-v7a/. $TMP_DIR_MAGISK/system/lib
|
||||
[[ -d $LIBS_OUTPUT/x86_64 ]] && cp -a $LIBS_OUTPUT/x86_64/. $TMP_DIR_MAGISK/system_x86/lib64
|
||||
[[ -d $LIBS_OUTPUT/x86 ]] && cp -a $LIBS_OUTPUT/x86/. $TMP_DIR_MAGISK/system_x86/lib
|
||||
|
||||
# run custom script
|
||||
if [ -f $MODULE_NAME/build-module.sh ]; then
|
||||
source $MODULE_NAME/build-module.sh
|
||||
copy_files
|
||||
fi
|
||||
|
||||
# zip
|
||||
mkdir -p $MODULE_NAME/release
|
||||
ZIP_NAME=magisk-$ZIP_NAME_PREFIX-"$VERSION".zip
|
||||
rm -f $MODULE_NAME/release/$ZIP_NAME
|
||||
rm -f $TMP_DIR_MAGISK/$ZIP_NAME
|
||||
(cd $TMP_DIR_MAGISK; zip -r $ZIP_NAME * > /dev/null)
|
||||
mv $TMP_DIR_MAGISK/$ZIP_NAME $MODULE_NAME/release/$ZIP_NAME
|
||||
|
||||
# clean tmp dir
|
||||
rm -rf $TMP_DIR
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
function copy_files {
|
||||
# /data/misc/riru/modules/template exists -> libriru_template.so will be loaded
|
||||
# Change "template" to your module name
|
||||
# You can also use this folder as your config folder
|
||||
NAME="edxp"
|
||||
mkdir -p $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME
|
||||
cp $MODULE_NAME/template_override/riru_module.prop $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/module.prop
|
||||
|
||||
cp $MODULE_NAME/template_override/config.sh $TMP_DIR_MAGISK
|
||||
cp $MODULE_NAME/template_override/module.prop $TMP_DIR_MAGISK
|
||||
|
||||
cp -r $MODULE_NAME/template_override/system $TMP_DIR_MAGISK
|
||||
cp -r $MODULE_NAME/template_override/system_x86 $TMP_DIR_MAGISK
|
||||
cp -r $MODULE_NAME/template_override/common $TMP_DIR_MAGISK
|
||||
cp -r $MODULE_NAME/template_override/META-INF $TMP_DIR_MAGISK
|
||||
}
|
||||
|
||||
|
|
@ -1,11 +1,12 @@
|
|||
import org.apache.tools.ant.filters.FixCrLfFilter
|
||||
import org.gradle.internal.os.OperatingSystem
|
||||
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
version "v0.4.1.4_beta"
|
||||
version "v0.4.2.0_beta"
|
||||
|
||||
ext {
|
||||
versionCode = "4140"
|
||||
versionCode = "4200"
|
||||
module_name = "EdXposed"
|
||||
jar_dest_dir = "${projectDir}/template_override/system/framework/"
|
||||
is_windows = OperatingSystem.current().isWindows()
|
||||
|
|
@ -13,6 +14,10 @@ ext {
|
|||
yahfa_authors = "solohsu, rk700 & MlgmXyysd"
|
||||
sandhook_authors = "solohsu, ganyao114 & MlgmXyysd"
|
||||
whale_authors = "solohsu, asLody & MlgmXyysd"
|
||||
|
||||
moduleId = "edxp"
|
||||
libPathRelease = "$buildDir/ndkBuild/release/lib"
|
||||
zipPathMagiskRelease = "$buildDir/tmp/release/magisk"
|
||||
}
|
||||
|
||||
android {
|
||||
|
|
@ -67,6 +72,57 @@ task cleanTemplate(type: Delete) {
|
|||
delete file(templateSystemPath), file(templateSystemx86Path)
|
||||
}
|
||||
|
||||
// riru related tasks
|
||||
|
||||
task buildNativeRelease(type: Exec) {
|
||||
if (is_windows)
|
||||
commandLine 'cmd', '/c', 'ndk-build.cmd',
|
||||
'-j8',
|
||||
"NDK_LIBS_OUT=$libPathRelease",
|
||||
"NDK_OUT=$buildDir/ndkBuild/release/obj".replace("\\", "/")
|
||||
else
|
||||
commandLine 'ndk-build',
|
||||
'-j8',
|
||||
"NDK_LIBS_OUT=$libPathRelease",
|
||||
"NDK_OUT=$buildDir/ndkBuild/release/obj"
|
||||
}
|
||||
|
||||
task cleanMagiskRelease(type: Delete) {
|
||||
delete file(zipPathMagiskRelease)
|
||||
}
|
||||
|
||||
task copyFilesMagiskRelease {
|
||||
doLast {
|
||||
copy {
|
||||
from "${projectDir}/template_override"
|
||||
into zipPathMagiskRelease
|
||||
}
|
||||
copy {
|
||||
from 'template_override/riru_module.prop'
|
||||
into "$zipPathMagiskRelease/data/misc/riru/modules/${moduleId}"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/armeabi-v7a"
|
||||
into "$zipPathMagiskRelease/system/lib"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/arm64-v8a"
|
||||
into "$zipPathMagiskRelease/system/lib64"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/x86"
|
||||
into "$zipPathMagiskRelease/system_x86/lib"
|
||||
}
|
||||
copy {
|
||||
from "$libPathRelease/x86_64"
|
||||
into "$zipPathMagiskRelease/system_x86/lib64"
|
||||
}
|
||||
|
||||
file("$zipPathMagiskRelease/riru_module.prop").delete()
|
||||
file("$zipPathMagiskRelease/data/misc/riru/modules/${moduleId}/riru_module.prop").renameTo("$zipPathMagiskRelease/data/misc/riru/modules/${moduleId}/module.prop")
|
||||
}
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
|
||||
android.libraryVariants.all { variant ->
|
||||
|
|
@ -80,12 +136,18 @@ afterEvaluate {
|
|||
def backendCapped = backendLowered.capitalize()
|
||||
def authorList = property("${backendLowered}" + "_authors")
|
||||
|
||||
def zipTask = task("zip${backendCapped}${variantCapped}", type: Exec) {
|
||||
def prepareJarsTask = task("prepareJars${backendCapped}${variantCapped}") {
|
||||
dependsOn cleanTemplate, copyDalvikdxJar, copyDexmakerJar
|
||||
dependsOn tasks.getByPath(":edxp-${backendLowered}:makeAndCopy${variantCapped}")
|
||||
workingDir '..'
|
||||
commandLine 'sh', 'build.sh', project.name,
|
||||
"${backend}-${project.version}-${variantLowered}", "${module_name}"
|
||||
}
|
||||
|
||||
def preZipTask = task("preZip${backendCapped}${variantCapped}", type: GradleBuild) {
|
||||
dependsOn prepareJarsTask
|
||||
tasks = [
|
||||
'buildNativeRelease',
|
||||
'cleanMagiskRelease',
|
||||
'copyFilesMagiskRelease'
|
||||
]
|
||||
doFirst {
|
||||
copy {
|
||||
from "${projectDir}/tpl/edconfig.tpl"
|
||||
|
|
@ -97,8 +159,9 @@ afterEvaluate {
|
|||
from "${projectDir}/tpl/module.prop.tpl"
|
||||
into templateRootPath
|
||||
rename "module.prop.tpl", "module.prop"
|
||||
expand(backend: "$backendCapped", versionName: "$version" + "($backend)",
|
||||
expand(backend: "$backendCapped", versionName: "$version" + "($backend)",
|
||||
versionCode: "$versionCode", authorList: "$authorList")
|
||||
filter(FixCrLfFilter.class, eol: FixCrLfFilter.CrLf.newInstance("lf"))
|
||||
}
|
||||
copy {
|
||||
from "${templateRootPath}/module.prop"
|
||||
|
|
@ -108,6 +171,13 @@ afterEvaluate {
|
|||
}
|
||||
}
|
||||
|
||||
def zipTask = task("zip${backendCapped}${variantCapped}", type: Zip) {
|
||||
dependsOn preZipTask
|
||||
archiveName "magisk-${module_name}-${backend}-${project.version}-${variantLowered}.zip"
|
||||
destinationDir file("$projectDir/release")
|
||||
from "$zipPathMagiskRelease"
|
||||
}
|
||||
|
||||
task("push${backendCapped}${variantCapped}", type: Exec) {
|
||||
dependsOn zipTask
|
||||
workingDir "${projectDir}/release"
|
||||
|
|
|
|||
|
|
@ -3,4 +3,20 @@ APP_PLATFORM := android-23
|
|||
APP_CFLAGS := -std=gnu99
|
||||
APP_CPPFLAGS := -std=c++11
|
||||
APP_STL := c++_static
|
||||
APP_SHORT_COMMANDS := true
|
||||
APP_SHORT_COMMANDS := true
|
||||
|
||||
ifeq ($(NDK_DEBUG),1)
|
||||
$(info building DEBUG version...)
|
||||
APP_CFLAGS += -O0
|
||||
APP_CPPFLAGS += -O0
|
||||
else
|
||||
$(info building RELEASE version...)
|
||||
APP_CFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2
|
||||
APP_CPPFLAGS += -fvisibility=hidden -fvisibility-inlines-hidden -O2
|
||||
endif
|
||||
|
||||
# do not remove this, or your module will crash apps on Android Q
|
||||
SCS_FLAGS := -ffixed-x18
|
||||
APP_LDFLAGS += $(SCS_FLAGS)
|
||||
APP_CFLAGS += $(SCS_FLAGS)
|
||||
APP_CPPFLAGS += $(SCS_FLAGS)
|
||||
|
|
@ -8,7 +8,7 @@ LOCAL_C_INCLUDES := \
|
|||
LOCAL_CPPFLAGS += $(CPPFLAGS)
|
||||
LOCAL_STATIC_LIBRARIES := xhook
|
||||
LOCAL_LDLIBS += -ldl -llog
|
||||
LOCAL_LDFLAGS := -Wl
|
||||
LOCAL_LDFLAGS := -Wl,--hash-style=both
|
||||
|
||||
LOCAL_SRC_FILES:= \
|
||||
main.cpp \
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#include <dlfcn.h>
|
||||
#include <memory.h>
|
||||
#include <include/logging.h>
|
||||
#include <jni.h>
|
||||
|
||||
#ifdef __LP64__
|
||||
#define LIB "/system/lib64/libmemtrack.so"
|
||||
|
|
@ -73,4 +73,46 @@ void riru_set_native_method_func(const char *className, const char *name, const
|
|||
if (sym)
|
||||
((void *(*)(const char *, const char *, const char *, const char *, void *)) sym)(
|
||||
riru_get_module_name(), className, name, signature, func);
|
||||
}
|
||||
|
||||
const JNINativeMethod *riru_get_original_native_methods(const char *className, const char *name,
|
||||
const char *signature) {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return NULL;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_original_native_methods");
|
||||
if (sym)
|
||||
return ((JNINativeMethod *(*)(const char *, const char *, const char *)) sym)
|
||||
(className, name, signature);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int riru_is_zygote_methods_replaced() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return 0;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_is_zygote_methods_replaced");
|
||||
if (sym)
|
||||
return ((int (*)()) sym)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int riru_get_nativeForkAndSpecialize_calls_count() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return 0;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_nativeForkAndSpecialize_calls_count");
|
||||
if (sym)
|
||||
return ((int (*)()) sym)();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int riru_get_nativeForkSystemServer_calls_count() {
|
||||
static void **sym;
|
||||
void *handle;
|
||||
if ((handle = get_handle()) == NULL) return 0;
|
||||
if (sym == NULL) sym = dlsym(handle, "riru_get_nativeForkSystemServer_calls_count");
|
||||
if (sym)
|
||||
return ((int (*)()) sym)();
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,6 +1,8 @@
|
|||
#ifndef RIRU_H
|
||||
#define RIRU_H
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -50,6 +52,40 @@ void riru_set_func(const char *name, void *func);
|
|||
*/
|
||||
void riru_set_native_method_func(const char *className, const char *name, const char *signature,
|
||||
void *func);
|
||||
|
||||
/**
|
||||
* Get native methods from Riru's jniRegisterNativeMethods hook.
|
||||
* If both name and signature are null, all the class's methods will be returned.
|
||||
*
|
||||
* @param className className
|
||||
* @param name method name, null for the method with specific signature
|
||||
* @param signature method signature, null for the method with specific name
|
||||
* @return JNINativeMethod*
|
||||
*/
|
||||
const JNINativeMethod *riru_get_original_native_methods(const char *className, const char *name,
|
||||
const char *signature);
|
||||
|
||||
/**
|
||||
* Return if Zygote class's native method nativeForkAndSpecialize & nativeForkSystemServer is replaced by
|
||||
* Riru.
|
||||
*
|
||||
* @return methods replaced
|
||||
*/
|
||||
int riru_is_zygote_methods_replaced();
|
||||
|
||||
/**
|
||||
* Return calls count of Zygote class's native method nativeForkAndSpecialize replaced by Riru.
|
||||
*
|
||||
* @return nativeForkAndSpecialize calls count
|
||||
*/
|
||||
int riru_get_nativeForkAndSpecialize_calls_count();
|
||||
|
||||
/**
|
||||
* Return calls count of Zygote class native's method nativeForkSystemServer replaced by Riru.
|
||||
*
|
||||
* @return nativeForkAndSpecialize calls count
|
||||
*/
|
||||
int riru_get_nativeForkSystemServer_calls_count();
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -29,22 +29,17 @@ __attribute__((visibility("default"))) int shouldSkipUid(int uid) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) void nativeForkAndSpecializePre(JNIEnv *env, jclass clazz,
|
||||
jint _uid, jint gid,
|
||||
jintArray gids,
|
||||
jint runtime_flags,
|
||||
jobjectArray rlimits,
|
||||
jint _mount_external,
|
||||
jstring se_info,
|
||||
jstring se_name,
|
||||
jintArray fdsToClose,
|
||||
jintArray fdsToIgnore,
|
||||
jboolean is_child_zygote,
|
||||
jstring instructionSet,
|
||||
jstring appDataDir) {
|
||||
onNativeForkAndSpecializePre(env, clazz, _uid, gid, gids, runtime_flags, rlimits,
|
||||
_mount_external, se_info, se_name, fdsToClose, fdsToIgnore,
|
||||
is_child_zygote, instructionSet, appDataDir);
|
||||
__attribute__((visibility("default"))) void
|
||||
nativeForkAndSpecializePre(JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids,
|
||||
jint *runtime_flags,
|
||||
jobjectArray *rlimits, jint *_mount_external, jstring *se_info,
|
||||
jstring *se_name,
|
||||
jintArray *fdsToClose, jintArray *fdsToIgnore, jboolean *is_child_zygote,
|
||||
jstring *instructionSet, jstring *appDataDir, jstring *packageName,
|
||||
jobjectArray *packagesForUID, jstring *sandboxId) {
|
||||
onNativeForkAndSpecializePre(env, clazz, *_uid, *gid, *gids, *runtime_flags, *rlimits,
|
||||
*_mount_external, *se_info, *se_name, *fdsToClose, *fdsToIgnore,
|
||||
*is_child_zygote, *instructionSet, *appDataDir);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) int nativeForkAndSpecializePost(JNIEnv *env, jclass clazz,
|
||||
|
|
@ -53,11 +48,12 @@ __attribute__((visibility("default"))) int nativeForkAndSpecializePost(JNIEnv *e
|
|||
}
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
void nativeForkSystemServerPre(JNIEnv *env, jclass clazz, uid_t uid, gid_t gid, jintArray gids,
|
||||
jint runtime_flags, jobjectArray rlimits,
|
||||
jlong permittedCapabilities, jlong effectiveCapabilities) {
|
||||
onNativeForkSystemServerPre(env, clazz, uid, gid, gids, runtime_flags, rlimits,
|
||||
permittedCapabilities, effectiveCapabilities);
|
||||
void nativeForkSystemServerPre(JNIEnv *env, jclass clazz, uid_t *uid, gid_t *gid, jintArray *gids,
|
||||
jint *runtime_flags,
|
||||
jobjectArray *rlimits, jlong *permittedCapabilities,
|
||||
jlong *effectiveCapabilities) {
|
||||
onNativeForkSystemServerPre(env, clazz, *uid, *gid, *gids, *runtime_flags, *rlimits,
|
||||
*permittedCapabilities, *effectiveCapabilities);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default")))
|
||||
|
|
@ -65,4 +61,19 @@ int nativeForkSystemServerPost(JNIEnv *env, jclass clazz, jint res) {
|
|||
return onNativeForkSystemServerPost(env, clazz, res);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) void specializeAppProcessPre(
|
||||
JNIEnv *env, jclass clazz, jint *_uid, jint *gid, jintArray *gids, jint *runtimeFlags,
|
||||
jobjectArray *rlimits, jint *mountExternal, jstring *seInfo, jstring *niceName,
|
||||
jboolean *startChildZygote, jstring *instructionSet, jstring *appDataDir,
|
||||
jstring *packageName, jobjectArray *packagesForUID, jstring *sandboxId) {
|
||||
onNativeForkAndSpecializePre(env, clazz, *_uid, *gid, *gids, *runtimeFlags, *rlimits,
|
||||
*mountExternal, *seInfo, *niceName, nullptr, nullptr,
|
||||
*startChildZygote, *instructionSet, *appDataDir);
|
||||
}
|
||||
|
||||
__attribute__((visibility("default"))) int specializeAppProcessPost(
|
||||
JNIEnv *env, jclass clazz) {
|
||||
return onNativeForkAndSpecializePost(env, clazz, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,55 +1,47 @@
|
|||
#!/sbin/sh
|
||||
##########################################################################################
|
||||
#
|
||||
# Magisk Module Template Install Script
|
||||
# by topjohnwu
|
||||
#
|
||||
##########################################################################################
|
||||
|
||||
TMPDIR=/dev/tmp
|
||||
INSTALLER=$TMPDIR/install
|
||||
# Always mount under tmp
|
||||
MOUNTPATH=$TMPDIR/magisk_img
|
||||
MOUNTPATH=/dev/magisk_img
|
||||
|
||||
# Default permissions
|
||||
umask 022
|
||||
|
||||
# Initial cleanup
|
||||
rm -rf $TMPDIR 2>/dev/null
|
||||
mkdir -p $INSTALLER
|
||||
mkdir -p $TMPDIR
|
||||
|
||||
# echo before loading util_functions
|
||||
ui_print() { echo "$1"; }
|
||||
|
||||
require_new_magisk() {
|
||||
ui_print "*******************************"
|
||||
ui_print " Please install Magisk v17.0+! "
|
||||
ui_print "*******************************"
|
||||
ui_print "***********************************"
|
||||
ui_print " Please install the latest Magisk! "
|
||||
ui_print "***********************************"
|
||||
exit 1
|
||||
}
|
||||
|
||||
imageless_magisk() {
|
||||
[ $MAGISK_VER_CODE -gt 18100 ]
|
||||
return $?
|
||||
}
|
||||
|
||||
##########################################################################################
|
||||
# Environment
|
||||
##########################################################################################
|
||||
|
||||
OUTFD=$2
|
||||
ZIP=$3
|
||||
ZIPFILE=$3
|
||||
|
||||
mount /data 2>/dev/null
|
||||
|
||||
# Load utility functions
|
||||
if [ -f /data/adb/magisk/util_functions.sh ]; then
|
||||
. /data/adb/magisk/util_functions.sh
|
||||
elif [ -f /data/magisk/util_functions.sh ]; then
|
||||
NVBASE=/data
|
||||
. /data/magisk/util_functions.sh
|
||||
NVBASE=/data/adb
|
||||
else
|
||||
require_new_magisk
|
||||
fi
|
||||
|
||||
# Use alternative image if in BOOTMODE
|
||||
$BOOTMODE && IMG=$NVBASE/magisk_merge.img
|
||||
|
||||
# Preperation for flashable zips
|
||||
setup_flashable
|
||||
|
||||
|
|
@ -59,9 +51,6 @@ mount_partitions
|
|||
# Detect version and architecture
|
||||
api_level_arch_detect
|
||||
|
||||
# You can get the Android API version from $API, the CPU architecture from $ARCH
|
||||
# Useful if you are creating Android version / platform dependent mods
|
||||
|
||||
# Setup busybox and binaries
|
||||
$BOOTMODE && boot_actions || recovery_actions
|
||||
|
||||
|
|
@ -70,25 +59,28 @@ $BOOTMODE && boot_actions || recovery_actions
|
|||
##########################################################################################
|
||||
|
||||
# Extract common files
|
||||
unzip -o "$ZIP" module.prop config.sh 'common/*' -d $INSTALLER >&2
|
||||
unzip -oj "$ZIPFILE" module.prop install.sh uninstall.sh 'common/*' -d $TMPDIR >&2
|
||||
|
||||
[ ! -f $INSTALLER/config.sh ] && abort "! Unable to extract zip file!"
|
||||
# Load configurations
|
||||
. $INSTALLER/config.sh
|
||||
[ ! -f $TMPDIR/install.sh ] && abort "! Unable to extract zip file!"
|
||||
# Load install script
|
||||
. $TMPDIR/install.sh
|
||||
|
||||
# Check architecture
|
||||
check_architecture
|
||||
if imageless_magisk; then
|
||||
$BOOTMODE && MODDIRNAME=modules_update || MODDIRNAME=modules
|
||||
MODULEROOT=$NVBASE/$MODDIRNAME
|
||||
else
|
||||
$BOOTMODE && IMGNAME=magisk_merge.img || IMGNAME=magisk.img
|
||||
IMG=$NVBASE/$IMGNAME
|
||||
request_zip_size_check "$ZIPFILE"
|
||||
mount_magisk_img
|
||||
MODULEROOT=$MOUNTPATH
|
||||
fi
|
||||
|
||||
# Check the installed magisk version
|
||||
MIN_VER=`grep_prop minMagisk $INSTALLER/module.prop`
|
||||
[ ! -z $MAGISK_VER_CODE -a $MAGISK_VER_CODE -ge $MIN_VER ] || require_new_magisk
|
||||
MODID=`grep_prop id $INSTALLER/module.prop`
|
||||
MODPATH=$MOUNTPATH/$MODID
|
||||
MODID=`grep_prop id $TMPDIR/module.prop`
|
||||
MODPATH=$MODULEROOT/$MODID
|
||||
|
||||
# Print mod name
|
||||
print_modname
|
||||
|
||||
# Please leave this message in your flashable zip for credits :)
|
||||
ui_print "******************************"
|
||||
ui_print "Powered by Magisk (@topjohnwu)"
|
||||
ui_print "******************************"
|
||||
|
|
@ -97,51 +89,52 @@ ui_print "******************************"
|
|||
# Install
|
||||
##########################################################################################
|
||||
|
||||
# Get the variable reqSizeM. Use your own method to determine reqSizeM if needed
|
||||
request_zip_size_check "$ZIP"
|
||||
|
||||
# This function will mount $IMG to $MOUNTPATH, and resize the image based on $reqSizeM
|
||||
mount_magisk_img
|
||||
|
||||
# Create mod paths
|
||||
rm -rf $MODPATH 2>/dev/null
|
||||
mkdir -p $MODPATH
|
||||
|
||||
# Extract files to system. Use your own method if needed
|
||||
ui_print "- Extracting module files"
|
||||
unzip -o "$ZIP" 'system/*' -d $MODPATH >&2
|
||||
on_install
|
||||
|
||||
# Remove placeholder
|
||||
rm -f $MODPATH/system/placeholder 2>/dev/null
|
||||
|
||||
# Extra copy file function
|
||||
copy_files
|
||||
# Custom uninstaller
|
||||
[ -f $TMPDIR/uninstall.sh ] && cp -af $TMPDIR/uninstall.sh $MODPATH/uninstall.sh
|
||||
|
||||
# Auto Mount
|
||||
if imageless_magisk; then
|
||||
$SKIPMOUNT && touch $MODPATH/skip_mount
|
||||
else
|
||||
$SKIPMOUNT || touch $MODPATH/auto_mount
|
||||
fi
|
||||
|
||||
# prop files
|
||||
$PROPFILE && cp -af $TMPDIR/system.prop $MODPATH/system.prop
|
||||
|
||||
# Module info
|
||||
cp -af $TMPDIR/module.prop $MODPATH/module.prop
|
||||
if $BOOTMODE; then
|
||||
# Update info for Magisk Manager
|
||||
if imageless_magisk; then
|
||||
mktouch $NVBASE/modules/$MODID/update
|
||||
cp -af $TMPDIR/module.prop $NVBASE/modules/$MODID/module.prop
|
||||
else
|
||||
mktouch /sbin/.magisk/img/$MODID/update
|
||||
cp -af $TMPDIR/module.prop /sbin/.magisk/img/$MODID/module.prop
|
||||
fi
|
||||
fi
|
||||
|
||||
# post-fs-data mode scripts
|
||||
$POSTFSDATA && cp -af $TMPDIR/post-fs-data.sh $MODPATH/post-fs-data.sh
|
||||
|
||||
# service mode scripts
|
||||
$LATESTARTSERVICE && cp -af $TMPDIR/service.sh $MODPATH/service.sh
|
||||
|
||||
# Handle replace folders
|
||||
for TARGET in $REPLACE; do
|
||||
mktouch $MODPATH$TARGET/.replace
|
||||
done
|
||||
|
||||
# Auto Mount
|
||||
$AUTOMOUNT && touch $MODPATH/auto_mount
|
||||
|
||||
# prop files
|
||||
$PROPFILE && cp -af $INSTALLER/common/system.prop $MODPATH/system.prop
|
||||
|
||||
# Module info
|
||||
cp -af $INSTALLER/module.prop $MODPATH/module.prop
|
||||
if $BOOTMODE; then
|
||||
# Update info for Magisk Manager
|
||||
mktouch /sbin/.core/img/$MODID/update
|
||||
cp -af $INSTALLER/module.prop /sbin/.core/img/$MODID/module.prop
|
||||
fi
|
||||
|
||||
# post-fs-data mode scripts
|
||||
$POSTFSDATA && cp -af $INSTALLER/common/post-fs-data.sh $MODPATH/post-fs-data.sh
|
||||
|
||||
# service mode scripts
|
||||
$LATESTARTSERVICE && cp -af $INSTALLER/common/service.sh $MODPATH/service.sh
|
||||
|
||||
ui_print "- Setting permissions"
|
||||
set_permissions
|
||||
|
||||
|
|
@ -149,11 +142,10 @@ set_permissions
|
|||
# Finalizing
|
||||
##########################################################################################
|
||||
|
||||
# Unmount magisk image and shrink if possible
|
||||
unmount_magisk_img
|
||||
|
||||
cd /
|
||||
imageless_magisk || unmount_magisk_img
|
||||
$BOOTMODE || recovery_cleanup
|
||||
rm -rf $TMPDIR
|
||||
rm -rf $TMPDIR $MOUNTPATH
|
||||
|
||||
ui_print "- Done"
|
||||
exit 0
|
||||
exit 0
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
#!/system/bin/sh
|
||||
|
||||
EDXP_VERSION="0.4.1.4_beta (4140)"
|
||||
EDXP_VERSION="0.4.2.0_beta (4200)"
|
||||
ANDROID_SDK=`getprop ro.build.version.sdk`
|
||||
BUILD_DESC=`getprop ro.build.description`
|
||||
PRODUCT=`getprop ro.build.product`
|
||||
|
|
|
|||
|
|
@ -1,142 +0,0 @@
|
|||
##########################################################################################
|
||||
#
|
||||
# Magisk Module Template Config Script
|
||||
# by topjohnwu
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
#
|
||||
# Instructions:
|
||||
#
|
||||
# 1. Place your files into system folder (delete the placeholder file)
|
||||
# 2. Fill in your module's info into module.prop
|
||||
# 3. Configure the settings in this file (config.sh)
|
||||
# 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh
|
||||
# 5. Add your additional or modified system properties into common/system.prop
|
||||
#
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# Configs
|
||||
##########################################################################################
|
||||
|
||||
# Set to true if you need to enable Magic Mount
|
||||
# Most mods would like it to be enabled
|
||||
AUTOMOUNT=true
|
||||
|
||||
# Set to true if you need to load system.prop
|
||||
PROPFILE=true
|
||||
|
||||
# Set to true if you need post-fs-data script
|
||||
POSTFSDATA=true
|
||||
|
||||
# Set to true if you need late_start service script
|
||||
LATESTARTSERVICE=false
|
||||
|
||||
##########################################################################################
|
||||
# Installation Message
|
||||
##########################################################################################
|
||||
|
||||
# Set what you want to show when installing your mod
|
||||
|
||||
print_modname() {
|
||||
ui_print "************************************"
|
||||
ui_print " Riru - Ed Xposed "
|
||||
ui_print "************************************"
|
||||
}
|
||||
|
||||
##########################################################################################
|
||||
# Replace list
|
||||
##########################################################################################
|
||||
|
||||
# List all directories you want to directly replace in the system
|
||||
# Check the documentations for more info about how Magic Mount works, and why you need this
|
||||
|
||||
# This is an example
|
||||
REPLACE="
|
||||
/system/app/Youtube
|
||||
/system/priv-app/SystemUI
|
||||
/system/priv-app/Settings
|
||||
/system/framework
|
||||
"
|
||||
|
||||
# Construct your own list here, it will override the example above
|
||||
# !DO NOT! remove this if you don't need to replace anything, leave it empty as it is now
|
||||
REPLACE="
|
||||
"
|
||||
|
||||
##########################################################################################
|
||||
# Permissions
|
||||
##########################################################################################
|
||||
|
||||
set_permissions() {
|
||||
# Only some special files require specific permissions
|
||||
# The default permissions should be good enough for most cases
|
||||
|
||||
# Here are some examples for the set_perm functions:
|
||||
|
||||
# set_perm_recursive <dirname> <owner> <group> <dirpermission> <filepermission> <contexts> (default: u:object_r:system_file:s0)
|
||||
# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
|
||||
|
||||
# set_perm <filename> <owner> <group> <permission> <contexts> (default: u:object_r:system_file:s0)
|
||||
# set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
|
||||
# set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
|
||||
# set_perm $MODPATH/system/lib/libart.so 0 0 0644
|
||||
|
||||
# The following is default permissions, DO NOT remove
|
||||
set_perm_recursive $MODPATH 0 0 0755 0644
|
||||
}
|
||||
|
||||
##########################################################################################
|
||||
# Custom Functions
|
||||
##########################################################################################
|
||||
|
||||
# This file (config.sh) will be sourced by the main flash script after util_functions.sh
|
||||
# If you need custom logic, please add them here as functions, and call these functions in
|
||||
# update-binary. Refrain from adding code directly into update-binary, as it will make it
|
||||
# difficult for you to migrate your modules to newer template versions.
|
||||
# Make update-binary as clean as possible, try to only do function calls in it.
|
||||
fail() {
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
check_architecture() {
|
||||
if [[ "$ARCH" != "arm" && "$ARCH" != "arm64" && "$ARCH" != "x86" && "$ARCH" != "x64" ]]; then
|
||||
ui_print "- Unsupported platform: $ARCH"
|
||||
exit 1
|
||||
else
|
||||
ui_print "- Device platform: $ARCH"
|
||||
fi
|
||||
}
|
||||
|
||||
copy_files() {
|
||||
cp -af $INSTALLER/common/util_functions.sh $MODPATH/util_functions.sh
|
||||
if [[ "$ARCH" == "x86" || "$ARCH" == "x64" ]]; then
|
||||
ui_print "- Removing arm/arm64 libraries"
|
||||
rm -rf "$MODPATH/system/lib"
|
||||
rm -rf "$MODPATH/system/lib64"
|
||||
ui_print "- Extracting x86/64 libraries"
|
||||
unzip -o "$ZIP" 'system_x86/*' -d $MODPATH >&2
|
||||
mv "$MODPATH/system_x86/lib" "$MODPATH/system/lib"
|
||||
mv "$MODPATH/system_x86/lib64" "$MODPATH/system/lib64"
|
||||
fi
|
||||
|
||||
if [[ "$IS64BIT" = false ]]; then
|
||||
ui_print "- Removing 64-bit libraries"
|
||||
rm -rf "$MODPATH/system/lib64"
|
||||
fi
|
||||
|
||||
ui_print "- Extracting extra files"
|
||||
unzip -o "$ZIP" 'data/*' -d "$MODPATH" >&2
|
||||
|
||||
TARGET="/data/misc/riru/modules"
|
||||
|
||||
# TODO: do not overwrite if file exists
|
||||
[[ -d "$TARGET" ]] || mkdir -p "$TARGET" || fail "- Can't mkdir -p $TARGET"
|
||||
cp -af "$MODPATH$TARGET/." "$TARGET" || fail "- Can't cp -af $MODPATH$TARGET/. $TARGET"
|
||||
|
||||
rm -rf "$MODPATH/data" 2>/dev/null
|
||||
|
||||
ui_print "- Files copied"
|
||||
}
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
##########################################################################################
|
||||
#
|
||||
# Magisk Module Installer Script
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
#
|
||||
# Instructions:
|
||||
#
|
||||
# 1. Place your files into system folder (delete the placeholder file)
|
||||
# 2. Fill in your module's info into module.prop
|
||||
# 3. Configure and implement callbacks in this file
|
||||
# 4. If you need boot scripts, add them into common/post-fs-data.sh or common/service.sh
|
||||
# 5. Add your additional or modified system properties into common/system.prop
|
||||
#
|
||||
##########################################################################################
|
||||
|
||||
##########################################################################################
|
||||
# Config Flags
|
||||
##########################################################################################
|
||||
|
||||
# Set to true if you do *NOT* want Magisk to mount
|
||||
# any files for you. Most modules would NOT want
|
||||
# to set this flag to true
|
||||
SKIPMOUNT=false
|
||||
|
||||
# Set to true if you need to load system.prop
|
||||
PROPFILE=true
|
||||
|
||||
# Set to true if you need post-fs-data script
|
||||
POSTFSDATA=true
|
||||
|
||||
# Set to true if you need late_start service script
|
||||
LATESTARTSERVICE=false
|
||||
|
||||
##########################################################################################
|
||||
# Replace list
|
||||
##########################################################################################
|
||||
|
||||
# List all directories you want to directly replace in the system
|
||||
# Check the documentations for more info why you would need this
|
||||
|
||||
# Construct your list in the following format
|
||||
# This is an example
|
||||
REPLACE_EXAMPLE="
|
||||
/system/app/Youtube
|
||||
/system/priv-app/SystemUI
|
||||
/system/priv-app/Settings
|
||||
/system/framework
|
||||
"
|
||||
|
||||
# Construct your own list here
|
||||
REPLACE="
|
||||
"
|
||||
|
||||
##########################################################################################
|
||||
#
|
||||
# Function Callbacks
|
||||
#
|
||||
# The following functions will be called by the installation framework.
|
||||
# You do not have the ability to modify update-binary, the only way you can customize
|
||||
# installation is through implementing these functions.
|
||||
#
|
||||
# When running your callbacks, the installation framework will make sure the Magisk
|
||||
# internal busybox path is *PREPENDED* to PATH, so all common commands shall exist.
|
||||
# Also, it will make sure /data, /system, and /vendor is properly mounted.
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
#
|
||||
# The installation framework will export some variables and functions.
|
||||
# You should use these variables and functions for installation.
|
||||
#
|
||||
# ! DO NOT use any Magisk internal paths as those are NOT public API.
|
||||
# ! DO NOT use other functions in util_functions.sh as they are NOT public API.
|
||||
# ! Non public APIs are not guranteed to maintain compatibility between releases.
|
||||
#
|
||||
# Available variables:
|
||||
#
|
||||
# MAGISK_VER (string): the version string of current installed Magisk
|
||||
# MAGISK_VER_CODE (int): the version code of current installed Magisk
|
||||
# BOOTMODE (bool): true if the module is currently installing in Magisk Manager
|
||||
# MODPATH (path): the path where your module files should be installed
|
||||
# TMPDIR (path): a place where you can temporarily store files
|
||||
# ZIPFILE (path): your module's installation zip
|
||||
# ARCH (string): the architecture of the device. Value is either arm, arm64, x86, or x64
|
||||
# IS64BIT (bool): true if $ARCH is either arm64 or x64
|
||||
# API (int): the API level (Android version) of the device
|
||||
#
|
||||
# Availible functions:
|
||||
#
|
||||
# ui_print <msg>
|
||||
# print <msg> to console
|
||||
# Avoid using 'echo' as it will not display in custom recovery's console
|
||||
#
|
||||
# abort <msg>
|
||||
# print error message <msg> to console and terminate installation
|
||||
# Avoid using 'exit' as it will skip the termination cleanup steps
|
||||
#
|
||||
# set_perm <target> <owner> <group> <permission> [context]
|
||||
# if [context] is empty, it will default to "u:object_r:system_file:s0"
|
||||
# this function is a shorthand for the following commands
|
||||
# chown owner.group target
|
||||
# chmod permission target
|
||||
# chcon context target
|
||||
#
|
||||
# set_perm_recursive <directory> <owner> <group> <dirpermission> <filepermission> [context]
|
||||
# if [context] is empty, it will default to "u:object_r:system_file:s0"
|
||||
# for all files in <directory>, it will call:
|
||||
# set_perm file owner group filepermission context
|
||||
# for all directories in <directory> (including itself), it will call:
|
||||
# set_perm dir owner group dirpermission context
|
||||
#
|
||||
##########################################################################################
|
||||
##########################################################################################
|
||||
# If you need boot scripts, DO NOT use general boot scripts (post-fs-data.d/service.d)
|
||||
# ONLY use module scripts as it respects the module status (remove/disable) and is
|
||||
# guaranteed to maintain the same behavior in future Magisk releases.
|
||||
# Enable boot scripts by setting the flags in the config section above.
|
||||
##########################################################################################
|
||||
|
||||
RIRU_PATH="/data/misc/riru"
|
||||
|
||||
print_modname() {
|
||||
ui_print "*******************************"
|
||||
ui_print "* Riru - Ed Xposed *"
|
||||
ui_print "*******************************"
|
||||
}
|
||||
|
||||
check_riru_version() {
|
||||
[[ ! -f "$RIRU_PATH/api_version" ]] && abort "! Please Install Riru - Core v19 or above"
|
||||
VERSION=$(cat "$RIRU_PATH/api_version")
|
||||
ui_print "- Riru API version is $VERSION"
|
||||
[[ "$VERSION" -ge 4 ]] || abort "! Please Install Riru - Core v19 or above"
|
||||
}
|
||||
|
||||
check_architecture() {
|
||||
if [[ "$ARCH" != "arm" && "$ARCH" != "arm64" && "$ARCH" != "x86" && "$ARCH" != "x64" ]]; then
|
||||
abort "! Unsupported platform: $ARCH"
|
||||
else
|
||||
ui_print "- Device platform: $ARCH"
|
||||
fi
|
||||
}
|
||||
|
||||
on_install() {
|
||||
check_architecture
|
||||
check_riru_version
|
||||
|
||||
if [[ "$ARCH" == "x86" || "$ARCH" == "x64" ]]; then
|
||||
ui_print "- Extracting x86/64 libraries"
|
||||
unzip -o "$ZIPFILE" 'system_x86/*' -d $MODPATH >&2
|
||||
mv "$MODPATH/system_x86/lib" "$MODPATH/system/lib"
|
||||
mv "$MODPATH/system_x86/lib64" "$MODPATH/system/lib64"
|
||||
else
|
||||
ui_print "- Extracting arm/arm64 libraries"
|
||||
unzip -o "$ZIPFILE" 'system/*' -d $MODPATH >&2
|
||||
fi
|
||||
|
||||
if [[ "$IS64BIT" = false ]]; then
|
||||
ui_print "- Removing 64-bit libraries"
|
||||
rm -rf "$MODPATH/system/lib64"
|
||||
fi
|
||||
|
||||
TARGET="$RIRU_PATH/modules"
|
||||
|
||||
ui_print "- Extracting extra files"
|
||||
unzip -o "$ZIPFILE" 'data/*' -d "$TMPDIR" >&2
|
||||
|
||||
[[ -d "$TARGET" ]] || mkdir -p "$TARGET" || abort "! Can't mkdir -p $TARGET"
|
||||
cp -af "$TMPDIR$TARGET/." "$TARGET" || abort "! Can't cp -af $TMPDIR$TARGET/. $TARGET"
|
||||
|
||||
ui_print "- Files copied"
|
||||
}
|
||||
|
||||
set_permissions() {
|
||||
# The following is the default rule, DO NOT remove
|
||||
set_perm_recursive $MODPATH 0 0 0755 0644
|
||||
|
||||
# Here are some examples:
|
||||
# set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
|
||||
# set_perm $MODPATH/system/bin/app_process32 0 2000 0755 u:object_r:zygote_exec:s0
|
||||
# set_perm $MODPATH/system/bin/dex2oat 0 2000 0755 u:object_r:dex2oat_exec:s0
|
||||
# set_perm $MODPATH/system/lib/libart.so 0 0 0644
|
||||
}
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
#!/sbin/sh
|
||||
|
||||
rm -r -f /data/misc/riru/modules/edxposed/
|
||||
rm -r -f /data/misc/riru/modules/edxp/
|
||||
|
|
@ -3,5 +3,5 @@ name=Riru - Ed Xposed
|
|||
version=${versionName}
|
||||
versionCode=${versionCode}
|
||||
author=${authorList}
|
||||
description=Magisk version of Xposed. Require Riru - Core installed.
|
||||
minMagisk=17000
|
||||
description=Magisk version of Xposed. Require Riru - Core v19+ installed.
|
||||
api=4
|
||||
|
|
|
|||
Loading…
Reference in New Issue