You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jan 8, 2024. It is now read-only.
Copy file name to clipboardExpand all lines: README.md
+14-14Lines changed: 14 additions & 14 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@ The name Riru is from https://www.pixiv.net/member_illust.php?mode=medium&illust
16
16
In short, replace a shared library which will be loaded by the zygote process.
17
17
18
18
First, we need to find that library. The library needs to be as simple as possible, so we found libmemtrack, with only 10 exported functions.
19
-
Then we can provide a library named libmemtrack with all its functions, so the functionality will not be affected and we will able to in the zygote process.
19
+
Then we can provide a library named libmemtrack with all its functions, so the functionality will not be affected and we will able to in the zygote process. (However, it seems that choose libmemtrack is very good now)
20
20
21
21
Now the next question, how to know if we are in an app process or a system server process.
22
22
We found some JNI functions (`com.android.internal.os.Zygote#nativeForkAndSpecialize` & `com.android.internal.os.Zygote#nativeForkSystemServer`) will be called when a app or system server is forked.
@@ -50,28 +50,28 @@ From v8, core starts to providing some APIs, see [riru.h](https://github.com/Rik
50
50
51
51
## Where your own module needs attention
52
52
53
-
* To ensure your hook is not being overwritten by other modules, use API from core
54
-
* DO NOT overwrite `jniRegisterNativeMethods` hook in core in your `attribute constructor` func (or `LOCAL_LDFLAGS -init`)
55
-
(To get JNI method address, use `riru_get_native_method_func`)
56
53
* DO NOT overwrite `android.os.SystemProperties#native_set` in core, or your data may be wiped
(If you really need to hook this, remember to clear exception)
59
56
* DO NO print log (`__android_log_print`) in `nativeForkAndSpecialize(Pre/Post)``nativeForkSystemServer(Pre/Post)` when in zygote process, or it may cause zygote not work
60
57
(magic not confirmed, [Detail info](https://github.com/RikkaApps/Riru/blob/77adfd6a4a6a81bfd20569c910bc4854f2f84f5e/riru-core/jni/main/jni_native_method.cpp#L55-L66))
58
+
* Add `-ffixed-x18` to both compiler and linker parameter, or it will cause problems on Android Q (see template)
61
59
62
-
## Method to ensure your hook not being overwritten
60
+
## Riru API
63
61
64
-
```
65
-
#include "riru.h"
62
+
* Currently, one module version can only support one API version
63
+
* See template for details
66
64
67
-
your_hook_func(func, new_func, &old_func);
65
+
### v3 (core v18+)
68
66
69
-
if (riru_get_version() >= 8) { // determine riru version first
70
-
void *f = riru_get_func("func"); // if f is not null, other module has set it
71
-
if (f) old_func = f; // set your old_func as f (new_func in last module) to ensure last module's hook not being overwritten
72
-
riru_set_func("func", new_func); // set new_func to let next module get correct old_func
73
-
}
74
-
```
67
+
* Add `api=3` to `riru_module.prop` to declare API version
68
+
* Check and deny installation if Riru version is below v18 in `config.sh`
69
+
* Parameter of `nativeForkAndSpecializePre` changes (compare to v2, added `jstring *packageName, jobjectArray *packagesForUID, jobjectArray *visibleVolIDs` in the end)
70
+
71
+
### v2 (core v16-v17.1)
72
+
73
+
* Export `int getApiVersion() { return 2; }` to declare API version
74
+
* Parameter of `nativeForkAndSpecializePre` changes (compare to v1, all parameter is pointer)
0 commit comments