From fc68fde5463fc363284213ccfcde92b3baed86df Mon Sep 17 00:00:00 2001 From: Konloch Date: Tue, 13 Jul 2021 04:46:21 -0700 Subject: [PATCH] Better Plugin Handling This isn't a perfect solution since it will create a new console window for each resource, however it maintains compatibility and makes it easy on plugin authors A new plugin class would be a good idea for a better alternative, then more advanced plugins could use that as the class base instead of just the.bytecode.club.bytecodeviewer.api.Plugin --- .../club/bytecodeviewer/api/Plugin.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) 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 18362296..c3309ddc 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/Plugin.java @@ -1,8 +1,11 @@ package the.bytecode.club.bytecodeviewer.api; import java.util.ArrayList; +import java.util.List; + import org.objectweb.asm.tree.ClassNode; import the.bytecode.club.bytecodeviewer.BytecodeViewer; +import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; /*************************************************************************** * Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite * @@ -30,6 +33,10 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; public abstract class Plugin extends Thread { + //as long as your code is being called from the execute function + // this will be the current container + public ResourceContainer activeContainer = null; + @Override public void run() { @@ -39,8 +46,8 @@ public abstract class Plugin extends Thread { if (BytecodeViewer.promptIfNoLoadedClasses()) return; - - execute(BytecodeViewer.getLoadedClasses()); + + executeContainer(); } catch (Exception e) { BytecodeViewer.handleException(e); } finally { @@ -68,9 +75,24 @@ public abstract class Plugin extends Thread public void setFinished() { finished = true; } - + /** - * Whenever the plugin is started, this method is called + * On plugin start each resource container is iterated through + */ + public void executeContainer() + { + BytecodeViewer.getResourceContainers().forEach(container -> { + //set the active container + activeContainer = container; + + //call on the plugin code + execute(new ArrayList<>(container.resourceClasses.values())); + }); + } + + /** + * On plugin start each resource container is iterated through, + * then this is called with the resource container classes * * @param classNodeList all of the loaded classes for easy access. */