diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java index efbcbd96..131d9b1a 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java @@ -5,8 +5,11 @@ import java.util.List; import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.plugin.strategies.JavascriptPluginLaunchStrategy; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; +import javax.script.ScriptEngine; + /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * * Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com * diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java index 3bc1b1f1..bd3db8f2 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/plugin/strategies/JavascriptPluginLaunchStrategy.java @@ -55,7 +55,6 @@ public class JavascriptPluginLaunchStrategy implements PluginLaunchStrategy bindings.put("polyglot.js.allowHostAccess", true); bindings.put("polyglot.js.allowAllAccess", true); bindings.put("polyglot.js.allowHostClassLookup", true); - bindings.put("activeContainer", activeContainer); } Reader reader = new FileReader(file); @@ -63,13 +62,16 @@ public class JavascriptPluginLaunchStrategy implements PluginLaunchStrategy ScriptEngine finalEngine = engine; - Plugin plugin = new Plugin() + return new Plugin() { @Override public void execute(ArrayList classNodeList) { try { + //add the active container as a global variable to the JS script + finalEngine.put("activeContainer", activeContainer); + //invoke the JS function ((Invocable) finalEngine).invokeFunction("execute", classNodeList); } @@ -79,7 +81,5 @@ public class JavascriptPluginLaunchStrategy implements PluginLaunchStrategy } } }; - - plugin.setupJSContainer(finalEngine); } } \ No newline at end of file