From d304ededd5a210b7625c44d78b7b26873c25b8b9 Mon Sep 17 00:00:00 2001 From: xiaozhou233 Date: Sat, 15 Aug 2026 14:20:00 +0800 Subject: [PATCH] Docs: sync README with current project structure --- README.md | 28 +++++++++++++++++++++++----- README_ZH.md | 28 +++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 811edf9..379346e 100644 --- a/README.md +++ b/README.md @@ -80,7 +80,8 @@ The `JuiceAgent-API` jar is embedded in the native binaries, so no separate down - `src/libloader` — `libloader.dll`. Injected into the target JVM. Attaches to the JVM, parses `config.toml`, injects the embedded `JuiceAgent-API`, and bootstraps the agent. - `src/libagent` — `libagent.dll`. The JVMTI agent. Registers callbacks (e.g. `ClassFileLoadHook`) and implements the native side of `JuiceAgent-API`. -- `src/libinjector` — `injector.exe` + `libinject.dll`. Reflective DLL injector that loads `libloader.dll` into the target process. Can be driven from the command line or through JNI. +- `src/injector` — `injector.exe`. Command-line driver that loads `libinject.dll` and injects `libloader.dll` into the target process. +- `src/libinject` — `libinject.dll`. Reflective DLL injector. Exposes a native `inject` function and JNI bindings (`cn.xiaozhou233.juiceagent.injector.InjectorNative`). ## Quick Start @@ -162,7 +163,25 @@ You can also pass arguments directly: `injector.exe [ #### Method B: Use JNI to call `inject` -See [docs/Inject.md](docs/Inject.md) for details. +Create `cn/xiaozhou233/juiceagent/injector/InjectorNative.java` in your project: + +```java +package cn.xiaozhou233.juiceagent.injector; + +public class InjectorNative { + public native boolean inject(int pid, String path); + public native boolean inject(int pid, String path, String configDir); +} +``` + +Example: + +```java +System.load(""); +InjectorNative injectorNative = new InjectorNative(); + +injectorNative.inject(, "", ""); +``` ### 5. Done @@ -189,7 +208,7 @@ The following native functions are exposed to Java through the `cn.xiaozhou233.j ## Examples - `examples/load-via-injector-exe` — loads a JAR into a target JVM via `injector.exe` and runs an entry point. -- `examples/retansform-class` — demonstrates class retransformation with a target JVM and a modified copy of the class. +- `examples/retransform-class` — demonstrates class retransformation with a target JVM and a modified copy of the class. ## How To Build @@ -229,6 +248,5 @@ This project is intended for learning and research in controlled environments on ## Acknowledgements - [ReflectiveDLLInjection](https://github.com/stephenfewer/ReflectiveDLLInjection) — DLL injection implementation -- [plog](https://github.com/SergiusTheBest/plog) — Portable, simple, and extensible C++ logging library +- [spdlog](https://github.com/gabime/spdlog) — Fast C++ logging library - [toml11](https://github.com/ToruNiina/toml11) — TOML for Modern C++ -- [eventpp](https://github.com/wqking/eventpp) — C++ library for event dispatchers and callback lists diff --git a/README_ZH.md b/README_ZH.md index 710032f..ec3d240 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -82,7 +82,8 @@ JuiceAgent 是 [JuiceAgent-API](https://github.com/xiaozhou233/JuiceAgent-API) - `src/libloader` — `libloader.dll`。注入到目标 JVM,附加 JVM、解析 `config.toml`、注入内嵌的 `JuiceAgent-API` 并引导 agent。 - `src/libagent` — `libagent.dll`。JVMTI agent。注册回调(例如 `ClassFileLoadHook`)并实现 `JuiceAgent-API` 的原生侧。 -- `src/libinjector` — `injector.exe` + `libinject.dll`。反射式 DLL 注入器,将 `libloader.dll` 加载到目标进程。可通过命令行或 JNI 驱动。 +- `src/injector` — `injector.exe`。命令行驱动,加载 `libinject.dll` 并将 `libloader.dll` 注入到目标进程。 +- `src/libinject` — `libinject.dll`。反射式 DLL 注入器,导出原生 `inject` 函数并提供 JNI 绑定(`cn.xiaozhou233.juiceagent.injector.InjectorNative`)。 ## 快速开始 @@ -164,7 +165,25 @@ Input PID: #### 方法 B:通过 JNI 调用 `inject` -详见 [docs/Inject.md](docs/Inject.md)。 +在你的项目中创建 `cn/xiaozhou233/juiceagent/injector/InjectorNative.java`: + +```java +package cn.xiaozhou233.juiceagent.injector; + +public class InjectorNative { + public native boolean inject(int pid, String path); + public native boolean inject(int pid, String path, String configDir); +} +``` + +示例: + +```java +System.load(""); +InjectorNative injectorNative = new InjectorNative(); + +injectorNative.inject(, "", "<配置文件所在目录>"); +``` ### 5. 完成 @@ -191,7 +210,7 @@ Input PID: ## 示例 - `examples/load-via-injector-exe` — 通过 `injector.exe` 将 JAR 加载到目标 JVM 并运行入口点。 -- `examples/retansform-class` — 演示使用目标 JVM 和修改后的类副本进行类重变换。 +- `examples/retransform-class` — 演示使用目标 JVM 和修改后的类副本进行类重变换。 ## 如何构建 @@ -231,6 +250,5 @@ cmake --build build ## 致谢 - [ReflectiveDLLInjection](https://github.com/stephenfewer/ReflectiveDLLInjection) — DLL 注入实现 -- [plog](https://github.com/SergiusTheBest/plog) — 轻量、简单、可扩展的 C++ 日志库 +- [spdlog](https://github.com/gabime/spdlog) — 高性能 C++ 日志库 - [toml11](https://github.com/ToruNiina/toml11) — 现代 C++ 的 TOML 库 -- [eventpp](https://github.com/wqking/eventpp) — 事件分发器与回调列表 C++ 库