Feat: Event of preload & loaded

This commit is contained in:
xiaozhou233 committed 2026-04-04 21:51:12 +08:00
1 parent eb3a76769d
commit f8be8cb795
2 files changed
+29

No files matched your search

+16
View File
@@ -1,6 +1,8 @@
#include <libagent.hpp>
#include <jni_impl.hpp>
#include <bytecodes_opt.hpp>
#include <event/event_type.hpp>
#include <event/eventbus.hpp>
namespace JuiceAgent {
// ===== Singleton =====
@@ -12,6 +14,13 @@ namespace JuiceAgent {
bool Agent::init(JavaVM* jvm, JNIEnv* env, jvmtiEnv* jvmti) {
PLOGI << "JuiceAgent Native EntryPoint Invoked!";
// PreLoad Event
eventbus.post(EventPreLoad{
.jvm = jvm,
.env = env,
.jvmti = jvmti
});
// ======== neccessary environment check ========
if (jvm == nullptr) {
PLOGE << "Failed to initialize JuiceAgent: jvm is null";
@@ -64,6 +73,13 @@ namespace JuiceAgent {
// register bytecodes_opt
JuiceAgent::Bytecodes::register_bytecodes();
// Loaded Event
eventbus.post(EventLoaded{
.jvm = jvm,
.env = env,
.jvmti = jvmti
});
return true;
}
}