Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
v7
Browse files Browse the repository at this point in the history
remove extra '\n' in config file
  • Loading branch information
RikkaW committed Jan 14, 2019
1 parent 590cbb5 commit 4e26bb3
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 25 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,5 @@ android {

task zip(type: Exec) {
workingDir '..'
commandLine 'sh', 'build.sh', project.name, 'v6'
commandLine 'sh', 'build.sh', project.name, 'v7'
}
6 changes: 3 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
27 changes: 10 additions & 17 deletions jni/main/hook.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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__); \
Expand Down Expand Up @@ -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_);
}
}
}
4 changes: 2 additions & 2 deletions template_override/module.prop
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions template_override/riru_module.prop
Original file line number Diff line number Diff line change
@@ -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.

0 comments on commit 4e26bb3

Please sign in to comment.