diff --git a/tests/.gitignore b/tests/.gitignore index 4ba1afd..17ac124 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -1,3 +1,5 @@ *.class *.log +*.dll +*.exe build/ diff --git a/tests/java-system-load/Loader.java b/tests/java-system-load/Loader.java new file mode 100644 index 0000000..a842bdf --- /dev/null +++ b/tests/java-system-load/Loader.java @@ -0,0 +1,16 @@ +import java.io.File; +import java.io.IOException; + +public class Loader { + public static void main(String[] args) { + System.load(new File("./libinject.dll").getAbsolutePath()); + System.out.println("Loaded libinject.dll"); + System.out.println("===================================="); + System.load(new File("./libloader.dll").getAbsolutePath()); + System.out.println("Loaded libloader.dll"); + System.out.println("===================================="); + System.load(new File("./libagent.dll").getAbsolutePath()); + System.out.println("Loaded libagent.dll"); + + } +} \ No newline at end of file diff --git a/tests/java-system-load/config.toml b/tests/java-system-load/config.toml new file mode 100644 index 0000000..e2f3f1d --- /dev/null +++ b/tests/java-system-load/config.toml @@ -0,0 +1,21 @@ +[JuiceAgent] +Version = 1 + +[JuiceAgent.Loader] +# Path to JuiceAgent-API jar, leave empty to use the built-in API +JuiceAgentAPIJarPath = "" +# Path to libagent.dll, default is "./libagent.dll" +JuiceAgentNativeLibraryPath = "" + +[JuiceAgent.Modules] + +[JuiceAgent.Modules.JarLoader] +Enabled = true +# Directory containing dependency JARs to load into the JVM (put your deps here) +InjectionDir = "./injection" +# Path to the injection JAR to be loaded +JarPath = "./demo.jar" +# Entry class to be executed after loading the JAR +EntryClass = "Example.Main" +# Entry method, must be: public static void run() +EntryMethod = "run" diff --git a/tests/java-system-load/copy-and-build.bat b/tests/java-system-load/copy-and-build.bat new file mode 100644 index 0000000..0e3b2b8 --- /dev/null +++ b/tests/java-system-load/copy-and-build.bat @@ -0,0 +1,23 @@ +@echo off +setlocal +cd /d "%~dp0" + +set "SRC=..\..\build\bin" + +echo [INFO] Copying build artifacts from "%SRC%" ... +xcopy /Y "%SRC%\libagent.dll" .\ >nul +xcopy /Y "%SRC%\libinject.dll" .\ >nul +xcopy /Y "%SRC%\libloader.dll" .\ >nul +echo [OK] Artifacts copied. + +if not exist build mkdir build + +javac -d build Loader.java +if errorlevel 1 ( + echo [ERROR] Build failed. + exit /b 1 +) + +echo [OK] Build succeeded: build\Loader.class + +endlocal \ No newline at end of file diff --git a/tests/java-system-load/run.bat b/tests/java-system-load/run.bat new file mode 100644 index 0000000..7087958 --- /dev/null +++ b/tests/java-system-load/run.bat @@ -0,0 +1,11 @@ +@echo off +setlocal +cd /d "%~dp0" + +java -cp build Loader +if errorlevel 1 ( + echo [ERROR] Run failed. + exit /b 1 +) + +endlocal \ No newline at end of file