├── app
├── .gitignore
├── src
│ └── main
│ │ ├── res
│ │ ├── values
│ │ │ ├── strings.xml
│ │ │ ├── colors.xml
│ │ │ └── themes.xml
│ │ ├── mipmap-hdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-mdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-xxxhdpi
│ │ │ ├── ic_launcher.webp
│ │ │ └── ic_launcher_round.webp
│ │ ├── mipmap-anydpi
│ │ │ ├── ic_launcher.xml
│ │ │ └── ic_launcher_round.xml
│ │ ├── xml
│ │ │ ├── backup_rules.xml
│ │ │ └── data_extraction_rules.xml
│ │ ├── values-night
│ │ │ └── themes.xml
│ │ └── drawable
│ │ │ ├── ic_launcher_foreground.xml
│ │ │ └── ic_launcher_background.xml
│ │ └── AndroidManifest.xml
├── proguard-rules.pro
└── build.gradle
├── module
├── .gitignore
├── consumer-rules.pro
├── magisk_module
│ ├── common
│ │ ├── install.sh
│ │ ├── addon
│ │ │ └── placeholder
│ │ └── functions.sh
│ ├── .gitignore
│ ├── META-INF
│ │ └── com
│ │ │ └── google
│ │ │ └── android
│ │ │ ├── updater-script
│ │ │ └── update-binary
│ ├── module.prop
│ ├── update.json
│ ├── .gitattributes
│ ├── uninstall.sh
│ └── customize.sh
├── src
│ └── main
│ │ ├── AndroidManifest.xml
│ │ └── cpp
│ │ ├── third
│ │ ├── log2file
│ │ │ ├── CMakeLists.txt
│ │ │ ├── app_file_writer.cpp
│ │ │ └── app_file_writer.h
│ │ ├── CMakeLists.txt
│ │ └── utils
│ │ │ ├── java_vm.cpp
│ │ │ ├── wait_group.h
│ │ │ ├── map_helper.h
│ │ │ ├── stack.asm
│ │ │ ├── meminfo.h
│ │ │ ├── log.cpp
│ │ │ ├── macro_helper.h
│ │ │ ├── thread_poool.h
│ │ │ ├── meminfo.cpp
│ │ │ ├── linux_helper.h
│ │ │ ├── utils.h
│ │ │ ├── log.h
│ │ │ ├── jni_helper.cpp
│ │ │ ├── java_vm.h
│ │ │ ├── utils.cpp
│ │ │ ├── linux_helper.cpp
│ │ │ └── jni_helper.hpp
│ │ ├── CMakeLists.txt
│ │ ├── example.cpp
│ │ └── zygisk.hpp
├── proguard-rules.pro
├── build.gradle
└── make_plug.gradle
├── gradle
├── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
└── libs.versions.toml
├── README.md
├── .gitignore
├── settings.gradle
├── gradle.properties
├── gradlew.bat
└── gradlew
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module/.gitignore:
--------------------------------------------------------------------------------
1 | /build
--------------------------------------------------------------------------------
/module/consumer-rules.pro:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module/magisk_module/common/install.sh:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module/magisk_module/common/addon/placeholder:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/module/magisk_module/.gitignore:
--------------------------------------------------------------------------------
1 | __MACOSX
2 | .DS_Store
3 |
--------------------------------------------------------------------------------
/module/magisk_module/META-INF/com/google/android/updater-script:
--------------------------------------------------------------------------------
1 | #MAGISK
2 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | jni_trace
3 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/xbyl1234/jni_trace/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.webp
--------------------------------------------------------------------------------
/module/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/module/magisk_module/module.prop:
--------------------------------------------------------------------------------
1 | id=jni_trace
2 | name=jni_trace
3 | version=v3.7
4 | versionCode=19
5 | author=jni_trace
6 | description=jni_trace
7 | updateJson=https://raw.githubusercontent.com/Zackptg5/MMT-Extended/master/update.json
8 |
--------------------------------------------------------------------------------
/module/magisk_module/update.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": "v3.6",
3 | "versionCode": 18,
4 | "zipUrl": "https://raw.githubusercontent.com/Zackptg5/MMT-Extended/install.zip",
5 | "changelog": "https://raw.githubusercontent.com/Zackptg5/MMT-Extended/changelog.md"
6 | }
--------------------------------------------------------------------------------
/module/src/main/cpp/third/log2file/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.28.0+)
2 | project("log2file")
3 |
4 | file(GLOB log2file_src
5 | "*.h"
6 | "*.cpp"
7 | "*.c")
8 |
9 | add_library(log2file
10 | STATIC
11 | ${log2file_src})
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 20 15:19:49 CST 2025
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
5 | zipStoreBase=GRADLE_USER_HOME
6 | zipStorePath=wrapper/dists
7 |
--------------------------------------------------------------------------------
/module/magisk_module/.gitattributes:
--------------------------------------------------------------------------------
1 | # Declare files that will always have LF line endings on checkout.
2 | *.sh text eol=lf
3 | *.prop text eol=lf
4 | *.md text eol=lf
5 | *.xml text eol=lf
6 | META-INF/** text eol=lf
7 |
8 | # Denote all files that are truly binary and should not be modified.
9 | common/addon/**/tools/** binary
10 |
--------------------------------------------------------------------------------
/module/src/main/cpp/third/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.28.0+)
2 | project("third")
3 | enable_language(ASM)
4 |
5 | file(GLOB utils_src
6 | "utils/*.h"
7 | "utils/*.cpp"
8 | "utils/*.c"
9 | "utils/*.asm"
10 | )
11 |
12 | add_library(libutils
13 | STATIC
14 | ${utils_src})
15 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-anydpi/ic_launcher_round.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #FFBB86FC
4 | #FF6200EE
5 | #FF3700B3
6 | #FF03DAC5
7 | #FF018786
8 | #FF000000
9 | #FFFFFFFF
10 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 代码
6 | 没有
7 | 同步
8 | 最新
9 | 代码
10 | 查看
11 | android_analysis
12 | 仓库
13 | 自行
14 | 同步
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 | 直接编译, 模块生成在out目录
24 | 需要删除postAppSpecialize(const AppSpecializeArgs *args)中我调试其他app的代码
25 | 需要在jni_trace.cpp
26 | JNIEXPORT jboolean JNICALL init(JNIEnv *env, jclass frida_helper)函数中配置你目标so
27 |
28 | 疯狂星期四 v我50
29 | 我是秦始皇 v我50封你为大牛马
30 |
31 | 哦对了 需要一个frida_helper.dex 在我另一个项目里面 android_analysis 编译安装给root就写到对应目录了
32 |
--------------------------------------------------------------------------------
/module/magisk_module/uninstall.sh:
--------------------------------------------------------------------------------
1 | # Don't modify anything after this
2 | if [ -f $INFO ]; then
3 | while read LINE; do
4 | if [ "$(echo -n $LINE | tail -c 1)" == "~" ]; then
5 | continue
6 | elif [ -f "$LINE~" ]; then
7 | mv -f $LINE~ $LINE
8 | else
9 | rm -f $LINE
10 | while true; do
11 | LINE=$(dirname $LINE)
12 | [ "$(ls -A $LINE 2>/dev/null)" ] && break 1 || rm -rf $LINE
13 | done
14 | fi
15 | done < $INFO
16 | rm -f $INFO
17 | fi
--------------------------------------------------------------------------------
/app/src/main/res/xml/backup_rules.xml:
--------------------------------------------------------------------------------
1 |
8 |
9 |
13 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/caches
5 | /.idea/libraries
6 | /.idea/modules.xml
7 | /.idea/workspace.xml
8 | /.idea/navEditor.xml
9 | /.idea/assetWizardSettings.xml
10 | .DS_Store
11 | /build
12 | /captures
13 | .externalNativeBuild
14 | .cxx
15 | local.properties
16 | /.idea/.gitignore
17 | /.idea/compiler.xml
18 | /.idea/deploymentTargetSelector.xml
19 | /.idea/gradle.xml
20 | /.idea/migrations.xml
21 | /.idea/misc.xml
22 | /.idea/runConfigurations.xml
23 | /.idea/vcs.xml
24 | /module/libs/arm64-v8a/libanalyse.so
25 | /module/magisk_module/zygisk/arm64-v8a.so
26 | /module/out/output.zip
27 |
--------------------------------------------------------------------------------
/app/src/main/res/xml/data_extraction_rules.xml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
12 |
13 |
19 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | pluginManagement {
2 | repositories {
3 | google {
4 | content {
5 | includeGroupByRegex("com\\.android.*")
6 | includeGroupByRegex("com\\.google.*")
7 | includeGroupByRegex("androidx.*")
8 | }
9 | }
10 | mavenCentral()
11 | gradlePluginPortal()
12 | }
13 | }
14 | dependencyResolutionManagement {
15 | repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
16 | repositories {
17 | google()
18 | mavenCentral()
19 | }
20 | }
21 |
22 | rootProject.name = "jni_trace"
23 | include ':app'
24 | include ':module'
25 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
15 |
16 |
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/java_vm.cpp:
--------------------------------------------------------------------------------
1 | //#include
2 | //#include "../dlfc/dlfcn_nougat.h"
3 | //
4 | //JNIEnv *g_tls_jnienv = nullptr;
5 | //
6 | //JNIEnv *get_jni_env() {
7 | // if (!g_tls_jnienv) {
8 | // elf_info *dlctx = fake_dlopen("libandroid_runtime.so", 0);
9 | // if (dlctx) {
10 | // typedef JNIEnv *(*getJNIEnv_t)();
11 | // getJNIEnv_t getJNIEnv = (getJNIEnv_t) fake_dlsym(dlctx,
12 | // "_ZN7android14AndroidRuntime9getJNIEnvEv");
13 | // if (getJNIEnv)
14 | // g_tls_jnienv = getJNIEnv();
15 | // fake_dlclose(dlctx);
16 | // }
17 | // }
18 | // return g_tls_jnienv;
19 | //}
--------------------------------------------------------------------------------
/module/magisk_module/META-INF/com/google/android/update-binary:
--------------------------------------------------------------------------------
1 | #!/sbin/sh
2 |
3 | #################
4 | # Initialization
5 | #################
6 |
7 | umask 022
8 |
9 | # echo before loading util_functions
10 | ui_print() { echo "$1"; }
11 |
12 | require_new_magisk() {
13 | ui_print "*******************************"
14 | ui_print " Please install Magisk v20.4+! "
15 | ui_print "*******************************"
16 | exit 1
17 | }
18 |
19 | #########################
20 | # Load util_functions.sh
21 | #########################
22 |
23 | OUTFD=$2
24 | ZIPFILE=$3
25 |
26 | mount /data 2>/dev/null
27 |
28 | [ -f /data/adb/magisk/util_functions.sh ] || require_new_magisk
29 | . /data/adb/magisk/util_functions.sh
30 | [ $MAGISK_VER_CODE -lt 20400 ] && require_new_magisk
31 |
32 | install_module
33 | exit 0
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/module/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # You can control the set of applied configuration files using the
3 | # proguardFiles setting in build.gradle.
4 | #
5 | # For more details, see
6 | # http://developer.android.com/guide/developing/tools/proguard.html
7 |
8 | # If your project uses WebView with JS, uncomment the following
9 | # and specify the fully qualified class name to the JavaScript interface
10 | # class:
11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
12 | # public *;
13 | #}
14 |
15 | # Uncomment this to preserve the line number information for
16 | # debugging stack traces.
17 | #-keepattributes SourceFile,LineNumberTable
18 |
19 | # If you keep the line number information, uncomment this to
20 | # hide the original source file name.
21 | #-renamesourcefileattribute SourceFile
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/wait_group.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 |
8 | using std::atomic;
9 | using std::mutex;
10 | using std::shared_ptr;
11 | using std::condition_variable;
12 |
13 | class _WaitGroup {
14 | public:
15 | _WaitGroup() : count(0) {}
16 |
17 | void add(int n = 1) {
18 | count += n;
19 | }
20 |
21 | void done() {
22 | --count;
23 | if (count == 0) { cv.notify_all(); }
24 | }
25 |
26 | void wait() {
27 | std::unique_lock lock(mtx);
28 | while (count > 0) {
29 | cv.wait(lock);
30 | }
31 | }
32 |
33 | private:
34 | std::atomic count;
35 | std::mutex mtx;
36 | std::condition_variable cv;
37 | };
38 |
39 | using WaitGroup = shared_ptr<_WaitGroup>;
--------------------------------------------------------------------------------
/app/src/main/res/values/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/app/src/main/res/values-night/themes.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
16 |
--------------------------------------------------------------------------------
/module/src/main/cpp/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 3.28.0+)
2 | project("jni_trace")
3 | set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${ANDROID_ABI}")
4 | set(CXX_FLAGS "${CXX_FLAGS} -std=c++20 -fno-exceptions -fno-rtti -fvisibility=hidden -fvisibility-inlines-hidden")
5 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS}")
6 |
7 | enable_language(ASM)
8 |
9 | find_library(log-lib log)
10 | find_package(cxx REQUIRED CONFIG)
11 | link_libraries(cxx::cxx)
12 |
13 | add_subdirectory(third/log2file)
14 | add_subdirectory(./third)
15 |
16 | file(GLOB analyse_src
17 | "*.h"
18 | "*.hpp"
19 | "*.cpp"
20 | )
21 |
22 | add_library(
23 | analyse
24 | SHARED
25 | ${analyse_src}
26 | )
27 |
28 | target_link_libraries(
29 | analyse
30 | libutils
31 | log2file
32 | ${log-lib}
33 | )
--------------------------------------------------------------------------------
/gradle/libs.versions.toml:
--------------------------------------------------------------------------------
1 | [versions]
2 | agp = "8.8.2"
3 | junit = "4.13.2"
4 | junitVersion = "1.2.1"
5 | espressoCore = "3.6.1"
6 | appcompat = "1.7.1"
7 | material = "1.12.0"
8 |
9 | [libraries]
10 | junit = { group = "junit", name = "junit", version.ref = "junit" }
11 | ext-junit = { group = "androidx.test.ext", name = "junit", version.ref = "junitVersion" }
12 | espresso-core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espressoCore" }
13 | appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
14 | material = { group = "com.google.android.material", name = "material", version.ref = "material" }
15 |
16 | cxx = { module = "org.lsposed.libcxx:libcxx", version = "27.0.12077973" }
17 |
18 | [plugins]
19 | android-application = { id = "com.android.application", version.ref = "agp" }
20 | android-library = { id = "com.android.library", version.ref = "agp" }
21 |
22 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | alias(libs.plugins.android.application)
3 | }
4 |
5 | android {
6 | namespace 'com.jni_trace'
7 | compileSdk 35
8 |
9 | defaultConfig {
10 | applicationId "com.jni_trace"
11 | minSdk 27
12 | targetSdk 35
13 | versionCode 1
14 | versionName "1.0"
15 |
16 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
17 | }
18 |
19 | buildTypes {
20 | release {
21 | minifyEnabled false
22 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
23 | }
24 | }
25 | compileOptions {
26 | sourceCompatibility JavaVersion.VERSION_11
27 | targetCompatibility JavaVersion.VERSION_11
28 | }
29 | }
30 |
31 | dependencies {
32 | implementation libs.appcompat
33 | implementation libs.material
34 | implementation project(path: ':module')
35 | }
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/map_helper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 |
12 | class FileMapHelper {
13 | int fd;
14 | struct stat sb;
15 | void *mapped;
16 |
17 | void *MapFile(const std::string &filePath) {
18 | if ((fd = open(filePath.c_str(), O_RDWR)) < 0) {
19 | return nullptr;
20 | }
21 |
22 | if ((fstat(fd, &sb)) == -1) {
23 | }
24 |
25 | mapped = mmap(NULL, sb.st_size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
26 | if (mapped == (void *) -1) {
27 | }
28 | return mapped;
29 | }
30 |
31 | bool FlushMap() {
32 | return msync((void *) mapped, sb.st_size, MS_SYNC) == -1;
33 | }
34 |
35 | bool Close() {
36 | return munmap((void *) mapped, sb.st_size)) == -1
37 | }
38 | };
39 |
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/stack.asm:
--------------------------------------------------------------------------------
1 | .text
2 | .arch arm64v8a
3 | .global get_call_stack
4 | .type get_call_stack,%function
5 | get_call_stack:
6 | stp x29, x30, [sp, #-0x10]! // 保存帧指针和返回地址
7 | stp x19, x20, [sp, #-0x10]! // 保存被调用者寄存器
8 | stp x21, x22, [sp, #-0x10]! // 保存被调用者寄存器
9 |
10 | mov x19, x0 // X19 保存数组地址
11 | mov x20, #0 // 初始化计数器
12 | mov x21, x29 // 当前帧指针
13 | mov x22, x30 // 当前返回地址
14 |
15 | loop:
16 | cmp x20, #10
17 | bge done // 达到 10 层,退出
18 |
19 | mov x0, x21
20 | bl check_stack
21 | cbz x0, done // 内存不可读,退出
22 |
23 | xpaclri // 清除 PAC
24 |
25 | str x22, [x19, x20, lsl #3] // 保存返回地址到 stack[i]
26 | ldr x21, [x21] // 获取上一帧指针
27 | ldr x22, [x21, #8] // 获取上一帧返回地址
28 |
29 | add x20, x20, #1
30 | b loop
31 |
32 | done:
33 | mov x0, x20
34 | ldp x21, x22, [sp], 0x10
35 | ldp x19, x20, [sp], 0x10
36 | ldp x29, x30, [sp], 0x10
37 | ret
38 | .end
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/meminfo.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | struct MemInfo {
6 | int MemTotal;
7 | int MemFree;
8 | int MemAvailable;
9 | int Buffers;
10 | int Cached;
11 | int SwapCached;
12 | int Active;
13 | int Inactive;
14 | int Active_anon;
15 | int Inactive_anon;
16 | int Active_file;
17 | int Inactive_file;
18 | int Unevictable;
19 | int Mlocked;
20 | int SwapTotal;
21 | int SwapFree;
22 | int Dirty;
23 | int Writeback;
24 | int AnonPages;
25 | int Mapped;
26 | int Shmem;
27 | int Slab;
28 | int SReclaimable;
29 | int SUnreclaim;
30 | int KernelStack;
31 | int PageTables;
32 | int NFS_Unstable;
33 | int Bounce;
34 | int WritebackTmp;
35 | int CommitLimit;
36 | int Committed_AS;
37 | int VmallocTotal;
38 | int VmallocUsed;
39 | int VmallocChunk;
40 | int CmaTotal;
41 | int CmaFree;
42 | };
43 |
44 | bool GetMemInfo(const std::string &path, MemInfo *memInfo);
45 |
46 | bool GetMemInfo(const std::string &path, MemInfo *memInfo, int maxLine);
47 |
48 |
49 |
--------------------------------------------------------------------------------
/module/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'com.android.library'
3 | }
4 |
5 | apply from: "./make_plug.gradle"
6 |
7 | android {
8 | namespace 'com.jni_trace'
9 | compileSdk 34
10 | ndkVersion '27.0.12077973'
11 | defaultConfig {
12 | minSdk 21
13 | targetSdk 35
14 | externalNativeBuild {
15 | cmake {
16 | cppFlags '-std=c++20'
17 | arguments '-DANDROID_STL=none'
18 | }
19 | }
20 | ndk {
21 | // abiFilters "armeabi-v7a"
22 | abiFilters "arm64-v8a"
23 | // abiFilters "x86_64"
24 | }
25 | }
26 | externalNativeBuild {
27 | cmake {
28 | path file('src/main/cpp/CMakeLists.txt')
29 | version "3.28.0+"
30 | }
31 | }
32 | buildFeatures {
33 | prefab true
34 | }
35 | tasks.configureEach { task ->
36 | if (task.name == 'copyDebugJniLibsProjectOnly' || task.name == 'assembleRelease') {
37 | task.doLast {
38 | project.BuildMagiskPlug()
39 | }
40 | }
41 | }
42 | }
43 |
44 | dependencies {
45 | implementation(libs.cxx)
46 | }
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/log.cpp:
--------------------------------------------------------------------------------
1 | #include "log.h"
2 | #include "utils.h"
3 |
4 | namespace xbyl {
5 | log defaultLog;
6 |
7 | void init_log(const string &tag, adapter *adapt) {
8 | if (adapt == nullptr) {
9 | defaultLog.enabled = false;
10 | return;
11 | }
12 | defaultLog.adapters.clear();
13 | defaultLog.set_adapt(adapt);
14 | defaultLog.setTag(tag);
15 | }
16 |
17 | // void init_log(const string &tag, vector> &adapt) {
18 | // defaultLog.adapters.clear();
19 | // defaultLog.adapters = std::move(adapt);
20 | // defaultLog.setTag(tag);
21 | // }
22 |
23 | void init_log(const string &tag) {
24 | defaultLog.setTag(tag);
25 | }
26 |
27 | void disable_adb_log() {
28 | for (const std::unique_ptr &item: defaultLog.adapters) {
29 | if (item->type == log_adapt::use_adb) {
30 | item->enabled = false;
31 | }
32 | }
33 | }
34 |
35 | void enable_adb_log() {
36 | for (const std::unique_ptr &item: defaultLog.adapters) {
37 | if (item->type == log_adapt::use_adb) {
38 | item->enabled = true;
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 | # IDE (e.g. Android Studio) users:
3 | # Gradle settings configured through the IDE *will override*
4 | # any settings specified in this file.
5 | # For more details on how to configure your build environment visit
6 | # http://www.gradle.org/docs/current/userguide/build_environment.html
7 | # Specifies the JVM arguments used for the daemon process.
8 | # The setting is particularly useful for tweaking memory settings.
9 | org.gradle.jvmargs=-Xmx2048m -Dfile.encoding=UTF-8
10 | # When configured, Gradle will run in incubating parallel mode.
11 | # This option should only be used with decoupled projects. For more details, visit
12 | # https://developer.android.com/r/tools/gradle-multi-project-decoupled-projects
13 | # org.gradle.parallel=true
14 | # AndroidX package structure to make it clearer which packages are bundled with the
15 | # Android operating system, and which are packaged with your app's APK
16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn
17 | android.useAndroidX=true
18 | # Enables namespacing of each library's R class so that its R class includes only the
19 | # resources declared in the library itself and none from the library's dependencies,
20 | # thereby reducing the size of the R class for that library
21 | android.nonTransitiveRClass=true
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/macro_helper.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define Symbol(lib, x) (decltype(lib##_##x))DobbySymbolResolver(#lib".so",#x)
4 | #define Symbol2(type, lib, name) (decltype(type))DobbySymbolResolver(lib,name)
5 | #define IsBit64 __x86_64__ || __arm64__ || __aarch64__
6 | #define IsBit32 __i386__ || __arm__
7 | #define IsArm64 __arm64__ || __aarch64__
8 | #define IsArm32 __arm__
9 | #define IsX86_64 __x86_64__
10 | #define IsX86_32 __i386__
11 | #define IsX86 __x86_64__||__i386__
12 | #define IsArm __arm__||__arm64__||__aarch64__
13 |
14 | #define InlineHook(lib, name, exportName) { \
15 | void* tmp_##name = DobbySymbolResolver(lib,#exportName); \
16 | if(tmp_##name == nullptr){ \
17 | loge("DobbySymbolResolver %s -> %s failed!!!",lib,#name); \
18 | } \
19 | int tmp2_##name = DobbyHook(tmp_##name,(dobby_dummy_func_t) Hook_##name,(dobby_dummy_func_t*) &p##name); \
20 | if(tmp2_##name== -1) { \
21 | loge("DobbyHook %s -> %s failed!!!",lib,#name); \
22 | } \
23 | }
--------------------------------------------------------------------------------
/module/src/main/cpp/third/log2file/app_file_writer.cpp:
--------------------------------------------------------------------------------
1 | #include "app_file_writer.h"
2 |
3 | app_file_writer logWriter;
4 |
5 | string getPkgName();
6 |
7 | string get_extern_data_path() {
8 | return "/sdcard/Android/data/" + getPkgName();
9 | }
10 |
11 | string get_data_path() {
12 | return "/data/data/" + getPkgName();
13 | }
14 |
15 | void log2file(const string &log) {
16 | if (!logWriter.is_open()) {
17 | logWriter.open(get_data_path(), "log");
18 | }
19 | logWriter.write2file(log);
20 | }
21 |
22 | void log2file(const char *fmt, ...) {
23 | va_list ap;
24 | va_start(ap, fmt);
25 | string result = xbyl::format_string(fmt, ap);
26 | va_end(ap);
27 | log2file(result);
28 | }
29 |
30 | extern "C"
31 | JNIEXPORT void JNICALL
32 | Java_com_android_analyse_hook_Native_nativeLog(JNIEnv *env, jclass clazz, jint level, jstring msg) {
33 | log2file(string(lsplant::JUTFString(env, msg).get()));
34 | }
35 |
36 | extern "C"
37 | JNIEXPORT jlong JNICALL
38 | Java_com_android_analyse_hook_Native_nativeOpenFile(JNIEnv *env, jclass clazz, jstring name) {
39 | return (int64_t) new app_file_writer(get_extern_data_path(), lsplant::JUTFString(env, name));
40 | }
41 |
42 | extern "C"
43 | JNIEXPORT void JNICALL
44 | Java_com_android_analyse_hook_Native_nativeWrite__JLjava_lang_String_2(JNIEnv *env, jclass clazz,
45 | jlong handle, jstring data) {
46 | auto obj = (app_file_writer *) handle;
47 | obj->write2file(lsplant::JUTFString(env, data));
48 | }
49 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/ic_launcher_foreground.xml:
--------------------------------------------------------------------------------
1 |
7 |
8 |
9 |
15 |
18 |
21 |
22 |
23 |
24 |
30 |
--------------------------------------------------------------------------------
/module/src/main/cpp/example.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 | #include
4 |
5 | #include "third/utils/utils.h"
6 | #include "third/utils/log.h"
7 | #include "third/utils/linux_helper.h"
8 | #include "zygisk.hpp"
9 |
10 | using namespace std;
11 | using zygisk::Api;
12 | using zygisk::AppSpecializeArgs;
13 | using zygisk::ServerSpecializeArgs;
14 |
15 |
16 | class MyModule : public zygisk::ModuleBase {
17 | public:
18 | void onLoad(Api *api, JNIEnv *env) override {
19 | this->api = api;
20 | this->env = env;
21 | }
22 |
23 | void preAppSpecialize(AppSpecializeArgs *args) override {
24 | const char *process = env->GetStringUTFChars(args->nice_name, nullptr);
25 | this->process = process;
26 | env->ReleaseStringUTFChars(args->nice_name, process);
27 | }
28 |
29 | void postAppSpecialize(const AppSpecializeArgs *args) {
30 | allowPkg = ReadFile("/data/pkg");
31 | if (allowPkg.empty()) {
32 | loge("pkg empty %d", errno);
33 | return;
34 | }
35 | allowPkg = replace_all(allowPkg, "\n", "");
36 | allowPkg = replace_all(allowPkg, "\r", "");
37 | if (process.find(allowPkg) == -1) {
38 | return;
39 | }
40 | auto handle = dlopen("/data/libanalyse.so", RTLD_NOW);
41 | if (handle != nullptr) {
42 | logi("inject to %s", process.c_str());
43 | } else {
44 | loge("inject to %s error %d", process.c_str(), errno);
45 | return;
46 | }
47 | void *inject_entry = dlsym(handle, "inject_entry");
48 | if (!inject_entry) {
49 | loge("inject_entry error %d", errno);
50 | return;
51 | }
52 | ((void (*)(JNIEnv *, const char *)) inject_entry)(env, this->process.c_str());
53 | }
54 |
55 | private:
56 | Api *api;
57 | JNIEnv *env;
58 | string process;
59 | string allowPkg;
60 | };
61 |
62 | static void companion_handler(int i) {
63 | }
64 |
65 | // Register our module class and the companion handler function
66 | REGISTER_ZYGISK_MODULE(MyModule)
67 |
68 | REGISTER_ZYGISK_COMPANION(companion_handler)
--------------------------------------------------------------------------------
/module/make_plug.gradle:
--------------------------------------------------------------------------------
1 | boolean deleteFile(File file) {
2 | if (file == null || !file.exists()) {
3 | return false
4 | }
5 | File[] files = file.listFiles();
6 | for (File f : files) {
7 | if (f.isDirectory()) {
8 | deleteFile(f)
9 | } else {
10 | f.delete()
11 | }
12 | }
13 | file.delete()
14 | return true
15 | }
16 |
17 | def copyFile(src, des, name) {
18 | File srcFile = file(src)
19 | File destDir = file(des)
20 | if (!srcFile.exists()) {
21 | println("$srcFile not exists!")
22 | return
23 | }
24 | if (destDir.exists() && !destDir.isDirectory()) {
25 | throw new GradleException("$destDir not is a directory!")
26 | }
27 |
28 | copy {
29 | from srcFile
30 | into destDir
31 | rename { String filename ->
32 | return name == null ? filename : name
33 | }
34 | }
35 | }
36 |
37 | def copyFile(src, des) {
38 | copyFile(src, des, null)
39 | }
40 |
41 | void CpyPlugFile() {
42 | String base32Path = "${projectDir}/libs/armeabi-v7a/"
43 | String base64Path = "${projectDir}/libs/arm64-v8a/"
44 | String so32Name = "armeabi-v7a.so"
45 | String so64Name = "arm64-v8a.so"
46 |
47 | copyFile(base64Path + "libanalyse.so", "${projectDir}/magisk_module/zygisk", so64Name)
48 | copyFile(base32Path + "libanalyse.so", "${projectDir}/magisk_module/zygisk", so32Name)
49 | }
50 |
51 | tasks.register('ZipPlug', Zip) {
52 | archiveFileName = "output.zip"
53 | destinationDirectory = file("${projectDir}/out/")
54 | from file("${projectDir}/magisk_module/")
55 | }
56 |
57 | void executeTask(Task task) {
58 | task.taskDependencies.getDependencies(task).each {
59 | subTask -> executeTask(subTask)
60 | }
61 | task.actions.each { it.execute(task) }
62 | }
63 |
64 | void BuildMagiskPlug() {
65 | try {
66 | println "start make magisk plug"
67 | file("${projectDir}/out").mkdirs()
68 | CpyPlugFile()
69 | executeTask(ZipPlug)
70 | println "make magisk plug finish"
71 | } catch (Throwable e) {
72 | println("make plug error: " + e)
73 | e.printStackTrace()
74 | }
75 | }
76 |
77 | ext {
78 | BuildMagiskPlug = this.&BuildMagiskPlug
79 | }
80 |
--------------------------------------------------------------------------------
/module/src/main/cpp/third/log2file/app_file_writer.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "../utils/jni_helper.hpp"
10 | #include "../utils/log.h"
11 |
12 | using namespace std;
13 |
14 | void log2file(const string &log);
15 |
16 | void log2file(const char *fmt, ...);
17 |
18 | class app_file_writer {
19 | public:
20 | app_file_writer(const string &dataPath, const string &name) {
21 | open(dataPath, name);
22 | }
23 |
24 | app_file_writer() = default;
25 |
26 | ~app_file_writer() {
27 | if (file == nullptr) {
28 | return;
29 | }
30 | fclose(file);
31 | }
32 |
33 | bool is_open() {
34 | return file != nullptr;
35 | }
36 |
37 | bool open(const string &dataPath, const string &name) {
38 | lock_guard guard(fileLock);
39 | if (is_open()) {
40 | return true;
41 | }
42 | this->appDataPath = dataPath;
43 | this->fileName = name;
44 | this->myPid = getpid();
45 | file = open_file(dataPath, name);
46 | return file != nullptr;
47 | }
48 |
49 | void write2file(const char *data, int len) {
50 | lock_guard guard(fileLock);
51 | check_process();
52 | if (len > 0 && file != nullptr) {
53 | fwrite(data, 1, len, file);
54 | fflush(file);
55 | }
56 | }
57 |
58 | void write2file(const string &data) {
59 | lock_guard guard(fileLock);
60 | check_process();
61 | if (data.size() > 0 && file != nullptr) {
62 | fwrite(data.c_str(), 1, data.size(), file);
63 | fwrite("\n", 1, 1, file);
64 | fflush(file);
65 | }
66 | }
67 |
68 | private:
69 | int myPid{};
70 | string appDataPath;
71 | string fileName;
72 | FILE *file{};
73 | mutex fileLock;
74 |
75 | void check_process() {
76 | if (myPid == getpid()) {
77 | return;
78 | }
79 | LOGI("log pid change: %d -> %d", myPid, getpid());
80 | myPid = getpid();
81 | file = open_file(this->appDataPath, this->fileName);
82 | }
83 |
84 | public:
85 | static FILE *open_file(const string &appDataPath, const string &name) {
86 | srandom(::time(nullptr) + getpid());
87 | char path[256];
88 | snprintf(path, sizeof(path), "%s/%s_%d_%ld", appDataPath.c_str(), name.c_str(), getpid(), random());
89 | FILE *file = fopen(path, "wb");
90 | if (!file) {
91 | LOGI("analyse open log file %s error: %d", path, errno);
92 | return nullptr;
93 | }
94 | return file;
95 | }
96 | };
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if "%ERRORLEVEL%" == "0" goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if "%ERRORLEVEL%"=="0" goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
84 | exit /b 1
85 |
86 | :mainEnd
87 | if "%OS%"=="Windows_NT" endlocal
88 |
89 | :omega
90 |
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/thread_poool.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 | #include
11 | #include
12 | #include
13 |
14 | class ThreadPool {
15 | public:
16 | ThreadPool(size_t);
17 |
18 | template
19 | auto enqueue(F &&f, Args &&... args)
20 | -> std::future::type>;
21 |
22 | ~ThreadPool();
23 |
24 | size_t size() const { return workers.size(); }
25 |
26 | private:
27 | // need to keep track of threads so we can join them
28 | std::vector workers;
29 | // the task queue
30 | std::queue > tasks;
31 |
32 | // synchronization
33 | std::mutex queue_mutex;
34 | std::condition_variable condition;
35 | bool stop;
36 | };
37 |
38 | // the constructor just launches some amount of workers
39 | inline ThreadPool::ThreadPool(size_t threads)
40 | : stop(false) {
41 | for (size_t i = 0; i < threads; ++i)
42 | workers.emplace_back(
43 | [this] {
44 | for (;;) {
45 | std::function task;
46 | {
47 | std::unique_lock lock(this->queue_mutex);
48 | this->condition.wait(lock,
49 | [this] {
50 | return this->stop || !this->tasks.empty();
51 | });
52 | if (this->stop && this->tasks.empty())
53 | return;
54 | task = std::move(this->tasks.front());
55 | this->tasks.pop();
56 | }
57 | task();
58 | }
59 | }
60 | );
61 | }
62 |
63 | // add new work item to the pool
64 | template
65 | auto ThreadPool::enqueue(F &&f, Args &&... args)
66 | -> std::future::type> {
67 | using return_type = typename std::result_of::type;
68 |
69 | auto task = std::make_shared >(
70 | std::bind(std::forward(f), std::forward(args)...)
71 | );
72 |
73 | std::future res = task->get_future();
74 | {
75 | std::unique_lock lock(queue_mutex);
76 |
77 | // don't allow enqueueing after stopping the pool
78 | assert(stop == false);
79 |
80 | tasks.emplace([task]() { (*task)(); });
81 | }
82 | condition.notify_one();
83 | return res;
84 | }
85 |
86 | // the destructor joins all threads
87 | inline ThreadPool::~ThreadPool() {
88 | {
89 | std::unique_lock lock(queue_mutex);
90 | stop = true;
91 | }
92 | condition.notify_all();
93 | for (std::thread &worker: workers)
94 | worker.join();
95 | }
--------------------------------------------------------------------------------
/module/magisk_module/customize.sh:
--------------------------------------------------------------------------------
1 | ##########################################################################################
2 | #
3 | # MMT Extended Config Script
4 | #
5 | ##########################################################################################
6 |
7 | ##########################################################################################
8 | # Config Flags
9 | ##########################################################################################
10 |
11 | # Uncomment and change 'MINAPI' and 'MAXAPI' to the minimum and maximum android version for your mod
12 | # Uncomment DYNLIB if you want libs installed to vendor for oreo+ and system for anything older
13 | # Uncomment PARTOVER if you have a workaround in place for extra partitions in regular magisk install (can mount them yourself - you will need to do this each boot as well). If unsure, keep commented
14 | # Uncomment PARTITIONS and list additional partitions you will be modifying (other than system and vendor), for example: PARTITIONS="/odm /product /system_ext"
15 | #MINAPI=21
16 | #MAXAPI=25
17 | #DYNLIB=true
18 | #PARTOVER=true
19 | #PARTITIONS=""
20 |
21 | ##########################################################################################
22 | # Replace list
23 | ##########################################################################################
24 |
25 | # List all directories you want to directly replace in the system
26 | # Check the documentations for more info why you would need this
27 |
28 | # Construct your list in the following format
29 | # This is an example
30 | REPLACE_EXAMPLE="
31 | /system/app/Youtube
32 | /system/priv-app/SystemUI
33 | /system/priv-app/Settings
34 | /system/framework
35 | "
36 |
37 | # Construct your own list here
38 | REPLACE="
39 | "
40 |
41 | ##########################################################################################
42 | # Permissions
43 | ##########################################################################################
44 |
45 | set_permissions() {
46 | : # Remove this if adding to this function
47 |
48 | # Note that all files/folders in magisk module directory have the $MODPATH prefix - keep this prefix on all of your files/folders
49 | # Some examples:
50 |
51 | # For directories (includes files in them):
52 | # set_perm_recursive (default: u:object_r:system_file:s0)
53 |
54 | # set_perm_recursive $MODPATH/system/lib 0 0 0755 0644
55 | # set_perm_recursive $MODPATH/system/vendor/lib/soundfx 0 0 0755 0644
56 |
57 | # For files (not in directories taken care of above)
58 | # set_perm (default: u:object_r:system_file:s0)
59 |
60 | # set_perm $MODPATH/system/lib/libart.so 0 0 0644
61 | # set_perm /data/local/tmp/file.txt 0 0 644
62 | }
63 |
64 | ##########################################################################################
65 | # MMT Extended Logic - Don't modify anything after this
66 | ##########################################################################################
67 |
68 | SKIPUNZIP=1
69 | unzip -qjo "$ZIPFILE" 'common/functions.sh' -d $TMPDIR >&2
70 | . $TMPDIR/functions.sh
71 |
--------------------------------------------------------------------------------
/module/src/main/cpp/third/utils/meminfo.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include