From 4f1bc258b1cc75a600f76ef0907c2c0c44718d04 Mon Sep 17 00:00:00 2001 From: RikkaW Date: Wed, 8 Jan 2020 00:23:39 +0800 Subject: [PATCH] update README --- README.md | 62 ++++----------------------------------------- README.zh-CN.md | 62 +++++---------------------------------------- module/build.gradle | 6 ++--- 3 files changed, 14 insertions(+), 116 deletions(-) diff --git a/README.md b/README.md index 433bc9fb..df294cbd 100644 --- a/README.md +++ b/README.md @@ -4,8 +4,6 @@ Riru is a very simple but useful thing. Only requires to replace one system file The name Riru comes from a character. (https://www.pixiv.net/member_illust.php?mode=medium&illust_id=74128856) -[中文说明](https://github.com/RikkaApps/Riru/blob/master/README.zh-CN.md) - ## Requirements * Rooted Android 6.0+ devices @@ -27,64 +25,14 @@ Then we can call `RegisterNatives` again to replace them. There is only one `libmemtrack.so`, if someone wants to do something by replacing it, others can't. So I made Riru occupy libmemtrack but provide the ability to make modules. -## Build Requirements - -Android NDK (add the directory with `ndk-build` to `PATH`) - -## Build core - -* Magisk Module - - Run `:riru-core:assembleMagiskRelease` task in the command line (use `gradlew`) or Android Studio, zip will be saved to `release` - -## Build your own module - -1. Copy `riru-module-template` and rename to your name -2. Change module name in `riru-your-module/jni/main/Android.mk` -3. Change module information in `build.gradle` -4. Write your code -5. Run `:riru-your-module:assembleMagiskRelease` task in command line (use `gradlew`) or Android Studio, zip will be saved to `release` - -## Where your own module needs attention - -* DO NOT overwrite `android.os.SystemProperties#native_set` in core, or your data may be wiped - ([Detail info](https://github.com/RikkaApps/Riru/blob/v7/riru-core/jni/main/jni_native_method.cpp#L162-L176)) - (If you really need to hook this, remember to clear exception) -* DO NO print log (`__android_log_print`) in `nativeForkAndSpecialize(Pre/Post)` `nativeForkSystemServer(Pre/Post)` when in zygote process, or it may cause zygote not work - (magic not confirmed, [Detail info](https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66)) -* Add `-ffixed-x18` to both compiler and linker parameter, or it will cause problems on Android Q (see template) +## Build -## Riru API - -* Currently, one module version can only support one API version -* See template for details - -### v4 (core v19+) - -* Add `api=4` to `riru_module.prop` to declare API version -* Check and deny installation if Riru version is below v19 in `config.sh` -* Add `specializeAppProcessPre` `specializeAppProcessPost` used by Android Q beta 3 (see template) - -### v3 (core v18+) - -* Add `api=3` to `riru_module.prop` to declare API version -* Check and deny installation if Riru version is below v18 in `config.sh` -* Parameter of `nativeForkAndSpecializePre` changes (compare to v2, added `jstring *packageName, jobjectArray *packagesForUID, jstring *sandboxId` in the end) - -### v2 (core v16-v17.1) - -* Export `int getApiVersion() { return 2; }` to declare API version -* Parameter of `nativeForkAndSpecializePre` changes (compare to v1, all parameter is pointer) +Run gradle task `:module:assembleRelease` task from Android Studio or command line, zip will be saved to `out`. ## Install -Current only support Magisk. - -1. Install core zip in Magisk -2. Install module zip in Magisk - -## Modules +Install zip in Magisk Manager. -[Riru-LocationReportEnabler](https://github.com/RikkaApps/Riru-LocationReportEnabler) (also a good example) +## Create your own module -[Riru-EdXposed](https://github.com/ElderDrivers/EdXposed) (port Xposed to Android P & Q) +[View template](https://github.com/RikkaApps/Riru-Template) \ No newline at end of file diff --git a/README.zh-CN.md b/README.zh-CN.md index 40176cd7..95a51979 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -7,7 +7,7 @@ Riru 这个名字来自 https://www.pixiv.net/member_illust.php?mode=medium&illu ## 需求 * Root 过的 Android 6.0+ 设备 -* Magisk (用于替换系统文件,暂时只提供 Magisk zip,当然你也可以直接去换文件) +* Magisk (用于替换系统文件,暂时只提供 Magisk zip) ## 她怎么工作呢? @@ -24,64 +24,14 @@ JNI 函数 (`com.android.internal.os.Zygote#nativeForkAndSpecialize` & `com.andr 因为 `libmemtrack.so` 只有一个,如果有人想用替换 libmemtrack 的套路来做点什么别人就做不了。所以就制造了 Riru 来占下 libmemtrack 但是提供了模块这样的东西。 -## 构建需求 +## 构建 -Android NDK (把有 `ndk-build` 的目录加到 `PATH`) - -## 构建 core - -* Magisk 模块 - - 在命令行 (用 `gradlew`) 或者 Android Studio 执行 `:riru-core:assembleMagiskRelease`,zip 会被存到 `release` - -## 构建你自己的模块 - -1. 复制 `riru-module-template` 并重命名 -2. 在 `riru-your-module/jni/main/Android.mk` 中修改模块名字 -3. 在 `build.gradle` 修改模块信息 -4. 发明你自己的魔法( -5. 直接在命令行 (用 `gradlew`) 或者 Android Studio 执行 `:riru-your-module:assembleMagiskRelease`,zip 会被存到 `release` - -## 自己的模块需要注意的地方 - -* 不要掩盖 core 中 hook 的 `android.os.SystemProperties#native_set`, - 否则在 Android P 以上可能导致数据抹除([详细信息](https://github.com/RikkaApps/Riru/blob/v7/riru-core/jni/main/jni_native_method.cpp#L162-L176))(如果一定要 hook 则要记得清掉异常) -* 不要在 `nativeForkAndSpecialize(Pre/Post)` `nativeForkSystemServer(Pre/Post)` 中在还处于 zygote 进程时输出 log(`__android_log_print`), - 否则可能导致 zygote 不工作(未确定的魔法,[详细信息](https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66)) -* 编译时需要为编译和链接指令加上 `-ffixed-x18`,否则在 Android Q 上会产生问题(参考 template) - -## Riru API - -* 目前,一个模块版本只可支持一个 API 版本 -* 看 template 来知道具体做法 - -### v4 (core v19+) - -* 在 `riru_module.prop` 加入 `api=4` 来声明 API 版本 -* 在 `config.sh` 检查并拒绝在 Riru v19 以下安装 -* 增加 Android Q beta 3 使用的 `specializeAppProcessPre` `specializeAppProcessPost`(请参看 template) - -### v3 (core v18+) - -* 在 `riru_module.prop` 加入 `api=3` 来声明 API 版本 -* 在 `config.sh` 检查并拒绝在 Riru v18 以下安装 -* `nativeForkAndSpecializePre` 参数变化(相对 v2,末尾增加 `jstring *packageName, jobjectArray *packagesForUID, jstring *sandboxId`) - -### v2 (core v16-v17.1) - -* 导出 `int getApiVersion() { return 2; }` 来声明版本号 -* `nativeForkAndSpecializePre` 参数变化(相对 v1,所有参数都是指针) -* 加入 `shouldSkipUid` +在 Android Studio 或命令行执行 gradle task `:riru-core:assembleMagiskRelease`,zip 会被存到 `release`。 ## 安装 -目前只支持 Magisk - -1. Install core zip in Magisk -2. Install module zip in Magisk - -## 模块 +在 Magisk Manager 中安装 zip。 -[Riru-LocationReportEnabler](https://github.com/RikkaApps/Riru-LocationReportEnabler) (also a good example) +## 创造你自己的模块 -[Riru-EdXposed](https://github.com/ElderDrivers/EdXposed) (port Xposed to Android P & Q) +[查看模板](https://github.com/RikkaApps/Riru-Template) \ No newline at end of file diff --git a/module/build.gradle b/module/build.gradle index 5f201445..0e6f179a 100644 --- a/module/build.gradle +++ b/module/build.gradle @@ -30,7 +30,7 @@ def zipName = "magisk-${moduleProp['id']}-${moduleProp['version']}.zip" import java.nio.file.Files import java.security.MessageDigest -static def calcSha1(file) { +static def sha256sum(file) { def md = MessageDigest.getInstance("SHA-256") file.eachByte 4096, { bytes, size -> md.update(bytes, 0, size); @@ -38,7 +38,7 @@ static def calcSha1(file) { return md.digest().encodeHex() } -static def renameOrFail(File from, File to) { +static def renameOrFail(from, to) { if (!from.renameTo(to)) { throw new IOException("Unable reanme file $from to $to") } @@ -90,7 +90,7 @@ android.libraryVariants.all { variant -> exclude "README.md", "META-INF" }.visit { f -> if (f.directory) return - file(f.file.path + ".sha256sum").text = calcSha1(f.file) + file(f.file.path + ".sha256sum").text = sha256sum(f.file) } } task.finalizedBy zipMagiskMoudle