Revert preload

This commit is contained in:
Nullptr
2023-01-31 19:29:20 +08:00
parent 335a1c3437
commit 4cbac00e28
3 changed files with 5 additions and 19 deletions

View File

@@ -5,7 +5,6 @@
using namespace std;
void *self_handle = nullptr;
vector<zygiskd::Module> preloaded_modules;
[[gnu::destructor]] [[maybe_unused]]
static void zygisk_cleanup_wait() {
@@ -16,18 +15,9 @@ static void zygisk_cleanup_wait() {
}
}
void preload_modules() {
LOGI("Preload modules");
preloaded_modules = zygiskd::ReadModules();
for (auto& module : preloaded_modules) {
LOGD(" Preloaded `%s`", module.name.data());
}
}
extern "C" __used void entry(void *handle) {
LOGD("Load injector successful");
LOGD("Load injector successfully");
self_handle = handle;
preload_modules();
hook_functions();
}

View File

@@ -536,17 +536,16 @@ void HookContext::fork_post() {
}
void HookContext::run_modules_pre() {
size_t size = preloaded_modules.size();
auto ms = zygiskd::ReadModules();
auto size = ms.size();
modules.reserve(size);
for (size_t i = 0; i < size; i++) {
auto& module = preloaded_modules[i];
if (void* handle = DlopenMem(module.memfd, RTLD_NOW);
auto& m = ms[i];
if (void* handle = DlopenMem(m.memfd, RTLD_NOW);
void* entry = handle ? dlsym(handle, "zygisk_module_entry") : nullptr) {
modules.emplace_back(i, handle, entry);
}
}
// memfds will be closed by RTTI
preloaded_modules.clear();
for (auto &m : modules) {
m.onLoad(env);

View File

@@ -4,9 +4,6 @@
#include <jni.h>
#include <vector>
#include "daemon.h"
extern void *self_handle;
extern std::vector<zygiskd::Module> preloaded_modules;
void hook_functions();