From 4e26bb33b7a6cf3252a1e4bc2f8363d7d3309954 Mon Sep 17 00:00:00 2001 From: RikkaW Date: Mon, 14 Jan 2019 16:12:12 +0800 Subject: [PATCH] v7 remove extra '\n' in config file --- build.gradle | 2 +- build.sh | 6 +++--- jni/main/hook.cpp | 27 ++++++++++----------------- template_override/module.prop | 4 ++-- template_override/riru_module.prop | 4 ++-- 5 files changed, 18 insertions(+), 25 deletions(-) diff --git a/build.gradle b/build.gradle index fb317b6..b6c61de 100644 --- a/build.gradle +++ b/build.gradle @@ -22,5 +22,5 @@ android { task zip(type: Exec) { workingDir '..' - commandLine 'sh', 'build.sh', project.name, 'v6' + commandLine 'sh', 'build.sh', project.name, 'v7' } \ No newline at end of file diff --git a/build.sh b/build.sh index b363412..a5943da 100644 --- a/build.sh +++ b/build.sh @@ -9,10 +9,10 @@ function copy_files { cp $MODULE_NAME/template_override/config.sh $TMP_DIR_MAGISK cp $MODULE_NAME/template_override/module.prop $TMP_DIR_MAGISK - echo "310030" > $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/gsm.sim.operator.numeric - echo "us" > $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/gsm.sim.operator.iso-country + echo -n "310030" > $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/gsm.sim.operator.numeric + echo -n "us" > $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/gsm.sim.operator.iso-country mkdir $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.gms touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.gsf - touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.apps.map + touch $TMP_DIR_MAGISK/data/misc/riru/modules/$NAME/packages/com.google.android.apps.maps } \ No newline at end of file diff --git a/jni/main/hook.cpp b/jni/main/hook.cpp index a1c0d42..82b01e1 100644 --- a/jni/main/hook.cpp +++ b/jni/main/hook.cpp @@ -27,8 +27,16 @@ void set_sim_operator_country(const char *string) { } #define XHOOK_REGISTER(NAME) \ - if (xhook_register(".*", #NAME, (void*) new_##NAME, (void **) &old_##NAME) != 0) \ + 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 hook " #NAME "."); \ + } #define NEW_FUNC_DEF(ret, func, ...) \ static ret (*old_##func)(__VA_ARGS__); \ @@ -66,26 +74,11 @@ void install_hook(const char *package_name, int user) { XHOOK_REGISTER(__system_property_get); char sdk[PROP_VALUE_MAX + 1]; - int sdkLevel = 0; - if (__system_property_get("ro.build.version.sdk", sdk) > 0 && (sdkLevel = atoi(sdk)) >= 28) + if (__system_property_get("ro.build.version.sdk", sdk) > 0 && atoi(sdk) >= 28) XHOOK_REGISTER(_ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_); if (xhook_refresh(0) == 0) xhook_clear(); else LOGE("failed to refresh hook"); - - if (riru_get_version() >= 8) { - void *f = riru_get_func("__system_property_get"); - if (f != nullptr) old___system_property_get = (int (*)(const char *, char *)) f; - riru_set_func("__system_property_get", (void *) new___system_property_get); - - if (sdkLevel >= 28) { - f = riru_get_func("_ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_"); - if (f != nullptr) old__ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_ = (std::string (*)(const std::string &, const std::string &)) f; - - riru_set_func("_ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_", - (void *) new__ZN7android4base11GetPropertyERKNSt3__112basic_stringIcNS1_11char_traitsIcEENS1_9allocatorIcEEEES9_); - } - } } \ No newline at end of file diff --git a/template_override/module.prop b/template_override/module.prop index 20d0807..0e274f3 100644 --- a/template_override/module.prop +++ b/template_override/module.prop @@ -1,7 +1,7 @@ id=riru_location_report_enabler name=Riru - Location Report Enabler -version=v6 -versionCode=6 +version=v7 +versionCode=7 author=Rikka description=Enable location report by hook system_property_get. Require Riru - Core installed. minMagisk=17000 diff --git a/template_override/riru_module.prop b/template_override/riru_module.prop index 04cc168..949bac8 100644 --- a/template_override/riru_module.prop +++ b/template_override/riru_module.prop @@ -1,5 +1,5 @@ name=Location Report Enabler -version=v6 -versionCode=6 +version=v7 +versionCode=7 author=Rikka description=Enable location report by hook system_property_get. Require Riru - Core installed. \ No newline at end of file