mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-01-03 11:17:38 +00:00
One stage zygisk loading
This commit is contained in:
parent
df66458db6
commit
79334b7702
@ -16,25 +16,11 @@ using namespace std;
|
|||||||
void *self_handle = nullptr;
|
void *self_handle = nullptr;
|
||||||
string native_bridge = "0";
|
string native_bridge = "0";
|
||||||
|
|
||||||
extern "C" [[maybe_unused]] void zygisk_inject_entry(void *handle) {
|
|
||||||
self_handle = handle;
|
|
||||||
zygisk_logging();
|
|
||||||
hook_functions();
|
|
||||||
ZLOGD("load success\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool is_compatible_with(uint32_t) {
|
static bool is_compatible_with(uint32_t) {
|
||||||
auto name = get_prop(NBPROP);
|
auto name = get_prop(NBPROP);
|
||||||
android_dlextinfo info = {
|
android_logging();
|
||||||
.flags = ANDROID_DLEXT_FORCE_LOAD
|
hook_functions();
|
||||||
};
|
ZLOGD("load success\n");
|
||||||
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -187,6 +187,7 @@ DCL_HOOK_FUNC(static int, pthread_attr_destroy, void *target) {
|
|||||||
if (should_unmap_zygisk) {
|
if (should_unmap_zygisk) {
|
||||||
g_hook->restore_plt_hook();
|
g_hook->restore_plt_hook();
|
||||||
if (should_unmap_zygisk) {
|
if (should_unmap_zygisk) {
|
||||||
|
ZLOGV("dlclosing self\n");
|
||||||
delete g_hook;
|
delete g_hook;
|
||||||
|
|
||||||
// Because both `pthread_attr_destroy` and `dlclose` have the same function signature,
|
// Because both `pthread_attr_destroy` and `dlclose` have the same function signature,
|
||||||
@ -202,13 +203,12 @@ DCL_HOOK_FUNC(static int, pthread_attr_destroy, void *target) {
|
|||||||
|
|
||||||
// it should be safe to assume all dlclose's in libnativebridge are for zygisk_loader
|
// it should be safe to assume all dlclose's in libnativebridge are for zygisk_loader
|
||||||
DCL_HOOK_FUNC(static int, dlclose, void *handle) {
|
DCL_HOOK_FUNC(static int, dlclose, void *handle) {
|
||||||
static bool kDone = false;
|
if (!self_handle) {
|
||||||
if (!kDone) {
|
|
||||||
ZLOGV("dlclose zygisk_loader\n");
|
ZLOGV("dlclose zygisk_loader\n");
|
||||||
kDone = true;
|
self_handle = handle;
|
||||||
g_hook->post_native_bridge_load();
|
g_hook->post_native_bridge_load();
|
||||||
}
|
}
|
||||||
[[clang::musttail]] return old_dlclose(handle);
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef DCL_HOOK_FUNC
|
#undef DCL_HOOK_FUNC
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
{
|
{
|
||||||
zygisk_inject_entry;
|
|
||||||
NativeBridgeItf;
|
NativeBridgeItf;
|
||||||
};
|
};
|
||||||
|
Loading…
x
Reference in New Issue
Block a user