Ensure necessary system props
Some other Magisk modules may override the system props we set, e.g. compiler-filter, which will likely result in boot loops. We PLT hook native getSystemProp implementation methods to make sure the values of related system props are always what we want. Fix #156.
This commit is contained in:
parent
8c4a7e90f3
commit
e2fb9709e4
|
|
@ -1,7 +1,7 @@
|
||||||
import org.gradle.internal.os.OperatingSystem;
|
import org.gradle.internal.os.OperatingSystem;
|
||||||
|
|
||||||
apply plugin: 'com.android.library'
|
apply plugin: 'com.android.library'
|
||||||
version "v0.3.1.4_beta-SNAPSHOT"
|
version "v0.3.1.5_beta-SNAPSHOT"
|
||||||
extensions["module_name"] = "EdXposed"
|
extensions["module_name"] = "EdXposed"
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 28
|
compileSdkVersion 28
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ LOCAL_LDFLAGS := -Wl
|
||||||
LOCAL_SRC_FILES:= \
|
LOCAL_SRC_FILES:= \
|
||||||
main.cpp \
|
main.cpp \
|
||||||
native_hook/native_hook.cpp \
|
native_hook/native_hook.cpp \
|
||||||
|
native_hook/riru_hook.cpp \
|
||||||
include/misc.cpp \
|
include/misc.cpp \
|
||||||
include/riru.c \
|
include/riru.c \
|
||||||
yahfa/HookMain.c \
|
yahfa/HookMain.c \
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#include "include/logging.h"
|
#include "include/logging.h"
|
||||||
#include "native_hook.h"
|
#include "native_hook.h"
|
||||||
|
#include "riru_hook.h"
|
||||||
|
|
||||||
static bool inlineHooksInstalled = false;
|
static bool inlineHooksInstalled = false;
|
||||||
|
|
||||||
|
|
@ -272,6 +273,7 @@ void install_inline_hooks() {
|
||||||
LOGE("api level not supported: %d, skip", api_level);
|
LOGE("api level not supported: %d, skip", api_level);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
install_riru_hooks();
|
||||||
LOGI("using api level %d", api_level);
|
LOGI("using api level %d", api_level);
|
||||||
void *whaleHandle = dlopen(kLibWhalePath, RTLD_LAZY | RTLD_GLOBAL);
|
void *whaleHandle = dlopen(kLibWhalePath, RTLD_LAZY | RTLD_GLOBAL);
|
||||||
if (!whaleHandle) {
|
if (!whaleHandle) {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,82 @@
|
||||||
|
//
|
||||||
|
// Created by solo on 2019/3/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
#include <string>
|
||||||
|
#include <include/riru.h>
|
||||||
|
#include <xhook/xhook.h>
|
||||||
|
#include <sys/system_properties.h>
|
||||||
|
#include <include/logging.h>
|
||||||
|
#include <include/android_build.h>
|
||||||
|
#include "riru_hook.h"
|
||||||
|
|
||||||
|
#define PROP_KEY_COMPILER_FILTER "dalvik.vm.dex2oat-filter"
|
||||||
|
#define PROP_KEY_COMPILER_FLAGS "dalvik.vm.dex2oat-flags"
|
||||||
|
#define PROP_VALUE_COMPILER_FILTER "quicken"
|
||||||
|
#define PROP_VALUE_COMPILER_FLAGS "--inline-max-code-units=0"
|
||||||
|
|
||||||
|
#define XHOOK_REGISTER(NAME) \
|
||||||
|
if (xhook_register(".*", #NAME, (void*) new_##NAME, (void **) &old_##NAME) == 0) { \
|
||||||
|
if (riru_get_version() >= 8) { \
|
||||||
|
void *f = riru_get_func(#NAME); \
|
||||||
|
if (f != nullptr) { \
|
||||||
|
memcpy(&old_##NAME, &f, sizeof(void *)); \
|
||||||
|
} \
|
||||||
|
riru_set_func(#NAME, (void *) new_##NAME); \
|
||||||
|
} \
|
||||||
|
} else { \
|
||||||
|
LOGE("failed to register riru hook " #NAME "."); \
|
||||||
|
}
|
||||||
|
|
||||||
|
#define NEW_FUNC_DEF(ret, func, ...) \
|
||||||
|
static ret (*old_##func)(__VA_ARGS__); \
|
||||||
|
static ret new_##func(__VA_ARGS__)
|
||||||
|
|
||||||
|
NEW_FUNC_DEF(int, __system_property_get, const char *key, char *value) {
|
||||||
|
int res = old___system_property_get(key, value);
|
||||||
|
if (key) {
|
||||||
|
if (strcmp(PROP_KEY_COMPILER_FILTER, key) == 0) {
|
||||||
|
strcpy(value, PROP_VALUE_COMPILER_FILTER);
|
||||||
|
LOGI("system_property_get: %s -> %s", key, value);
|
||||||
|
} else if (strcmp(PROP_KEY_COMPILER_FLAGS, key) == 0) {
|
||||||
|
strcpy(value, PROP_VALUE_COMPILER_FLAGS);
|
||||||
|
LOGI("system_property_get: %s -> %s", key, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
NEW_FUNC_DEF(std::string,
|
||||||
|
_ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_,
|
||||||
|
const std::string &key, const std::string &default_value) {
|
||||||
|
std::string res = old__ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_(
|
||||||
|
key, default_value);
|
||||||
|
if (strcmp(PROP_KEY_COMPILER_FILTER, key.c_str()) == 0) {
|
||||||
|
res = PROP_VALUE_COMPILER_FILTER;
|
||||||
|
LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str());
|
||||||
|
} else if (strcmp(PROP_KEY_COMPILER_FLAGS, key.c_str()) == 0) {
|
||||||
|
res = PROP_VALUE_COMPILER_FLAGS;
|
||||||
|
LOGI("android::base::GetProperty: %s -> %s", key.c_str(), res.c_str());
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
void install_riru_hooks() {
|
||||||
|
|
||||||
|
LOGI("install riru hook");
|
||||||
|
|
||||||
|
XHOOK_REGISTER(__system_property_get);
|
||||||
|
|
||||||
|
if (GetAndroidApiLevel() >= ANDROID_P) {
|
||||||
|
XHOOK_REGISTER(
|
||||||
|
_ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (xhook_refresh(0) == 0) {
|
||||||
|
xhook_clear();
|
||||||
|
LOGI("riru hooks installed");
|
||||||
|
} else {
|
||||||
|
LOGE("failed to install riru hooks");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
//
|
||||||
|
// Created by solo on 2019/3/16.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef EDXPOSED_RIRU_HOOK_H
|
||||||
|
#define EDXPOSED_RIRU_HOOK_H
|
||||||
|
|
||||||
|
void install_riru_hooks();
|
||||||
|
|
||||||
|
#endif //EDXPOSED_RIRU_HOOK_H
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#!/system/bin/sh
|
#!/system/bin/sh
|
||||||
|
|
||||||
EDXP_VERSION="0.3.1.4_beta-SNAPSHOT (3140)"
|
EDXP_VERSION="0.3.1.5_beta-SNAPSHOT (3150)"
|
||||||
ANDROID_SDK=`getprop ro.build.version.sdk`
|
ANDROID_SDK=`getprop ro.build.version.sdk`
|
||||||
BUILD_DESC=`getprop ro.build.description`
|
BUILD_DESC=`getprop ro.build.description`
|
||||||
PRODUCT=`getprop ro.build.product`
|
PRODUCT=`getprop ro.build.product`
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ LATESTARTSERVICE=false
|
||||||
|
|
||||||
print_modname() {
|
print_modname() {
|
||||||
ui_print "************************************"
|
ui_print "************************************"
|
||||||
ui_print " Riru - Ed Xposed v0.3.1.4 "
|
ui_print " Riru - Ed Xposed v0.3.1.5 "
|
||||||
ui_print "************************************"
|
ui_print "************************************"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
id=riru_edxposed
|
id=riru_edxposed
|
||||||
name=Riru - Ed Xposed
|
name=Riru - Ed Xposed
|
||||||
version=v0.3.1.4_beta-SNAPSHOT
|
version=v0.3.1.5_beta-SNAPSHOT
|
||||||
versionCode=3140
|
versionCode=3150
|
||||||
author=solohsu & MlgmXyysd
|
author=solohsu & MlgmXyysd
|
||||||
description=Magisk version of Xposed. Require Riru - Core installed.
|
description=Magisk version of Xposed. Require Riru - Core installed.
|
||||||
minMagisk=17000
|
minMagisk=17000
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
name=Ed Xposed
|
name=Ed Xposed
|
||||||
version=v0.3.1.4_beta-SNAPSHOT
|
version=v0.3.1.5_beta-SNAPSHOT
|
||||||
versionCode=3140
|
versionCode=3150
|
||||||
author=solohsu & MlgmXyysd
|
author=solohsu & MlgmXyysd
|
||||||
description=Magisk version of Xposed. Require Riru - Core installed.
|
description=Magisk version of Xposed. Require Riru - Core installed.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
version=90.0-0.3.1.4-beta-SNAPSHOT
|
version=90.0-0.3.1.5-beta-SNAPSHOT
|
||||||
arch=arm64
|
arch=arm64
|
||||||
minsdk=23
|
minsdk=23
|
||||||
maxsdk=28
|
maxsdk=28
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue