DELETE: all code

This commit is contained in:
xiaozhou233 committed 2026-08-15 10:23:15 +08:00
1 parent 56b6ab7e98
commit fe64308942
134 files changed
-41980

No files matched your search

-61
View File
@@ -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() {
}
}
@@ -1,68 +0,0 @@
#include <services.hpp>
namespace JuiceAgent::services::JarLoader {
static JarLoaderConfig config;
static const char* MODULE_CLASS = "cn/xiaozhou233/juiceagent/api/modules/JarLoader";
static const char* MODULE_METHOD = "loadJar";
void init() {
auto& cfg = agent.get_config();
config.enabled = cfg.get<bool>(
"JuiceAgent.Modules.JarLoader.Enabled",
false
);
config.injection_dir = cfg.get<std::string>(
"JuiceAgent.Modules.JarLoader.InjectionDir",
(cfg.runtime_dir() / "injection").string(),
true
);
config.jar_path = cfg.get<std::string>(
"JuiceAgent.Modules.JarLoader.JarPath",
"./Entry.jar",
true
);
config.entry_class = cfg.get<std::string>(
"JuiceAgent.Modules.JarLoader.EntryClass",
"Example.Main",
false
);
config.entry_method = cfg.get<std::string>(
"JuiceAgent.Modules.JarLoader.EntryMethod",
"start",
false
);
PLOGI << "JarLoaderService initialized";
}
void start() {
if (!config.enabled) {
return;
}
JuiceAgent::Utils::Serializer ser;
ser.add_kv("InjectionDir", config.injection_dir);
ser.add_kv("JarPath", config.jar_path);
ser.add_kv("EntryClass", config.entry_class);
ser.add_kv("EntryMethod", config.entry_method);
auto data = ser.serialize();
JuiceAgent::Utils::call_java_impl(
agent.get_env(),
MODULE_CLASS,
MODULE_METHOD,
data.c_str()
);
PLOGI << "JarLoader start";
return;
}
}
-38
View File
@@ -1,38 +0,0 @@
#include <services.hpp>
#include <event/event_type.hpp>
namespace JuiceAgent::services::Manager {
void register_events() {
// PreLoad
agent.get_eventbus().subscribe<EventPreLoad>(init);
// Loaded
agent.get_eventbus().subscribe<EventLoaded>(start);
// TODO: Stopped
PLOGI << "Services Manager registered events";
}
void init(const EventPreLoad& event) {
PLOGI << "Initializing services";
// JarLoader
JuiceAgent::services::JarLoader::init();
// Bytecode
JuiceAgent::services::Bytecode::init();
}
void start(const EventLoaded& event) {
PLOGI << "Starting services";
// JarLoader
JuiceAgent::services::JarLoader::start();
// Bytecode
JuiceAgent::services::Bytecode::start();
}
void stop() {
}
}