Commit Graph
333 Commits
Author SHA1 Message Date
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
xiaozhou233 27abc2bf6a Fix: propagate preload/init failure from JNI init entry
Java_cn_xiaozhou233_juiceagent_api_JuiceAgent_init now checks the return
values of Agent::preload and Agent::init and returns JNI_FALSE when either
fails, instead of always reporting success to Java.
2026-08-17 20:04:40 +08:00
xiaozhou233 4f433bc6ee Fix: init lifecycle event payloads and clean up service listeners
- fill EventPreLoad/EventLoaded struct members instead of leaving them
  as uninitialized garbage; post PreLoad only after the agent environment
  (JavaVM/JNIEnv/JVMTI) is set so listeners can query Agent state
- store (EventId, Handle) pairs in IService and add unlistenAll() to
  remove registered listeners on shutdown, preventing dangling callbacks
  into destroyed services; BytecodeService and JarLoaderService now call
  it from onShutdown
2026-08-17 20:02:39 +08:00
xiaozhou233 20747124d1 Feat: add JarLoaderService that loads jar on EventLoaded
- add JarLoaderService registered via JUICEAGENT_REGISTER_SERVICE; it
  listens for EventId::Loaded, reads JuiceAgent.Modules.JarLoader config
  from config.toml, serializes it and calls the Java JarLoader.loadJar
  module to inject the jar into the JVM
- post EventPreLoad during Agent::preload and EventLoaded after services
  initialize so services can react to agent lifecycle
2026-08-17 19:59:23 +08:00
xiaozhou233 4833b512f5 Test: add bytecode API integration tests
- add Java tests for getClassBytes(ByName), redefineClass(ByName),
  retransformClass(ByName) and defineClass
- ignore tests/tmp/ directory for captured bytecode output
2026-08-17 19:42:12 +08:00
xiaozhou233 63dd69abc6 Fix: use FindClass in getClassBytesByName to resolve class lookup 2026-08-17 19:27:15 +08:00
xiaozhou233 f38743e863 Feat: add JNI bytecode API and BytecodeStore
- introduce thread-safe BytecodeStore singleton for pending captures,
  captured bytecode cache, and pending patches; replaces ad-hoc global
  mutex/map pairs
- implement BytecodeService capture/patch listeners that operate on
  the store; keep JVMTI Allocate outside of store locks and put failed
  patches back so they can be retried
- add JNI bindings: getClassBytes(ByName), redefineClass(ByName),
  retransformClass(ByName); use JVMTI GetLoadedClasses for name-based
  lookup instead of JNI FindClass, validate array length vs declared
  length in redefineClass
2026-08-17 19:19:26 +08:00
xiaozhou233 8e1b8b38e4 Refactor: auto-register services and inline BytecodeService
- add ServiceRegistry and JUICEAGENT_REGISTER_SERVICE macro so each
  service self-registers at static init; initializeAll() no longer
  includes concrete service headers
- move BytecodeService class entirely into its .cpp (no header needed,
  only accessed via IService)
- split ClassFileLoadHook handling into captureBytecodes and
  patchBytecodes listeners, registered in order
2026-08-17 18:54:36 +08:00
xiaozhou233 6962c4a477 Feat: add event bus and service framework
- introduce EventBus singleton wrapping eventpp::EventDispatcher with
  typed event ids and const void* payloads
- post EventClassFileLoadHook from ClassFileLoadHook callback
- add IService base with typed listen<>() helper that binds a member
  function directly to an event, no virtual onEvent dispatch
- add ServiceManager to register, initialize and shutdown services
- add BytecodeService that subscribes to ClassFileLoadHook
- wire Services::initializeAll() into Agent::init()
2026-08-17 15:45:39 +08:00
xiaozhou233 6bf2d31798 Feat: add IntelliJ integration tests for native API
- Add test JVM sources (Loop, Target) and API tests
  (AddToBootstrap/SystemClassLoaderSearch, AddToClassLoader,
  GetClassByName, GetLoadedClasses)
- Add injection module (Injection jar) for classloader tests
- Add copy-bin.bat to refresh resources/ from build output
- Remove obsolete java-loop/java-system-load tests
- Ignore IDE dirs and resources/ build artifacts
2026-08-17 00:16:24 +08:00
xiaozhou233 6afa44f90a Feat: add classloader JNI layer for the new agent
- Re-add addToBootstrap/SystemClassLoaderSearch, addToClassLoader, defineClass,
  getLoadedClasses, getClassByName on the new Agent singleton
- Add utils.hpp with check_env/get_class_name helpers
- Pull utils.hpp into jni_common.hpp umbrella header
2026-08-16 22:49:13 +08:00
xiaozhou233 2ab1c134ed Feat: load config in libagent to prepare for modules
- Make runtime_dir optional in JuiceAgent.init (tolerate null jstring)
- Load config.toml into Agent and expose getConfig/setConfig
- Warn instead of failing when runtime directory or config is missing
2026-08-16 22:38:08 +08:00
xiaozhou233 51bcfbd549 Refactor: rebuild libagent with simplified lifecycle
- Replace eventbus/services with Agent preload/init lifecycle
- Move JNI header to shared includes; add jni_common.hpp umbrella header
- Reduce ClassFileLoadHook to a stub for later implementation
- Add eventpp dependency
- Document custom API JAR workflow (WIP)
2026-08-16 21:14:44 +08:00
xiaozhou233 3b180e7199 Fix: harden libloader config handling
- Guard Config against NULL runtime_dir
- Read JuiceAgent.Version from config instead of hardcoding 2
- Move LoaderConfig to ConfigStruct.hpp; remove obsolete JuiceAgent.hpp
2026-08-16 21:08:13 +08:00
xiaozhou233 b34377d447 Refactor: restructure libloader and drop config parsing
- Move loader logic to core/ and rename plantform/ to platform/
- Remove config.toml parsing from loader; pass runtime_dir to Bootstrap directly
- Rewrite JvmAttach: RAII detach, drop dead thread_local, merge acquire helpers
- Fix initialize() missing namespace qualification
- Make GLOB sources pick up new files with CONFIGURE_DEPENDS
2026-08-16 18:53:31 +08:00
xiaozhou233 f2ce4e6a5a Fix: simplify DllMain attach logic and add pause to java-system-load test 2026-08-16 16:13:26 +08:00
xiaozhou233 757c5f70f0 Fix: Delete unuse config 2026-08-16 16:03:28 +08:00
xiaozhou233 78160a33a9 Feat: add java-system-load test with copy-and-build and run scripts 2026-08-16 16:02:43 +08:00
xiaozhou233 092110672a Fix: avoid running agent/loader logic on plain System.load 2026-08-16 15:32:23 +08:00
xiaozhou233 c5acf2aba0 Docs: add examples markdown docs (EN/CN) and index 2026-08-15 22:15:13 +08:00
xiaozhou233 316735cfef Version 4.0.1 Build 2 v4.0.1_b2 2026-08-15 22:01:28 +08:00
xiaozhou233 a1b0eb8b84 Feat: add inject-via-java-api example with JNI refactor
- Rename JNI class from InjectorNative to Injector in libinject.c

- Add JNI header for cn.xiaozhou233.juiceagent.injector.Injector

- Add inject-via-java-api example with HowToUse.txt and 如何使用.txt
2026-08-15 21:51:48 +08:00
xiaozhou233 32e9199d4a Docs: add community links and examples reference to READMEs 2026-08-15 16:10:01 +08:00
xiaozhou233 56ebafd48d Docs: add examples link to Quick Start section 2026-08-15 15:59:08 +08:00
xiaozhou233 d304ededd5 Docs: sync README with current project structure 2026-08-15 14:20:00 +08:00
xiaozhou233 7a4d8cb101 Feat: add license 2026-08-15 14:04:43 +08:00
xiaozhou233 3303630a45 Docs: Add Chinese README and improve AV notice 2026-08-15 14:03:37 +08:00
xiaozhou233 20fd69d239 Docs: fix link and build script 2026-08-15 14:00:45 +08:00
xiaozhou233 b8a4b805c7 Docs: Add antivirus false positive notice 2026-08-15 13:58:58 +08:00
xiaozhou233 a56caffe09 Version 4.0.0 Build 1 v4.0.0_b1 2026-08-15 13:48:09 +08:00
xiaozhou233 b08656daa6 Feat: add retransform-class example with build/run scripts and docs 2026-08-15 13:41:26 +08:00
xiaozhou233 57405e810c Restore: re-add README, examples and tools 2026-08-15 13:17:50 +08:00
xiaozhou233 6e417035b6 Merge branch 'refactor' into main 2026-08-15 13:15:02 +08:00
xiaozhou233 1d3755952f Feat: migrate libagent from JuiceAgent and port to spdlog 2026-08-15 13:13:55 +08:00
xiaozhou233 bcc1ecbf0e Refactor: simplify injector/libinject/loader code
- libinject: drop debug cruft, dedup JNI overloads into jni_inject, const-correct inject()
- loader: reuse Utils::call_java_impl for JNI bootstrap
- JvmAttach: collapse acquire_jvm/env/jvmti retry loops into one template
- injector: remove redundant copy_arg wrapper
- DllMain: remove no-op DLL_THREAD cases, merge attach logs
- libagent: guard add_library so empty source dir does not break configure
2026-08-15 12:55:27 +08:00
xiaozhou233 a251b8996e Feat: add libagent CMakeLists.txt 2026-08-15 12:48:23 +08:00