Reorganize zygisk code

This commit is contained in:
topjohnwu
2023-11-08 17:46:39 -08:00
parent 65c18f9c09
commit ef48abf19d
7 changed files with 667 additions and 649 deletions

View File

@@ -22,6 +22,27 @@ extern "C" [[maybe_unused]] void zygisk_inject_entry(void *handle) {
ZLOGD("load success\n");
}
static bool is_compatible_with(uint32_t) {
auto name = get_prop(NBPROP);
android_dlextinfo info = {
.flags = ANDROID_DLEXT_FORCE_LOAD
};
void *handle = android_dlopen_ext(name.data(), RTLD_LAZY, &info);
if (handle) {
auto entry = reinterpret_cast<void (*)(void *)>(dlsym(handle, "zygisk_inject_entry"));
if (entry) {
entry(handle);
}
}
return false;
}
extern "C" [[maybe_unused]] NativeBridgeCallbacks NativeBridgeItf{
.version = 2,
.padding = {},
.isCompatibleWith = &is_compatible_with,
};
// The following code runs in zygote/app process
static inline bool should_load_modules(uint32_t flags) {