diff --git a/src/libagent/includes/bytecodes_opt.hpp b/src/libagent/includes/bytecodes_opt.hpp deleted file mode 100644 index 673345c..0000000 --- a/src/libagent/includes/bytecodes_opt.hpp +++ /dev/null @@ -1,10 +0,0 @@ -#pragma once - -#include "event/event_type.hpp" - -namespace JuiceAgent::Bytecodes { - void register_bytecodes(); - - void capture_bytecodes(const EventClassFileLoadHook& e); - void patch_bytecodes(const EventClassFileLoadHook& e); -} \ No newline at end of file diff --git a/src/libagent/includes/services.hpp b/src/libagent/includes/services.hpp index 6927211..9abcf1b 100644 --- a/src/libagent/includes/services.hpp +++ b/src/libagent/includes/services.hpp @@ -29,4 +29,9 @@ namespace JuiceAgent::services void start(); } // namespace JarLoader + namespace Bytecode + { + void init(); + void start(); + } } // namespace JuiceAgent::services \ No newline at end of file diff --git a/src/libagent/libagent.cpp b/src/libagent/libagent.cpp index ab3de89..e99a8d8 100644 --- a/src/libagent/libagent.cpp +++ b/src/libagent/libagent.cpp @@ -1,6 +1,5 @@ #include #include -#include #include #include #include @@ -82,9 +81,6 @@ namespace JuiceAgent { PLOGE << "Failed to enable event notification: " << result; } - // register bytecodes_opt - JuiceAgent::Bytecodes::register_bytecodes(); - // Loaded Event eventbus.post(EventLoaded{ .jvm = jvm, diff --git a/src/libagent/core/bytecodes_opt.cpp b/src/libagent/services/BytecodeService.cpp similarity index 89% rename from src/libagent/core/bytecodes_opt.cpp rename to src/libagent/services/BytecodeService.cpp index 7210557..b74961c 100644 --- a/src/libagent/core/bytecodes_opt.cpp +++ b/src/libagent/services/BytecodeService.cpp @@ -1,16 +1,8 @@ -#include +#include #include -#include -namespace JuiceAgent::Bytecodes { - void register_bytecodes() { - auto& agent = JuiceAgent::Agent::instance(); - - agent.get_eventbus().subscribe(capture_bytecodes); - agent.get_eventbus().subscribe(patch_bytecodes); - } - - void capture_bytecodes(const EventClassFileLoadHook& e) { +namespace JuiceAgent::services::Bytecode { + void capture_bytecodes(const EventClassFileLoadHook& e) { /* ========================= * 1. Capture original bytes * ========================= */ @@ -56,4 +48,14 @@ namespace JuiceAgent::Bytecodes { PLOGI << "Retransformed: " << e.name << " (new length: " << bytes.size() << ")"; } } + + void init() { + agent.get_eventbus().subscribe(capture_bytecodes); + agent.get_eventbus().subscribe(patch_bytecodes); + } + + void start() { + + } + } \ No newline at end of file diff --git a/src/libagent/services/ServicesManager.cpp b/src/libagent/services/ServicesManager.cpp index 7ac27ac..6decdd1 100644 --- a/src/libagent/services/ServicesManager.cpp +++ b/src/libagent/services/ServicesManager.cpp @@ -19,12 +19,17 @@ namespace JuiceAgent::services::Manager { // 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() {