mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
38 lines
1.2 KiB
C++
38 lines
1.2 KiB
C++
#include <jni_impl.hpp>
|
|
#include <event/event_type.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("name is null");
|
|
return;
|
|
}
|
|
|
|
auto& agent = JuiceAgent::Agent::instance();
|
|
|
|
EventClassFileLoadHook event{
|
|
.jvmti_env = jvmti_env,
|
|
.jni_env = jni_env,
|
|
.class_being_redefined = class_being_redefined,
|
|
.loader = loader,
|
|
.name = name,
|
|
.protection_domain = protection_domain,
|
|
.class_data_len = class_data_len,
|
|
.classbytes = classbytes,
|
|
.new_class_data_len = new_class_data_len,
|
|
.new_classbytes = new_classbytes
|
|
};
|
|
|
|
agent.get_eventbus().post(event);
|
|
|
|
agent.get_eventbus().post_mutable(event);
|
|
} |