mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 13:05:53 +08:00
DELETE: all code
This commit is contained in:
1 parent
56b6ab7e98
commit
fe64308942
134 files changed
-41980
No files matched your search
@@ -1,61 +0,0 @@
|
||||
#include <services.hpp>
|
||||
#include <jni_impl.hpp>
|
||||
|
||||
namespace JuiceAgent::services::Bytecode {
|
||||
void capture_bytecodes(const EventClassFileLoadHook& e) {
|
||||
/* =========================
|
||||
* 1. Capture original bytes
|
||||
* ========================= */
|
||||
std::lock_guard<std::mutex> lock(classDataMutex);
|
||||
if (classToCapture.contains(e.name)) {
|
||||
if (!classFileDataMap.contains(e.name)) {
|
||||
ClassFileData data;
|
||||
|
||||
data.classname = e.name;
|
||||
data.bytecode.assign(e.classbytes, e.classbytes + e.class_data_len);
|
||||
// Experimental: class/classloader/protection_domain references (to be used in future features, e.g. dynamic patching)
|
||||
data.clazz = e.class_being_redefined;
|
||||
data.classloader = e.loader;
|
||||
data.protection_domain = e.protection_domain;
|
||||
|
||||
|
||||
classFileDataMap[e.name] = std::move(data);
|
||||
|
||||
classToCapture.erase(e.name);
|
||||
|
||||
PLOGI << "Captured class: " << e.name << " (length: " << e.class_data_len << ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void patch_bytecodes(const EventClassFileLoadHook& e) {
|
||||
/* =========================
|
||||
* 2. Apply patches
|
||||
* ========================= */
|
||||
if (pendingRetransform.contains(e.name)) {
|
||||
auto& bytes = pendingRetransform[e.name];
|
||||
|
||||
unsigned char* new_buf = nullptr;
|
||||
e.jvmti_env->Allocate(bytes.size(), &new_buf);
|
||||
|
||||
memcpy(new_buf, bytes.data(), bytes.size());
|
||||
|
||||
*e.new_class_data_len = (jint)bytes.size();
|
||||
*e.new_classbytes = new_buf;
|
||||
|
||||
pendingRetransform.erase(e.name);
|
||||
|
||||
PLOGI << "Retransformed: " << e.name << " (new length: " << bytes.size() << ")";
|
||||
}
|
||||
}
|
||||
|
||||
void init() {
|
||||
agent.get_eventbus().subscribe<EventClassFileLoadHook>(capture_bytecodes);
|
||||
agent.get_eventbus().subscribe<EventClassFileLoadHook>(patch_bytecodes);
|
||||
}
|
||||
|
||||
void start() {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user