-
Notifications
You must be signed in to change notification settings - Fork 632
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
10 changed files
with
103 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
id=riru_edxposed | ||
name=Riru - Ed Xposed | ||
version=v0.3.1.4_beta-SNAPSHOT | ||
versionCode=3140 | ||
version=v0.3.1.5_beta-SNAPSHOT | ||
versionCode=3150 | ||
author=solohsu & MlgmXyysd | ||
description=Magisk version of Xposed. Require Riru - Core installed. | ||
minMagisk=17000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
name=Ed Xposed | ||
version=v0.3.1.4_beta-SNAPSHOT | ||
versionCode=3140 | ||
version=v0.3.1.5_beta-SNAPSHOT | ||
versionCode=3150 | ||
author=solohsu & MlgmXyysd | ||
description=Magisk version of Xposed. Require Riru - Core installed. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=90.0-0.3.1.4-beta-SNAPSHOT | ||
version=90.0-0.3.1.5-beta-SNAPSHOT | ||
arch=arm64 | ||
minsdk=23 | ||
maxsdk=28 | ||
|