From 57b9f0e2b392645d604684280c785c5a29a845df Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Tue, 20 Jul 2021 17:03:30 +0200 Subject: [PATCH 1/5] Warn user if no decompiler is selected --- .../gui/resourceviewer/viewer/ClassViewer.java | 11 ++++++++++- .../bytecodeviewer/translation/TranslatedStrings.java | 1 + .../club/bytecodeviewer/translation/Translation.java | 1 + src/main/resources/translations/english.json | 1 + src/main/resources/translations/german.json | 1 + 5 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java index c94e44b4e..7c4fbdfe1 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java @@ -26,6 +26,8 @@ import the.bytecode.club.bytecodeviewer.SettingsSerializer; import the.bytecode.club.bytecodeviewer.resources.Resource; import the.bytecode.club.bytecodeviewer.resources.ResourceContainer; +import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings; +import the.bytecode.club.bytecodeviewer.translation.Translation; import the.bytecode.club.bytecodeviewer.util.MethodParser; import static the.bytecode.club.bytecodeviewer.util.MethodParser.Method; @@ -89,7 +91,14 @@ public void refresh(final JButton button) { setPanes(); refreshTitle(); - + + // Warn user if no Decompiler is selected + if (bytecodeViewPanel1.decompiler == Decompiler.NONE + && bytecodeViewPanel2.decompiler == Decompiler.NONE + && bytecodeViewPanel3.decompiler == Decompiler.NONE) { + BytecodeViewer.showMessage(TranslatedStrings.SUGGESTED_FIX_NO_DECOMPILER_WARNING.getText()); + } + bytecodeViewPanel1.createPane(this); bytecodeViewPanel2.createPane(this); bytecodeViewPanel3.createPane(this); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java index ba363618b..e9b90fe29 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/TranslatedStrings.java @@ -84,6 +84,7 @@ public enum TranslatedStrings FIRST_OPEN_A_RESOURCE, FIRST_OPEN_A_CLASS, FIRST_VIEW_A_CLASS, + SUGGESTED_FIX_NO_DECOMPILER_WARNING, DRAG_CLASS_JAR, ; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Translation.java b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Translation.java index e09f37060..93e888bc7 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/translation/Translation.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/translation/Translation.java @@ -226,6 +226,7 @@ public enum Translation ERROR, SUGGESTED_FIX_DECOMPILER_ERROR, SUGGESTED_FIX_COMPILER_ERROR, + SUGGESTED_FIX_NO_DECOMPILER_WARNING, PROCYON_DECOMPILER, CFR_DECOMPILER, FERNFLOWER_DECOMPILER, diff --git a/src/main/resources/translations/english.json b/src/main/resources/translations/english.json index 9d01042ab..8a740971f 100644 --- a/src/main/resources/translations/english.json +++ b/src/main/resources/translations/english.json @@ -126,6 +126,7 @@ "NEW_JAVASCRIPT_PLUGIN": "New Javascript Plugin", "SUGGESTED_FIX_DECOMPILER_ERROR": "Suggested Fix: Click refresh class, if it fails again try another decompiler.", "SUGGESTED_FIX_COMPILER_ERROR": "Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable.", + "SUGGESTED_FIX_NO_DECOMPILER_WARNING": "WARNING: No decompiler is currently selected. Try View>Pane and choose a decompiler.", "COMPILER_TIP": "Keep in mind most decompilers cannot produce compilable classes", "FIRST_OPEN_A_RESOURCE": "First open a resource inside of BCV (class, jar, zip or apk file)", "FIRST_OPEN_A_CLASS": "First open a classfile resource inside of BCV (jar, zip, apk, dex)", diff --git a/src/main/resources/translations/german.json b/src/main/resources/translations/german.json index 6ad9e5bfb..d97d79f74 100644 --- a/src/main/resources/translations/german.json +++ b/src/main/resources/translations/german.json @@ -93,6 +93,7 @@ "ERROR": "Fehler", "SUGGESTED_FIX_DECOMPILER_ERROR": "Vorgeschlagene Lösung: Klicken Sie auf Klasse aktualisieren und wenn es wieder fehlschlägt, versuchen Sie einen anderen Dekompilierer.", "SUGGESTED_FIX_COMPILER_ERROR": "Vorgeschlagene Lösung: Aktivieren Sie unter Ansicht>Fenster>Krakatau>Bytecode Editierbar.", + "SUGGESTED_FIX_NO_DECOMPILER_WARNING": "ACHTUNG: Derzeit ist kein Dekompilierer ausgewählt. Versuchen Sie unter Ansicht>Fenster einen Dekompilierer auszuwählen.", "FILES": "Dateien", "QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Dateien-Schnellsuche öffnen (ohne Dateiendungen)", "WORK_SPACE": "Arbeitsbereich", From 27d1dea9ddcbb7f88742d51744ba640c9cb01a60 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Tue, 20 Jul 2021 17:35:27 +0200 Subject: [PATCH 2/5] Read version directly from POM --- pom.xml | 25 +++++++++---------- .../club/bytecodeviewer/Constants.java | 2 +- .../compilers/impl/KrakatauAssembler.java | 2 -- .../decompilers/impl/CFRDecompiler.java | 1 - .../malwarescanner/MalwareCodeScanner.java | 6 ++--- .../bytecodeviewer/util/VersionChecker.java | 3 ++- 6 files changed, 18 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index feddd948f..2f8d6f1f1 100644 --- a/pom.xml +++ b/pom.xml @@ -237,19 +237,6 @@ - - org.apache.maven.plugins - maven-jar-plugin - 3.1.1 - - - - true - the.bytecode.club.bytecodeviewer.BytecodeViewer - - - - org.apache.maven.plugins maven-compiler-plugin @@ -287,9 +274,21 @@ META-INF/*.SF META-INF/*.DSA META-INF/*.RSA + META-INF/*LICENSE* + META-INF/*NOTICE* + META-INF/MANIFEST.MF + + + the.bytecode.club.bytecodeviewer.BytecodeViewer + + ${version} + + + diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java index b146fc4b6..ebe19ff3e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/Constants.java @@ -16,7 +16,7 @@ public class Constants { /*per version*/ - public static final String VERSION = "2.10.14"; //could be loaded from the pom + public static final String VERSION = BytecodeViewer.class.getPackage().getImplementationVersion(); public static String krakatauVersion = "12"; public static String enjarifyVersion = "4"; public static final boolean BLOCK_TAB_MENU = true; 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 3093fc94b..3ac886c40 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 @@ -51,8 +51,6 @@ public byte[] compile(String contents, String fullyQualifiedName) if(!ExternalResources.getSingleton().hasSetPython2Command()) return null; - String origName = MiscUtils.randomString(20); - File tempD = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs); tempD.mkdir(); diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java index e4a0243fb..8d4a90a54 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/decompilers/impl/CFRDecompiler.java @@ -11,7 +11,6 @@ import java.io.StringWriter; import java.util.Deque; import java.util.LinkedList; -import java.util.Objects; import java.util.Random; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java b/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java index 52e32a7fb..bcfac4ccf 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/malwarescanner/MalwareCodeScanner.java @@ -117,16 +117,16 @@ public String header() public void foundLDC(MalwareScan scan, String ldc, String foundAt) { - scan.sb.append(header() + " Found LDC \"").append(ldc).append("\" ").append(foundAt); + scan.sb.append(header()).append(" Found LDC \"").append(ldc).append("\" ").append(foundAt); } public void foundMethod(MalwareScan scan, String foundAt) { - scan.sb.append(header() + " Found Method call to ").append(foundAt); + scan.sb.append(header()).append(" Found Method call to ").append(foundAt); } public void found(MalwareScan scan, String found) { - scan.sb.append(header() + " Found ").append(found); + scan.sb.append(header()).append(" Found ").append(found); } } diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java b/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java index 9a7f6cdcd..eda49bc7e 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/util/VersionChecker.java @@ -1,5 +1,6 @@ package the.bytecode.club.bytecodeviewer.util; +import java.util.Objects; import me.konloch.kontainer.io.HTTPRequest; import the.bytecode.club.bytecodeviewer.BytecodeViewer; import the.bytecode.club.bytecodeviewer.Configuration; @@ -58,7 +59,7 @@ public void run() } - if (!VERSION.equals(version)) + if (VERSION != null && !VERSION.equals(version)) { MultipleChoiceDialogue outdatedDialogue = new MultipleChoiceDialogue("Bytecode Viewer - Outdated Version", "Your version: " + VERSION + ", latest version: " From 4b51297e6c1aa1e57b0dba494490891a793928b2 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Tue, 20 Jul 2021 17:39:04 +0200 Subject: [PATCH 3/5] Use new version expression --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 2f8d6f1f1..91ccf2c93 100644 --- a/pom.xml +++ b/pom.xml @@ -285,7 +285,7 @@ implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> the.bytecode.club.bytecodeviewer.BytecodeViewer - ${version} + ${project.version} From fcfd6d3ae6d60180481f814be8ef8915e175be41 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Tue, 20 Jul 2021 17:45:40 +0200 Subject: [PATCH 4/5] Fix DarkLaf related errors --- pom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 91ccf2c93..42be1227a 100644 --- a/pom.xml +++ b/pom.xml @@ -226,7 +226,12 @@ com.github.weisj darklaf-core - 2.6.2-SNAPSHOT + 2.6.2-20210719.010320-83 + + + com.github.weisj + darklaf-windows + 2.6.2-20210719.010320-83 com.github.weisj From adb403f89a196990949571cbe7f7bd6ad462ed65 Mon Sep 17 00:00:00 2001 From: Nico Mexis Date: Tue, 20 Jul 2021 18:13:52 +0200 Subject: [PATCH 5/5] Fix compile error --- .../bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java index 7c4fbdfe1..fee9258e9 100644 --- a/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java +++ b/src/main/java/the/bytecode/club/bytecodeviewer/gui/resourceviewer/viewer/ClassViewer.java @@ -96,7 +96,7 @@ public void refresh(final JButton button) if (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel3.decompiler == Decompiler.NONE) { - BytecodeViewer.showMessage(TranslatedStrings.SUGGESTED_FIX_NO_DECOMPILER_WARNING.getText()); + BytecodeViewer.showMessage(TranslatedStrings.SUGGESTED_FIX_NO_DECOMPILER_WARNING.toString()); } bytecodeViewPanel1.createPane(this);