Skip to content

Add app black list #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -13,4 +13,3 @@
.externalNativeBuild
.cxx
elf-cleaner.sh
settings.gradle
674 changes: 674 additions & 0 deletions LICENSE

Large diffs are not rendered by default.

32 changes: 14 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
# Riru - Template
# Riru - MiPushFake

[Riru](https://github.com/RikkaApps/Riru) module template.
![License GPL-3.0](https://img.shields.io/badge/license-GPLv3.0-green.svg)

## Build
Fake as a Xiaomi device by hook system_property_get.

1. Replace all "template" to your name

* `module/build.gradle`: "template" in variable `moduleId`, `moduleProp`
* `module/src/main/cpp/CMakeLists.txt`: "riru_template" in `set(MODULE_NAME )`
* `template/magisk_module/post-fs-data.sh`: `MODULE_ID="template"`
* `template/magisk_module/uninstall.sh`: `MODULE_ID="template"`
Requires Riru - Core v19 or above installed.

2. Write you codes
3. Run gradle task `:module:assembleRelease` task from Android Studio or command line, zip will be saved in `out`.
## What does this module do

## Notes
By default, `__system_property_get` (`android::base::GetProperty` on Pie+) will be hooked in packages selected in
MiPushFramework with value map below

* 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)
* `ro.miui.ui.version.name` -> `V11`
* `ro.miui.ui.version.code` -> `9`
* `ro.miui.version.code_time` -> `1570636800`
* `ro.miui.internal.storage` -> `/sdcard/`
* `ro.product.manufacturer` -> `Xiaomi`
* `ro.product.brand` -> `Xiaomi`
* `ro.product.name` -> `Xiaomi`
Empty file modified gradlew
100644 → 100755
Empty file.
168 changes: 84 additions & 84 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
22 changes: 22 additions & 0 deletions module.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
ext {
moduleId = "mipush_fake"
riruApiVersion = 4

moduleProp = [
name : "Riru - MiPushFake",
version : "v13.0",
versionCode: "13",
author : "Timothy, MlgmXyysd",
description: "Fake as a Xiaomi device by hook system_property_get. Requires Riru - Core v19 or above installed.",
api : riruApiVersion
]

magiskModuleProp = [
id : "riru-${moduleId.replace('_', '-')}",
name : "Riru - ${moduleProp['name']}",
version : moduleProp['version'],
versionCode: moduleProp['versionCode'],
author : moduleProp['author'],
description: moduleProp['description']
]
}
44 changes: 23 additions & 21 deletions module/build.gradle
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
apply plugin: 'com.android.library'
apply from: file(rootProject.file('module.gradle'))

android {
compileSdkVersion rootProject.ext.targetSdkVersion
defaultConfig {
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
externalNativeBuild {
cmake {
arguments "-DMODULE_NAME:STRING=riru_$moduleId"
}
}
}
externalNativeBuild {
cmake {
@@ -14,29 +20,10 @@ android {
}
}

def moduleId = "template"
def moduleProp = [
name : "Template",
version : "v1.0",
versionCode: "1",
author : "Template",
description: "Riru module template.",
api : 4
]

def magiskModuleProp = [
id : "riru-${moduleId.replace('_', '-')}",
name : "Riru - ${moduleProp['name']}",
version : moduleProp['version'],
versionCode: moduleProp['versionCode'],
author : moduleProp['author'],
description: moduleProp['description']
]

def outDir = file("$rootDir/out")
def magiskDir = file("$outDir/magisk_module")
def zipName = "magisk-${magiskModuleProp['id']}-${magiskModuleProp['version']}.zip"
def riruDir = "$magiskDir/data/misc/riru/modules/${moduleId}"
def zipName = "magisk-${magiskModuleProp['id'].replace('_', '-')}-${magiskModuleProp['version']}.zip"
def riruDir = "$magiskDir/riru"

import java.nio.file.Files
import java.security.MessageDigest
@@ -55,6 +42,8 @@ static def renameOrFail(File from, File to) {
}
}

import org.apache.tools.ant.filters.FixCrLfFilter

android.libraryVariants.all { variant ->
def task = variant.assembleProvider.get()
task.doLast {
@@ -65,6 +54,19 @@ android.libraryVariants.all { variant ->
copy {
from "$rootDir/template/magisk_module"
into magiskDir.path
exclude 'riru.sh'
}
// copy riru.sh
copy {
from "$rootDir/template/magisk_module"
into magiskDir.path
include 'riru.sh'
filter { line ->
line.replaceAll('%%%RIRU_MODULE_ID%%%', moduleId)
.replaceAll('%%%RIRU_MIN_API_VERSION%%%', riruApiVersion.toString())
}
filter(FixCrLfFilter.class,
eol: FixCrLfFilter.CrLf.newInstance("lf"))
}
// copy .git files manually since gradle exclude it by default
Files.copy(file("$rootDir/template/magisk_module/.gitattributes").toPath(), file("${magiskDir.path}/.gitattributes").toPath())
2 changes: 1 addition & 1 deletion module/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="riru.template" />
<manifest package="top.trumeet.mipushframework" />
34 changes: 31 additions & 3 deletions module/src/main/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
cmake_minimum_required(VERSION 3.4.1)

set(MODULE_NAME "riru_template")
set(MODULE_NAME "riru_mipush_fake")

SET(XHOOK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/external/xhook/)


INCLUDE_DIRECTORIES(
${CMAKE_CURRENT_SOURCE_DIR}/include
${XHOOK_PATH}/include
)

LINK_DIRECTORIES(
${XHOOK_PATH}/lib/
)

message("Build type: ${CMAKE_BUILD_TYPE}")

@@ -22,6 +34,22 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${C_FLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${LINKER_FLAGS}")

add_library(${MODULE_NAME} SHARED main.cpp)
target_link_libraries(${MODULE_NAME} log)

SET(XHOOK_OBJS
external/xhook/xhook.c
external/xhook/xh_core.c
external/xhook/xh_elf.c
external/xhook/xh_jni.c
external/xhook/xh_log.c
external/xhook/xh_util.c
external/xhook/xh_version.c
)
ADD_LIBRARY(libxhook STATIC ${XHOOK_OBJS})
set_target_properties(libxhook PROPERTIES LINKER_LANGUAGE CXX C_STANDARD 11 OUTPUT_NAME "xhook")


add_library(${MODULE_NAME} SHARED hook.cpp riru.c main.cpp)
target_link_libraries(${MODULE_NAME} log libxhook)
set_target_properties(${MODULE_NAME} PROPERTIES LINK_FLAGS_RELEASE -s)


15 changes: 15 additions & 0 deletions module/src/main/cpp/external/Android.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := xhook
LOCAL_SRC_FILES := xhook/xhook.c \
xhook/xh_core.c \
xhook/xh_elf.c \
xhook/xh_jni.c \
xhook/xh_log.c \
xhook/xh_util.c \
xhook/xh_version.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_CFLAGS := -Wall -Wextra -Werror -fvisibility=hidden
LOCAL_CONLYFLAGS := -std=c11
include $(BUILD_STATIC_LIBRARY)
Loading