This repository has been archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
157 additions
and
7 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
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,76 @@ | ||
#include <dlfcn.h> | ||
#include <memory.h> | ||
#include <logging.h> | ||
|
||
#ifdef __LP64__ | ||
#define LIB "/system/lib64/libmemtrack.so" | ||
#else | ||
#define LIB "/system/lib/libmemtrack.so" | ||
#endif | ||
|
||
static void *riru_handle; | ||
static char *riru_module_name; | ||
|
||
static void *get_handle() { | ||
if (riru_handle == NULL) | ||
riru_handle = dlopen(LIB, RTLD_NOW | RTLD_GLOBAL); | ||
|
||
return riru_handle; | ||
} | ||
|
||
const char *riru_get_module_name() { | ||
return riru_module_name; | ||
} | ||
|
||
void riru_set_module_name(const char *name) { | ||
riru_module_name = strdup(name); | ||
} | ||
|
||
int riru_get_version() { | ||
static void **sym; | ||
void *handle; | ||
if ((handle = get_handle()) == NULL) return -1; | ||
if (sym == NULL) sym = dlsym(handle, "riru_get_version"); | ||
if (sym) return ((int (*)()) sym)(); | ||
return -1; | ||
} | ||
|
||
void *riru_get_func(const char *name) { | ||
static void **sym; | ||
void *handle; | ||
if ((handle = get_handle()) == NULL) return NULL; | ||
if (sym == NULL) sym = dlsym(handle, "riru_get_func"); | ||
if (sym) return ((void *(*)(const char *, const char *)) sym)(riru_get_module_name(), name); | ||
return NULL; | ||
} | ||
|
||
void *riru_get_native_method_func(const char *className, const char *name, const char *signature) { | ||
static void **sym; | ||
void *handle; | ||
if ((handle = get_handle()) == NULL) return NULL; | ||
if (sym == NULL) sym = dlsym(handle, "riru_get_native_method_func"); | ||
if (sym) | ||
return ((void *(*)(const char *, const char *, const char *, const char *)) sym)( | ||
riru_get_module_name(), className, name, signature); | ||
return NULL; | ||
} | ||
|
||
void riru_set_func(const char *name, void *func) { | ||
static void **sym; | ||
void *handle; | ||
if ((handle = get_handle()) == NULL) return; | ||
if (sym == NULL) sym = dlsym(handle, "riru_set_func"); | ||
if (sym) | ||
((void *(*)(const char *, const char *, void *)) sym)(riru_get_module_name(), name, func); | ||
} | ||
|
||
void riru_set_native_method_func(const char *className, const char *name, const char *signature, | ||
void *func) { | ||
static void **sym; | ||
void *handle; | ||
if ((handle = get_handle()) == NULL) return; | ||
if (sym == NULL) sym = dlsym(handle, "riru_set_native_method_func"); | ||
if (sym) | ||
((void *(*)(const char *, const char *, const char *, const char *, void *)) sym)( | ||
riru_get_module_name(), className, name, signature, func); | ||
} |
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,57 @@ | ||
#ifndef RIRU_H | ||
#define RIRU_H | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
__attribute__((visibility("default"))) void riru_set_module_name(const char *name); | ||
|
||
/** | ||
* Get Riru version. | ||
* | ||
* @return Riru version | ||
*/ | ||
int riru_get_version(); | ||
|
||
/* | ||
* Get new_func address from last module which hook func. | ||
* Use this as your old_func if you want to hook func. | ||
* | ||
* @param name a unique name | ||
* @return new_func from last module or null | ||
*/ | ||
void *riru_get_func(const char *name); | ||
|
||
/* | ||
* Java native version of riru_get_func. | ||
* | ||
* @param className class name | ||
* @param name method name | ||
* @param signature method signature | ||
* @return new_func address from last module or original address | ||
*/ | ||
void *riru_get_native_method_func(const char *className, const char *name, const char *signature); | ||
|
||
/* | ||
* Set new_func address for next module which wants to hook func. | ||
* | ||
* @param name a unique name | ||
* @param func your new_func address | ||
*/ | ||
void riru_set_func(const char *name, void *func); | ||
|
||
/* | ||
* Java native method version of riru_set_func. | ||
* | ||
* @param className class name | ||
* @param name method name | ||
* @param signature method signature | ||
* @param func your new_func address | ||
*/ | ||
void riru_set_native_method_func(const char *className, const char *name, const char *signature, | ||
void *func); | ||
#ifdef __cplusplus | ||
} | ||
#endif | ||
|
||
#endif |
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_location_report_enabler | ||
name=Riru - Location Report Enabler | ||
version=v5 | ||
versionCode=5 | ||
version=v6 | ||
versionCode=6 | ||
author=Rikka | ||
description=Enable location report by hook system_property_get. 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=Location Report Enabler | ||
version=v5 | ||
versionCode=5 | ||
version=v6 | ||
versionCode=6 | ||
author=Rikka | ||
description=Enable location report by hook system_property_get. Require Riru - Core installed. |