Commit Graph
368 Commits
Author SHA1 Message Date
xiaozhou233 d31e43af31 Refactor: Vendor ptrace-inject-cpp into includes
- ptrace-inject-cpp: remove the submodule, its .gitmodules entry and config section
- includes/ptrace-inject-cpp: add the injection library sources, public header and LICENSE
- includes/ptrace-inject-cpp: add CMakeLists defining the ptrace_inject static library
- cmake: build includes/ptrace-inject-cpp on non-Windows instead of the submodule
- docs: list the vendored library in the AGENTS.md layout
2026-10-24 23:02:50 +08:00
xiaozhou233 4b1ca5a490 CI: check out submodules in the Linux build job
- ci: add submodules: recursive to the build-linux checkout; without it the
  ptrace-inject-cpp directory is empty and configure fails on add_subdirectory
2026-10-20 13:37:13 +08:00
xiaozhou233 483a12cd3c Feat: implement the Linux injector with ptrace-inject-cpp
- cmake: build the ptrace-inject-cpp submodule on non-Windows with its CLI and
  examples disabled, and link ptrace_inject::ptrace_inject into the injector
- injector: replace the placeholder injector_linux.c with injector_linux.cpp,
  a CLI that injects a shared library into -p PID or -n NAME and forwards the
  library's log output to stderr
2026-10-20 13:36:22 +08:00
xiaozhou233 416e83f36e [Feat] add ptrace-inject-cpp as submodule 2026-10-20 13:36:22 +08:00
xiaozhou233 4b9d371357 CI: add a Linux build job
- ci: add build-linux on ubuntu-latest (GCC + Ninja): configure, build, package, no tests
- ci: upload dist/JuiceAgent_*.tar.gz as JuiceAgent-linux-x64 (14-day retention)
- docs: describe the Windows and Linux jobs in AGENTS.md
2026-10-19 13:35:22 +08:00
xiaozhou233 c710547cc8 Docs: point Linux users at the Jenkins builds
- readme: note in Quick Start that Linux builds are not attached to GitHub Releases
- readme: add a Download subsection to Linux Support with the Jenkins job URL
- readme-zh: mirror the same changes in Chinese
2026-10-19 13:29:37 +08:00
xiaozhou233 4bb0d6ecd1 Feat: add a Linux packaging script
- script: add package.sh, packing injector/libloader.so/libagent.so into dist/JuiceAgent_vX.Y.Z_x64_linux.tar.gz
- docs: record the Linux package output in AGENTS.md
2026-10-19 13:21:09 +08:00
xiaozhou233 0e1280ef7f Docs: document Linux injection support
- readme: add the Linux platform overview, components and build requirements
- readme: describe ptrace + remote dlopen and the $HOME/.juiceagent config default
- readme-zh: mirror the same changes in Chinese
2026-10-19 13:19:57 +08:00
xiaozhou233 6eb1925ec3 Feat: add Linux libloader entry point
- libloader: add platform/linux/Entry.cpp that starts the loader from a constructor
- libloader: read the config path from JuiceAgent_ConfigPath, falling back to $HOME/.juiceagent
- libloader: default JuiceAgentNativeLibraryPath to libagent.so on non-Windows
- injector: print a notice that the Linux injector is not open source yet
2026-10-18 22:32:14 +08:00
xiaozhou233 59e705510e BugFix: restore ReflectiveDLLInjection link for libloader
- cmake: link ReflectiveDLLInjection into loader on Windows again; the platform split dropped it when jvm moved into the WIN32 branch
2026-10-18 19:18:04 +08:00
xiaozhou233 c548022068 Feat: add Linux build support scaffolding
- cmake: guard Windows-only link dir and projects (ReflectiveDLLInjection, libinject)
- agent/loader: select win32 or linux JVM headers by platform, link jvm only on Windows
- loader: glob platform/linux sources for non-Windows builds
- injector: add a Linux entry point stub selected on non-Windows
- jvm: vendor Linux jni_md.h and jawt_md.h
2026-10-18 19:12:31 +08:00
xiaozhou233 6a43b3437a BugFix: fix playload typo in retransform-class example [skip ci]
- examples: rename playload to payload (directory, class, jar, config, docs)

- payload.jar: rebuild with payload.class
2026-10-17 13:21:42 +08:00
xiaozhou233 8cd4c54c07 Docs: add QuickStartForAgents.md [skip ci]
- docs: add the agent-facing quick start (environment check, requirements, config.toml, injection, verification)
- readme: point new users at the agent guide and show how to prompt an agent
- readme-zh: mirror the same note in Chinese
2026-10-16 20:44:24 +08:00
xiaozhou233 3796cca9a1 Docs: add AGENTS.md [skip ci]
- document the build/test/release flow for agents working in this repo

- record the hard-won rules: libloader must stay exception-free (reflective loading breaks unwind), config reads are non-throwing, no MinGW runtime DLL deps, and tests must be asserted on output
2026-10-16 13:14:09 +08:00
xiaozhou233 80f926fde6 Version 5.0.1 v5.0.1 2026-10-16 13:08:25 +08:00
xiaozhou233 9351556cda Docs: add v5.0.1 release notes and changelog
- docs/update: add v5.0.1 release notes (bilingual) for the libloader crash fix, the typed event bus and the new CI

- docs/update: add the 5.0.1 entry to the changelog
2026-10-16 13:08:25 +08:00
xiaozhou233 19b1bfb88a CI: package and upload the release zip as a build artifact
- ci: after the integration tests, run script/package.cmake and upload dist/JuiceAgent_*.zip via actions/upload-artifact (14-day retention)
2026-10-16 13:02:02 +08:00
xiaozhou233 3cd28c9bcb BugFix: keep libloader exception-free so a bad config cannot crash the JVM
- loader: libloader is reflectively loaded, so its unwind tables are never registered with the OS and a C++ exception thrown inside it cannot be caught - it crashed the target JVM with EXCEPTION_ILLEGAL_INSTRUCTION when config.toml was missing a required key. Replace the throwing config reads with contains() + get(key, default) + early return, and drop the ineffective try/catch in entrypoint()

- config: parse config.toml without exceptions (toml++ parse_result) and remove the throwing get()/getPath()/getArray() overloads

- build: compile libloader with -fno-exceptions (+ SPDLOG_NO_EXCEPTIONS) so exception-capable code fails the build instead of crashing at runtime
2026-10-16 12:59:26 +08:00
xiaozhou233 124c656400 BugFix: contain exceptions at the loader entry point
- loader: wrap entrypoint() in try/catch; it runs from DllMain inside the target JVM process, so an uncaught exception (e.g. a missing required key in config.toml) would take the target process down
2026-10-16 12:50:06 +08:00
xiaozhou233 e6da1d6fff CI: statically link the runtime and bundle imported DLLs
- ci: build with -static-libgcc -static-libstdc++ (matching w64devkit, the local toolchain) so the DLLs do not depend on a libstdc++-6.dll that could be shadowed by an incompatible one on the runner

- ci: bundle only the non-system DLLs actually imported, taken from the compiler that built them, and print the import list for diagnosis
2026-10-16 12:43:20 +08:00
xiaozhou233 08fe3a8815 CI: bundle MinGW runtime DLLs and print test output on failure
- ci: copy libstdc++-6/libgcc_s_seh-1/libwinpthread-1 next to the built binaries so the tests can load libagent.dll; without them every test failed with a load error on the runner

- tests: run-tests.ps1 now prints a failing test's captured output, so a failure is diagnosable even though the test program exits 0
2026-10-16 12:38:05 +08:00
xiaozhou233 9aebf29bb5 CI: add Windows workflow and a reusable integration-test runner
- ci: build with MinGW-w64 (MSYS2) + Ninja on windows-latest and run the integration tests

- tests: add run-tests.ps1, which compiles the modules, refreshes tests/resources, then runs every test and asserts on its output (the tests exit 0 even on failure, so exit codes are not enough)
2026-10-16 12:29:31 +08:00
xiaozhou233 13145f77c9 Feat: add front-insertion listener registration to the event bus
- libagent: add EventBus::subscribeFront to insert a listener ahead of the existing ones for the same event

- libagent: add IService::listenFront, tracked like listen() so unlistenAll() still cleans it up; for cases where listener ordering matters (e.g. a transformer pipeline)
2026-10-15 21:03:03 +08:00
xiaozhou233 5b0a26d49e Refactor: replace eventpp with a small typed event bus
- libagent: rewrite EventBus as a type-safe dispatcher keyed by event type; listeners are invoked with the concrete event type instead of 'const void*', and the bus is mutex-protected

- libagent: services subscribe/unsubscribe by event type (IService::listen no longer takes an EventId)

- libagent: remove the unused MethodEntry/MethodExit events and EventMethodEntry/EventMethodExit structs

- build: drop the in-tree eventpp headers (23 files) and its license
2026-10-15 20:58:23 +08:00
xiaozhou233 4c3798735b Docs: add v5.0.0 release notes and changelog
- docs/update: add v5.0.0 release notes (bilingual) covering the v1 -> v2 breaking config change, migration steps and the BuiltIn / CustomJar modes

- docs/update: add CHANGELOG starting from v4.1.2
2026-10-15 20:09:37 +08:00
xiaozhou233 5cf0d6ebd8 Version 5.0.0 v5.0.0 2026-10-15 20:06:34 +08:00
xiaozhou233 fd6fe0abdb Refactor: remove unused loader config helpers
- config: drop get_loader_config / print_loader_config and the LoaderConfig struct, which were unused and still referenced the v1 key JuiceAgent.Loader.JuiceAgentNativeLibraryPath

- config: drop the now-unneeded ConfigStruct.hpp and Utils.hpp includes (consumers include Utils.hpp directly)
2026-10-15 20:06:22 +08:00
xiaozhou233 5170d50517 Docs: update config docs to v2 schema and add config.md
- docs: add config.md documenting the v2 schema ([JuiceAgent] / [JarLoader]), key defaults and the BuiltIn / CustomJar modes

- docs: rewrite advanced.md around the JarLoader.Mode = CustomJar workflow instead of the removed JUICEAGENT_API_* environment variables

- readme: migrate the Quick Start config example from v1 to v2 and link docs/config.md, list inject-via-java-api under Examples

- examples: update inject-via-java-api HowToUse docs (.md/.txt, EN/ZH) to the v2 config
2026-10-15 20:02:32 +08:00
xiaozhou233 af22f80b23 BugFix: fix integration test setup and GetClassBytesByName test
- tests: rewrite copy-bin.bat with native COPY /Y, cwd-independent paths and error handling so it no longer fails silently when a test JVM is locking resources\libagent.dll

- tests: load Target before calling getClassBytesByName, which only resolves classes that are already loaded
2026-10-14 21:46:22 +08:00
xiaozhou233 56a1c32f49 Feat: add Enabled flag for JarLoader module
- libagent: gate JarLoaderService::onLoaded on the JarLoader.Enabled key (default false) so the module can be turned off from config

- examples: set Enabled = true in inject-via-java-api, load-via-injector-exe and retransform-class config.toml
2026-10-14 21:46:18 +08:00
xiaozhou233 f38a28e8b3 Refactor: migrate config to v2 format across examples and libagent
- examples: update config.toml to the v2 schema ([JarLoader] with Mode / InjectionDir / JarPath / EntryClass / EntryMethod) for inject-via-java-api, load-via-injector-exe and retransform-class

- libagent: read JarLoader.* instead of JuiceAgent.Modules.JarLoader.*, use Config::isValid() and the new get()/getPath() accessors

- libagent: rename call_java_impl to call_static_java_method
2026-10-14 21:21:02 +08:00
xiaozhou233 eb7fd31817 Feat: initialize built-in / custom jar loader and fix entry class lookup
- Loader: dispatch initialize() on JarLoader.Mode; BuiltIn serializes the config and calls JuiceAgentBootstrap.start, CustomJar calls the configured EntryClass.EntryMethod

- Utils: normalize class names to the JNI internal form ('.' -> '/') so JNI FindClass accepts Java binary names like Example.Main (fixes NoClassDefFoundError on custom jar entry)

- Utils: rework Serializer, drop the unused Deserializer/LocalRef, add to_java_string_array / toDelimitedString and a no-argument call_static_java_method overload

- Config: remove the unused serialize_loader_config helper
2026-10-14 21:01:14 +08:00
xiaozhou233 92ad21003f Feat: support built-in and custom jar loading modes
- Split jar loading into load_builtin (extract and register the bundled JuiceAgent API jar) and load_custom (register a user-supplied jar) in a new JarLoader.cpp

- Check JuiceAgent.Version against CONFIG_VERSION and dispatch on JarLoader.Mode (BuiltIn / CustomJar) during preload

- Pass the parsed Config into Loader::initialize and add CONFIG_VERSION in JuiceAgent.hpp

- Restore Config::Utils loader-config helpers on top of the new getPath API
2026-10-14 19:23:41 +08:00
xiaozhou233 11cf47c4c2 Feat: add logging for config parse and access errors
- Log parse failures in the Config constructor via spdlog::error

- Log missing keys and type mismatches (error when throwing, warn when falling back to defaults)
2026-10-14 16:25:29 +08:00
xiaozhou233 3626abb35a Refactor: migrate TOML parser from toml11 to toml++
- Replace vendored single-header toml11 (includes/toml.hpp) with the toml++ library (includes/toml++)

- Rewrite Config to use toml::parse_file and expose typed get/getArray/getPath/contains accessors, storing parse errors instead of logging them

- Update bundled license to toml++
2026-10-14 16:21:48 +08:00
xiaozhou233 382bfb7fed Version 4.1.2 v4.1.2 2026-10-11 14:23:16 +08:00
xiaozhou233 560215c0ae Feat: add version-based packaging script
Add script/package.bat and script/package.cmake to package build/bin artifacts into a versioned zip under dist/.

Version.txt now uses Major/Minor/Patch key-value format so the script can parse it, and dist/ is ignored.
2026-10-10 22:16:09 +08:00
xiaozhou233 55303b7dc9 BugFix: fix getClassBytesByName cannot get class in some environments 2026-08-25 20:32:56 +08:00
xiaozhou233 41049f1852 Docs: Fix doc path 2026-08-19 19:03:05 +08:00
xiaozhou233 396ec1a96f Docs: Update Inject.md 2026-08-19 19:01:25 +08:00
xiaozhou233 10ec330480 Version 4.1.1 v4.1.1 2026-08-19 18:36:07 +08:00
xiaozhou233 0ddcfcd7c8 Remove remapper whitelist JNI declarations 2026-08-19 18:30:58 +08:00
xiaozhou233 87a91376c5 Remove JuiceRemapper module
Remove the runtime class remapping feature including its JNI bindings, service, config example, and Remapper singleton from global.hpp.
2026-08-19 18:29:38 +08:00
xiaozhou233 dbae5e5258 Fix: do not auto-read config when runtime dir is empty
Config no longer falls back to the current working directory when no
runtime directory is specified, so an empty runtime dir leaves the config
invalid instead of silently parsing config.toml from the CWD.
2026-08-18 20:11:00 +08:00
xiaozhou233 ff216aabee Fix: harden remapper filters and agent init guard
- skip empty include/exclude entries in Remapper::shouldRemap to avoid
  calling back() on an empty std::string (undefined behavior)
- null-check new_class_data_len/new_classbytes in JuiceRemapperService
  before writing remapped bytes back to the JVMTI callback
- add Agent::initialized_ guard so init() is a no-op on second call,
  preventing duplicate service instantiation and listeners
2026-08-18 16:51:21 +08:00
xiaozhou233 18a923373b Merge branch 'feat/remapper' into main 2026-08-18 16:43:47 +08:00
xiaozhou233 6fe467bccf Feat: add include/exclude filters for JuiceRemapper
- add thread-safe include/exclude sets to Remapper; shouldRemap matches
  exact name, package prefix (trailing '/'), or nested class ('\$' after
  the prefix), with exclude taking priority
- remapping stays OFF by default: an empty include set remaps nothing;
  it is only enabled once addInclude is called (no config include)
- implement addInclude/addExclude/removeInclude/removeExclude/
  clearIncludes/clearExcludes JNI bindings
- apply shouldRemap filter in JuiceRemapperService::onClassFileLoadHook
2026-08-18 16:41:55 +08:00
xiaozhou233 4bed99f417 Feat: add JuiceRemapper runtime class remapping
- add JuiceRemapperService that listens for ClassFileLoadHook and calls
  the Java static Remap.remap(String, byte[]) via cached JNI declarations,
  then writes the returned bytes back to the JVMTI callback
- add JNI bindings (initNative, add/remove/clear include/exclude) with
  Remapper singleton init state and cached jclass/jmethodID stored in
  Remapper (global.hpp)
- cache static class/method declarations lazily in initNative to avoid
  repeated FindClass/GetStaticMethodID
- add generated JuiceRemapper JNI header and runtime-remap example config
2026-08-18 16:28:29 +08:00
xiaozhou233 81905d6c3f Merge branch 'dev' into main v4.1.0 2026-08-17 20:07:11 +08:00
xiaozhou233 6822c1dc63 Version 4.1.0 2026-08-17 20:06:34 +08:00