diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java index 28c64097..cae26b22 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/BytecodeViewer.java @@ -249,7 +249,7 @@ public class BytecodeViewer */ public static synchronized String getJavaCommand() { - sm.stopBlocking(); + sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder("java", "-version"); @@ -258,7 +258,7 @@ public class BytecodeViewer } catch (Exception e) //ignore { - sm.setBlocking(); + sm.resumeBlocking(); boolean empty = Configuration.java.isEmpty(); while (empty) { @@ -270,7 +270,7 @@ public class BytecodeViewer } finally { - sm.setBlocking(); + sm.resumeBlocking(); } return Configuration.java; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java index 97762cf2..01e5c89b 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java @@ -1,16 +1,6 @@ package the.bytecode.club.bytecodeviewer; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.reflect.TypeToken; -import me.konloch.kontainer.io.DiskReader; -import me.konloch.kontainer.io.DiskWriter; -import the.bytecode.club.bytecodeviewer.util.MiscUtils; - -import javax.swing.*; import java.io.File; -import java.util.ArrayList; -import java.util.List; /** * General program constants, to use this class include everything as a wildcard static import: @@ -78,13 +68,13 @@ public class Constants */ private static void hideFile(File f) { - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { // Hide file by running attrib system command (on Windows) Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath()); } catch (Exception e) { BytecodeViewer.handleException(e); } - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMRenameUtil.java b/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java similarity index 91% rename from src/main/java/the/bytecode/club/bytecodeviewer/api/ASMRenameUtil.java rename to src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java index 096aecf6..2646b38d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMRenameUtil.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/api/ASMResourceUtil.java @@ -30,13 +30,33 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer; ***************************************************************************/ /** - * Used to rename/replace methods/classes/fields loaded as a BCV resource + * Used to interact with classnodes loaded inside of BCV as resources * * @author Konloch */ -public final class ASMRenameUtil +public final class ASMResourceUtil { + /** + * Attempts to a method main inside of the loaded resources and returns the fully qualified name + */ + public static String findMainMethod(String defaultFQN) + { + for (ClassNode cn : BytecodeViewer.getLoadedClasses()) + { + for (Object o : cn.methods.toArray()) + { + MethodNode m = (MethodNode) o; + + if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V")) + { + return cn.name + "." + m.name; + } + } + } + + return defaultFQN; + } public static void renameFieldNode(String originalParentName, String originalFieldName, String originalFieldDesc, diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java index eb514f1a..0cb34702 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/JavaCompiler.java @@ -67,7 +67,7 @@ public class JavaCompiler extends InternalCompiler JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), cp.getAbsolutePath()); boolean cont = true; - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { StringBuilder log = new StringBuilder(); ProcessBuilder pb; @@ -142,7 +142,7 @@ public class JavaCompiler extends InternalCompiler cont = false; e.printStackTrace(); } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } cp.delete(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java index a1f5695b..927eb140 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/compilers/impl/KrakatauAssembler.java @@ -72,7 +72,7 @@ public class KrakatauAssembler extends InternalCompiler StringBuilder log = new StringBuilder(); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( @@ -120,7 +120,7 @@ public class KrakatauAssembler extends InternalCompiler e.printStackTrace(); //BytecodeViewer.handleException(log.toString()); } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } return null; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java index 0edd9033..45eadc1d 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/FernFlowerDecompiler.java @@ -91,14 +91,14 @@ public class FernFlowerDecompiler extends InternalDecompiler generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath()) )); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); Process p = pb.start(); BytecodeViewer.createdProcesses.add(p); p.waitFor(); } catch (Exception e) { BytecodeViewer.handleException(e); } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } } else { try { diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java index 0ece9497..d0b2db54 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDecompiler.java @@ -91,7 +91,7 @@ public class KrakatauDecompiler extends InternalDecompiler String s = "Bytecode Viewer Version: " + VERSION + nl + nl + "Please send this to konloch@gmail.com. " + nl + nl; - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( Configuration.python, @@ -141,7 +141,7 @@ public class KrakatauDecompiler extends InternalDecompiler e.printStackTrace(); s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } return s; @@ -178,7 +178,7 @@ public class KrakatauDecompiler extends InternalDecompiler JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( @@ -232,7 +232,7 @@ public class KrakatauDecompiler extends InternalDecompiler e.printStackTrace(); s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } return s; @@ -259,7 +259,7 @@ public class KrakatauDecompiler extends InternalDecompiler final File tempJar = new File(sourceJar); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( @@ -284,7 +284,7 @@ public class KrakatauDecompiler extends InternalDecompiler } catch (Exception e) { BytecodeViewer.handleException(e); } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java index 400e3f38..b158d31f 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/KrakatauDisassembler.java @@ -59,7 +59,7 @@ public class KrakatauDisassembler extends InternalDecompiler String s = "Bytecode Viewer Version: " + VERSION + nl + nl + "Please send this to konloch@gmail.com. " + nl + nl; - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( Configuration.python, @@ -108,7 +108,7 @@ public class KrakatauDisassembler extends InternalDecompiler e.printStackTrace(); s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } return s; } @@ -133,7 +133,7 @@ public class KrakatauDisassembler extends InternalDecompiler final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar"); JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath()); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( Configuration.python, @@ -181,7 +181,7 @@ public class KrakatauDisassembler extends InternalDecompiler e.printStackTrace(); s += nl + "Bytecode Viewer Version: " + VERSION + nl + nl + sw; } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } return s; } @@ -199,7 +199,7 @@ public class KrakatauDisassembler extends InternalDecompiler final File tempJar = new File(sourceJar); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( Configuration.python, @@ -220,7 +220,7 @@ public class KrakatauDisassembler extends InternalDecompiler } catch (Exception e) { BytecodeViewer.handleException(e); } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java index f53d6192..35cd4872 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/APKTool.java @@ -68,10 +68,10 @@ public class APKTool { //save entire jar as smali files System.out.println("Building!"); - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); brut.apktool.Main.main(new String[]{"b", container.APKToolContents.getAbsolutePath(), "--frame-path", tempAPKPath.getAbsolutePath(), "-o", output.getAbsolutePath()}); - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); tempAPKPath.delete(); } catch (Exception e) { BytecodeViewer.handleException(e); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java index 7befca10..ac60e7ab 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/Enjarify.java @@ -49,7 +49,7 @@ public class Enjarify { return; } - BytecodeViewer.sm.stopBlocking(); + BytecodeViewer.sm.pauseBlocking(); try { ProcessBuilder pb = new ProcessBuilder( Configuration.python3, @@ -71,7 +71,7 @@ public class Enjarify { } catch (Exception e) { BytecodeViewer.handleException(e); } finally { - BytecodeViewer.sm.setBlocking(); + BytecodeViewer.sm.resumeBlocking(); } } }