mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
- introduce EventBus singleton wrapping eventpp::EventDispatcher with typed event ids and const void* payloads - post EventClassFileLoadHook from ClassFileLoadHook callback - add IService base with typed listen<>() helper that binds a member function directly to an event, no virtual onEvent dispatch - add ServiceManager to register, initialize and shutdown services - add BytecodeService that subscribes to ClassFileLoadHook - wire Services::initializeAll() into Agent::init()
34 lines
992 B
C++
34 lines
992 B
C++
#include <jni_common.hpp>
|
|
#include <eventbus.hpp>
|
|
|
|
void JNICALL ClassFileLoadHook(
|
|
jvmtiEnv* jvmti_env,
|
|
JNIEnv* jni_env,
|
|
jclass class_being_redefined,
|
|
jobject loader,
|
|
const char* name,
|
|
jobject protection_domain,
|
|
jint class_data_len,
|
|
const unsigned char* classbytes,
|
|
jint* new_class_data_len,
|
|
unsigned char** new_classbytes) {
|
|
if (!name) {
|
|
spdlog::warn("[ClassFileLoadHook] name is null");
|
|
return;
|
|
}
|
|
|
|
EventClassFileLoadHook event{
|
|
jvmti_env,
|
|
jni_env,
|
|
class_being_redefined,
|
|
loader,
|
|
name,
|
|
protection_domain,
|
|
class_data_len,
|
|
classbytes,
|
|
new_class_data_len,
|
|
new_classbytes
|
|
};
|
|
|
|
EventBus::getInstance().post(EventId::ClassFileLoadHook, &event);
|
|
} |