mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 21:15:56 +08:00
Feat: Event of preload & loaded
This commit is contained in:
1 parent
eb3a76769d
commit
f8be8cb795
2 files changed
+29
No files matched your search
@@ -15,3 +15,16 @@ struct EventClassFileLoadHook {
|
|||||||
jint* new_class_data_len;
|
jint* new_class_data_len;
|
||||||
unsigned char** new_classbytes;
|
unsigned char** new_classbytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// JuiceAgent PreLoad/PostLoad
|
||||||
|
struct EventPreLoad {
|
||||||
|
JavaVM* jvm;
|
||||||
|
JNIEnv* env;
|
||||||
|
jvmtiEnv* jvmti;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct EventLoaded {
|
||||||
|
JavaVM* jvm;
|
||||||
|
JNIEnv* env;
|
||||||
|
jvmtiEnv* jvmti;
|
||||||
|
};
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
#include <libagent.hpp>
|
#include <libagent.hpp>
|
||||||
#include <jni_impl.hpp>
|
#include <jni_impl.hpp>
|
||||||
#include <bytecodes_opt.hpp>
|
#include <bytecodes_opt.hpp>
|
||||||
|
#include <event/event_type.hpp>
|
||||||
|
#include <event/eventbus.hpp>
|
||||||
|
|
||||||
namespace JuiceAgent {
|
namespace JuiceAgent {
|
||||||
// ===== Singleton =====
|
// ===== Singleton =====
|
||||||
@@ -12,6 +14,13 @@ namespace JuiceAgent {
|
|||||||
bool Agent::init(JavaVM* jvm, JNIEnv* env, jvmtiEnv* jvmti) {
|
bool Agent::init(JavaVM* jvm, JNIEnv* env, jvmtiEnv* jvmti) {
|
||||||
PLOGI << "JuiceAgent Native EntryPoint Invoked!";
|
PLOGI << "JuiceAgent Native EntryPoint Invoked!";
|
||||||
|
|
||||||
|
// PreLoad Event
|
||||||
|
eventbus.post(EventPreLoad{
|
||||||
|
.jvm = jvm,
|
||||||
|
.env = env,
|
||||||
|
.jvmti = jvmti
|
||||||
|
});
|
||||||
|
|
||||||
// ======== neccessary environment check ========
|
// ======== neccessary environment check ========
|
||||||
if (jvm == nullptr) {
|
if (jvm == nullptr) {
|
||||||
PLOGE << "Failed to initialize JuiceAgent: jvm is null";
|
PLOGE << "Failed to initialize JuiceAgent: jvm is null";
|
||||||
@@ -64,6 +73,13 @@ namespace JuiceAgent {
|
|||||||
// register bytecodes_opt
|
// register bytecodes_opt
|
||||||
JuiceAgent::Bytecodes::register_bytecodes();
|
JuiceAgent::Bytecodes::register_bytecodes();
|
||||||
|
|
||||||
|
|
||||||
|
// Loaded Event
|
||||||
|
eventbus.post(EventLoaded{
|
||||||
|
.jvm = jvm,
|
||||||
|
.env = env,
|
||||||
|
.jvmti = jvmti
|
||||||
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user