Code Style Update
This commit is contained in:
parent
fda1ecab66
commit
0e7bd2bba1
|
@ -7,7 +7,7 @@ import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialog
|
||||||
|
|
||||||
import java.lang.reflect.Field
|
import java.lang.reflect.Field
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl
|
import static the.bytecode.club.bytecodeviewer.Constants.NL
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** This is an example of a String Decrypter Groovy Plugin for BCV.
|
** This is an example of a String Decrypter Groovy Plugin for BCV.
|
||||||
|
@ -22,7 +22,7 @@ class ExampleStringDecrypter extends Plugin {
|
||||||
|
|
||||||
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING",
|
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING",
|
||||||
"WARNING: This will load the classes into the JVM and execute the initialize function"
|
"WARNING: This will load the classes into the JVM and execute the initialize function"
|
||||||
+ nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
|
+ NL + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.",
|
||||||
new String[]{"Continue", "Cancel"})
|
new String[]{"Continue", "Cancel"})
|
||||||
|
|
||||||
if (dialog.promptChoice() == 0) {
|
if (dialog.promptChoice() == 0) {
|
||||||
|
|
|
@ -141,13 +141,13 @@ public class BytecodeViewer
|
||||||
public static Refactorer refactorer = new Refactorer();
|
public static Refactorer refactorer = new Refactorer();
|
||||||
|
|
||||||
//GSON Reference
|
//GSON Reference
|
||||||
public static final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
public static Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
|
|
||||||
//Threads
|
//Threads
|
||||||
private static final Thread versionChecker = new Thread(new UpdateCheck(), "Version Checker");
|
private static final Thread VERSION_CHECKER = new Thread(new UpdateCheck(), "Version Checker");
|
||||||
private static final Thread pingBack = new Thread(new PingBack(), "Pingback");
|
private static final Thread PING_BACK = new Thread(new PingBack(), "Pingback");
|
||||||
private static final Thread installFatJar = new Thread(new InstallFatJar(), "Install Fat-Jar");
|
private static final Thread INSTALL_FAT_JAR = new Thread(new InstallFatJar(), "Install Fat-Jar");
|
||||||
private static final Thread bootCheck = new Thread(new BootCheck(), "Boot Check");
|
private static final Thread BOOT_CHECK = new Thread(new BootCheck(), "Boot Check");
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Main startup
|
* Main startup
|
||||||
|
@ -202,23 +202,23 @@ public class BytecodeViewer
|
||||||
MiscUtils.setLanguage(MiscUtils.guessLanguage());
|
MiscUtils.setLanguage(MiscUtils.guessLanguage());
|
||||||
|
|
||||||
//handle CLI
|
//handle CLI
|
||||||
int CLI = CommandLineInput.parseCommandLine(args);
|
int isCLI = CommandLineInput.parseCommandLine(args);
|
||||||
if (CLI == CommandLineInput.STOP)
|
if (isCLI == CommandLineInput.STOP)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//load with shaded libraries
|
//load with shaded libraries
|
||||||
if (FAT_JAR)
|
if (FAT_JAR)
|
||||||
{
|
{
|
||||||
installFatJar.start();
|
INSTALL_FAT_JAR.start();
|
||||||
}
|
}
|
||||||
else //load through bootloader
|
else //load through bootloader
|
||||||
{
|
{
|
||||||
bootCheck.start();
|
BOOT_CHECK.start();
|
||||||
Boot.boot(args, CLI != CommandLineInput.GUI);
|
Boot.boot(args, isCLI != CommandLineInput.GUI);
|
||||||
}
|
}
|
||||||
|
|
||||||
//CLI arguments say spawn the GUI
|
//CLI arguments say spawn the GUI
|
||||||
if (CLI == CommandLineInput.GUI)
|
if (isCLI == CommandLineInput.GUI)
|
||||||
{
|
{
|
||||||
BytecodeViewer.boot(false);
|
BytecodeViewer.boot(false);
|
||||||
Configuration.bootState = BootState.GUI_SHOWING;
|
Configuration.bootState = BootState.GUI_SHOWING;
|
||||||
|
@ -264,20 +264,20 @@ public class BytecodeViewer
|
||||||
//ping back once on first boot to add to global user count
|
//ping back once on first boot to add to global user count
|
||||||
if (!Configuration.pingback)
|
if (!Configuration.pingback)
|
||||||
{
|
{
|
||||||
pingBack.start();
|
PING_BACK.start();
|
||||||
Configuration.pingback = true;
|
Configuration.pingback = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//version checking
|
//version checking
|
||||||
if (viewer.updateCheck.isSelected() && !DEV_MODE)
|
if (viewer.updateCheck.isSelected() && !DEV_MODE)
|
||||||
versionChecker.start();
|
VERSION_CHECKER.start();
|
||||||
|
|
||||||
//show the main UI
|
//show the main UI
|
||||||
if (!cli)
|
if (!cli)
|
||||||
viewer.setVisible(true);
|
viewer.setVisible(true);
|
||||||
|
|
||||||
//print startup time
|
//print startup time
|
||||||
System.out.println("Start up took " + ((System.currentTimeMillis() - Configuration.start) / 1000) + " seconds");
|
System.out.println("Start up took " + ((System.currentTimeMillis() - Configuration.BOOT_TIMESTAMP) / 1000) + " seconds");
|
||||||
|
|
||||||
//request focus on GUI for hotkeys on start
|
//request focus on GUI for hotkeys on start
|
||||||
if (!cli)
|
if (!cli)
|
||||||
|
@ -677,11 +677,13 @@ public class BytecodeViewer
|
||||||
new Thread(() ->
|
new Thread(() ->
|
||||||
{
|
{
|
||||||
updateBusyStatus(true);
|
updateBusyStatus(true);
|
||||||
|
|
||||||
for (int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
|
for (int i = 0; i < BytecodeViewer.viewer.workPane.tabs.getTabCount(); i++)
|
||||||
{
|
{
|
||||||
ResourceViewer viewer = (ResourceViewer) BytecodeViewer.viewer.workPane.tabs.getComponentAt(i);
|
ResourceViewer viewer = (ResourceViewer) BytecodeViewer.viewer.workPane.tabs.getComponentAt(i);
|
||||||
viewer.refresh(null);
|
viewer.refresh(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateBusyStatus(false);
|
updateBusyStatus(false);
|
||||||
}, "Refresh All Tabs").start();
|
}, "Refresh All Tabs").start();
|
||||||
}
|
}
|
||||||
|
@ -695,7 +697,8 @@ public class BytecodeViewer
|
||||||
{
|
{
|
||||||
if (ask)
|
if (ask)
|
||||||
{
|
{
|
||||||
MultipleChoiceDialog dialog = new MultipleChoiceDialog(TranslatedStrings.RESET_TITLE.toString(), TranslatedStrings.RESET_CONFIRM.toString(), new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
|
MultipleChoiceDialog dialog = new MultipleChoiceDialog(TranslatedStrings.RESET_TITLE.toString(), TranslatedStrings.RESET_CONFIRM.toString(),
|
||||||
|
new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
|
||||||
|
|
||||||
if (dialog.promptChoice() != 0)
|
if (dialog.promptChoice() != 0)
|
||||||
return;
|
return;
|
||||||
|
@ -732,7 +735,7 @@ public class BytecodeViewer
|
||||||
*/
|
*/
|
||||||
public static void cleanup()
|
public static void cleanup()
|
||||||
{
|
{
|
||||||
File tempF = new File(tempDirectory);
|
File tempF = new File(TEMP_DIRECTORY);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -767,6 +770,7 @@ public class BytecodeViewer
|
||||||
{
|
{
|
||||||
Object key = enumeration.nextElement();
|
Object key = enumeration.nextElement();
|
||||||
Object value = UIManager.get(key);
|
Object value = UIManager.get(key);
|
||||||
|
|
||||||
if (value instanceof Font)
|
if (value instanceof Font)
|
||||||
UIManager.put(key, font);
|
UIManager.put(key, font);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,23 +43,23 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
public class CommandLineInput
|
public class CommandLineInput
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Options options = new Options();
|
private static final Options OPTIONS = new Options();
|
||||||
private static final CommandLineParser parser = new DefaultParser();
|
private static final CommandLineParser PARSER = new DefaultParser();
|
||||||
|
|
||||||
/*BECAUSE WHO DOESN'T LOVE MAGIC NUMBERS*/
|
/*BECAUSE WHO DOESN'T LOVE MAGIC NUMBERS*/
|
||||||
public static int STOP = -1;
|
public static final int STOP = -1;
|
||||||
public static int GUI = 0;
|
public static final int GUI = 0;
|
||||||
public static int CLI = 1;
|
public static final int CLI = 1;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
options.addOption("help", false, "prints the help menu.");
|
OPTIONS.addOption("help", false, "prints the help menu.");
|
||||||
options.addOption("list", false, "lists all the available decompilers for BCV " + VERSION + ".");
|
OPTIONS.addOption("list", false, "lists all the available decompilers for BCV " + VERSION + ".");
|
||||||
options.addOption("decompiler", true, "sets the decompiler, procyon by default.");
|
OPTIONS.addOption("decompiler", true, "sets the decompiler, procyon by default.");
|
||||||
options.addOption("i", true, "sets the input.");
|
OPTIONS.addOption("i", true, "sets the input.");
|
||||||
options.addOption("o", true, "sets the output.");
|
OPTIONS.addOption("o", true, "sets the output.");
|
||||||
options.addOption("t", true, "sets the target class to decompile, append all to decomp all as zip.");
|
OPTIONS.addOption("t", true, "sets the target class to decompile, append all to decomp all as zip.");
|
||||||
options.addOption("nowait", true, "won't wait the 5 seconds to allow the user to read the CLI.");
|
OPTIONS.addOption("nowait", true, "won't wait the 5 seconds to allow the user to read the CLI.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean containsCommand(String[] args)
|
public static boolean containsCommand(String[] args)
|
||||||
|
@ -69,8 +69,17 @@ public class CommandLineInput
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CommandLine cmd = parser.parse(options, args);
|
CommandLine cmd = PARSER.parse(OPTIONS, args);
|
||||||
if (cmd.hasOption("help") || cmd.hasOption("clean") || cmd.hasOption("english") || cmd.hasOption("list") || cmd.hasOption("decompiler") || cmd.hasOption("i") || cmd.hasOption("o") || cmd.hasOption("t") || cmd.hasOption("nowait"))
|
|
||||||
|
if (cmd.hasOption("help")
|
||||||
|
|| cmd.hasOption("clean")
|
||||||
|
|| cmd.hasOption("english")
|
||||||
|
|| cmd.hasOption("list")
|
||||||
|
|| cmd.hasOption("decompiler")
|
||||||
|
|| cmd.hasOption("i")
|
||||||
|
|| cmd.hasOption("o")
|
||||||
|
|| cmd.hasOption("t")
|
||||||
|
|| cmd.hasOption("nowait"))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +98,8 @@ public class CommandLineInput
|
||||||
return GUI;
|
return GUI;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CommandLine cmd = parser.parse(options, args);
|
CommandLine cmd = PARSER.parse(OPTIONS, args);
|
||||||
|
|
||||||
if (cmd.hasOption("list"))
|
if (cmd.hasOption("list"))
|
||||||
{
|
{
|
||||||
System.out.println("Procyon");
|
System.out.println("Procyon");
|
||||||
|
@ -100,12 +110,16 @@ public class CommandLineInput
|
||||||
System.out.println("JD-GUI");
|
System.out.println("JD-GUI");
|
||||||
System.out.println("Smali");
|
System.out.println("Smali");
|
||||||
System.out.println("ASMifier");
|
System.out.println("ASMifier");
|
||||||
|
|
||||||
return STOP;
|
return STOP;
|
||||||
}
|
}
|
||||||
else if (cmd.hasOption("clean"))
|
else if (cmd.hasOption("clean"))
|
||||||
{
|
{
|
||||||
new File(Constants.getBCVDirectory()).delete();
|
new File(Constants.getBCVDirectory()).delete();
|
||||||
if (cmd.getOptionValue("i") == null && cmd.getOptionValue("o") == null && cmd.getOptionValue("t") == null)
|
|
||||||
|
if (cmd.getOptionValue("i") == null
|
||||||
|
&& cmd.getOptionValue("o") == null
|
||||||
|
&& cmd.getOptionValue("t") == null)
|
||||||
return GUI;
|
return GUI;
|
||||||
}
|
}
|
||||||
else if (cmd.hasOption("english"))
|
else if (cmd.hasOption("english"))
|
||||||
|
@ -115,7 +129,15 @@ public class CommandLineInput
|
||||||
}
|
}
|
||||||
else if (cmd.hasOption("help"))
|
else if (cmd.hasOption("help"))
|
||||||
{
|
{
|
||||||
for (String s : new String[]{"-help Displays the help menu", "-clean Deletes the BCV directory", "-english Forces English language translations", "-list Displays the available decompilers", "-decompiler <decompiler> Selects the decompiler, procyon by default", "-i <input file> Selects the input file", "-o <output file> Selects the output file", "-t <target classname> Must either be the fully qualified classname or \"all\" to decompile all as zip", "-nowait Doesn't wait for the user to read the CLI messages"})
|
for (String s : new String[]{"-help Displays the help menu",
|
||||||
|
"-clean Deletes the BCV directory",
|
||||||
|
"-english Forces English language translations",
|
||||||
|
"-list Displays the available decompilers",
|
||||||
|
"-decompiler <decompiler> Selects the decompiler, procyon by default",
|
||||||
|
"-i <input file> Selects the input file",
|
||||||
|
"-o <output file> Selects the output file",
|
||||||
|
"-t <target classname> Must either be the fully qualified classname or \"all\" to decompile all as zip",
|
||||||
|
"-nowait Doesn't wait for the user to read the CLI messages"})
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
return STOP;
|
return STOP;
|
||||||
}
|
}
|
||||||
|
@ -181,7 +203,7 @@ public class CommandLineInput
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CommandLine cmd = parser.parse(options, args);
|
CommandLine cmd = PARSER.parse(OPTIONS, args);
|
||||||
String decompiler = cmd.getOptionValue("decompiler");
|
String decompiler = cmd.getOptionValue("decompiler");
|
||||||
File input = new File(cmd.getOptionValue("i"));
|
File input = new File(cmd.getOptionValue("i"));
|
||||||
File output = new File(cmd.getOptionValue("o"));
|
File output = new File(cmd.getOptionValue("o"));
|
||||||
|
@ -197,7 +219,7 @@ public class CommandLineInput
|
||||||
//if its zip/jar/apk/dex attempt unzip as whole zip
|
//if its zip/jar/apk/dex attempt unzip as whole zip
|
||||||
//if its just class allow any
|
//if its just class allow any
|
||||||
|
|
||||||
File tempZip = new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar");
|
File tempZip = new File(TEMP_DIRECTORY + FS + "temp_" + MiscUtils.getRandomizedName() + ".jar");
|
||||||
if (tempZip.exists())
|
if (tempZip.exists())
|
||||||
tempZip.delete();
|
tempZip.delete();
|
||||||
|
|
||||||
|
|
|
@ -70,7 +70,7 @@ public class Configuration
|
||||||
public static boolean needsReDump = true;
|
public static boolean needsReDump = true;
|
||||||
public static boolean warnForEditing = false;
|
public static boolean warnForEditing = false;
|
||||||
public static boolean runningObfuscation = false;
|
public static boolean runningObfuscation = false;
|
||||||
public static final long start = System.currentTimeMillis();
|
public static final long BOOT_TIMESTAMP = System.currentTimeMillis();
|
||||||
public static String lastOpenDirectory = ".";
|
public static String lastOpenDirectory = ".";
|
||||||
public static String lastSaveDirectory = ".";
|
public static String lastSaveDirectory = ".";
|
||||||
public static String lastPluginDirectory = ".";
|
public static String lastPluginDirectory = ".";
|
||||||
|
@ -80,7 +80,7 @@ public class Configuration
|
||||||
public static int silenceExceptionGUI = 0;
|
public static int silenceExceptionGUI = 0;
|
||||||
public static int pauseExceptionGUI = 0;
|
public static int pauseExceptionGUI = 0;
|
||||||
|
|
||||||
public static final int maxRecentFiles = 25; //eventually may be a setting
|
public static int maxRecentFiles = 25; //eventually may be a setting
|
||||||
public static boolean verifyCorruptedStateOnBoot = false; //eventually may be a setting
|
public static boolean verifyCorruptedStateOnBoot = false; //eventually may be a setting
|
||||||
|
|
||||||
public static BootState bootState = BootState.START_UP;
|
public static BootState bootState = BootState.START_UP;
|
||||||
|
|
|
@ -66,31 +66,31 @@ public class Constants
|
||||||
//if true the version checker will prompt and ask how you would like to proceed
|
//if true the version checker will prompt and ask how you would like to proceed
|
||||||
public static final boolean FORCE_VERSION_CHECKER_PROMPT = false;
|
public static final boolean FORCE_VERSION_CHECKER_PROMPT = false;
|
||||||
|
|
||||||
public static final String fs = System.getProperty("file.separator");
|
public static final String FS = System.getProperty("file.separator");
|
||||||
public static final String nl = System.getProperty("line.separator");
|
public static final String NL = System.getProperty("line.separator");
|
||||||
|
|
||||||
public static final File BCVDir = resolveBCVRoot();
|
|
||||||
public static final File RT_JAR = new File(System.getProperty("java.home") + fs + "lib" + fs + "rt.jar");
|
|
||||||
public static final File JAVA_BINARY = new File(System.getProperty("java.home") + fs + "bin" + fs + "java.exe");
|
|
||||||
public static final File JAVA_BINARY_NIX = new File(System.getProperty("java.home") + fs + "bin" + fs + "java");
|
|
||||||
public static final File RT_JAR_DUMPED = new File(getBCVDirectory() + fs + "rt.jar");
|
|
||||||
public static final String filesName = getBCVDirectory() + fs + "recentfiles.json";
|
|
||||||
public static final String pluginsName = getBCVDirectory() + fs + "recentplugins.json";
|
|
||||||
public static final String settingsName = getBCVDirectory() + fs + "settings.bcv";
|
|
||||||
public static final String tempDirectory = getBCVDirectory() + fs + "bcv_temp" + fs;
|
|
||||||
public static final String systemTempDirectory = System.getProperty("java.io.tmpdir");
|
|
||||||
public static final String libsDirectory = getBCVDirectory() + fs + "libs" + fs;
|
|
||||||
public static String krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + krakatauVersion;
|
|
||||||
public static String enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + enjarifyVersion;
|
|
||||||
public static final String[] SUPPORTED_FILE_EXTENSIONS = ResourceType.supportedBCVExtensionMap.keySet().toArray(new String[0]);
|
public static final String[] SUPPORTED_FILE_EXTENSIONS = ResourceType.supportedBCVExtensionMap.keySet().toArray(new String[0]);
|
||||||
public static final int ASM_VERSION = Opcodes.ASM9;
|
public static final int ASM_VERSION = Opcodes.ASM9;
|
||||||
|
|
||||||
|
public static final File BCVDir = resolveBCVRoot();
|
||||||
|
public static final File RT_JAR = new File(System.getProperty("java.home") + FS + "lib" + FS + "rt.jar");
|
||||||
|
public static final File JAVA_BINARY = new File(System.getProperty("java.home") + FS + "bin" + FS + "java.exe");
|
||||||
|
public static final File JAVA_BINARY_NIX = new File(System.getProperty("java.home") + FS + "bin" + FS + "java");
|
||||||
|
public static final File RT_JAR_DUMPED = new File(getBCVDirectory() + FS + "rt.jar");
|
||||||
|
public static final String FILES_NAME = getBCVDirectory() + FS + "recentfiles.json";
|
||||||
|
public static final String PLUGINS_NAME = getBCVDirectory() + FS + "recentplugins.json";
|
||||||
|
public static final String SETTINGS_NAME = getBCVDirectory() + FS + "settings.bcv";
|
||||||
|
public static final String TEMP_DIRECTORY = getBCVDirectory() + FS + "bcv_temp" + FS;
|
||||||
|
public static final String SYSTEM_TEMP_DIRECTORY = System.getProperty("java.io.tmpdir");
|
||||||
|
public static final String LIBS_DIRECTORY = getBCVDirectory() + FS + "libs" + FS;
|
||||||
|
public static String krakatauWorkingDirectory = getBCVDirectory() + FS + "krakatau_" + krakatauVersion;
|
||||||
|
public static String enjarifyWorkingDirectory = getBCVDirectory() + FS + "enjarify_" + enjarifyVersion;
|
||||||
|
|
||||||
public static final PrintStream ERR = System.err;
|
public static final PrintStream ERR = System.err;
|
||||||
public static final PrintStream OUT = System.out;
|
public static final PrintStream OUT = System.out;
|
||||||
|
|
||||||
public static File resolveBCVRoot()
|
public static File resolveBCVRoot()
|
||||||
{
|
{
|
||||||
File defaultLocation = new File(System.getProperty("user.home") + fs + ".Bytecode-Viewer");
|
File defaultLocation = new File(System.getProperty("user.home") + FS + ".Bytecode-Viewer");
|
||||||
|
|
||||||
//if BCV was previously installed using the default directory, continue to use that
|
//if BCV was previously installed using the default directory, continue to use that
|
||||||
if (defaultLocation.exists())
|
if (defaultLocation.exists())
|
||||||
|
@ -99,11 +99,11 @@ public class Constants
|
||||||
//handle XDG Base Directory - https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
//handle XDG Base Directory - https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
||||||
if (isNix())
|
if (isNix())
|
||||||
{
|
{
|
||||||
File homeLocal = new File(System.getProperty("user.home") + fs + ".local");
|
File homeLocal = new File(System.getProperty("user.home") + FS + ".local");
|
||||||
if (homeLocal.exists())
|
if (homeLocal.exists())
|
||||||
return new File(homeLocal, "share" + fs + ".Bytecode-Viewer");
|
return new File(homeLocal, "share" + FS + ".Bytecode-Viewer");
|
||||||
|
|
||||||
File homeConfig = new File(System.getProperty("user.home") + fs + ".config");
|
File homeConfig = new File(System.getProperty("user.home") + FS + ".config");
|
||||||
if (homeConfig.exists())
|
if (homeConfig.exists())
|
||||||
return new File(homeConfig, ".Bytecode-Viewer");
|
return new File(homeConfig, ".Bytecode-Viewer");
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,15 +47,15 @@ public class Settings
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (new File(filesName).exists())
|
if (new File(FILES_NAME).exists())
|
||||||
recentFiles = gson.fromJson(DiskReader.loadAsString(filesName), new TypeToken<ArrayList<String>>() {}.getType());
|
recentFiles = gson.fromJson(DiskReader.loadAsString(FILES_NAME), new TypeToken<ArrayList<String>>() {}.getType());
|
||||||
else
|
else
|
||||||
recentFiles = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentfiles.bcv", false);
|
recentFiles = DiskReader.loadArrayList(getBCVDirectory() + FS + "recentfiles.bcv", false);
|
||||||
|
|
||||||
if (new File(pluginsName).exists())
|
if (new File(PLUGINS_NAME).exists())
|
||||||
recentPlugins = gson.fromJson(DiskReader.loadAsString(pluginsName), new TypeToken<ArrayList<String>>() {}.getType());
|
recentPlugins = gson.fromJson(DiskReader.loadAsString(PLUGINS_NAME), new TypeToken<ArrayList<String>>() {}.getType());
|
||||||
else
|
else
|
||||||
recentPlugins = DiskReader.loadArrayList(getBCVDirectory() + fs + "recentplugins.bcv", false);
|
recentPlugins = DiskReader.loadArrayList(getBCVDirectory() + FS + "recentplugins.bcv", false);
|
||||||
|
|
||||||
MiscUtils.deduplicateAndTrim(recentFiles, maxRecentFiles);
|
MiscUtils.deduplicateAndTrim(recentFiles, maxRecentFiles);
|
||||||
MiscUtils.deduplicateAndTrim(recentPlugins, maxRecentFiles);
|
MiscUtils.deduplicateAndTrim(recentPlugins, maxRecentFiles);
|
||||||
|
@ -76,7 +76,7 @@ public class Settings
|
||||||
recentFiles.remove(f.getAbsolutePath()); // already added on the list
|
recentFiles.remove(f.getAbsolutePath()); // already added on the list
|
||||||
recentFiles.add(0, f.getAbsolutePath());
|
recentFiles.add(0, f.getAbsolutePath());
|
||||||
MiscUtils.deduplicateAndTrim(recentFiles, maxRecentFiles);
|
MiscUtils.deduplicateAndTrim(recentFiles, maxRecentFiles);
|
||||||
DiskWriter.replaceFile(filesName, MiscUtils.listToString(recentFiles), false);
|
DiskWriter.replaceFile(FILES_NAME, MiscUtils.listToString(recentFiles), false);
|
||||||
resetRecentFilesMenu();
|
resetRecentFilesMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ public class Settings
|
||||||
{
|
{
|
||||||
if (recentFiles.remove(f.getAbsolutePath()))
|
if (recentFiles.remove(f.getAbsolutePath()))
|
||||||
{
|
{
|
||||||
DiskWriter.replaceFile(filesName, MiscUtils.listToString(recentFiles), false);
|
DiskWriter.replaceFile(FILES_NAME, MiscUtils.listToString(recentFiles), false);
|
||||||
resetRecentFilesMenu();
|
resetRecentFilesMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,7 +107,7 @@ public class Settings
|
||||||
recentPlugins.remove(f.getAbsolutePath()); // already added on the list
|
recentPlugins.remove(f.getAbsolutePath()); // already added on the list
|
||||||
recentPlugins.add(0, f.getAbsolutePath());
|
recentPlugins.add(0, f.getAbsolutePath());
|
||||||
MiscUtils.deduplicateAndTrim(recentPlugins, maxRecentFiles);
|
MiscUtils.deduplicateAndTrim(recentPlugins, maxRecentFiles);
|
||||||
DiskWriter.replaceFile(pluginsName, MiscUtils.listToString(recentPlugins), false);
|
DiskWriter.replaceFile(PLUGINS_NAME, MiscUtils.listToString(recentPlugins), false);
|
||||||
resetRecentFilesMenu();
|
resetRecentFilesMenu();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public class Settings
|
||||||
{
|
{
|
||||||
if (recentPlugins.remove(f.getAbsolutePath()))
|
if (recentPlugins.remove(f.getAbsolutePath()))
|
||||||
{
|
{
|
||||||
DiskWriter.replaceFile(pluginsName, MiscUtils.listToString(recentPlugins), false);
|
DiskWriter.replaceFile(PLUGINS_NAME, MiscUtils.listToString(recentPlugins), false);
|
||||||
resetRecentFilesMenu();
|
resetRecentFilesMenu();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ import javax.swing.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
|
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.settingsName;
|
import static the.bytecode.club.bytecodeviewer.Constants.SETTINGS_NAME;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to handle loading/saving the GUI (options).
|
* Used to handle loading/saving the GUI (options).
|
||||||
|
@ -51,7 +51,7 @@ public class SettingsSerializer
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DiskWriter.replaceFile(settingsName, "BCV: " + VERSION, false);
|
DiskWriter.replaceFile(SETTINGS_NAME, "BCV: " + VERSION, false);
|
||||||
save(BytecodeViewer.viewer.rbr.isSelected());
|
save(BytecodeViewer.viewer.rbr.isSelected());
|
||||||
save(BytecodeViewer.viewer.rsy.isSelected());
|
save(BytecodeViewer.viewer.rsy.isSelected());
|
||||||
save(BytecodeViewer.viewer.din.isSelected());
|
save(BytecodeViewer.viewer.din.isSelected());
|
||||||
|
@ -167,9 +167,9 @@ public class SettingsSerializer
|
||||||
save(Configuration.deleteForeignLibraries);
|
save(Configuration.deleteForeignLibraries);
|
||||||
|
|
||||||
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||||
DiskWriter.writeNewLine(settingsName, "0");
|
DiskWriter.writeNewLine(SETTINGS_NAME, "0");
|
||||||
else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
|
else if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionEnjarify.getModel()))
|
||||||
DiskWriter.writeNewLine(settingsName, "1");
|
DiskWriter.writeNewLine(SETTINGS_NAME, "1");
|
||||||
|
|
||||||
save(Configuration.python3);
|
save(Configuration.python3);
|
||||||
save(Configuration.javac);
|
save(Configuration.javac);
|
||||||
|
@ -216,13 +216,13 @@ public class SettingsSerializer
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
settingsFileExists = new File(settingsName).exists();
|
settingsFileExists = new File(SETTINGS_NAME).exists();
|
||||||
|
|
||||||
if (!settingsFileExists)
|
if (!settingsFileExists)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//precache the file
|
//precache the file
|
||||||
DiskReader.loadString(settingsName, 0, true);
|
DiskReader.loadString(SETTINGS_NAME, 0, true);
|
||||||
|
|
||||||
//process the cached file
|
//process the cached file
|
||||||
Configuration.lafTheme = LAFTheme.valueOf(asString(127));
|
Configuration.lafTheme = LAFTheme.valueOf(asString(127));
|
||||||
|
@ -416,21 +416,21 @@ public class SettingsSerializer
|
||||||
|
|
||||||
public static void save(Object o)
|
public static void save(Object o)
|
||||||
{
|
{
|
||||||
DiskWriter.writeNewLine(settingsName, String.valueOf(o), false);
|
DiskWriter.writeNewLine(SETTINGS_NAME, String.valueOf(o), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String asString(int lineNumber) throws Exception
|
public static String asString(int lineNumber) throws Exception
|
||||||
{
|
{
|
||||||
return DiskReader.loadString(settingsName, lineNumber, false);
|
return DiskReader.loadString(SETTINGS_NAME, lineNumber, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean asBoolean(int lineNumber) throws Exception
|
public static boolean asBoolean(int lineNumber) throws Exception
|
||||||
{
|
{
|
||||||
return Boolean.parseBoolean(DiskReader.loadString(settingsName, lineNumber, false));
|
return Boolean.parseBoolean(DiskReader.loadString(SETTINGS_NAME, lineNumber, false));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int asInt(int lineNumber) throws Exception
|
public static int asInt(int lineNumber) throws Exception
|
||||||
{
|
{
|
||||||
return Integer.parseInt(DiskReader.loadString(settingsName, lineNumber, false));
|
return Integer.parseInt(DiskReader.loadString(SETTINGS_NAME, lineNumber, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,16 +41,15 @@ public final class ASMResourceUtil
|
||||||
MethodNode m = (MethodNode) o;
|
MethodNode m = (MethodNode) o;
|
||||||
|
|
||||||
if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V"))
|
if (m.name.equals("main") && m.desc.equals("([Ljava/lang/String;)V"))
|
||||||
{
|
|
||||||
return cn.name + "." + m.name;
|
return cn.name + "." + m.name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return defaultFQN;
|
return defaultFQN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renameFieldNode(String originalParentName, String originalFieldName, String originalFieldDesc, String newFieldParent, String newFieldName, String newFieldDesc)
|
public static void renameFieldNode(String originalParentName, String originalFieldName, String originalFieldDesc,
|
||||||
|
String newFieldParent, String newFieldName, String newFieldDesc)
|
||||||
{
|
{
|
||||||
for (ClassNode c : BytecodeViewer.getLoadedClasses())
|
for (ClassNode c : BytecodeViewer.getLoadedClasses())
|
||||||
{
|
{
|
||||||
|
@ -78,7 +77,8 @@ public final class ASMResourceUtil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void renameMethodNode(String originalParentName, String originalMethodName, String originalMethodDesc, String newParent, String newName, String newDesc)
|
public static void renameMethodNode(String originalParentName, String originalMethodName, String originalMethodDesc,
|
||||||
|
String newParent, String newName, String newDesc)
|
||||||
{
|
{
|
||||||
for (ClassNode c : BytecodeViewer.getLoadedClasses())
|
for (ClassNode c : BytecodeViewer.getLoadedClasses())
|
||||||
{
|
{
|
||||||
|
@ -182,6 +182,7 @@ public final class ASMResourceUtil
|
||||||
mi.owner = newName;
|
mi.owner = newName;
|
||||||
mi.desc = mi.desc.replace(oldName, newName);
|
mi.desc = mi.desc.replace(oldName, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i instanceof FieldInsnNode)
|
if (i instanceof FieldInsnNode)
|
||||||
{
|
{
|
||||||
FieldInsnNode fi = (FieldInsnNode) i;
|
FieldInsnNode fi = (FieldInsnNode) i;
|
||||||
|
|
|
@ -113,7 +113,7 @@ public class BCV
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File f = new File(tempDirectory + fs + MiscUtils.randomString(12) + "loaded_temp.jar");
|
File f = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12) + "loaded_temp.jar");
|
||||||
List<Class<?>> ret = new ArrayList<>();
|
List<Class<?>> ret = new ArrayList<>();
|
||||||
|
|
||||||
JarUtils.saveAsJar(BCV.getLoadedClasses(), f.getAbsolutePath());
|
JarUtils.saveAsJar(BCV.getLoadedClasses(), f.getAbsolutePath());
|
||||||
|
|
|
@ -40,9 +40,10 @@ import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||||
|
|
||||||
public class ExceptionUI extends JFrameConsole
|
public class ExceptionUI extends JFrameConsole
|
||||||
{
|
{
|
||||||
public static final String KONLOCH = "https://github.com/Konloch/bytecode-viewer/issues or Konloch at https://the.bytecode.club or konloch@gmail.com";
|
public static final String KONLOCH = "https://github.com/Konloch/bytecode-viewer/issues" +
|
||||||
|
"or Konloch at https://the.bytecode.club or konloch@gmail.com";
|
||||||
public static final String SEND_STACKTRACE_TO = buildErrorLogHeader(KONLOCH);
|
public static final String SEND_STACKTRACE_TO = buildErrorLogHeader(KONLOCH);
|
||||||
public static final String SEND_STACKTRACE_TO_NL = SEND_STACKTRACE_TO + nl + nl;
|
public static final String SEND_STACKTRACE_TO_NL = SEND_STACKTRACE_TO + NL + NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param e The exception to be shown
|
* @param e The exception to be shown
|
||||||
|
@ -116,7 +117,7 @@ public class ExceptionUI extends JFrameConsole
|
||||||
setTitle("Bytecode Viewer " + VERSION + " - Error Log - Send this to " + author);
|
setTitle("Bytecode Viewer " + VERSION + " - Error Log - Send this to " + author);
|
||||||
getContentPane().setLayout(new CardLayout(0, 0));
|
getContentPane().setLayout(new CardLayout(0, 0));
|
||||||
|
|
||||||
getTextArea().setText(buildErrorLogHeader(author) + nl + nl + error);
|
getTextArea().setText(buildErrorLogHeader(author) + NL + NL + error);
|
||||||
getTextArea().setCaretPosition(0);
|
getTextArea().setCaretPosition(0);
|
||||||
|
|
||||||
//embed error log as a new tab
|
//embed error log as a new tab
|
||||||
|
@ -138,7 +139,9 @@ public class ExceptionUI extends JFrameConsole
|
||||||
{
|
{
|
||||||
String fatJar = FAT_JAR ? " [Fat Jar]" : "";
|
String fatJar = FAT_JAR ? " [Fat Jar]" : "";
|
||||||
|
|
||||||
return TranslatedStrings.PLEASE_SEND_THIS_ERROR_LOG_TO + " " + author + "\n" + TranslatedStrings.PLEASE_SEND_RESOURCES + "\nBytecode Viewer Version: " + VERSION + fatJar + ", OS: " + System.getProperty("os.name") + ", Java: " + System.getProperty("java.version");
|
return TranslatedStrings.PLEASE_SEND_THIS_ERROR_LOG_TO + " " + author + "\n"
|
||||||
|
+ TranslatedStrings.PLEASE_SEND_RESOURCES
|
||||||
|
+ "\nBytecode Viewer Version: " + VERSION + fatJar + ", OS: " + System.getProperty("os.name") + ", Java: " + System.getProperty("java.version");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final long serialVersionUID = -5230501978224926296L;
|
private static final long serialVersionUID = -5230501978224926296L;
|
||||||
|
|
|
@ -51,23 +51,22 @@ public class Boot
|
||||||
{
|
{
|
||||||
|
|
||||||
/*flags*/
|
/*flags*/
|
||||||
public static boolean globalstop = false;
|
public static boolean completedBoot = false;
|
||||||
public static boolean completedboot = false;
|
|
||||||
public static boolean downloading = false;
|
public static boolean downloading = false;
|
||||||
|
|
||||||
private static InitialBootScreen screen;
|
private static InitialBootScreen screen;
|
||||||
private static final List<String> libsList = new ArrayList<>();
|
private static final List<String> LIBS_LIST = new ArrayList<>();
|
||||||
private static final List<String> libsFileList = new ArrayList<>();
|
private static final List<String> LIBS_FILE_LIST = new ArrayList<>();
|
||||||
private static final List<String> urlList = new ArrayList<>();
|
private static final List<String> URL_LIST = new ArrayList<>();
|
||||||
|
|
||||||
public static void boot(String[] args, boolean CLI) throws Exception
|
public static void boot(String[] args, boolean isCLI) throws Exception
|
||||||
{
|
{
|
||||||
bootstrap();
|
bootstrap();
|
||||||
ILoader<?> loader = findLoader();
|
ILoader<?> loader = findLoader();
|
||||||
|
|
||||||
screen = new InitialBootScreen();
|
screen = new InitialBootScreen();
|
||||||
|
|
||||||
if (!CLI)
|
if (!isCLI)
|
||||||
SwingUtilities.invokeLater(() -> screen.setVisible(true));
|
SwingUtilities.invokeLater(() -> screen.setVisible(true));
|
||||||
|
|
||||||
create(loader, args.length <= 0 || Boolean.parseBoolean(args[0]));
|
create(loader, args.length <= 0 || Boolean.parseBoolean(args[0]));
|
||||||
|
@ -88,17 +87,11 @@ public class Boot
|
||||||
|
|
||||||
populateUrlList();
|
populateUrlList();
|
||||||
|
|
||||||
if (globalstop)
|
if (URL_LIST.isEmpty())
|
||||||
{
|
{
|
||||||
while (true)
|
JOptionPane.showMessageDialog(null, "Bytecode Viewer ran into an issue, for some reason github is not "
|
||||||
{
|
+ "returning what we're expecting. Please try rebooting, if this issue persists please contact "
|
||||||
Thread.sleep(100);//just keep this thread halted.
|
+ "@Konloch.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (urlList.isEmpty())
|
|
||||||
{
|
|
||||||
JOptionPane.showMessageDialog(null, "Bytecode Viewer ran into an issue, for some reason github is not " + "returning what we're expecting. Please try rebooting, if this issue persists please contact " + "@Konloch.", "Error", JOptionPane.ERROR_MESSAGE);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,11 +103,11 @@ public class Boot
|
||||||
|
|
||||||
populateLibsDirectory();
|
populateLibsDirectory();
|
||||||
|
|
||||||
screen.getProgressBar().setMaximum(urlList.size() * 2);
|
screen.getProgressBar().setMaximum(URL_LIST.size() * 2);
|
||||||
|
|
||||||
int completedCheck = 0;
|
int completedCheck = 0;
|
||||||
|
|
||||||
for (String s : urlList)
|
for (String s : URL_LIST)
|
||||||
{
|
{
|
||||||
String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length());
|
String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length());
|
||||||
File file = new File(libsDirectory, fileName);
|
File file = new File(libsDirectory, fileName);
|
||||||
|
@ -122,13 +115,14 @@ public class Boot
|
||||||
boolean passed = false;
|
boolean passed = false;
|
||||||
while (!passed)
|
while (!passed)
|
||||||
{
|
{
|
||||||
if (!libsList.contains(fileName))
|
if (!LIBS_LIST.contains(fileName))
|
||||||
{
|
{
|
||||||
downloading = true;
|
downloading = true;
|
||||||
setState("Bytecode Viewer Boot Screen - Downloading " + fileName + "...");
|
setState("Bytecode Viewer Boot Screen - Downloading " + fileName + "...");
|
||||||
System.out.println("Downloading " + fileName);
|
System.out.println("Downloading " + fileName);
|
||||||
|
|
||||||
try (InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/raw/master/libs/" + fileName).openConnection().getInputStream(); FileOutputStream fos = new FileOutputStream(file))
|
try (InputStream is = new URL("https://github.com/Konloch/bytecode-viewer/raw/master/libs/" + fileName).openConnection().getInputStream();
|
||||||
|
FileOutputStream fos = new FileOutputStream(file))
|
||||||
{
|
{
|
||||||
System.out.println("Downloading from " + s);
|
System.out.println("Downloading from " + s);
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
|
@ -157,7 +151,7 @@ public class Boot
|
||||||
setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "...");
|
setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "...");
|
||||||
System.out.println("Verifying " + fileName + "...");
|
System.out.println("Verifying " + fileName + "...");
|
||||||
|
|
||||||
File f = new File(Constants.tempDirectory, "temp");
|
File f = new File(Constants.TEMP_DIRECTORY, "temp");
|
||||||
if (!f.exists())
|
if (!f.exists())
|
||||||
{
|
{
|
||||||
f.getParentFile().mkdirs();
|
f.getParentFile().mkdirs();
|
||||||
|
@ -165,7 +159,7 @@ public class Boot
|
||||||
ZipUtils.zipFile(file, f);
|
ZipUtils.zipFile(file, f);
|
||||||
f.delete();
|
f.delete();
|
||||||
|
|
||||||
libsFileList.add(file.getAbsolutePath());
|
LIBS_FILE_LIST.add(file.getAbsolutePath());
|
||||||
System.out.println("Download finished!");
|
System.out.println("Download finished!");
|
||||||
passed = true;
|
passed = true;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +177,7 @@ public class Boot
|
||||||
setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "...");
|
setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "...");
|
||||||
System.out.println("Verifying " + fileName + "...");
|
System.out.println("Verifying " + fileName + "...");
|
||||||
|
|
||||||
File f = new File(Constants.tempDirectory, "temp");
|
File f = new File(Constants.TEMP_DIRECTORY, "temp");
|
||||||
ZipUtils.zipFile(file, f);
|
ZipUtils.zipFile(file, f);
|
||||||
f.delete();
|
f.delete();
|
||||||
|
|
||||||
|
@ -193,7 +187,7 @@ public class Boot
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.out.println("Jar or Zip" + file.getAbsolutePath() + " is corrupt, redownloading.");
|
System.out.println("Jar or Zip" + file.getAbsolutePath() + " is corrupt, redownloading.");
|
||||||
libsFileList.remove(file.getAbsolutePath());
|
LIBS_FILE_LIST.remove(file.getAbsolutePath());
|
||||||
file.delete();
|
file.delete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,11 +203,11 @@ public class Boot
|
||||||
|
|
||||||
setState("Bytecode Viewer Boot Screen - Checking & Deleting Foreign/Outdated Libraries...");
|
setState("Bytecode Viewer Boot Screen - Checking & Deleting Foreign/Outdated Libraries...");
|
||||||
System.out.println("Checking & Deleting foreign/outdated libraries");
|
System.out.println("Checking & Deleting foreign/outdated libraries");
|
||||||
for (String s : libsFileList)
|
for (String s : LIBS_FILE_LIST)
|
||||||
{
|
{
|
||||||
File f = new File(s);
|
File f = new File(s);
|
||||||
boolean delete = true;
|
boolean delete = true;
|
||||||
for (String urlS : urlList)
|
for (String urlS : URL_LIST)
|
||||||
{
|
{
|
||||||
String fileName = urlS.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length());
|
String fileName = urlS.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length());
|
||||||
if (fileName.equals(f.getName()))
|
if (fileName.equals(f.getName()))
|
||||||
|
@ -229,7 +223,7 @@ public class Boot
|
||||||
setState("Bytecode Viewer Boot Screen - Loading Libraries...");
|
setState("Bytecode Viewer Boot Screen - Loading Libraries...");
|
||||||
System.out.println("Loading libraries...");
|
System.out.println("Loading libraries...");
|
||||||
|
|
||||||
for (String s : libsFileList)
|
for (String s : LIBS_FILE_LIST)
|
||||||
{
|
{
|
||||||
if (s.endsWith(".jar"))
|
if (s.endsWith(".jar"))
|
||||||
{
|
{
|
||||||
|
@ -249,7 +243,8 @@ public class Boot
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
f.delete();
|
f.delete();
|
||||||
JOptionPane.showMessageDialog(null, "Error, Library " + f.getName() + " is corrupt, please " + "restart to redownload it.", "Error", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(null, "Error, Library " + f.getName() + " is corrupt, please "
|
||||||
|
+ "restart to redownload it.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,7 +262,7 @@ public class Boot
|
||||||
screen.getProgressBar().setValue(completedCheck);
|
screen.getProgressBar().setValue(completedCheck);
|
||||||
|
|
||||||
setState("Bytecode Viewer Boot Screen - Booting!");
|
setState("Bytecode Viewer Boot Screen - Booting!");
|
||||||
completedboot = true;
|
completedBoot = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static File libsDir()
|
public static File libsDir()
|
||||||
|
@ -305,7 +300,7 @@ public class Boot
|
||||||
for (String s : req.read())
|
for (String s : req.read())
|
||||||
if (s.contains("href=\"/Konloch/bytecode-viewer/blob/master/libs/"))
|
if (s.contains("href=\"/Konloch/bytecode-viewer/blob/master/libs/"))
|
||||||
{
|
{
|
||||||
urlList.add("https://github.com" + s.split("href=")[1].split("\"")[1]);
|
URL_LIST.add("https://github.com" + s.split("href=")[1].split("\"")[1]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,16 +310,16 @@ public class Boot
|
||||||
if (libsDir.exists())
|
if (libsDir.exists())
|
||||||
for (File f : MiscUtils.listFiles(libsDir))
|
for (File f : MiscUtils.listFiles(libsDir))
|
||||||
{
|
{
|
||||||
libsList.add(f.getName());
|
LIBS_LIST.add(f.getName());
|
||||||
libsFileList.add(f.getAbsolutePath());
|
LIBS_FILE_LIST.add(f.getAbsolutePath());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void dropKrakatau()
|
public static void dropKrakatau()
|
||||||
{
|
{
|
||||||
File temp = new File(getBCVDirectory() + fs + "krakatau_" + krakatauVersion + ".zip");
|
File temp = new File(getBCVDirectory() + FS + "krakatau_" + krakatauVersion + ".zip");
|
||||||
File krakatauDirectory = new File(krakatauWorkingDirectory);
|
File krakatauDirectory = new File(krakatauWorkingDirectory);
|
||||||
krakatauWorkingDirectory += fs + "Krakatau-master";
|
krakatauWorkingDirectory += FS + "Krakatau-master";
|
||||||
if (!krakatauDirectory.exists() || temp.exists())
|
if (!krakatauDirectory.exists() || temp.exists())
|
||||||
{
|
{
|
||||||
if (temp.exists())
|
if (temp.exists())
|
||||||
|
@ -359,9 +354,9 @@ public class Boot
|
||||||
|
|
||||||
public static void dropEnjarify()
|
public static void dropEnjarify()
|
||||||
{
|
{
|
||||||
File temp = new File(getBCVDirectory() + fs + "enjarify" + Constants.enjarifyVersion + ".zip");
|
File temp = new File(getBCVDirectory() + FS + "enjarify" + Constants.enjarifyVersion + ".zip");
|
||||||
File enjarifyDirectory = new File(Constants.enjarifyWorkingDirectory);
|
File enjarifyDirectory = new File(Constants.enjarifyWorkingDirectory);
|
||||||
Constants.enjarifyWorkingDirectory += fs + "enjarify-master";
|
Constants.enjarifyWorkingDirectory += FS + "enjarify-master";
|
||||||
if (!enjarifyDirectory.exists() || temp.exists())
|
if (!enjarifyDirectory.exists() || temp.exists())
|
||||||
{
|
{
|
||||||
if (temp.exists())
|
if (temp.exists())
|
||||||
|
@ -396,7 +391,7 @@ public class Boot
|
||||||
|
|
||||||
public static void downloadZipsOnly()
|
public static void downloadZipsOnly()
|
||||||
{
|
{
|
||||||
for (String s : urlList)
|
for (String s : URL_LIST)
|
||||||
{
|
{
|
||||||
String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length());
|
String fileName = s.substring("https://github.com/Konloch/bytecode-viewer/blob/master/libs/".length());
|
||||||
File file = new File(libsDir(), fileName);
|
File file = new File(libsDir(), fileName);
|
||||||
|
@ -404,7 +399,7 @@ public class Boot
|
||||||
boolean passed = false;
|
boolean passed = false;
|
||||||
while (!passed)
|
while (!passed)
|
||||||
{
|
{
|
||||||
if (!libsList.contains(fileName) && fileName.endsWith(".zip"))
|
if (!LIBS_LIST.contains(fileName) && fileName.endsWith(".zip"))
|
||||||
{
|
{
|
||||||
downloading = true;
|
downloading = true;
|
||||||
setState("Bytecode Viewer Boot Screen - Downloading " + fileName + "...");
|
setState("Bytecode Viewer Boot Screen - Downloading " + fileName + "...");
|
||||||
|
@ -443,11 +438,11 @@ public class Boot
|
||||||
setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "...");
|
setState("Bytecode Viewer Boot Screen - Verifying " + fileName + "...");
|
||||||
System.out.println("Verifying " + fileName + "...");
|
System.out.println("Verifying " + fileName + "...");
|
||||||
|
|
||||||
File f = new File(Constants.tempDirectory, "temp");
|
File f = new File(Constants.TEMP_DIRECTORY, "temp");
|
||||||
ZipUtils.zipFile(file, f);
|
ZipUtils.zipFile(file, f);
|
||||||
f.delete();
|
f.delete();
|
||||||
|
|
||||||
libsFileList.add(file.getAbsolutePath());
|
LIBS_FILE_LIST.add(file.getAbsolutePath());
|
||||||
System.out.println("Download finished!");
|
System.out.println("Download finished!");
|
||||||
passed = true;
|
passed = true;
|
||||||
}
|
}
|
||||||
|
@ -469,7 +464,7 @@ public class Boot
|
||||||
setState("Bytecode Viewer Boot Screen - Checking Enjarify...");
|
setState("Bytecode Viewer Boot Screen - Checking Enjarify...");
|
||||||
System.out.println("Checking enjarify");
|
System.out.println("Checking enjarify");
|
||||||
File enjarifyZip = null;
|
File enjarifyZip = null;
|
||||||
for (File f : MiscUtils.listFiles(new File(Constants.libsDirectory)))
|
for (File f : MiscUtils.listFiles(new File(Constants.LIBS_DIRECTORY)))
|
||||||
{
|
{
|
||||||
if (f.getName().toLowerCase().startsWith("enjarify-"))
|
if (f.getName().toLowerCase().startsWith("enjarify-"))
|
||||||
{
|
{
|
||||||
|
@ -495,8 +490,8 @@ public class Boot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Constants.enjarifyWorkingDirectory = getBCVDirectory() + fs + "enjarify_" + Constants.enjarifyVersion + fs + "enjarify-master";
|
Constants.enjarifyWorkingDirectory = getBCVDirectory() + FS + "enjarify_" + Constants.enjarifyVersion + FS + "enjarify-master";
|
||||||
File enjarifyDirectory = new File(getBCVDirectory() + fs + "enjarify_" + Constants.enjarifyVersion);
|
File enjarifyDirectory = new File(getBCVDirectory() + FS + "enjarify_" + Constants.enjarifyVersion);
|
||||||
if (!enjarifyDirectory.exists())
|
if (!enjarifyDirectory.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -507,7 +502,8 @@ public class Boot
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("ERROR: There was an issue unzipping enjarify (possibly corrupt). Restart " + "BCV." + nl + "If the error persists contact @Konloch.");
|
BytecodeViewer.showMessage("ERROR: There was an issue unzipping enjarify (possibly corrupt). Restart BCV."
|
||||||
|
+ NL + "If the error persists contact @Konloch.");
|
||||||
BytecodeViewer.handleException(e);
|
BytecodeViewer.handleException(e);
|
||||||
Objects.requireNonNull(enjarifyZip).delete();
|
Objects.requireNonNull(enjarifyZip).delete();
|
||||||
}
|
}
|
||||||
|
@ -521,7 +517,7 @@ public class Boot
|
||||||
System.out.println("Checking krakatau");
|
System.out.println("Checking krakatau");
|
||||||
|
|
||||||
File krakatauZip = null;
|
File krakatauZip = null;
|
||||||
for (File f : MiscUtils.listFiles(new File(Constants.libsDirectory)))
|
for (File f : MiscUtils.listFiles(new File(Constants.LIBS_DIRECTORY)))
|
||||||
{
|
{
|
||||||
if (f.getName().toLowerCase().startsWith("krakatau-"))
|
if (f.getName().toLowerCase().startsWith("krakatau-"))
|
||||||
{
|
{
|
||||||
|
@ -548,9 +544,9 @@ public class Boot
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Constants.krakatauWorkingDirectory = getBCVDirectory() + fs + "krakatau_" + Constants.krakatauVersion + fs + "Krakatau-master";
|
Constants.krakatauWorkingDirectory = getBCVDirectory() + FS + "krakatau_" + Constants.krakatauVersion + FS + "Krakatau-master";
|
||||||
|
|
||||||
File krakatauDirectory = new File(getBCVDirectory() + fs + "krakatau_" + Constants.krakatauVersion);
|
File krakatauDirectory = new File(getBCVDirectory() + FS + "krakatau_" + Constants.krakatauVersion);
|
||||||
if (!krakatauDirectory.exists())
|
if (!krakatauDirectory.exists())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -561,7 +557,8 @@ public class Boot
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("ERROR: There was an issue unzipping Krakatau decompiler (possibly " + "corrupt). Restart BCV." + nl + "If the error persists contact @Konloch.");
|
BytecodeViewer.showMessage("ERROR: There was an issue unzipping Krakatau decompiler (possibly corrupt). Restart BCV."
|
||||||
|
+ NL + "If the error persists contact @Konloch.");
|
||||||
BytecodeViewer.handleException(e);
|
BytecodeViewer.handleException(e);
|
||||||
Objects.requireNonNull(krakatauZip).delete();
|
Objects.requireNonNull(krakatauZip).delete();
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,25 +60,26 @@ public class InitialBootScreen extends JFrame
|
||||||
gridBagLayout.columnWidths = new int[]{0, 0};
|
gridBagLayout.columnWidths = new int[]{0, 0};
|
||||||
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
gridBagLayout.columnWeights = new double[]{1.0, Double.MIN_VALUE};
|
||||||
gridBagLayout.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
gridBagLayout.rowWeights = new double[]{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
||||||
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
|
||||||
getContentPane().setLayout(gridBagLayout);
|
getContentPane().setLayout(gridBagLayout);
|
||||||
|
|
||||||
JScrollPane scrollPane = new JScrollPane();
|
JScrollPane scrollPane = new JScrollPane();
|
||||||
GridBagConstraints gbc_scrollPane = new GridBagConstraints();
|
GridBagConstraints scrollPaneConstraints = new GridBagConstraints();
|
||||||
gbc_scrollPane.gridheight = 24;
|
scrollPaneConstraints.gridheight = 24;
|
||||||
gbc_scrollPane.insets = new Insets(0, 0, 5, 0);
|
scrollPaneConstraints.insets = new Insets(0, 0, 5, 0);
|
||||||
gbc_scrollPane.fill = GridBagConstraints.BOTH;
|
scrollPaneConstraints.fill = GridBagConstraints.BOTH;
|
||||||
gbc_scrollPane.gridx = 0;
|
scrollPaneConstraints.gridx = 0;
|
||||||
gbc_scrollPane.gridy = 0;
|
scrollPaneConstraints.gridy = 0;
|
||||||
getContentPane().add(scrollPane, gbc_scrollPane);
|
getContentPane().add(scrollPane, scrollPaneConstraints);
|
||||||
|
|
||||||
scrollPane.setViewportView(HTMLPane.fromResource(language.getHTMLPath("intro")));
|
scrollPane.setViewportView(HTMLPane.fromResource(language.getHTMLPath("intro")));
|
||||||
|
|
||||||
GridBagConstraints gbc_progressBar = new GridBagConstraints();
|
GridBagConstraints progressBarConstraints = new GridBagConstraints();
|
||||||
gbc_progressBar.fill = GridBagConstraints.HORIZONTAL;
|
progressBarConstraints.fill = GridBagConstraints.HORIZONTAL;
|
||||||
gbc_progressBar.gridx = 0;
|
progressBarConstraints.gridx = 0;
|
||||||
gbc_progressBar.gridy = 24;
|
progressBarConstraints.gridy = 24;
|
||||||
getContentPane().add(progressBar, gbc_progressBar);
|
getContentPane().add(progressBar, progressBarConstraints);
|
||||||
this.setLocationRelativeTo(null);
|
this.setLocationRelativeTo(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.net.URI;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
|
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -43,7 +43,8 @@ public class UpdateCheck implements Runnable
|
||||||
{
|
{
|
||||||
//just brute force download the url path
|
//just brute force download the url path
|
||||||
//one of these works for every single version of BCV
|
//one of these works for every single version of BCV
|
||||||
public static final String[] remoteGithubReleases = new String[]{
|
public static final String[] REMOTE_GITHUB_RELEASES = new String[]
|
||||||
|
{
|
||||||
//current url scheme since v2.9.12
|
//current url scheme since v2.9.12
|
||||||
"https://github.com/Konloch/bytecode-viewer/releases/download/v{VERSION}/Bytecode-Viewer-{VERSION}.jar",
|
"https://github.com/Konloch/bytecode-viewer/releases/download/v{VERSION}/Bytecode-Viewer-{VERSION}.jar",
|
||||||
//for v2.9.10 and v2.9.11
|
//for v2.9.10 and v2.9.11
|
||||||
|
@ -59,13 +60,17 @@ public class UpdateCheck implements Runnable
|
||||||
//for v1.0
|
//for v1.0
|
||||||
"https://github.com/Konloch/bytecode-viewer/releases/download/B{VERSION}/BytecodeViewer.jar",
|
"https://github.com/Konloch/bytecode-viewer/releases/download/B{VERSION}/BytecodeViewer.jar",
|
||||||
//zip variant of current url scheme since v2.9.12 (not currently used but incase it ever does)
|
//zip variant of current url scheme since v2.9.12 (not currently used but incase it ever does)
|
||||||
"https://github.com/Konloch/bytecode-viewer/releases/download/v{VERSION}/Bytecode-Viewer-{VERSION}.zip",};
|
"https://github.com/Konloch/bytecode-viewer/releases/download/v{VERSION}/Bytecode-Viewer-{VERSION}.zip"
|
||||||
|
};
|
||||||
|
|
||||||
//a list of all of the released versions of BCV
|
//a list of all of the released versions of BCV
|
||||||
public static final String[] versions = new String[]{
|
public static final String[] BCV_VERSIONS = new String[]
|
||||||
|
{
|
||||||
//"2.11.0",
|
//"2.11.0",
|
||||||
//"2.10.15",
|
//"2.10.15",
|
||||||
"2.10.14", "2.10.13", "2.10.12", "2.10.11", "2.9.22", "2.9.21", "2.9.20", "2.9.19", "2.9.18", "2.9.17", "2.9.16", "2.9.15", "2.9.14", "2.9.13", "2.9.12", "2.9.11", "2.9.10", //broken due to repo change
|
"2.10.14", "2.10.13", "2.10.12", "2.10.11",
|
||||||
|
"2.9.22", "2.9.21", "2.9.20",
|
||||||
|
"2.9.19", "2.9.18", "2.9.17", "2.9.16", "2.9.15", "2.9.14", "2.9.13", "2.9.12", "2.9.11", "2.9.10", //broken due to repo change
|
||||||
"2.9.8", //broken due to repo change & zip
|
"2.9.8", //broken due to repo change & zip
|
||||||
"2.9.7", //broken due to repo change & zip
|
"2.9.7", //broken due to repo change & zip
|
||||||
"2.9.6", //zip
|
"2.9.6", //zip
|
||||||
|
@ -79,7 +84,11 @@ public class UpdateCheck implements Runnable
|
||||||
"2.8.0", //zip
|
"2.8.0", //zip
|
||||||
"2.7.1", //zip
|
"2.7.1", //zip
|
||||||
"2.7.0", //zip
|
"2.7.0", //zip
|
||||||
"2.6.0", "2.5.2", "2.5.1", "2.5.0", "2.4.0", "2.3.0", "2.2.1", "2.2.0", "2.1.1", "2.1.0", "2.0.1", "2.0", "1.5.3", "1.5.2", "1.5.1", "1.5", "1.4", "1.3.1", "1.3", "1.2", "1.1", "1.0",};
|
"2.6.0", "2.5.2", "2.5.1", "2.5.0", "2.4.0", "2.3.0", "2.2.1", "2.2.0", "2.1.1", "2.1.0", "2.0.1",
|
||||||
|
"2.0",
|
||||||
|
"1.5.3", "1.5.2", "1.5.1", "1.5", "1.4", "1.3.1", "1.3",
|
||||||
|
"1.2", "1.1", "1.0"
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
|
@ -100,7 +109,7 @@ public class UpdateCheck implements Runnable
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MultipleChoiceDialog outdatedDialog = new MultipleChoiceDialog("Bytecode Viewer - Outdated Version", "Your version: " + localVersion + ", latest version: " + version + nl + "What would you like to do?", new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing (And Don't Ask Again)"});
|
MultipleChoiceDialog outdatedDialog = new MultipleChoiceDialog("Bytecode Viewer - Outdated Version", "Your version: " + localVersion + ", latest version: " + version + NL + "What would you like to do?", new String[]{"Open The Download Page", "Download The Updated Jar", "Do Nothing (And Don't Ask Again)"});
|
||||||
|
|
||||||
int result = outdatedDialog.promptChoice();
|
int result = outdatedDialog.promptChoice();
|
||||||
|
|
||||||
|
@ -109,7 +118,7 @@ public class UpdateCheck implements Runnable
|
||||||
if (Desktop.isDesktopSupported())
|
if (Desktop.isDesktopSupported())
|
||||||
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
|
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
|
||||||
else
|
else
|
||||||
BytecodeViewer.showMessage("Cannot open the page, please manually type it." + nl + "https://github.com/Konloch/bytecode-viewer/releases");
|
BytecodeViewer.showMessage("Cannot open the page, please manually type it." + NL + "https://github.com/Konloch/bytecode-viewer/releases");
|
||||||
}
|
}
|
||||||
else if (result == 1)
|
else if (result == 1)
|
||||||
{
|
{
|
||||||
|
@ -152,7 +161,9 @@ public class UpdateCheck implements Runnable
|
||||||
|
|
||||||
if (file.exists())
|
if (file.exists())
|
||||||
{
|
{
|
||||||
MultipleChoiceDialog overwriteDialog = new MultipleChoiceDialog("Bytecode Viewer - Overwrite File", "The file " + file + " exists, would you like to overwrite it?", new String[]{TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString()});
|
MultipleChoiceDialog overwriteDialog = new MultipleChoiceDialog("Bytecode Viewer - Overwrite File",
|
||||||
|
"The file " + file + " exists, would you like to overwrite it?",
|
||||||
|
new String[]{ TranslatedStrings.YES.toString(), TranslatedStrings.NO.toString() });
|
||||||
|
|
||||||
if (overwriteDialog.promptChoice() != 0)
|
if (overwriteDialog.promptChoice() != 0)
|
||||||
return null;
|
return null;
|
||||||
|
@ -168,7 +179,7 @@ public class UpdateCheck implements Runnable
|
||||||
/*public static void main(String[] args)
|
/*public static void main(String[] args)
|
||||||
{
|
{
|
||||||
BytecodeViewer.viewer = new MainViewerGUI();
|
BytecodeViewer.viewer = new MainViewerGUI();
|
||||||
for(String version : versions)
|
for(String version : BCV_VERSIONS)
|
||||||
{
|
{
|
||||||
//TODO most are jars, check which are zip and append zip as needed
|
//TODO most are jars, check which are zip and append zip as needed
|
||||||
File file = new File("./" + version + ".zip");
|
File file = new File("./" + version + ".zip");
|
||||||
|
@ -180,7 +191,7 @@ public class UpdateCheck implements Runnable
|
||||||
private static void downloadBCV(String version, File saveTo, Runnable onFinish, Runnable onFail)
|
private static void downloadBCV(String version, File saveTo, Runnable onFinish, Runnable onFail)
|
||||||
{
|
{
|
||||||
boolean found = false;
|
boolean found = false;
|
||||||
for (String urlAttempt : remoteGithubReleases)
|
for (String urlAttempt : REMOTE_GITHUB_RELEASES)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
@ -223,7 +234,7 @@ public class UpdateCheck implements Runnable
|
||||||
private static void download(String url, File saveTo, Runnable onFinish) throws Exception
|
private static void download(String url, File saveTo, Runnable onFinish) throws Exception
|
||||||
{
|
{
|
||||||
BCV.log("Downloading from: " + url);
|
BCV.log("Downloading from: " + url);
|
||||||
BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished you will be alerted with another message box." + nl + nl + "Expect this to take several minutes.");
|
BytecodeViewer.showMessage("Downloading the jar in the background, when it's finished you will be alerted with another message box." + NL + NL + "Expect this to take several minutes.");
|
||||||
|
|
||||||
try (InputStream is = new URL(url).openConnection().getInputStream(); FileOutputStream fos = new FileOutputStream(saveTo))
|
try (InputStream is = new URL(url).openConnection().getInputStream(); FileOutputStream fos = new FileOutputStream(saveTo))
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,13 +52,13 @@ public class ClassTree
|
||||||
this(convertToMap(classes));
|
this(convertToMap(classes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassTree(Map<String, ClassNode> classes_)
|
public ClassTree(Map<String, ClassNode> classes)
|
||||||
{
|
{
|
||||||
classes = copyOf(classes_);
|
this.classes = copyOf(classes);
|
||||||
supers = new NullPermeableHashMap<>(SET_CREATOR);
|
supers = new NullPermeableHashMap<>(SET_CREATOR);
|
||||||
delgates = new NullPermeableHashMap<>(SET_CREATOR);
|
delgates = new NullPermeableHashMap<>(SET_CREATOR);
|
||||||
|
|
||||||
build(classes);
|
build(this.classes);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: optimise
|
// TODO: optimise
|
||||||
|
@ -66,32 +66,36 @@ public class ClassTree
|
||||||
{
|
{
|
||||||
for (ClassNode node : classes.values())
|
for (ClassNode node : classes.values())
|
||||||
{
|
{
|
||||||
for (String iface : node.interfaces)
|
for (String iFace : node.interfaces)
|
||||||
{
|
{
|
||||||
ClassNode ifacecs = classes.get(iface);
|
ClassNode iFaces = classes.get(iFace);
|
||||||
if (ifacecs == null)
|
if (iFaces == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
getDelegates0(ifacecs).add(node);
|
getDelegates0(iFaces).add(node);
|
||||||
|
|
||||||
Set<ClassNode> superinterfaces = new HashSet<>();
|
Set<ClassNode> superinterfaces = new HashSet<>();
|
||||||
buildSubTree(classes, superinterfaces, ifacecs);
|
buildSubTree(classes, superinterfaces, iFaces);
|
||||||
|
|
||||||
getSupers0(node).addAll(superinterfaces);
|
getSupers0(node).addAll(superinterfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
ClassNode currentSuper = classes.get(node.superName);
|
ClassNode currentSuper = classes.get(node.superName);
|
||||||
|
|
||||||
while (currentSuper != null)
|
while (currentSuper != null)
|
||||||
{
|
{
|
||||||
getDelegates0(currentSuper).add(node);
|
getDelegates0(currentSuper).add(node);
|
||||||
getSupers0(node).add(currentSuper);
|
getSupers0(node).add(currentSuper);
|
||||||
for (String iface : currentSuper.interfaces)
|
for (String iFace : currentSuper.interfaces)
|
||||||
{
|
{
|
||||||
ClassNode ifacecs = classes.get(iface);
|
ClassNode iFaces = classes.get(iFace);
|
||||||
if (ifacecs == null)
|
|
||||||
|
if (iFaces == null)
|
||||||
continue;
|
continue;
|
||||||
getDelegates0(ifacecs).add(currentSuper);
|
|
||||||
|
getDelegates0(iFaces).add(currentSuper);
|
||||||
Set<ClassNode> superinterfaces = new HashSet<>();
|
Set<ClassNode> superinterfaces = new HashSet<>();
|
||||||
buildSubTree(classes, superinterfaces, ifacecs);
|
buildSubTree(classes, superinterfaces, iFaces);
|
||||||
getSupers0(currentSuper).addAll(superinterfaces);
|
getSupers0(currentSuper).addAll(superinterfaces);
|
||||||
getSupers0(node).addAll(superinterfaces);
|
getSupers0(node).addAll(superinterfaces);
|
||||||
}
|
}
|
||||||
|
@ -108,6 +112,7 @@ public class ClassTree
|
||||||
for (String iface : node.interfaces)
|
for (String iface : node.interfaces)
|
||||||
{
|
{
|
||||||
ClassNode ifacecs = classes.get(iface);
|
ClassNode ifacecs = classes.get(iface);
|
||||||
|
|
||||||
if (ifacecs == null)
|
if (ifacecs == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -126,14 +131,17 @@ public class ClassTree
|
||||||
for (String iface : currentSuper.interfaces)
|
for (String iface : currentSuper.interfaces)
|
||||||
{
|
{
|
||||||
ClassNode ifacecs = classes.get(iface);
|
ClassNode ifacecs = classes.get(iface);
|
||||||
|
|
||||||
if (ifacecs == null)
|
if (ifacecs == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
getDelegates0(ifacecs).add(currentSuper);
|
getDelegates0(ifacecs).add(currentSuper);
|
||||||
Set<ClassNode> superinterfaces = new HashSet<>();
|
Set<ClassNode> superinterfaces = new HashSet<>();
|
||||||
buildSubTree(classes, superinterfaces, ifacecs);
|
buildSubTree(classes, superinterfaces, ifacecs);
|
||||||
getSupers0(currentSuper).addAll(superinterfaces);
|
getSupers0(currentSuper).addAll(superinterfaces);
|
||||||
getSupers0(node).addAll(superinterfaces);
|
getSupers0(node).addAll(superinterfaces);
|
||||||
}
|
}
|
||||||
|
|
||||||
currentSuper = classes.get(currentSuper.superName);
|
currentSuper = classes.get(currentSuper.superName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,16 +170,14 @@ public class ClassTree
|
||||||
public Set<MethodNode> getMethodsFromSuper(ClassNode node, String name, String desc)
|
public Set<MethodNode> getMethodsFromSuper(ClassNode node, String name, String desc)
|
||||||
{
|
{
|
||||||
Set<MethodNode> methods = new HashSet<>();
|
Set<MethodNode> methods = new HashSet<>();
|
||||||
for (ClassNode super_ : getSupers(node))
|
for (ClassNode superClassNode : getSupers(node))
|
||||||
{
|
{
|
||||||
for (MethodNode mn : super_.methods)
|
for (MethodNode mn : superClassNode.methods)
|
||||||
{
|
{
|
||||||
if (mn.name.equals(name) && mn.desc.equals(desc))
|
if (mn.name.equals(name) && mn.desc.equals(desc))
|
||||||
{
|
|
||||||
methods.add(mn);
|
methods.add(mn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,26 +189,22 @@ public class ClassTree
|
||||||
for (MethodNode mn : delegate.methods)
|
for (MethodNode mn : delegate.methods)
|
||||||
{
|
{
|
||||||
if (mn.name.equals(name) && mn.desc.equals(desc))
|
if (mn.name.equals(name) && mn.desc.equals(desc))
|
||||||
{
|
|
||||||
methods.add(mn);
|
methods.add(mn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return methods;
|
return methods;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MethodNode getFirstMethodFromSuper(ClassNode node, String name, String desc)
|
public MethodNode getFirstMethodFromSuper(ClassNode node, String name, String desc)
|
||||||
{
|
{
|
||||||
for (ClassNode super_ : getSupers(node))
|
for (ClassNode superClassNode : getSupers(node))
|
||||||
{
|
{
|
||||||
for (MethodNode mn : super_.methods)
|
for (MethodNode mn : superClassNode.methods)
|
||||||
{
|
{
|
||||||
if (mn.name.equals(name) && mn.desc.equals(desc))
|
if (mn.name.equals(name) && mn.desc.equals(desc))
|
||||||
{
|
|
||||||
return mn;
|
return mn;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -234,12 +236,10 @@ public class ClassTree
|
||||||
public Set<ClassNode> getSupers(ClassNode cn)
|
public Set<ClassNode> getSupers(ClassNode cn)
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableSet(supers.get(cn));
|
return Collections.unmodifiableSet(supers.get(cn));
|
||||||
// return supers.get(cn);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<ClassNode> getDelegates(ClassNode cn)
|
public Set<ClassNode> getDelegates(ClassNode cn)
|
||||||
{
|
{
|
||||||
return Collections.unmodifiableSet(delgates.get(cn));
|
return Collections.unmodifiableSet(delgates.get(cn));
|
||||||
// return delgates.get(cn);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,8 @@ import java.net.URLClassLoader;
|
||||||
public class ClassPathLoader implements ILoader<Object>
|
public class ClassPathLoader implements ILoader<Object>
|
||||||
{
|
{
|
||||||
|
|
||||||
void extendClassPath(URL url) throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
void extendClassPath(URL url) throws NoSuchMethodException, SecurityException,
|
||||||
|
IllegalAccessException, IllegalArgumentException, InvocationTargetException
|
||||||
{
|
{
|
||||||
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
URLClassLoader urlClassLoader = (URLClassLoader) ClassLoader.getSystemClassLoader();
|
||||||
Class<URLClassLoader> urlClass = URLClassLoader.class;
|
Class<URLClassLoader> urlClass = URLClassLoader.class;
|
||||||
|
@ -59,7 +60,8 @@ public class ClassPathLoader implements ILoader<Object>
|
||||||
extendClassPath(url);
|
extendClassPath(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}/* catch (IOException e) {
|
}
|
||||||
|
/* catch (IOException e) {
|
||||||
System.err.println("Error loading resource.");
|
System.err.println("Error loading resource.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}*/
|
}*/
|
||||||
|
|
|
@ -85,14 +85,14 @@ public class LibraryClassLoader extends ClassLoader implements ILoader<JarConten
|
||||||
@Override
|
@Override
|
||||||
public Class<?> findClass(String name) throws ClassNotFoundException, NoClassDefFoundError
|
public Class<?> findClass(String name) throws ClassNotFoundException, NoClassDefFoundError
|
||||||
{
|
{
|
||||||
String byte_name = name.replace(".", "/");
|
String byteName = name.replace(".", "/");
|
||||||
if (classCache.containsKey(byte_name))
|
if (classCache.containsKey(byteName))
|
||||||
return classCache.get(byte_name);
|
return classCache.get(byteName);
|
||||||
|
|
||||||
ClassNode cn = null;
|
ClassNode cn = null;
|
||||||
for (JarContents<ClassNode> contents : binded)
|
for (JarContents<ClassNode> contents : binded)
|
||||||
{
|
{
|
||||||
cn = contents.getClassContents().namedMap().get(byte_name);
|
cn = contents.getClassContents().namedMap().get(byteName);
|
||||||
if (cn != null)
|
if (cn != null)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class LibraryClassLoader extends ClassLoader implements ILoader<JarConten
|
||||||
Class<?> klass = define(cn);
|
Class<?> klass = define(cn);
|
||||||
if (klass != null)
|
if (klass != null)
|
||||||
{
|
{
|
||||||
classCache.put(byte_name, klass);
|
classCache.put(byteName, klass);
|
||||||
return klass;
|
return klass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,8 +29,9 @@ import the.bytecode.club.bytecodeviewer.compilers.impl.SmaliAssembler;
|
||||||
*/
|
*/
|
||||||
public enum Compiler
|
public enum Compiler
|
||||||
{
|
{
|
||||||
KRAKATAU_ASSEMBLER(new KrakatauAssembler()), SMALI_ASSEMBLER(new SmaliAssembler()), JAVA_COMPILER(new JavaCompiler()),
|
KRAKATAU_ASSEMBLER(new KrakatauAssembler()),
|
||||||
;
|
SMALI_ASSEMBLER(new SmaliAssembler()),
|
||||||
|
JAVA_COMPILER(new JavaCompiler());
|
||||||
|
|
||||||
private final InternalCompiler compiler;
|
private final InternalCompiler compiler;
|
||||||
|
|
||||||
|
|
|
@ -43,19 +43,20 @@ public class JavaCompiler extends InternalCompiler
|
||||||
@Override
|
@Override
|
||||||
public byte[] compile(String contents, String fullyQualifiedName)
|
public byte[] compile(String contents, String fullyQualifiedName)
|
||||||
{
|
{
|
||||||
String fileStart = tempDirectory + fs + "temp" + MiscUtils.randomString(12) + fs;
|
String fileStart = TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(12) + FS;
|
||||||
String fileStart2 = tempDirectory + fs + "temp" + MiscUtils.randomString(12) + fs;
|
String fileStart2 = TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(12) + FS;
|
||||||
File java = new File(fileStart + fs + fullyQualifiedName + ".java");
|
File java = new File(fileStart + FS + fullyQualifiedName + ".java");
|
||||||
File clazz = new File(fileStart2 + fs + fullyQualifiedName + ".class");
|
File clazz = new File(fileStart2 + FS + fullyQualifiedName + ".class");
|
||||||
File cp = new File(tempDirectory + fs + "cpath_" + MiscUtils.randomString(12) + ".jar");
|
File cp = new File(TEMP_DIRECTORY + FS + "cpath_" + MiscUtils.randomString(12) + ".jar");
|
||||||
File tempD = new File(fileStart + fs + fullyQualifiedName.substring(0, fullyQualifiedName.length() - fullyQualifiedName.split("/")[fullyQualifiedName.split("/").length - 1].length()));
|
File tempD = new File(fileStart + FS + fullyQualifiedName.substring(0, fullyQualifiedName.length() -
|
||||||
|
fullyQualifiedName.split("/")[fullyQualifiedName.split("/").length - 1].length()));
|
||||||
|
|
||||||
tempD.mkdirs();
|
tempD.mkdirs();
|
||||||
new File(fileStart2).mkdirs();
|
new File(fileStart2).mkdirs();
|
||||||
|
|
||||||
if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists())
|
if (Configuration.javac.isEmpty() || !new File(Configuration.javac).exists())
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("You need to set your Javac path, this requires the JDK to be downloaded." + nl + "(C:/Program Files/Java/JDK_xx/bin/javac.exe)");
|
BytecodeViewer.showMessage("You need to set your Javac path, this requires the JDK to be downloaded." + NL + "(C:/Program Files/Java/JDK_xx/bin/javac.exe)");
|
||||||
ExternalResources.getSingleton().selectJavac();
|
ExternalResources.getSingleton().selectJavac();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,13 +76,11 @@ public class JavaCompiler extends InternalCompiler
|
||||||
ProcessBuilder pb;
|
ProcessBuilder pb;
|
||||||
|
|
||||||
if (Configuration.library.isEmpty())
|
if (Configuration.library.isEmpty())
|
||||||
{
|
pb = new ProcessBuilder(Configuration.javac, "-d", fileStart2,
|
||||||
pb = new ProcessBuilder(Configuration.javac, "-d", fileStart2, "-classpath", cp.getAbsolutePath(), java.getAbsolutePath());
|
"-classpath", cp.getAbsolutePath(), java.getAbsolutePath());
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
pb = new ProcessBuilder(Configuration.javac, "-d", fileStart2,
|
||||||
pb = new ProcessBuilder(Configuration.javac, "-d", fileStart2, "-classpath", cp.getAbsolutePath() + System.getProperty("path.separator") + Configuration.library, java.getAbsolutePath());
|
"-classpath", cp.getAbsolutePath() + System.getProperty("path.separator") + Configuration.library, java.getAbsolutePath());
|
||||||
}
|
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
@ -102,22 +101,26 @@ public class JavaCompiler extends InternalCompiler
|
||||||
int exitValue = process.waitFor();
|
int exitValue = process.waitFor();
|
||||||
|
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
|
log.append(NL).append(NL).append(TranslatedStrings.ERROR2).append(NL).append(NL);
|
||||||
try (InputStream is = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getErrorStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
log.append(NL).append(NL).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
||||||
System.out.println(log);
|
System.out.println(log);
|
||||||
|
|
||||||
if (!clazz.exists())
|
if (!clazz.exists())
|
||||||
|
|
|
@ -51,16 +51,16 @@ public class KrakatauAssembler extends InternalCompiler
|
||||||
if (!ExternalResources.getSingleton().hasSetPython2Command())
|
if (!ExternalResources.getSingleton().hasSetPython2Command())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
File tempD = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
File tempD = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
|
||||||
tempD.mkdir();
|
tempD.mkdir();
|
||||||
|
|
||||||
File tempJ = new File(tempD.getAbsolutePath() + fs + fullyQualifiedName + ".j");
|
File tempJ = new File(tempD.getAbsolutePath() + FS + fullyQualifiedName + ".j");
|
||||||
DiskWriter.replaceFile(tempJ.getAbsolutePath(), contents, true);
|
DiskWriter.replaceFile(tempJ.getAbsolutePath(), contents, true);
|
||||||
|
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
|
|
||||||
final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
|
final File tempJar = new File(Constants.TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + ".jar");
|
||||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder();
|
StringBuilder log = new StringBuilder();
|
||||||
|
@ -72,29 +72,33 @@ public class KrakatauAssembler extends InternalCompiler
|
||||||
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
||||||
krakatauWorkingDirectory + fs + "assemble.py", "-out", tempDirectory.getAbsolutePath(), tempJ.getAbsolutePath()));
|
krakatauWorkingDirectory + FS + "assemble.py", "-out", tempDirectory.getAbsolutePath(), tempJ.getAbsolutePath()));
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
|
log.append(NL).append(NL).append(TranslatedStrings.ERROR2).append(NL).append(NL);
|
||||||
try (InputStream is = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getErrorStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitValue = process.waitFor();
|
int exitValue = process.waitFor();
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
log.append(NL).append(NL).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
||||||
System.err.println(log);
|
System.err.println(log);
|
||||||
|
|
||||||
byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull(ExternalResources.getSingleton().findFile(tempDirectory, ".class")));
|
byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull(ExternalResources.getSingleton().findFile(tempDirectory, ".class")));
|
||||||
|
|
|
@ -30,8 +30,8 @@ import the.bytecode.club.bytecodeviewer.util.ZipUtils;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Smali Assembler Wrapper for Java
|
* Smali Assembler Wrapper for Java
|
||||||
|
@ -44,16 +44,16 @@ public class SmaliAssembler extends InternalCompiler
|
||||||
@Override
|
@Override
|
||||||
public byte[] compile(String contents, String fullyQualifiedName)
|
public byte[] compile(String contents, String fullyQualifiedName)
|
||||||
{
|
{
|
||||||
String fileStart = tempDirectory + fs + "temp";
|
String fileStart = TEMP_DIRECTORY + FS + "temp";
|
||||||
int fileNumber = MiscUtils.getClassNumber(fileStart, ".dex");
|
int fileNumber = MiscUtils.getClassNumber(fileStart, ".dex");
|
||||||
|
|
||||||
final File tempSmaliFolder = new File(fileStart + fileNumber + "-smalifolder" + fs);
|
final File tempSmaliFolder = new File(fileStart + fileNumber + "-smalifolder" + FS);
|
||||||
tempSmaliFolder.mkdir();
|
tempSmaliFolder.mkdir();
|
||||||
|
|
||||||
File tempSmali = new File(tempSmaliFolder.getAbsolutePath() + fs + fileNumber + ".smali");
|
File tempSmali = new File(tempSmaliFolder.getAbsolutePath() + FS + fileNumber + ".smali");
|
||||||
File tempDex = new File("./out.dex");
|
File tempDex = new File("./out.dex");
|
||||||
File tempJar = new File(fileStart + fileNumber + ".jar");
|
File tempJar = new File(fileStart + fileNumber + ".jar");
|
||||||
File tempJarFolder = new File(fileStart + fileNumber + "-jar" + fs);
|
File tempJarFolder = new File(fileStart + fileNumber + "-jar" + FS);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,8 +29,23 @@ public enum Decompiler
|
||||||
{
|
{
|
||||||
//TODO WARNING: do not change the decompiler order, when adding a new decompiler just add it to the end
|
//TODO WARNING: do not change the decompiler order, when adding a new decompiler just add it to the end
|
||||||
// enum ordinal is used for settings serialization instead of the enum name
|
// enum ordinal is used for settings serialization instead of the enum name
|
||||||
NONE("None", "", null), PROCYON_DECOMPILER("Procyon Decompiler", "proycon", new ProcyonDecompiler()), CFR_DECOMPILER("CFR Decompiler", "cfr", new CFRDecompiler()), FERNFLOWER_DECOMPILER("FernFlower Decompiler", "fernflower", new FernFlowerDecompiler()), BYTECODE_DISASSEMBLER("Bytecode Disassembler", "bcvbd", new BytecodeDisassembler()), HEXCODE_VIEWER("Hexcode Viewer", "bcvhex", null), SMALI_DISASSEMBLER("Smali Disassembler", "smali", new SmaliDisassembler()), KRAKATAU_DECOMPILER("Krakatau Decompiler", "krakatau", new KrakatauDecompiler()), KRAKATAU_DISASSEMBLER("Krakatau Disassembler", "krakataud", new KrakatauDisassembler()), JD_DECOMPILER("JD-GUI Decompiler", "jdgui", new JDGUIDecompiler()), JADX_DECOMPILER("JADX Decompiler", "jadx", new JADXDecompiler()), ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", "asm", new ASMTextifierDisassembler()), ASMIFIER_DECOMPILER("ASMifier Generator", "asmifier", new ASMifierGenerator()), JAVAP_DISASSEMBLER("Javap Disassembler", "javap", new JavapDisassembler()),
|
NONE("None", "", null),
|
||||||
;
|
PROCYON_DECOMPILER("Procyon Decompiler", "proycon", new ProcyonDecompiler()),
|
||||||
|
CFR_DECOMPILER("CFR Decompiler", "cfr", new CFRDecompiler()),
|
||||||
|
FERNFLOWER_DECOMPILER("FernFlower Decompiler", "fernflower", new FernFlowerDecompiler()),
|
||||||
|
|
||||||
|
BYTECODE_DISASSEMBLER("Bytecode Disassembler", "bcvbd", new BytecodeDisassembler()),
|
||||||
|
HEXCODE_VIEWER("Hexcode Viewer", "bcvhex", null),
|
||||||
|
|
||||||
|
SMALI_DISASSEMBLER("Smali Disassembler", "smali", new SmaliDisassembler()),
|
||||||
|
KRAKATAU_DECOMPILER("Krakatau Decompiler", "krakatau", new KrakatauDecompiler()),
|
||||||
|
KRAKATAU_DISASSEMBLER("Krakatau Disassembler", "krakataud", new KrakatauDisassembler()),
|
||||||
|
JD_DECOMPILER("JD-GUI Decompiler", "jdgui", new JDGUIDecompiler()),
|
||||||
|
JADX_DECOMPILER("JADX Decompiler", "jadx", new JADXDecompiler()),
|
||||||
|
|
||||||
|
ASM_TEXTIFY_DISASSEMBLER("ASM Disassembler", "asm", new ASMTextifierDisassembler()),
|
||||||
|
ASMIFIER_DECOMPILER("ASMifier Generator", "asmifier", new ASMifierGenerator()),
|
||||||
|
JAVAP_DISASSEMBLER("Javap Disassembler", "javap", new JavapDisassembler());
|
||||||
|
|
||||||
private final String decompilerName;
|
private final String decompilerName;
|
||||||
private final String decompilerNameProgrammic;
|
private final String decompilerNameProgrammic;
|
||||||
|
|
|
@ -29,7 +29,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -45,6 +45,7 @@ public class ClassNodeDecompiler
|
||||||
sb.append(getAccessString(cn.access));
|
sb.append(getAccessString(cn.access));
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(cn.name);
|
sb.append(cn.name);
|
||||||
|
|
||||||
if (cn.superName != null && !cn.superName.equals("java/lang/Object"))
|
if (cn.superName != null && !cn.superName.equals("java/lang/Object"))
|
||||||
{
|
{
|
||||||
sb.append(" extends ");
|
sb.append(" extends ");
|
||||||
|
@ -52,34 +53,37 @@ public class ClassNodeDecompiler
|
||||||
}
|
}
|
||||||
|
|
||||||
int amountOfInterfaces = cn.interfaces.size();
|
int amountOfInterfaces = cn.interfaces.size();
|
||||||
|
|
||||||
if (amountOfInterfaces > 0)
|
if (amountOfInterfaces > 0)
|
||||||
{
|
{
|
||||||
sb.append(" implements ");
|
sb.append(" implements ");
|
||||||
sb.append(cn.interfaces.get(0));
|
sb.append(cn.interfaces.get(0));
|
||||||
|
|
||||||
for (int i = 1; i < amountOfInterfaces; i++)
|
for (int i = 1; i < amountOfInterfaces; i++)
|
||||||
{
|
{
|
||||||
sb.append(", ");
|
sb.append(", ");
|
||||||
sb.append(cn.interfaces.get(i));
|
sb.append(cn.interfaces.get(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sb.append(" {");
|
sb.append(" {");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append("<ClassVersion=" + cn.version + ">");
|
sb.append("<ClassVersion=" + cn.version + ">");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
|
|
||||||
if (cn.sourceDebug != null)
|
if (cn.sourceDebug != null)
|
||||||
{
|
{
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append("<SourceDebug=" + cn.sourceDebug + ">");
|
sb.append("<SourceDebug=" + cn.sourceDebug + ">");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cn.sourceFile != null)
|
if (cn.sourceFile != null)
|
||||||
{
|
{
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append("<SourceFile=" + cn.sourceFile + ">");
|
sb.append("<SourceFile=" + cn.sourceFile + ">");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cn.signature != null)
|
if (cn.signature != null)
|
||||||
|
@ -90,17 +94,19 @@ public class ClassNodeDecompiler
|
||||||
|
|
||||||
for (FieldNode fn : cn.fields)
|
for (FieldNode fn : cn.fields)
|
||||||
{
|
{
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
FieldNodeDecompiler.decompile(sb, fn);
|
FieldNodeDecompiler.decompile(sb, fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cn.fields.size() > 0)
|
if (cn.fields.size() > 0)
|
||||||
{
|
{
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (MethodNode mn : cn.methods)
|
for (MethodNode mn : cn.methods)
|
||||||
{
|
{
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
MethodNodeDecompiler.decompile(sb, mn, cn);
|
MethodNodeDecompiler.decompile(sb, mn, cn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,13 +117,14 @@ public class ClassNodeDecompiler
|
||||||
{
|
{
|
||||||
decompiledClasses.add(innerClassName);
|
decompiledClasses.add(innerClassName);
|
||||||
ClassNode cn1 = BytecodeViewer.blindlySearchForClassNode(innerClassName);
|
ClassNode cn1 = BytecodeViewer.blindlySearchForClassNode(innerClassName);
|
||||||
|
|
||||||
if (cn1 != null)
|
if (cn1 != null)
|
||||||
{
|
{
|
||||||
sb.appendPrefix(" ");
|
sb.appendPrefix(" ");
|
||||||
sb.append(nl + nl);
|
sb.append(NL + NL);
|
||||||
sb = decompile(sb, decompiledClasses, cn1);
|
sb = decompile(sb, decompiledClasses, cn1);
|
||||||
sb.trimPrefix(5);
|
sb.trimPrefix(5);
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -129,17 +136,20 @@ public class ClassNodeDecompiler
|
||||||
if (!unableToDecompile.isEmpty())
|
if (!unableToDecompile.isEmpty())
|
||||||
{
|
{
|
||||||
sb.append("// The following inner classes couldn't be decompiled: ");
|
sb.append("// The following inner classes couldn't be decompiled: ");
|
||||||
|
|
||||||
for (String s : unableToDecompile)
|
for (String s : unableToDecompile)
|
||||||
{
|
{
|
||||||
sb.append(s);
|
sb.append(s);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
}
|
}
|
||||||
sb.append(nl);
|
|
||||||
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cn.attrs != null)
|
if (cn.attrs != null)
|
||||||
{
|
{
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
|
|
||||||
for (Attribute attr : cn.attrs)
|
for (Attribute attr : cn.attrs)
|
||||||
{
|
{
|
||||||
//TODO: finish attributes
|
//TODO: finish attributes
|
||||||
|
@ -157,6 +167,7 @@ public class ClassNodeDecompiler
|
||||||
public static String getAccessString(int access)
|
public static String getAccessString(int access)
|
||||||
{
|
{
|
||||||
List<String> tokens = new ArrayList<>();
|
List<String> tokens = new ArrayList<>();
|
||||||
|
|
||||||
if ((access & Opcodes.ACC_PUBLIC) != 0)
|
if ((access & Opcodes.ACC_PUBLIC) != 0)
|
||||||
tokens.add("public");
|
tokens.add("public");
|
||||||
if ((access & Opcodes.ACC_PRIVATE) != 0)
|
if ((access & Opcodes.ACC_PRIVATE) != 0)
|
||||||
|
@ -182,11 +193,13 @@ public class ClassNodeDecompiler
|
||||||
|
|
||||||
// hackery delimeters
|
// hackery delimeters
|
||||||
StringBuilder sb = new StringBuilder(tokens.get(0));
|
StringBuilder sb = new StringBuilder(tokens.get(0));
|
||||||
|
|
||||||
for (int i = 1; i < tokens.size(); i++)
|
for (int i = 1; i < tokens.size(); i++)
|
||||||
{
|
{
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(tokens.get(i));
|
sb.append(tokens.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@ import java.util.Arrays;
|
||||||
*/
|
*/
|
||||||
public class InstructionPattern implements Opcodes
|
public class InstructionPattern implements Opcodes
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last instruction-match position pointer
|
* Last instruction-match position pointer
|
||||||
**/
|
**/
|
||||||
|
@ -67,6 +66,7 @@ public class InstructionPattern implements Opcodes
|
||||||
{
|
{
|
||||||
filters = new InstructionFilter[opcodes.length];
|
filters = new InstructionFilter[opcodes.length];
|
||||||
lastMatch = new AbstractInsnNode[opcodes.length];
|
lastMatch = new AbstractInsnNode[opcodes.length];
|
||||||
|
|
||||||
for (int i = 0; i < opcodes.length; i++)
|
for (int i = 0; i < opcodes.length; i++)
|
||||||
{
|
{
|
||||||
filters[i] = new OpcodeFilter(opcodes[i]);
|
filters[i] = new OpcodeFilter(opcodes[i]);
|
||||||
|
@ -100,16 +100,17 @@ public class InstructionPattern implements Opcodes
|
||||||
if (filter.accept(ain))
|
if (filter.accept(ain))
|
||||||
{
|
{
|
||||||
lastMatch[pointer] = ain;
|
lastMatch[pointer] = ain;
|
||||||
|
|
||||||
if (pointer >= (filters.length - 1))
|
if (pointer >= (filters.length - 1))
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
pointer++;
|
pointer++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -150,10 +151,12 @@ public class InstructionPattern implements Opcodes
|
||||||
public static InstructionFilter[] translate(AbstractInsnNode[] ains)
|
public static InstructionFilter[] translate(AbstractInsnNode[] ains)
|
||||||
{
|
{
|
||||||
InstructionFilter[] filters = new InstructionFilter[ains.length];
|
InstructionFilter[] filters = new InstructionFilter[ains.length];
|
||||||
|
|
||||||
for (int i = 0; i < ains.length; i++)
|
for (int i = 0; i < ains.length; i++)
|
||||||
{
|
{
|
||||||
filters[i] = translate(ains[i]);
|
filters[i] = translate(ains[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -167,63 +170,38 @@ public class InstructionPattern implements Opcodes
|
||||||
public static InstructionFilter translate(AbstractInsnNode ain)
|
public static InstructionFilter translate(AbstractInsnNode ain)
|
||||||
{
|
{
|
||||||
if (ain instanceof LdcInsnNode)
|
if (ain instanceof LdcInsnNode)
|
||||||
{
|
|
||||||
return new LdcInstructionFilter(((LdcInsnNode) ain).cst);
|
return new LdcInstructionFilter(((LdcInsnNode) ain).cst);
|
||||||
}
|
|
||||||
else if (ain instanceof TypeInsnNode)
|
else if (ain instanceof TypeInsnNode)
|
||||||
{
|
|
||||||
return new TypeInstructionFilter(ain.getOpcode(), ((TypeInsnNode) ain).desc);
|
return new TypeInstructionFilter(ain.getOpcode(), ((TypeInsnNode) ain).desc);
|
||||||
}
|
|
||||||
else if (ain instanceof FieldInsnNode)
|
else if (ain instanceof FieldInsnNode)
|
||||||
{
|
|
||||||
return new FieldInstructionFilter(ain.getOpcode(), ((FieldInsnNode) ain).owner, ((FieldInsnNode) ain).name, ((FieldInsnNode) ain).desc);
|
return new FieldInstructionFilter(ain.getOpcode(), ((FieldInsnNode) ain).owner, ((FieldInsnNode) ain).name, ((FieldInsnNode) ain).desc);
|
||||||
}
|
|
||||||
else if (ain instanceof MethodInsnNode)
|
else if (ain instanceof MethodInsnNode)
|
||||||
{
|
|
||||||
return new MethodInstructionFilter(ain.getOpcode(), ((MethodInsnNode) ain).owner, ((MethodInsnNode) ain).name, ((MethodInsnNode) ain).desc);
|
return new MethodInstructionFilter(ain.getOpcode(), ((MethodInsnNode) ain).owner, ((MethodInsnNode) ain).name, ((MethodInsnNode) ain).desc);
|
||||||
}
|
|
||||||
else if (ain instanceof VarInsnNode)
|
else if (ain instanceof VarInsnNode)
|
||||||
{
|
|
||||||
return new VarInstructionFilter(ain.getOpcode(), ((VarInsnNode) ain).var);
|
return new VarInstructionFilter(ain.getOpcode(), ((VarInsnNode) ain).var);
|
||||||
}
|
|
||||||
else if (ain instanceof InsnNode)
|
else if (ain instanceof InsnNode)
|
||||||
{
|
|
||||||
return new InsnInstructionFilter(ain.getOpcode());
|
return new InsnInstructionFilter(ain.getOpcode());
|
||||||
}
|
|
||||||
else if (ain instanceof IincInsnNode)
|
else if (ain instanceof IincInsnNode)
|
||||||
{
|
|
||||||
return new IincInstructionFilter(((IincInsnNode) ain).incr, ((IincInsnNode) ain).var);
|
return new IincInstructionFilter(((IincInsnNode) ain).incr, ((IincInsnNode) ain).var);
|
||||||
}
|
|
||||||
else if (ain instanceof JumpInsnNode)
|
else if (ain instanceof JumpInsnNode)
|
||||||
{
|
|
||||||
return new JumpInstructionFilter(ain.getOpcode());
|
return new JumpInstructionFilter(ain.getOpcode());
|
||||||
}
|
|
||||||
else if (ain instanceof LabelNode)
|
else if (ain instanceof LabelNode)
|
||||||
{
|
|
||||||
return InstructionFilter.ACCEPT_ALL; // TODO: Cache labels and
|
|
||||||
// check. // TODO: That's a
|
|
||||||
// fucking stupid idea.
|
|
||||||
}
|
|
||||||
else if (ain instanceof MultiANewArrayInsnNode)
|
|
||||||
{
|
|
||||||
return new MultiANewArrayInstructionFilter(((MultiANewArrayInsnNode) ain).desc, ((MultiANewArrayInsnNode) ain).dims);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return InstructionFilter.ACCEPT_ALL;
|
return InstructionFilter.ACCEPT_ALL;
|
||||||
}
|
else if (ain instanceof MultiANewArrayInsnNode)
|
||||||
|
return new MultiANewArrayInstructionFilter(((MultiANewArrayInsnNode) ain).desc, ((MultiANewArrayInsnNode) ain).dims);
|
||||||
|
else
|
||||||
|
return InstructionFilter.ACCEPT_ALL;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
{
|
{
|
||||||
AbstractInsnNode[] ains = new AbstractInsnNode[]{new LdcInsnNode("ldc"), new VarInsnNode(ASTORE, 0), new LdcInsnNode("ldc")};
|
AbstractInsnNode[] abstractInsnNodes = new AbstractInsnNode[]{new LdcInsnNode("ldc"), new VarInsnNode(ASTORE, 0), new LdcInsnNode("ldc")};
|
||||||
InstructionPattern pattern = new InstructionPattern(new AbstractInsnNode[]{new LdcInsnNode("ldc"), new VarInsnNode(-1, -1)});
|
InstructionPattern pattern = new InstructionPattern(new AbstractInsnNode[]{new LdcInsnNode("ldc"), new VarInsnNode(-1, -1)});
|
||||||
for (AbstractInsnNode ain : ains)
|
|
||||||
{
|
for (AbstractInsnNode insnNode : abstractInsnNodes)
|
||||||
if (pattern.accept(ain))
|
|
||||||
{
|
{
|
||||||
|
if (pattern.accept(insnNode))
|
||||||
System.out.println(Arrays.toString(pattern.getLastMatch()));
|
System.out.println(Arrays.toString(pattern.getLastMatch()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -111,6 +111,7 @@ public class JavaBytecodeTokenMaker extends AbstractJFlexCTokenMaker
|
||||||
int i = 0; /* index in packed string */
|
int i = 0; /* index in packed string */
|
||||||
int j = offset; /* index in unpacked array */
|
int j = offset; /* index in unpacked array */
|
||||||
int l = packed.length();
|
int l = packed.length();
|
||||||
|
|
||||||
while (i < l)
|
while (i < l)
|
||||||
{
|
{
|
||||||
int count = packed.charAt(i++);
|
int count = packed.charAt(i++);
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -39,15 +39,11 @@ public class MethodNodeDecompiler
|
||||||
|
|
||||||
public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, MethodNode m, ClassNode cn)
|
public static PrefixedStringBuilder decompile(PrefixedStringBuilder sb, MethodNode m, ClassNode cn)
|
||||||
{
|
{
|
||||||
String class_;
|
String className;
|
||||||
if (cn.name.contains("/"))
|
if (cn.name.contains("/"))
|
||||||
{
|
className = cn.name.substring(cn.name.lastIndexOf("/") + 1);
|
||||||
class_ = cn.name.substring(cn.name.lastIndexOf("/") + 1);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
className = cn.name;
|
||||||
class_ = cn.name;
|
|
||||||
}
|
|
||||||
|
|
||||||
String s = getAccessString(m.access);
|
String s = getAccessString(m.access);
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
@ -56,9 +52,7 @@ public class MethodNodeDecompiler
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
|
|
||||||
if (m.name.equals("<init>"))
|
if (m.name.equals("<init>"))
|
||||||
{
|
sb.append(className);
|
||||||
sb.append(class_);
|
|
||||||
}
|
|
||||||
else if (!m.name.equals("<clinit>"))
|
else if (!m.name.equals("<clinit>"))
|
||||||
{
|
{
|
||||||
Type returnType = Type.getReturnType(m.desc);
|
Type returnType = Type.getReturnType(m.desc);
|
||||||
|
@ -111,7 +105,7 @@ public class MethodNodeDecompiler
|
||||||
sb.append(" {}");
|
sb.append(" {}");
|
||||||
sb.append(" //");
|
sb.append(" //");
|
||||||
sb.append(m.desc);
|
sb.append(m.desc);
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -129,18 +123,18 @@ public class MethodNodeDecompiler
|
||||||
sb.append(" //");
|
sb.append(" //");
|
||||||
sb.append(m.desc);
|
sb.append(m.desc);
|
||||||
|
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
|
|
||||||
if (m.signature != null)
|
if (m.signature != null)
|
||||||
{
|
{
|
||||||
sb.append(" <sig:").append(m.signature).append(">");
|
sb.append(" <sig:").append(m.signature).append(">");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m.annotationDefault != null)
|
if (m.annotationDefault != null)
|
||||||
{
|
{
|
||||||
sb.append(m.annotationDefault);
|
sb.append(m.annotationDefault);
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
InstructionPrinter insnPrinter = new InstructionPrinter(m, args);
|
InstructionPrinter insnPrinter = new InstructionPrinter(m, args);
|
||||||
|
@ -155,6 +149,7 @@ public class MethodNodeDecompiler
|
||||||
addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb, insnPrinter);
|
addAttrList(m.visibleTypeAnnotations, "visTypeAnno", sb, insnPrinter);
|
||||||
|
|
||||||
List<TryCatchBlockNode> tryCatchBlocks = m.tryCatchBlocks;
|
List<TryCatchBlockNode> tryCatchBlocks = m.tryCatchBlocks;
|
||||||
|
|
||||||
for (int i = 0; i < tryCatchBlocks.size(); i++)
|
for (int i = 0; i < tryCatchBlocks.size(); i++)
|
||||||
{
|
{
|
||||||
TryCatchBlockNode o = tryCatchBlocks.get(i);
|
TryCatchBlockNode o = tryCatchBlocks.get(i);
|
||||||
|
@ -170,15 +165,16 @@ public class MethodNodeDecompiler
|
||||||
sb.append(o.type);
|
sb.append(o.type);
|
||||||
else
|
else
|
||||||
sb.append("Type is null.");
|
sb.append("Type is null.");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String insn : insnPrinter.createPrint())
|
for (String insn : insnPrinter.createPrint())
|
||||||
{
|
{
|
||||||
sb.append(" ");
|
sb.append(" ");
|
||||||
sb.append(insn);
|
sb.append(insn);
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
sb.append(" }" + nl);
|
sb.append(" }" + NL);
|
||||||
}
|
}
|
||||||
return sb;
|
return sb;
|
||||||
}
|
}
|
||||||
|
@ -196,9 +192,9 @@ public class MethodNodeDecompiler
|
||||||
sb.append(":");
|
sb.append(":");
|
||||||
sb.append(printAttr(o, insnPrinter));
|
sb.append(printAttr(o, insnPrinter));
|
||||||
sb.append(">");
|
sb.append(">");
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
sb.append(nl);
|
sb.append(NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,7 @@ import java.util.jar.JarFile;
|
||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.CFR;
|
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.CFR;
|
||||||
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.ERROR;
|
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.ERROR;
|
||||||
|
|
||||||
|
@ -86,7 +86,7 @@ public class CFRDecompiler extends InternalDecompiler
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
PrintWriter pw = new PrintWriter(sw);
|
PrintWriter pw = new PrintWriter(sw);
|
||||||
t.printStackTrace(pw);
|
t.printStackTrace(pw);
|
||||||
return CFR + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + sw;
|
return CFR + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + sw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -46,18 +46,18 @@ public class FernFlowerDecompiler extends InternalDecompiler
|
||||||
{
|
{
|
||||||
File tempZip = new File(sourceJar);
|
File tempZip = new File(sourceJar);
|
||||||
|
|
||||||
File f = new File(tempDirectory + fs + "temp" + fs);
|
File f = new File(TEMP_DIRECTORY + FS + "temp" + FS);
|
||||||
f.mkdir();
|
f.mkdir();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), tempDirectory + "./temp/"));
|
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempZip.getAbsolutePath(), TEMP_DIRECTORY + "./temp/"));
|
||||||
}
|
}
|
||||||
catch (StackOverflowError | Exception ignored)
|
catch (StackOverflowError | Exception ignored)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
File tempZip2 = new File(tempDirectory + fs + "temp" + fs + tempZip.getName());
|
File tempZip2 = new File(TEMP_DIRECTORY + FS + "temp" + FS + tempZip.getName());
|
||||||
if (tempZip2.exists())
|
if (tempZip2.exists())
|
||||||
tempZip2.renameTo(new File(zipName));
|
tempZip2.renameTo(new File(zipName));
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] b)
|
public String decompileClassNode(ClassNode cn, byte[] b)
|
||||||
{
|
{
|
||||||
String start = tempDirectory + fs + MiscUtils.getUniqueName("", ".class");
|
String start = TEMP_DIRECTORY + FS + MiscUtils.getUniqueName("", ".class");
|
||||||
|
|
||||||
final File tempClass = new File(start + ".class");
|
final File tempClass = new File(start + ".class");
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), new File(tempDirectory).getAbsolutePath()));
|
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), new File(TEMP_DIRECTORY).getAbsolutePath()));
|
||||||
}
|
}
|
||||||
catch (Throwable e)
|
catch (Throwable e)
|
||||||
{
|
{
|
||||||
|
@ -124,7 +124,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
|
||||||
String javaDir = start;
|
String javaDir = start;
|
||||||
if (BytecodeViewer.viewer.ren.isSelected())
|
if (BytecodeViewer.viewer.ren.isSelected())
|
||||||
{
|
{
|
||||||
javaDir = tempDirectory + "class_0";
|
javaDir = TEMP_DIRECTORY + "class_0";
|
||||||
}
|
}
|
||||||
|
|
||||||
final File outputJava = new File(javaDir + ".java");
|
final File outputJava = new File(javaDir + ".java");
|
||||||
|
@ -145,11 +145,11 @@ public class FernFlowerDecompiler extends InternalDecompiler
|
||||||
e.printStackTrace(new PrintWriter(exceptionWriter));
|
e.printStackTrace(new PrintWriter(exceptionWriter));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
exception += nl + nl + exceptionWriter;
|
exception += NL + NL + exceptionWriter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return FERNFLOWER + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
|
return FERNFLOWER + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String[] generateMainMethod(String className, String folder)
|
private String[] generateMainMethod(String className, String folder)
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class JADXDecompiler extends InternalDecompiler
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(ClassNode cn, byte[] b)
|
public String decompileClassNode(ClassNode cn, byte[] b)
|
||||||
{
|
{
|
||||||
String fileStart = tempDirectory + fs;
|
String fileStart = TEMP_DIRECTORY + FS;
|
||||||
|
|
||||||
String exception = "";
|
String exception = "";
|
||||||
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");
|
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");
|
||||||
|
@ -92,7 +92,7 @@ public class JADXDecompiler extends InternalDecompiler
|
||||||
if (exception.isEmpty())
|
if (exception.isEmpty())
|
||||||
exception = "Decompiled source file not found!";
|
exception = "Decompiled source file not found!";
|
||||||
|
|
||||||
return JADX + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
|
return JADX + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO remove
|
//TODO remove
|
||||||
|
@ -129,13 +129,13 @@ public class JADXDecompiler extends InternalDecompiler
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
String exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
String exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
|
|
||||||
return JADX + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
|
return JADX + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return "JADX error!" + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR;
|
return "JADX error!" + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,8 +34,8 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.ERROR;
|
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.ERROR;
|
||||||
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.JDGUI;
|
import static the.bytecode.club.bytecodeviewer.translation.TranslatedStrings.JDGUI;
|
||||||
|
|
||||||
|
@ -55,19 +55,19 @@ public class JDGUIDecompiler extends InternalDecompiler
|
||||||
String exception;
|
String exception;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
|
|
||||||
final File tempClass = new File(tempDirectory.getAbsolutePath() + fs + cn.name + ".class");
|
final File tempClass = new File(tempDirectory.getAbsolutePath() + FS + cn.name + ".class");
|
||||||
final File tempJava = new File(tempDirectory.getAbsolutePath() + fs + cn.name + ".java");
|
final File tempJava = new File(tempDirectory.getAbsolutePath() + FS + cn.name + ".java");
|
||||||
|
|
||||||
if (cn.name.contains("/"))
|
if (cn.name.contains("/"))
|
||||||
{
|
{
|
||||||
String[] raw = cn.name.split("/");
|
String[] raw = cn.name.split("/");
|
||||||
String path = tempDirectory.getAbsolutePath() + fs;
|
String path = tempDirectory.getAbsolutePath() + FS;
|
||||||
for (int i = 0; i < raw.length - 1; i++)
|
for (int i = 0; i < raw.length - 1; i++)
|
||||||
{
|
{
|
||||||
path += raw[i] + fs;
|
path += raw[i] + FS;
|
||||||
File f = new File(path);
|
File f = new File(path);
|
||||||
f.mkdir();
|
f.mkdir();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ public class JDGUIDecompiler extends InternalDecompiler
|
||||||
exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return JDGUI + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
|
return JDGUI + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.lang.reflect.Method;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLClassLoader;
|
import java.net.URLClassLoader;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.api.ExceptionUI.SEND_STACKTRACE_TO;
|
import static the.bytecode.club.bytecodeviewer.api.ExceptionUI.SEND_STACKTRACE_TO;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -59,9 +59,9 @@ public class JavapDisassembler extends InternalDecompiler
|
||||||
|
|
||||||
private synchronized String synchronizedDecompilation(ClassNode cn, byte[] b)
|
private synchronized String synchronizedDecompilation(ClassNode cn, byte[] b)
|
||||||
{
|
{
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
final File tempClass = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".class");
|
final File tempClass = new File(Constants.TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + ".class");
|
||||||
|
|
||||||
DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false);
|
DiskWriter.replaceFileBytes(tempClass.getAbsolutePath(), b, false);
|
||||||
|
|
||||||
|
|
|
@ -91,48 +91,52 @@ public class KrakatauDecompiler extends InternalDecompiler
|
||||||
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
||||||
krakatauWorkingDirectory + fs + "decompile.py", "-skip", //love you storyyeller <3
|
krakatauWorkingDirectory + FS + "decompile.py", "-skip", //love you storyyeller <3
|
||||||
"-nauto", "-path", Configuration.rt + ";" + krakatauTempJar.getAbsolutePath() + buildCLIArguments(), "-out", krakatauTempDir.getAbsolutePath(), cn.name + ".class"));
|
"-nauto", "-path", Configuration.rt + ";" + krakatauTempJar.getAbsolutePath() + buildCLIArguments(), "-out", krakatauTempDir.getAbsolutePath(), cn.name + ".class"));
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
|
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + NL + NL);
|
||||||
|
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
|
log.append(NL).append(NL).append(TranslatedStrings.ERROR2).append(NL).append(NL);
|
||||||
|
|
||||||
try (InputStream is = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getErrorStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitValue = process.waitFor();
|
int exitValue = process.waitFor();
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
log.append(NL).append(NL).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
||||||
s = log.toString();
|
s = log.toString();
|
||||||
|
|
||||||
//if the motherfucker failed this'll fail, aka wont set.
|
//if the motherfucker failed this'll fail, aka wont set.
|
||||||
s = DiskReader.loadAsString(krakatauTempDir.getAbsolutePath() + fs + cn.name + ".java");
|
s = DiskReader.loadAsString(krakatauTempDir.getAbsolutePath() + FS + cn.name + ".java");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
e.printStackTrace(new PrintWriter(sw));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
s += nl + ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
s += NL + ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -160,9 +164,9 @@ public class KrakatauDecompiler extends InternalDecompiler
|
||||||
|
|
||||||
String s = ExceptionUI.SEND_STACKTRACE_TO_NL;
|
String s = ExceptionUI.SEND_STACKTRACE_TO_NL;
|
||||||
|
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
|
final File tempJar = new File(Constants.TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + ".jar");
|
||||||
|
|
||||||
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||||
|
|
||||||
|
@ -173,41 +177,45 @@ public class KrakatauDecompiler extends InternalDecompiler
|
||||||
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
||||||
krakatauWorkingDirectory + fs + "decompile.py", "-skip", //love you storyyeller <3
|
krakatauWorkingDirectory + FS + "decompile.py", "-skip", //love you storyyeller <3
|
||||||
"-nauto", "-path", Configuration.rt + ";" + tempJar.getAbsolutePath() + buildCLIArguments(), "-out", tempDirectory.getAbsolutePath(), cn.name + ".class"));
|
"-nauto", "-path", Configuration.rt + ";" + tempJar.getAbsolutePath() + buildCLIArguments(), "-out", tempDirectory.getAbsolutePath(), cn.name + ".class"));
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
|
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + NL + NL);
|
||||||
|
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
|
log.append(NL).append(NL).append(TranslatedStrings.ERROR2).append(NL).append(NL);
|
||||||
|
|
||||||
try (InputStream is = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getErrorStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitValue = process.waitFor();
|
int exitValue = process.waitFor();
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
log.append(NL).append(NL).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
||||||
s = log.toString();
|
s = log.toString();
|
||||||
|
|
||||||
//if the motherfucker failed this'll fail, aka wont set.
|
//if the motherfucker failed this'll fail, aka wont set.
|
||||||
s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + fs + cn.name + ".java");
|
s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + FS + cn.name + ".java");
|
||||||
tempDirectory.delete();
|
tempDirectory.delete();
|
||||||
tempJar.delete();
|
tempJar.delete();
|
||||||
}
|
}
|
||||||
|
@ -216,7 +224,7 @@ public class KrakatauDecompiler extends InternalDecompiler
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
e.printStackTrace(new PrintWriter(sw));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
s += nl + ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
s += NL + ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
|
@ -236,7 +244,7 @@ public class KrakatauDecompiler extends InternalDecompiler
|
||||||
}
|
}
|
||||||
|
|
||||||
String ran = MiscUtils.randomString(32);
|
String ran = MiscUtils.randomString(32);
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + ran + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + ran + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
|
|
||||||
final File tempJar = new File(sourceJar);
|
final File tempJar = new File(sourceJar);
|
||||||
|
@ -248,7 +256,7 @@ public class KrakatauDecompiler extends InternalDecompiler
|
||||||
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
||||||
krakatauWorkingDirectory + fs + "decompile.py", "-skip", //love you storyyeller <3
|
krakatauWorkingDirectory + FS + "decompile.py", "-skip", //love you storyyeller <3
|
||||||
"-nauto", "-path", Configuration.rt + ";" + tempJar.getAbsolutePath(), "-out", tempDirectory.getAbsolutePath(), tempJar.getAbsolutePath()));
|
"-nauto", "-path", Configuration.rt + ";" + tempJar.getAbsolutePath(), "-out", tempDirectory.getAbsolutePath(), tempJar.getAbsolutePath()));
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
|
|
|
@ -52,9 +52,9 @@ public class KrakatauDisassembler extends InternalDecompiler
|
||||||
|
|
||||||
String s = ExceptionUI.SEND_STACKTRACE_TO_NL;
|
String s = ExceptionUI.SEND_STACKTRACE_TO_NL;
|
||||||
|
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
final File tempJar = new File(Constants.tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
|
final File tempJar = new File(Constants.TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + ".jar");
|
||||||
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), tempJar.getAbsolutePath());
|
||||||
|
|
||||||
try
|
try
|
||||||
|
@ -64,47 +64,51 @@ public class KrakatauDisassembler extends InternalDecompiler
|
||||||
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
||||||
krakatauWorkingDirectory + fs + "disassemble.py", "-path", tempJar.getAbsolutePath(), "-out", tempDirectory.getAbsolutePath(), cn.name + ".class"));
|
krakatauWorkingDirectory + FS + "disassemble.py", "-path", tempJar.getAbsolutePath(), "-out", tempDirectory.getAbsolutePath(), cn.name + ".class"));
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
|
||||||
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
|
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + NL + NL);
|
||||||
|
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
|
log.append(NL).append(NL).append(TranslatedStrings.ERROR2).append(NL).append(NL);
|
||||||
|
|
||||||
try (InputStream is = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getErrorStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
{
|
{
|
||||||
log.append(nl).append(line);
|
log.append(NL).append(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int exitValue = process.waitFor();
|
int exitValue = process.waitFor();
|
||||||
log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
log.append(NL).append(NL).append(TranslatedStrings.EXIT_VALUE_IS).append(" ").append(exitValue);
|
||||||
s = log.toString();
|
s = log.toString();
|
||||||
|
|
||||||
// if the motherfucker failed this'll fail, aka won't set.
|
// if the motherfucker failed this'll fail, aka won't set.
|
||||||
s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + fs + cn.name + ".j");
|
s = DiskReader.loadAsString(tempDirectory.getAbsolutePath() + FS + cn.name + ".j");
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
StringWriter sw = new StringWriter();
|
StringWriter sw = new StringWriter();
|
||||||
e.printStackTrace(new PrintWriter(sw));
|
e.printStackTrace(new PrintWriter(sw));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
s += nl + ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
s += NL + ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
@ -116,7 +120,7 @@ public class KrakatauDisassembler extends InternalDecompiler
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String ran = MiscUtils.randomString(32);
|
String ran = MiscUtils.randomString(32);
|
||||||
final File tempDirectory = new File(Constants.tempDirectory + fs + ran + fs);
|
final File tempDirectory = new File(Constants.TEMP_DIRECTORY + FS + ran + FS);
|
||||||
tempDirectory.mkdir();
|
tempDirectory.mkdir();
|
||||||
|
|
||||||
final File tempJar = new File(sourceJar);
|
final File tempJar = new File(sourceJar);
|
||||||
|
@ -128,7 +132,7 @@ public class KrakatauDisassembler extends InternalDecompiler
|
||||||
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
pythonCommands = ArrayUtils.addAll(pythonCommands, "-2");
|
||||||
|
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(pythonCommands, "-O", //love you storyyeller <3
|
||||||
krakatauWorkingDirectory + fs + "disassemble.py", "-path", Configuration.rt + ";" + tempJar.getAbsolutePath(), "-out", tempDirectory.getAbsolutePath(), tempJar.getAbsolutePath()));
|
krakatauWorkingDirectory + FS + "disassemble.py", "-path", Configuration.rt + ";" + tempJar.getAbsolutePath(), "-out", tempDirectory.getAbsolutePath(), tempJar.getAbsolutePath()));
|
||||||
|
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
|
|
@ -80,7 +80,7 @@ public class ProcyonDecompiler extends InternalDecompiler
|
||||||
String exception;
|
String exception;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
String fileStart = tempDirectory + fs + "temp";
|
String fileStart = TEMP_DIRECTORY + FS + "temp";
|
||||||
|
|
||||||
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");
|
final File tempClass = new File(MiscUtils.getUniqueName(fileStart, ".class") + ".class");
|
||||||
|
|
||||||
|
@ -121,7 +121,7 @@ public class ProcyonDecompiler extends InternalDecompiler
|
||||||
exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
exception = ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
|
return PROCYON + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class SmaliDisassembler extends InternalDecompiler
|
||||||
public String decompileClassNode(ClassNode cn, byte[] b)
|
public String decompileClassNode(ClassNode cn, byte[] b)
|
||||||
{
|
{
|
||||||
String exception = "";
|
String exception = "";
|
||||||
String fileStart = tempDirectory + fs + "temp";
|
String fileStart = TEMP_DIRECTORY + FS + "temp";
|
||||||
|
|
||||||
String start = MiscUtils.getUniqueName(fileStart, ".class");
|
String start = MiscUtils.getUniqueName(fileStart, ".class");
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class SmaliDisassembler extends InternalDecompiler
|
||||||
exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
exception += ExceptionUI.SEND_STACKTRACE_TO_NL + sw;
|
||||||
}
|
}
|
||||||
|
|
||||||
return SMALI + " " + DISASSEMBLER + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + nl + nl + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + nl + nl + exception;
|
return SMALI + " " + DISASSEMBLER + " " + ERROR + "! " + ExceptionUI.SEND_STACKTRACE_TO + NL + NL + TranslatedStrings.SUGGESTED_FIX_DECOMPILER_ERROR + NL + NL + exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -63,7 +63,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialog;
|
import static the.bytecode.club.bytecodeviewer.Configuration.useNewSettingsDialog;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
|
import static the.bytecode.club.bytecodeviewer.Constants.VERSION;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The main file for the GUI
|
* The main file for the GUI
|
||||||
|
@ -907,7 +907,7 @@ public class MainViewerGUI extends JFrame
|
||||||
|
|
||||||
for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
|
for (ResourceContainer container : BytecodeViewer.resourceContainers.values())
|
||||||
{
|
{
|
||||||
File newFile = new File(container.file.getParent() + fs + container.name);
|
File newFile = new File(container.file.getParent() + FS + container.name);
|
||||||
if (!container.file.getAbsolutePath().equals(newFile.getAbsolutePath()) && (container.file.getAbsolutePath().endsWith(".apk") || container.file.getAbsolutePath().endsWith(".dex"))) //APKs & dex get renamed
|
if (!container.file.getAbsolutePath().equals(newFile.getAbsolutePath()) && (container.file.getAbsolutePath().endsWith(".apk") || container.file.getAbsolutePath().endsWith(".dex"))) //APKs & dex get renamed
|
||||||
{
|
{
|
||||||
container.file.renameTo(newFile);
|
container.file.renameTo(newFile);
|
||||||
|
|
|
@ -25,7 +25,7 @@ import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A simple swing JFrame console
|
* A simple swing JFrame console
|
||||||
|
@ -130,7 +130,7 @@ public class JFrameConsole extends JFrame
|
||||||
{
|
{
|
||||||
//TODO if two consoles are ran at the same time and exceed the maximum this file will be overwritten
|
//TODO if two consoles are ran at the same time and exceed the maximum this file will be overwritten
|
||||||
|
|
||||||
final File tempFile = new File(tempDirectory, "console_" + consoleID + ".log");
|
final File tempFile = new File(TEMP_DIRECTORY, "console_" + consoleID + ".log");
|
||||||
|
|
||||||
//TODO this needs to be rewritten, it doesn't work for a plugin that causes multiple exception UIs
|
//TODO this needs to be rewritten, it doesn't work for a plugin that causes multiple exception UIs
|
||||||
new Thread(() ->
|
new Thread(() ->
|
||||||
|
|
|
@ -23,7 +23,7 @@ import the.bytecode.club.bytecodeviewer.Constants;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A swing console that can print out from PrintStreams
|
* A swing console that can print out from PrintStreams
|
||||||
|
@ -136,7 +136,7 @@ public class JFrameConsolePrintStream extends JFrameConsole
|
||||||
String start = split[0] + "'" + split[1] + "', ";
|
String start = split[0] + "'" + split[1] + "', ";
|
||||||
s = s.substring(start.length());
|
s = s.substring(start.length());
|
||||||
}
|
}
|
||||||
replace.append(s).append(nl);
|
replace.append(s).append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
setText(replace.toString());
|
setText(replace.toString());
|
||||||
|
|
|
@ -47,8 +47,8 @@ import java.io.File;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The file navigation pane.
|
* The file navigation pane.
|
||||||
|
@ -379,7 +379,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
|
||||||
|
|
||||||
//TODO make a settings toggle to disable preservation of the original name
|
//TODO make a settings toggle to disable preservation of the original name
|
||||||
// it should also detect if the file name is not compatible with the current OS and enable automatically
|
// it should also detect if the file name is not compatible with the current OS and enable automatically
|
||||||
File tempFile = new File(tempDirectory + fs + hash + fs + name + "." + extension);
|
File tempFile = new File(TEMP_DIRECTORY + FS + hash + FS + name + "." + extension);
|
||||||
if (!tempFile.exists())
|
if (!tempFile.exists())
|
||||||
{
|
{
|
||||||
DiskWriter.replaceFileBytes(tempFile.getAbsolutePath(), content, false);
|
DiskWriter.replaceFileBytes(tempFile.getAbsolutePath(), content, false);
|
||||||
|
|
|
@ -31,7 +31,7 @@ import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a Bytecode/ClassFile View Panel
|
* Represents a Bytecode/ClassFile View Panel
|
||||||
|
@ -79,7 +79,7 @@ public class BytecodeViewPanel extends JPanel
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString());
|
SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString());
|
||||||
errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS + " " + viewer.resource.getResourceClassNode().name + nl + TranslatedStrings.COMPILER_TIP + nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR + nl + nl);
|
errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS + " " + viewer.resource.getResourceClassNode().name + NL + TranslatedStrings.COMPILER_TIP + NL + NL + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR + NL + NL);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -104,7 +104,9 @@ public class Workspace extends TranslatedVisibleComponent
|
||||||
private void addResource(ResourceContainer container, String name, ResourceViewer resourceView)
|
private void addResource(ResourceContainer container, String name, ResourceViewer resourceView)
|
||||||
{
|
{
|
||||||
// Warn user and prevent 'nothing' from opening if no Decompiler is selected
|
// Warn user and prevent 'nothing' from opening if no Decompiler is selected
|
||||||
if (BytecodeViewer.viewer.viewPane1.getSelectedDecompiler() == Decompiler.NONE && BytecodeViewer.viewer.viewPane2.getSelectedDecompiler() == Decompiler.NONE && BytecodeViewer.viewer.viewPane3.getSelectedDecompiler() == Decompiler.NONE)
|
if (BytecodeViewer.viewer.viewPane1.getSelectedDecompiler() == Decompiler.NONE
|
||||||
|
&& BytecodeViewer.viewer.viewPane2.getSelectedDecompiler() == Decompiler.NONE
|
||||||
|
&& BytecodeViewer.viewer.viewPane3.getSelectedDecompiler() == Decompiler.NONE)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage(TranslatedStrings.SUGGESTED_FIX_NO_DECOMPILER_WARNING.toString());
|
BytecodeViewer.showMessage(TranslatedStrings.SUGGESTED_FIX_NO_DECOMPILER_WARNING.toString());
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -138,7 +138,9 @@ public class ClassViewer extends ResourceViewer
|
||||||
|
|
||||||
if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected() && !BytecodeViewer.viewer.compileOnSave.isSelected())
|
if (!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected() && !BytecodeViewer.viewer.compileOnSave.isSelected())
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("Make sure to compile (File>Compile or Ctrl + T) whenever you want to " + "test or export your changes.\nYou can set compile automatically on refresh or on save " + "in the settings menu.");
|
BytecodeViewer.showMessage("Make sure to compile (File>Compile or Ctrl + T) whenever you want to "
|
||||||
|
+ "test or export your changes.\nYou can set compile automatically on refresh or on save "
|
||||||
|
+ "in the settings menu.");
|
||||||
|
|
||||||
SettingsSerializer.saveSettingsAsync();
|
SettingsSerializer.saveSettingsAsync();
|
||||||
}
|
}
|
||||||
|
@ -293,10 +295,8 @@ public class ClassViewer extends ResourceViewer
|
||||||
for (Component c : this.getComponents())
|
for (Component c : this.getComponents())
|
||||||
{
|
{
|
||||||
if (c instanceof BytecodeViewPanel || c instanceof JSplitPane)
|
if (c instanceof BytecodeViewPanel || c instanceof JSplitPane)
|
||||||
{
|
|
||||||
this.remove(c);
|
this.remove(c);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.sp.setResizeWeight(0.5);
|
this.sp.setResizeWeight(0.5);
|
||||||
setDividerLocation(sp, 0.5);
|
setDividerLocation(sp, 0.5);
|
||||||
|
@ -307,13 +307,17 @@ public class ClassViewer extends ResourceViewer
|
||||||
this.sp.setLeftComponent(bytecodeViewPanel1);
|
this.sp.setLeftComponent(bytecodeViewPanel1);
|
||||||
this.sp.setRightComponent(bytecodeViewPanel2);
|
this.sp.setRightComponent(bytecodeViewPanel2);
|
||||||
this.add(sp, BorderLayout.CENTER);
|
this.add(sp, BorderLayout.CENTER);
|
||||||
} /* If panel 1 and panel 3 are ticked but not panel 2 */
|
}
|
||||||
|
|
||||||
|
/* If panel 1 and panel 3 are ticked but not panel 2 */
|
||||||
else if (bytecodeViewPanel1.decompiler != Decompiler.NONE && bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel3.decompiler != Decompiler.NONE)
|
else if (bytecodeViewPanel1.decompiler != Decompiler.NONE && bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel3.decompiler != Decompiler.NONE)
|
||||||
{
|
{
|
||||||
this.sp.setLeftComponent(bytecodeViewPanel1);
|
this.sp.setLeftComponent(bytecodeViewPanel1);
|
||||||
this.sp.setRightComponent(bytecodeViewPanel3);
|
this.sp.setRightComponent(bytecodeViewPanel3);
|
||||||
this.add(sp, BorderLayout.CENTER);
|
this.add(sp, BorderLayout.CENTER);
|
||||||
} /* If panel 2 and panel 3 are ticked but not panel 1 */
|
}
|
||||||
|
|
||||||
|
/* If panel 2 and panel 3 are ticked but not panel 1 */
|
||||||
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel3.decompiler != Decompiler.NONE)
|
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel3.decompiler != Decompiler.NONE)
|
||||||
{
|
{
|
||||||
this.sp.setLeftComponent(bytecodeViewPanel2);
|
this.sp.setLeftComponent(bytecodeViewPanel2);
|
||||||
|
@ -332,15 +336,25 @@ public class ClassViewer extends ResourceViewer
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If view panel 1 is only ticked... */
|
/* If view panel 1 is only ticked... */
|
||||||
if (bytecodeViewPanel1.decompiler != Decompiler.NONE && bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel3.decompiler == Decompiler.NONE)
|
if (bytecodeViewPanel1.decompiler != Decompiler.NONE
|
||||||
|
&& bytecodeViewPanel2.decompiler == Decompiler.NONE
|
||||||
|
&& bytecodeViewPanel3.decompiler == Decompiler.NONE)
|
||||||
{
|
{
|
||||||
this.add(bytecodeViewPanel1, BorderLayout.CENTER);
|
this.add(bytecodeViewPanel1, BorderLayout.CENTER);
|
||||||
} /* If view panel 2 is only ticked... */
|
}
|
||||||
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler != Decompiler.NONE && bytecodeViewPanel3.decompiler == Decompiler.NONE)
|
|
||||||
|
/* If view panel 2 is only ticked... */
|
||||||
|
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE
|
||||||
|
&& bytecodeViewPanel2.decompiler != Decompiler.NONE
|
||||||
|
&& bytecodeViewPanel3.decompiler == Decompiler.NONE)
|
||||||
{
|
{
|
||||||
this.add(bytecodeViewPanel2, BorderLayout.CENTER);
|
this.add(bytecodeViewPanel2, BorderLayout.CENTER);
|
||||||
} /* If view panel 3 is only ticked... */
|
}
|
||||||
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE && bytecodeViewPanel2.decompiler == Decompiler.NONE && bytecodeViewPanel3.decompiler != Decompiler.NONE)
|
|
||||||
|
/* If view panel 3 is only ticked... */
|
||||||
|
else if (bytecodeViewPanel1.decompiler == Decompiler.NONE
|
||||||
|
&& bytecodeViewPanel2.decompiler == Decompiler.NONE
|
||||||
|
&& bytecodeViewPanel3.decompiler != Decompiler.NONE)
|
||||||
{
|
{
|
||||||
this.add(bytecodeViewPanel3, BorderLayout.CENTER);
|
this.add(bytecodeViewPanel3, BorderLayout.CENTER);
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ public class FileViewer extends ResourceViewer
|
||||||
|
|
||||||
this.setName(name);
|
this.setName(name);
|
||||||
this.setLayout(new BorderLayout());
|
this.setLayout(new BorderLayout());
|
||||||
|
|
||||||
this.add(mainPanel, BorderLayout.CENTER);
|
this.add(mainPanel, BorderLayout.CENTER);
|
||||||
|
|
||||||
setContents();
|
setContents();
|
||||||
|
@ -69,7 +68,9 @@ public class FileViewer extends ResourceViewer
|
||||||
final byte[] contents = resource.getResourceBytes();
|
final byte[] contents = resource.getResourceBytes();
|
||||||
final String nameLowerCase = this.resource.name.toLowerCase();
|
final String nameLowerCase = this.resource.name.toLowerCase();
|
||||||
final String onlyName = FilenameUtils.getName(nameLowerCase);
|
final String onlyName = FilenameUtils.getName(nameLowerCase);
|
||||||
final boolean hexViewerOnly = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler() == Decompiler.HEXCODE_VIEWER && BytecodeViewer.viewer.viewPane2.getSelectedDecompiler() == Decompiler.NONE && BytecodeViewer.viewer.viewPane3.getSelectedDecompiler() == Decompiler.NONE;
|
final boolean hexViewerOnly = BytecodeViewer.viewer.viewPane1.getSelectedDecompiler() == Decompiler.HEXCODE_VIEWER
|
||||||
|
&& BytecodeViewer.viewer.viewPane2.getSelectedDecompiler() == Decompiler.NONE
|
||||||
|
&& BytecodeViewer.viewer.viewPane3.getSelectedDecompiler() == Decompiler.NONE;
|
||||||
|
|
||||||
//image viewer
|
//image viewer
|
||||||
if (MiscUtils.guessIfBinary(contents) || hexViewerOnly)
|
if (MiscUtils.guessIfBinary(contents) || hexViewerOnly)
|
||||||
|
@ -80,7 +81,6 @@ public class FileViewer extends ResourceViewer
|
||||||
// + ClassRead then quick-decompile using Pane1 Decompiler
|
// + ClassRead then quick-decompile using Pane1 Decompiler
|
||||||
// (If none selected, try Pane2, Pane3, default to Procyon)
|
// (If none selected, try Pane2, Pane3, default to Procyon)
|
||||||
|
|
||||||
|
|
||||||
//check by file extension to display image
|
//check by file extension to display image
|
||||||
if (!onlyName.contains(":") && ResourceType.imageExtensionMap.containsKey(FilenameUtils.getExtension(onlyName)) && !hexViewerOnly)
|
if (!onlyName.contains(":") && ResourceType.imageExtensionMap.containsKey(FilenameUtils.getExtension(onlyName)) && !hexViewerOnly)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,15 +29,18 @@ import java.util.Objects;
|
||||||
*/
|
*/
|
||||||
public class MethodData
|
public class MethodData
|
||||||
{
|
{
|
||||||
public String name, desc;
|
public String name;
|
||||||
|
public String desc;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
if (this == o)
|
if (this == o)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (!(o instanceof MethodData))
|
if (!(o instanceof MethodData))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
MethodData that = (MethodData) o;
|
MethodData that = (MethodData) o;
|
||||||
return Objects.equals(name, that.name) && Objects.equals(desc, that.desc);
|
return Objects.equals(name, that.name) && Objects.equals(desc, that.desc);
|
||||||
}
|
}
|
||||||
|
@ -51,11 +54,15 @@ public class MethodData
|
||||||
public String constructPattern()
|
public String constructPattern()
|
||||||
{
|
{
|
||||||
final StringBuilder pattern = new StringBuilder();
|
final StringBuilder pattern = new StringBuilder();
|
||||||
pattern.append(name).append(" *\\(");
|
|
||||||
final org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(desc);
|
final org.objectweb.asm.Type[] types = org.objectweb.asm.Type.getArgumentTypes(desc);
|
||||||
|
|
||||||
|
pattern.append(name).append(" *\\(");
|
||||||
pattern.append("(.*)");
|
pattern.append("(.*)");
|
||||||
Arrays.stream(types).map(Type::getClassName).forEach(clazzName -> pattern.append(clazzName.substring(clazzName.lastIndexOf(".") + 1)).append("(.*)"));
|
Arrays.stream(types).map(Type::getClassName)
|
||||||
|
.forEach(clazzName -> pattern.append(clazzName.substring(clazzName.lastIndexOf(".") + 1))
|
||||||
|
.append("(.*)"));
|
||||||
pattern.append("\\) *\\{");
|
pattern.append("\\) *\\{");
|
||||||
|
|
||||||
return pattern.toString();
|
return pattern.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,11 @@ public enum LAFTheme
|
||||||
SYSTEM("System Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SYSTEM_THEME), //System theme
|
SYSTEM("System Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SYSTEM_THEME), //System theme
|
||||||
DARK("Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.DARK_THEME), //DarkLaf
|
DARK("Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.DARK_THEME), //DarkLaf
|
||||||
LIGHT("Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.LIGHT_THEME), //Intellij theme
|
LIGHT("Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.LIGHT_THEME), //Intellij theme
|
||||||
ONE_DARK("One Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.ONE_DARK_THEME), SOLARIZED_DARK("Solarized Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_DARK_THEME), SOLARIZED_LIGHT("Solarized Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_LIGHT_THEME), HIGH_CONTRAST_DARK("High Contrast Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_DARK_THEME), HIGH_CONTRAST_LIGHT("High Contrast Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_LIGHT_THEME),
|
ONE_DARK("One Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.ONE_DARK_THEME),
|
||||||
|
SOLARIZED_DARK("Solarized Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_DARK_THEME),
|
||||||
|
SOLARIZED_LIGHT("Solarized Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.SOLARIZED_LIGHT_THEME),
|
||||||
|
HIGH_CONTRAST_DARK("High Contrast Dark Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_DARK_THEME),
|
||||||
|
HIGH_CONTRAST_LIGHT("High Contrast Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_LIGHT_THEME),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final String readableName;
|
private final String readableName;
|
||||||
|
|
|
@ -38,9 +38,7 @@ public enum RSTATheme
|
||||||
THEME_MATCH("Theme Match (Recommended)", null, TranslatedComponents.THEME_MATCH), //uses the default theme from RSyntaxTextArea
|
THEME_MATCH("Theme Match (Recommended)", null, TranslatedComponents.THEME_MATCH), //uses the default theme from RSyntaxTextArea
|
||||||
DEFAULT("Default (Recommended Light)", "/org/fife/ui/rsyntaxtextarea/themes/default.xml", TranslatedComponents.DEFAULT_RECOMMENDED_LIGHT), //uses the default dark theme from RSyntaxTextArea
|
DEFAULT("Default (Recommended Light)", "/org/fife/ui/rsyntaxtextarea/themes/default.xml", TranslatedComponents.DEFAULT_RECOMMENDED_LIGHT), //uses the default dark theme from RSyntaxTextArea
|
||||||
DARK("Dark (Recommended Dark)", "/org/fife/ui/rsyntaxtextarea/themes/dark.xml", TranslatedComponents.DARK),
|
DARK("Dark (Recommended Dark)", "/org/fife/ui/rsyntaxtextarea/themes/dark.xml", TranslatedComponents.DARK),
|
||||||
|
DEFAULT_ALT("Default-Alt", "/org/fife/ui/rsyntaxtextarea/themes/default-alt.xml", TranslatedComponents.DEFAULT_ALT), ECLIPSE("Eclipse", "/org/fife/ui/rsyntaxtextarea/themes/eclipse.xml", TranslatedComponents.ECLIPSE), IDEA("IntelliJ", "/org/fife/ui/rsyntaxtextarea/themes/idea.xml", TranslatedComponents.INTELLIJ), VS("Visual Studio", "/org/fife/ui/rsyntaxtextarea/themes/vs.xml", TranslatedComponents.VISUAL_STUDIO), DRUID("Druid (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/druid.xml", TranslatedComponents.DRUID_DARK), MONOKAI("Monokai (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/monokai.xml", TranslatedComponents.MONOKAI_DARK);
|
||||||
DEFAULT_ALT("Default-Alt", "/org/fife/ui/rsyntaxtextarea/themes/default-alt.xml", TranslatedComponents.DEFAULT_ALT), ECLIPSE("Eclipse", "/org/fife/ui/rsyntaxtextarea/themes/eclipse.xml", TranslatedComponents.ECLIPSE), IDEA("IntelliJ", "/org/fife/ui/rsyntaxtextarea/themes/idea.xml", TranslatedComponents.INTELLIJ), VS("Visual Studio", "/org/fife/ui/rsyntaxtextarea/themes/vs.xml", TranslatedComponents.VISUAL_STUDIO), DRUID("Druid (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/druid.xml", TranslatedComponents.DRUID_DARK), MONOKAI("Monokai (Dark)", "/org/fife/ui/rsyntaxtextarea/themes/monokai.xml", TranslatedComponents.MONOKAI_DARK),
|
|
||||||
;
|
|
||||||
|
|
||||||
private final String readableName;
|
private final String readableName;
|
||||||
private final String file;
|
private final String file;
|
||||||
|
@ -105,6 +103,7 @@ DARK("Dark (Recommended Dark)", "/org/fife/ui/rsyntaxtextarea/themes/dark.xml",
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -109,15 +109,17 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final Decompiler decompiler = bytecodeViewPanel.decompiler;
|
final Decompiler decompiler = bytecodeViewPanel.decompiler;
|
||||||
|
final String workingDecompilerName = viewer.resource.workingName + "-" + decompiler.getDecompilerName();
|
||||||
|
|
||||||
//perform decompiling inside of this thread
|
//perform decompiling inside of this thread
|
||||||
final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.resource.getResourceClassNode(), classBytes);
|
final String decompiledSource = decompiler.getDecompiler().decompileClassNode(viewer.resource.getResourceClassNode(), classBytes);
|
||||||
|
|
||||||
ClassFileContainer container = new ClassFileContainer(viewer.resource.workingName + "-" + decompiler.getDecompilerName(), decompiledSource, viewer.resource.container);
|
ClassFileContainer container = new ClassFileContainer(workingDecompilerName, decompiledSource, viewer.resource.container);
|
||||||
if (!BytecodeViewer.viewer.workPane.classFiles.containsKey(viewer.resource.workingName + "-" + decompiler.getDecompilerName()))
|
|
||||||
|
if (!BytecodeViewer.viewer.workPane.classFiles.containsKey(workingDecompilerName))
|
||||||
{
|
{
|
||||||
container.parse();
|
container.parse();
|
||||||
BytecodeViewer.viewer.workPane.classFiles.put(viewer.resource.workingName + "-" + decompiler.getDecompilerName(), container);
|
BytecodeViewer.viewer.workPane.classFiles.put(workingDecompilerName, container);
|
||||||
container.hasBeenParsed = true;
|
container.hasBeenParsed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,7 +182,9 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//nullcheck broken pane
|
//nullcheck broken pane
|
||||||
if (updateUpdaterTextArea == null || updateUpdaterTextArea.getScrollPane() == null || updateUpdaterTextArea.getScrollPane().getViewport() == null)
|
if (updateUpdaterTextArea == null
|
||||||
|
|| updateUpdaterTextArea.getScrollPane() == null
|
||||||
|
|| updateUpdaterTextArea.getScrollPane().getViewport() == null)
|
||||||
{
|
{
|
||||||
//build an error message
|
//build an error message
|
||||||
SwingUtilities.invokeLater(() -> buildTextArea(bytecodeViewPanel.decompiler, "Critical BCV Error"));
|
SwingUtilities.invokeLater(() -> buildTextArea(bytecodeViewPanel.decompiler, "Critical BCV Error"));
|
||||||
|
@ -252,6 +256,7 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
int activeLineDelta = -1;
|
int activeLineDelta = -1;
|
||||||
MethodParser.Method activeMethod = null;
|
MethodParser.Method activeMethod = null;
|
||||||
MethodParser activeMethods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
MethodParser activeMethods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
||||||
|
|
||||||
if (activeMethods != null)
|
if (activeMethods != null)
|
||||||
{
|
{
|
||||||
int activeMethodLine = activeMethods.findActiveMethod(activeLine);
|
int activeMethodLine = activeMethods.findActiveMethod(activeLine);
|
||||||
|
@ -262,6 +267,7 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
ClassViewer.selectMethod(updateUpdaterTextArea, activeMethodLine);
|
ClassViewer.selectMethod(updateUpdaterTextArea, activeMethodLine);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < panes; i++)
|
for (int i = 0; i < panes; i++)
|
||||||
{
|
{
|
||||||
if (i != bytecodeViewPanel.panelIndex)
|
if (i != bytecodeViewPanel.panelIndex)
|
||||||
|
@ -304,6 +310,7 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
{
|
{
|
||||||
setLine = activeLine;
|
setLine = activeLine;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (setLine >= 0)
|
if (setLine >= 0)
|
||||||
{
|
{
|
||||||
ClassViewer.setViewLine(area, setLine);
|
ClassViewer.setViewLine(area, setLine);
|
||||||
|
@ -329,10 +336,11 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
});
|
});
|
||||||
|
|
||||||
final MethodParser methods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
final MethodParser methods = viewer.methods.get(bytecodeViewPanel.panelIndex);
|
||||||
|
|
||||||
for (int i = 0; i < updateUpdaterTextArea.getLineCount(); i++)
|
for (int i = 0; i < updateUpdaterTextArea.getLineCount(); i++)
|
||||||
{
|
{
|
||||||
String lineText = updateUpdaterTextArea.getLineText(i);
|
String lineText = updateUpdaterTextArea.getLineText(i);
|
||||||
Matcher regexMatcher = MethodParser.regex.matcher(lineText);
|
Matcher regexMatcher = MethodParser.REGEX.matcher(lineText);
|
||||||
if (regexMatcher.find())
|
if (regexMatcher.find())
|
||||||
{
|
{
|
||||||
String methodName = regexMatcher.group("name");
|
String methodName = regexMatcher.group("name");
|
||||||
|
@ -411,6 +419,7 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
tokenMakerFactory.putMapping("text/javaBytecode", "the.bytecode.club.bytecodeviewer.decompilers.bytecode.JavaBytecodeTokenMaker");
|
tokenMakerFactory.putMapping("text/javaBytecode", "the.bytecode.club.bytecodeviewer.decompilers.bytecode.JavaBytecodeTokenMaker");
|
||||||
bytecodeViewPanel.textArea.setSyntaxEditingStyle("text/javaBytecode");
|
bytecodeViewPanel.textArea.setSyntaxEditingStyle("text/javaBytecode");
|
||||||
}
|
}
|
||||||
|
|
||||||
bytecodeViewPanel.textArea.setCodeFoldingEnabled(true);
|
bytecodeViewPanel.textArea.setCodeFoldingEnabled(true);
|
||||||
bytecodeViewPanel.textArea.setText(decompiledSource);
|
bytecodeViewPanel.textArea.setText(decompiledSource);
|
||||||
bytecodeViewPanel.textArea.setCaretPosition(0);
|
bytecodeViewPanel.textArea.setCaretPosition(0);
|
||||||
|
@ -488,6 +497,7 @@ public class BytecodeViewPanelUpdater implements Runnable
|
||||||
|
|
||||||
RSyntaxTextAreaHighlighterEx highlighterEx = (RSyntaxTextAreaHighlighterEx) textArea.getHighlighter();
|
RSyntaxTextAreaHighlighterEx highlighterEx = (RSyntaxTextAreaHighlighterEx) textArea.getHighlighter();
|
||||||
Token token = textArea.modelToToken(textArea.getCaretPosition());
|
Token token = textArea.modelToToken(textArea.getCaretPosition());
|
||||||
|
|
||||||
if (token == null)
|
if (token == null)
|
||||||
{
|
{
|
||||||
token = textArea.modelToToken(textArea.getCaretPosition() - 1);
|
token = textArea.modelToToken(textArea.getCaretPosition() - 1);
|
||||||
|
|
|
@ -23,7 +23,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareCodeScanner;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans for any trace of java/awt/Robot inside of method instructions and strings
|
* Scans for any trace of java/awt/Robot inside of method instructions and strings
|
||||||
|
@ -37,14 +37,14 @@ public class AWTRobotScanner extends MalwareCodeScanner
|
||||||
public void scanFieldString(MalwareScan scan, ClassNode cn, FieldNode field, SearchableString string)
|
public void scanFieldString(MalwareScan scan, ClassNode cn, FieldNode field, SearchableString string)
|
||||||
{
|
{
|
||||||
if (string.searchable.contains("java/awt/Robot") || string.searchable.contains("java.awt.Robot"))
|
if (string.searchable.contains("java/awt/Robot") || string.searchable.contains("java.awt.Robot"))
|
||||||
foundLDC(scan, string.original, "at field " + fieldToString(cn, field) + nl);
|
foundLDC(scan, string.original, "at field " + fieldToString(cn, field) + NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanMethodString(MalwareScan scan, ClassNode cn, MethodNode method, SearchableString string)
|
public void scanMethodString(MalwareScan scan, ClassNode cn, MethodNode method, SearchableString string)
|
||||||
{
|
{
|
||||||
if (string.searchable.contains("java/awt/Robot") || string.searchable.contains("java.awt.Robot"))
|
if (string.searchable.contains("java/awt/Robot") || string.searchable.contains("java.awt.Robot"))
|
||||||
foundLDC(scan, string.original, "at method " + methodToString(cn, method) + nl);
|
foundLDC(scan, string.original, "at method " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +54,7 @@ public class AWTRobotScanner extends MalwareCodeScanner
|
||||||
{
|
{
|
||||||
final MethodInsnNode min = (MethodInsnNode) instruction;
|
final MethodInsnNode min = (MethodInsnNode) instruction;
|
||||||
if (min.owner.startsWith("java/awt/Robot"))
|
if (min.owner.startsWith("java/awt/Robot"))
|
||||||
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + nl);
|
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareCodeScanner;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -48,7 +48,7 @@ public class JavaIOScanner extends MalwareCodeScanner
|
||||||
{
|
{
|
||||||
final MethodInsnNode min = (MethodInsnNode) instruction;
|
final MethodInsnNode min = (MethodInsnNode) instruction;
|
||||||
if (min.owner.startsWith("java/io"))
|
if (min.owner.startsWith("java/io"))
|
||||||
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + nl);
|
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareCodeScanner;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -49,7 +49,7 @@ public class JavaNetScanner extends MalwareCodeScanner
|
||||||
{
|
{
|
||||||
final MethodInsnNode min = (MethodInsnNode) instruction;
|
final MethodInsnNode min = (MethodInsnNode) instruction;
|
||||||
if (min.owner.startsWith("java/net"))
|
if (min.owner.startsWith("java/net"))
|
||||||
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + nl);
|
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareCodeScanner;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans for any trace of java/lang/Runtime inside of method instructions and strings
|
* Scans for any trace of java/lang/Runtime inside of method instructions and strings
|
||||||
|
@ -37,14 +37,14 @@ public class JavaRuntimeScanner extends MalwareCodeScanner
|
||||||
public void scanFieldString(MalwareScan scan, ClassNode cn, FieldNode field, SearchableString string)
|
public void scanFieldString(MalwareScan scan, ClassNode cn, FieldNode field, SearchableString string)
|
||||||
{
|
{
|
||||||
if (string.searchable.contains("java/lang/Runtime") || string.searchable.contains("java.lang.Runtime"))
|
if (string.searchable.contains("java/lang/Runtime") || string.searchable.contains("java.lang.Runtime"))
|
||||||
foundLDC(scan, string.original, "at field " + fieldToString(cn, field) + nl);
|
foundLDC(scan, string.original, "at field " + fieldToString(cn, field) + NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanMethodString(MalwareScan scan, ClassNode cn, MethodNode method, SearchableString string)
|
public void scanMethodString(MalwareScan scan, ClassNode cn, MethodNode method, SearchableString string)
|
||||||
{
|
{
|
||||||
if (string.searchable.contains("java/lang/Runtime") || string.searchable.contains("java.lang.Runtime"))
|
if (string.searchable.contains("java/lang/Runtime") || string.searchable.contains("java.lang.Runtime"))
|
||||||
foundLDC(scan, string.original, "at method " + methodToString(cn, method) + nl);
|
foundLDC(scan, string.original, "at method " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +54,7 @@ public class JavaRuntimeScanner extends MalwareCodeScanner
|
||||||
{
|
{
|
||||||
final MethodInsnNode min = (MethodInsnNode) instruction;
|
final MethodInsnNode min = (MethodInsnNode) instruction;
|
||||||
if (min.owner.startsWith("java/lang/Runtime"))
|
if (min.owner.startsWith("java/lang/Runtime"))
|
||||||
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + nl);
|
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareCodeScanner;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks for the security manager getting set to null
|
* Checks for the security manager getting set to null
|
||||||
|
@ -59,7 +59,7 @@ public class NullSecurityManagerScanner extends MalwareCodeScanner
|
||||||
|
|
||||||
if (lastInstruction == OpCode.ACONST_NULL.getCode() && owner.equals("java/lang/System") && name.equals("setSecurityManager"))
|
if (lastInstruction == OpCode.ACONST_NULL.getCode() && owner.equals("java/lang/System") && name.equals("setSecurityManager"))
|
||||||
{
|
{
|
||||||
found(scan, "Security Manager set to null at method " + methodToString(cn, method) + nl);
|
found(scan, "Security Manager set to null at method " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareCodeScanner;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.MalwareScan;
|
||||||
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans for method instructions containing java/lang/reflect
|
* Scans for method instructions containing java/lang/reflect
|
||||||
|
@ -51,7 +51,7 @@ public class ReflectionScanner extends MalwareCodeScanner
|
||||||
{
|
{
|
||||||
final MethodInsnNode min = (MethodInsnNode) instruction;
|
final MethodInsnNode min = (MethodInsnNode) instruction;
|
||||||
if (min.owner.startsWith("java/lang/reflect"))
|
if (min.owner.startsWith("java/lang/reflect"))
|
||||||
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + nl);
|
foundMethod(scan, instructionToString(instruction) + " at " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ import the.bytecode.club.bytecodeviewer.malwarescanner.util.SearchableString;
|
||||||
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scans strings for common URL patterns:
|
* Scans strings for common URL patterns:
|
||||||
|
@ -43,20 +43,26 @@ import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
||||||
*/
|
*/
|
||||||
public class URLScanner extends MalwareCodeScanner
|
public class URLScanner extends MalwareCodeScanner
|
||||||
{
|
{
|
||||||
private static final Pattern ipPattern = Pattern.compile("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b");
|
private static final Pattern IP_PATTERN = Pattern.compile("\\b\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\b");
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanFieldString(MalwareScan scan, ClassNode cn, FieldNode field, SearchableString string)
|
public void scanFieldString(MalwareScan scan, ClassNode cn, FieldNode field, SearchableString string)
|
||||||
{
|
{
|
||||||
if (string.searchable.contains("www.") || string.searchable.contains("http://") || string.searchable.contains("https://") || ipPattern.matcher(string.searchable).matches())
|
if (string.searchable.contains("www.")
|
||||||
foundLDC(scan, string.original, "at field " + fieldToString(cn, field) + nl);
|
|| string.searchable.contains("http://")
|
||||||
|
|| string.searchable.contains("https://")
|
||||||
|
|| IP_PATTERN.matcher(string.searchable).matches())
|
||||||
|
foundLDC(scan, string.original, "at field " + fieldToString(cn, field) + NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scanMethodString(MalwareScan scan, ClassNode cn, MethodNode method, SearchableString string)
|
public void scanMethodString(MalwareScan scan, ClassNode cn, MethodNode method, SearchableString string)
|
||||||
{
|
{
|
||||||
if (string.searchable.contains("www.") || string.searchable.contains("http://") || string.searchable.contains("https://") || ipPattern.matcher(string.searchable).matches())
|
if (string.searchable.contains("www.")
|
||||||
foundLDC(scan, string.original, "at method " + methodToString(cn, method) + nl);
|
|| string.searchable.contains("http://")
|
||||||
|
|| string.searchable.contains("https://")
|
||||||
|
|| IP_PATTERN.matcher(string.searchable).matches())
|
||||||
|
foundLDC(scan, string.original, "at method " + methodToString(cn, method) + NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -40,8 +40,8 @@ import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
import static the.bytecode.club.bytecodeviewer.Settings.addRecentPlugin;
|
import static the.bytecode.club.bytecodeviewer.Settings.addRecentPlugin;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -164,7 +164,7 @@ public class PluginWriter extends JFrame
|
||||||
|
|
||||||
public void runPlugin()
|
public void runPlugin()
|
||||||
{
|
{
|
||||||
File tempFile = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + fs + pluginName);
|
File tempFile = new File(TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + FS + pluginName);
|
||||||
tempFile.getParentFile().mkdirs();
|
tempFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|
|
@ -35,7 +35,7 @@ import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An Allatori String Decrypter, targets an unknown (old) version.
|
* An Allatori String Decrypter, targets an unknown (old) version.
|
||||||
|
@ -60,7 +60,7 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
{
|
{
|
||||||
PluginConsole frame = new PluginConsole("Allatori String Decrypter");
|
PluginConsole frame = new PluginConsole("Allatori String Decrypter");
|
||||||
|
|
||||||
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the allatori decrypter function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"});
|
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the allatori decrypter function" + NL + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"});
|
||||||
|
|
||||||
if (dialog.promptChoice() == 0)
|
if (dialog.promptChoice() == 0)
|
||||||
{
|
{
|
||||||
|
@ -97,7 +97,7 @@ public class AllatoriStringDecrypter extends Plugin
|
||||||
private void log(String msg)
|
private void log(String msg)
|
||||||
{
|
{
|
||||||
out.append(msg);
|
out.append(msg);
|
||||||
out.append(Constants.nl);
|
out.append(Constants.NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scanClassNode(ClassNode classNode) throws Exception
|
public void scanClassNode(ClassNode classNode) throws Exception
|
||||||
|
|
|
@ -33,7 +33,7 @@ import java.lang.reflect.Method;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* EZ Injection - This plugin is designed to provide a graphical way for the
|
* EZ Injection - This plugin is designed to provide a graphical way for the
|
||||||
|
@ -243,7 +243,7 @@ public class EZInjection extends Plugin
|
||||||
for (ClassNode cn : BytecodeViewer.getLoadedClasses())
|
for (ClassNode cn : BytecodeViewer.getLoadedClasses())
|
||||||
BCV.getClassNodeLoader().addClass(cn);
|
BCV.getClassNodeLoader().addClass(cn);
|
||||||
|
|
||||||
print("Attempting to find " + invokeMethodInformation + ":" + nl + nl);
|
print("Attempting to find " + invokeMethodInformation + ":" + NL + NL);
|
||||||
|
|
||||||
for (ClassNode classNode : classNodeList)
|
for (ClassNode classNode : classNodeList)
|
||||||
{
|
{
|
||||||
|
@ -258,7 +258,7 @@ public class EZInjection extends Plugin
|
||||||
{
|
{
|
||||||
if (m2.getName().equals(m.name))
|
if (m2.getName().equals(m.name))
|
||||||
{
|
{
|
||||||
print("Invoking " + invokeMethodInformation + ":" + nl + nl);
|
print("Invoking " + invokeMethodInformation + ":" + NL + NL);
|
||||||
|
|
||||||
GraphicalReflectionKit kit = launchKit ? new GraphicalReflectionKit() : null;
|
GraphicalReflectionKit kit = launchKit ? new GraphicalReflectionKit() : null;
|
||||||
try
|
try
|
||||||
|
|
|
@ -24,7 +24,7 @@ import the.bytecode.club.bytecodeviewer.api.PluginConsole;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Simply shows all the non-empty strings in every single class
|
* Simply shows all the non-empty strings in every single class
|
||||||
|
@ -51,7 +51,7 @@ public class ShowAllStrings extends Plugin
|
||||||
{
|
{
|
||||||
String s = (String) v;
|
String s = (String) v;
|
||||||
if (!s.isEmpty())
|
if (!s.isEmpty())
|
||||||
sb.append(classNode.name).append(".").append(f.name).append(f.desc).append(" -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")).append("\"").append(nl);
|
sb.append(classNode.name).append(".").append(f.name).append(f.desc).append(" -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")).append("\"").append(NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v instanceof String[])
|
if (v instanceof String[])
|
||||||
|
@ -60,7 +60,7 @@ public class ShowAllStrings extends Plugin
|
||||||
{
|
{
|
||||||
String s = ((String[]) v)[i];
|
String s = ((String[]) v)[i];
|
||||||
if (!s.isEmpty())
|
if (!s.isEmpty())
|
||||||
sb.append(classNode.name).append(".").append(f.name).append(f.desc).append("[").append(i).append("] -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")).append("\"").append(nl);
|
sb.append(classNode.name).append(".").append(f.name).append(f.desc).append("[").append(i).append("] -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")).append("\"").append(NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ public class ShowAllStrings extends Plugin
|
||||||
{
|
{
|
||||||
final String s = (String) ((LdcInsnNode) a).cst;
|
final String s = (String) ((LdcInsnNode) a).cst;
|
||||||
if (!s.isEmpty())
|
if (!s.isEmpty())
|
||||||
sb.append(classNode.name).append(".").append(m.name).append(m.desc).append(" -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")).append("\"").append(nl);
|
sb.append(classNode.name).append(".").append(m.name).append(m.desc).append(" -> \"").append(s.replaceAll("\\n", "\\\\n").replaceAll("\\r", "\\\\r")).append("\"").append(NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.lang.reflect.Modifier;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Runs the classes then simply grabs the static String[] z
|
* Runs the classes then simply grabs the static String[] z
|
||||||
|
@ -47,7 +47,7 @@ public class ZStringArrayDecrypter extends Plugin
|
||||||
PluginConsole gui = new PluginConsole("ZStringArray Decrypter");
|
PluginConsole gui = new PluginConsole("ZStringArray Decrypter");
|
||||||
StringBuilder out = new StringBuilder();
|
StringBuilder out = new StringBuilder();
|
||||||
|
|
||||||
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + nl + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"});
|
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - WARNING", "WARNING: This will load the classes into the JVM and execute the initialize function" + NL + "for each class. IF THE FILE YOU'RE LOADING IS MALICIOUS, DO NOT CONTINUE.", new String[]{"Continue", "Cancel"});
|
||||||
|
|
||||||
if (dialog.promptChoice() == 0)
|
if (dialog.promptChoice() == 0)
|
||||||
{
|
{
|
||||||
|
@ -61,13 +61,13 @@ public class ZStringArrayDecrypter extends Plugin
|
||||||
{
|
{
|
||||||
if (field.getName().equals("z"))
|
if (field.getName().equals("z"))
|
||||||
{
|
{
|
||||||
out.append(cn.getName()).append(":").append(nl);
|
out.append(cn.getName()).append(":").append(NL);
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
if (field.get(null) != null && field.get(null) instanceof String[] && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()))
|
if (field.get(null) != null && field.get(null) instanceof String[] && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers()))
|
||||||
{
|
{
|
||||||
String[] fieldVal = (String[]) field.get(null);
|
String[] fieldVal = (String[]) field.get(null);
|
||||||
for (int i = 0; i < fieldVal.length; i++)
|
for (int i = 0; i < fieldVal.length; i++)
|
||||||
out.append(" z[").append(i).append("] = ").append(fieldVal[i]).append(nl);
|
out.append(" z[").append(i).append("] = ").append(fieldVal[i]).append(NL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,7 @@ public class ZStringArrayDecrypter extends Plugin
|
||||||
|
|
||||||
if (needsWarning)
|
if (needsWarning)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them" + nl + "makes sure you include ALL the libraries it requires.");
|
BytecodeViewer.showMessage("Some classes failed to decrypt, if you'd like to decrypt all of them" + NL + "makes sure you include ALL the libraries it requires.");
|
||||||
}
|
}
|
||||||
|
|
||||||
gui.setText(out.toString());
|
gui.setText(out.toString());
|
||||||
|
|
|
@ -20,6 +20,7 @@ package the.bytecode.club.bytecodeviewer.resources;
|
||||||
|
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||||
|
import the.bytecode.club.bytecodeviewer.Constants;
|
||||||
import the.bytecode.club.bytecodeviewer.SettingsSerializer;
|
import the.bytecode.club.bytecodeviewer.SettingsSerializer;
|
||||||
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
||||||
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
|
||||||
|
@ -64,7 +65,7 @@ public class ExternalResources
|
||||||
boolean block = true;
|
boolean block = true;
|
||||||
//while (Configuration.java.isEmpty() && block)
|
//while (Configuration.java.isEmpty() && block)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("You need to set your Java path, this requires the JRE to be downloaded." + nl + "(C:/Program Files/Java/JDK_xx/bin/java.exe)");
|
BytecodeViewer.showMessage("You need to set your Java path, this requires the JRE to be downloaded." + NL + "(C:/Program Files/Java/JDK_xx/bin/java.exe)");
|
||||||
ExternalResources.getSingleton().selectJava();
|
ExternalResources.getSingleton().selectJava();
|
||||||
block = !blockTillSelected; //signal block flag off
|
block = !blockTillSelected; //signal block flag off
|
||||||
}
|
}
|
||||||
|
@ -94,7 +95,7 @@ public class ExternalResources
|
||||||
boolean block = true;
|
boolean block = true;
|
||||||
//while (Configuration.javaTools.isEmpty() && block)
|
//while (Configuration.javaTools.isEmpty() && block)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("You need to set your Java Tools path, this requires the JDK to be downloaded." + nl + "(C:/Program Files/Java/JDK_xx/lib/tools.jar)");
|
BytecodeViewer.showMessage("You need to set your Java Tools path, this requires the JDK to be downloaded." + NL + "(C:/Program Files/Java/JDK_xx/lib/tools.jar)");
|
||||||
ExternalResources.getSingleton().selectJavaTools();
|
ExternalResources.getSingleton().selectJavaTools();
|
||||||
block = !blockTillSelected; //signal block flag off
|
block = !blockTillSelected; //signal block flag off
|
||||||
}
|
}
|
||||||
|
@ -296,7 +297,7 @@ public class ExternalResources
|
||||||
*/
|
*/
|
||||||
public String findLibrary(String nameContains)
|
public String findLibrary(String nameContains)
|
||||||
{
|
{
|
||||||
for (File f : MiscUtils.listFiles(new File(libsDirectory)))
|
for (File f : MiscUtils.listFiles(new File(LIBS_DIRECTORY)))
|
||||||
if (f.getName().contains(nameContains))
|
if (f.getName().contains(nameContains))
|
||||||
return f.getAbsolutePath();
|
return f.getAbsolutePath();
|
||||||
|
|
||||||
|
@ -358,7 +359,9 @@ public class ExternalResources
|
||||||
*/
|
*/
|
||||||
public String readProcess(Process process) throws IOException
|
public String readProcess(Process process) throws IOException
|
||||||
{
|
{
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader reader = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader reader = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
String line;
|
String line;
|
||||||
|
@ -366,7 +369,7 @@ public class ExternalResources
|
||||||
while ((line = reader.readLine()) != null)
|
while ((line = reader.readLine()) != null)
|
||||||
{
|
{
|
||||||
builder.append(line);
|
builder.append(line);
|
||||||
builder.append(System.getProperty("line.separator"));
|
builder.append(Constants.NL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return builder.toString();
|
return builder.toString();
|
||||||
|
|
|
@ -32,8 +32,8 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -87,7 +87,7 @@ public class ResourceDecompiling
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//this temporary jar file will be used to store the classes while BCV performs decompilation
|
//this temporary jar file will be used to store the classes while BCV performs decompilation
|
||||||
File temporaryTargetJar = MiscUtils.deleteExistingFile(new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar"));
|
File temporaryTargetJar = MiscUtils.deleteExistingFile(new File(TEMP_DIRECTORY + FS + "temp_" + MiscUtils.getRandomizedName() + ".jar"));
|
||||||
|
|
||||||
//extract all the loaded classes imported into BCV to the temporary target jar
|
//extract all the loaded classes imported into BCV to the temporary target jar
|
||||||
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), temporaryTargetJar.getAbsolutePath());
|
JarUtils.saveAsJarClassesOnly(BytecodeViewer.getLoadedClasses(), temporaryTargetJar.getAbsolutePath());
|
||||||
|
|
|
@ -35,8 +35,8 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -106,7 +106,7 @@ public class APKExport implements Exporter
|
||||||
Thread saveThread = new Thread(() ->
|
Thread saveThread = new Thread(() ->
|
||||||
{
|
{
|
||||||
BytecodeViewer.updateBusyStatus(true);
|
BytecodeViewer.updateBusyStatus(true);
|
||||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
final String input = TEMP_DIRECTORY + FS + MiscUtils.getRandomizedName() + ".jar";
|
||||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||||
|
|
||||||
Thread buildAPKThread = new Thread(() ->
|
Thread buildAPKThread = new Thread(() ->
|
||||||
|
|
|
@ -30,8 +30,8 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -72,7 +72,7 @@ public class DexExport implements Exporter
|
||||||
Thread saveAsJar = new Thread(() ->
|
Thread saveAsJar = new Thread(() ->
|
||||||
{
|
{
|
||||||
BytecodeViewer.updateBusyStatus(true);
|
BytecodeViewer.updateBusyStatus(true);
|
||||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
final String input = TEMP_DIRECTORY + FS + MiscUtils.getRandomizedName() + ".jar";
|
||||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||||
|
|
||||||
Thread saveAsDex = new Thread(() ->
|
Thread saveAsDex = new Thread(() ->
|
||||||
|
|
|
@ -27,8 +27,8 @@ import the.bytecode.club.bytecodeviewer.util.*;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -40,7 +40,7 @@ public class APKResourceImporter implements Importer
|
||||||
@Override
|
@Override
|
||||||
public void open(File file) throws Exception
|
public void open(File file) throws Exception
|
||||||
{
|
{
|
||||||
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
|
File tempCopy = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + ".apk");
|
||||||
FileUtils.copyFile(file, tempCopy);
|
FileUtils.copyFile(file, tempCopy);
|
||||||
|
|
||||||
ResourceContainer container = new ResourceContainer(tempCopy, file.getName());
|
ResourceContainer container = new ResourceContainer(tempCopy, file.getName());
|
||||||
|
@ -48,7 +48,7 @@ public class APKResourceImporter implements Importer
|
||||||
// APK Resource Decoding Here
|
// APK Resource Decoding Here
|
||||||
if (BytecodeViewer.viewer.decodeAPKResources.isSelected())
|
if (BytecodeViewer.viewer.decodeAPKResources.isSelected())
|
||||||
{
|
{
|
||||||
File decodedResources = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
|
File decodedResources = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + ".apk");
|
||||||
APKTool.decodeResources(tempCopy, decodedResources, container);
|
APKTool.decodeResources(tempCopy, decodedResources, container);
|
||||||
container.resourceFiles = JarUtils.loadResources(decodedResources);
|
container.resourceFiles = JarUtils.loadResources(decodedResources);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ public class APKResourceImporter implements Importer
|
||||||
// to prevent unicode filenames
|
// to prevent unicode filenames
|
||||||
|
|
||||||
String name = MiscUtils.getRandomizedName() + ".jar";
|
String name = MiscUtils.getRandomizedName() + ".jar";
|
||||||
File output = new File(tempDirectory + fs + name);
|
File output = new File(TEMP_DIRECTORY + FS + name);
|
||||||
|
|
||||||
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||||
Dex2Jar.dex2Jar(tempCopy, output);
|
Dex2Jar.dex2Jar(tempCopy, output);
|
||||||
|
|
|
@ -29,8 +29,8 @@ import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -41,14 +41,14 @@ public class DEXResourceImporter implements Importer
|
||||||
@Override
|
@Override
|
||||||
public void open(File file) throws Exception
|
public void open(File file) throws Exception
|
||||||
{
|
{
|
||||||
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".dex");
|
File tempCopy = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + ".dex");
|
||||||
|
|
||||||
FileUtils.copyFile(file, tempCopy); //copy and rename to prevent unicode filenames
|
FileUtils.copyFile(file, tempCopy); //copy and rename to prevent unicode filenames
|
||||||
|
|
||||||
ResourceContainer container = new ResourceContainer(tempCopy, file.getName());
|
ResourceContainer container = new ResourceContainer(tempCopy, file.getName());
|
||||||
|
|
||||||
String name = MiscUtils.getRandomizedName() + ".jar";
|
String name = MiscUtils.getRandomizedName() + ".jar";
|
||||||
File output = new File(tempDirectory + fs + name);
|
File output = new File(TEMP_DIRECTORY + FS + name);
|
||||||
|
|
||||||
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
if (BytecodeViewer.viewer.apkConversionGroup.isSelected(BytecodeViewer.viewer.apkConversionDex.getModel()))
|
||||||
Dex2Jar.dex2Jar(tempCopy, output);
|
Dex2Jar.dex2Jar(tempCopy, output);
|
||||||
|
|
|
@ -37,8 +37,8 @@ import java.util.Map;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipFile;
|
import java.util.zip.ZipFile;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compressed APKs (XAPK)
|
* Compressed APKs (XAPK)
|
||||||
|
@ -68,7 +68,7 @@ public class XAPKResourceImporter implements Importer
|
||||||
|
|
||||||
if (fileName.endsWith(".apk"))
|
if (fileName.endsWith(".apk"))
|
||||||
{
|
{
|
||||||
File tempFile = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + fs + entry);
|
File tempFile = new File(TEMP_DIRECTORY + FS + "temp" + MiscUtils.randomString(32) + FS + entry);
|
||||||
tempFile.getParentFile().mkdirs();
|
tempFile.getParentFile().mkdirs();
|
||||||
|
|
||||||
try (InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(tempFile))
|
try (InputStream in = zipFile.getInputStream(entry); OutputStream out = new FileOutputStream(tempFile))
|
||||||
|
|
|
@ -24,8 +24,8 @@ import the.bytecode.club.bytecodeviewer.resources.ResourceContainer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.tempDirectory;
|
import static the.bytecode.club.bytecodeviewer.Constants.TEMP_DIRECTORY;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Konloch
|
* @author Konloch
|
||||||
|
@ -37,14 +37,14 @@ public class APKTool
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File dir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs + "Decoded Resources");
|
File dir = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(32) + FS + "Decoded Resources");
|
||||||
dir.mkdirs();
|
dir.mkdirs();
|
||||||
|
|
||||||
File tempAPKPath = new File(tempDirectory + fs + MiscUtils.randomString(12));
|
File tempAPKPath = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12));
|
||||||
tempAPKPath.mkdirs();
|
tempAPKPath.mkdirs();
|
||||||
brut.apktool.Main.main(new String[]{"r", "--frame-path", tempAPKPath.getAbsolutePath(), "d", input.getAbsolutePath(), "-o", dir.getAbsolutePath(), "-f"});
|
brut.apktool.Main.main(new String[]{"r", "--frame-path", tempAPKPath.getAbsolutePath(), "d", input.getAbsolutePath(), "-o", dir.getAbsolutePath(), "-f"});
|
||||||
|
|
||||||
File zip = new File(tempDirectory + fs + MiscUtils.randomString(12) + ".zip");
|
File zip = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12) + ".zip");
|
||||||
ZipUtils.zipFolderAPKTool(dir.getAbsolutePath(), zip.getAbsolutePath());
|
ZipUtils.zipFolderAPKTool(dir.getAbsolutePath(), zip.getAbsolutePath());
|
||||||
|
|
||||||
if (zip.exists())
|
if (zip.exists())
|
||||||
|
@ -61,17 +61,17 @@ public class APKTool
|
||||||
|
|
||||||
public static synchronized void buildAPK(File input, File output, ResourceContainer container)
|
public static synchronized void buildAPK(File input, File output, ResourceContainer container)
|
||||||
{
|
{
|
||||||
String temp = tempDirectory + fs;
|
String temp = TEMP_DIRECTORY + FS;
|
||||||
File tempDir = new File(temp + fs + MiscUtils.getRandomizedName() + fs);
|
File tempDir = new File(temp + FS + MiscUtils.getRandomizedName() + FS);
|
||||||
tempDir.mkdirs();
|
tempDir.mkdirs();
|
||||||
|
|
||||||
|
|
||||||
File tempAPKPath = new File(tempDirectory + fs + MiscUtils.randomString(12));
|
File tempAPKPath = new File(TEMP_DIRECTORY + FS + MiscUtils.randomString(12));
|
||||||
tempAPKPath.mkdirs();
|
tempAPKPath.mkdirs();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
File smaliFolder = new File(container.APKToolContents.getAbsolutePath() + fs + "smali");
|
File smaliFolder = new File(container.APKToolContents.getAbsolutePath() + FS + "smali");
|
||||||
FileUtils.deleteDirectory(smaliFolder);
|
FileUtils.deleteDirectory(smaliFolder);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.nl;
|
import static the.bytecode.club.bytecodeviewer.Constants.NL;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads the libraries on boot. If booting failed for some reason, this kicks in as a fail safe.
|
* Loads the libraries on boot. If booting failed for some reason, this kicks in as a fail safe.
|
||||||
|
@ -58,7 +58,7 @@ public class BootCheck implements Runnable
|
||||||
@SuppressWarnings({"rawtypes", "unchecked"})
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
public void failSafeLoadLibraries()
|
public void failSafeLoadLibraries()
|
||||||
{
|
{
|
||||||
if (!Boot.completedboot && !Boot.downloading)
|
if (!Boot.completedBoot && !Boot.downloading)
|
||||||
{
|
{
|
||||||
File libsDir = Boot.libsDir();
|
File libsDir = Boot.libsDir();
|
||||||
File[] listFiles = libsDir.listFiles();
|
File[] listFiles = libsDir.listFiles();
|
||||||
|
@ -66,7 +66,7 @@ public class BootCheck implements Runnable
|
||||||
//first boot failed to download libraries
|
//first boot failed to download libraries
|
||||||
if (listFiles == null || listFiles.length <= 0)
|
if (listFiles == null || listFiles.length <= 0)
|
||||||
{
|
{
|
||||||
BytecodeViewer.showMessage("Github is loading extremely slow, BCV needs to download libraries from github in order" + nl + "to work, please try adjusting your network settings or manually downloading these libraries" + nl + "if this error persists.");
|
BytecodeViewer.showMessage("Github is loading extremely slow, BCV needs to download libraries from github in order" + NL + "to work, please try adjusting your network settings or manually downloading these libraries" + NL + "if this error persists.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -107,7 +107,6 @@ public class BootCheck implements Runnable
|
||||||
Boot.checkEnjarify();
|
Boot.checkEnjarify();
|
||||||
Boot.checkKrakatau();
|
Boot.checkKrakatau();
|
||||||
|
|
||||||
Boot.globalstop = false;
|
|
||||||
Boot.hide();
|
Boot.hide();
|
||||||
|
|
||||||
int CLI = CommandLineInput.parseCommandLine(BytecodeViewer.launchArgs);
|
int CLI = CommandLineInput.parseCommandLine(BytecodeViewer.launchArgs);
|
||||||
|
|
|
@ -34,7 +34,7 @@ import java.awt.*;
|
||||||
*/
|
*/
|
||||||
public class JTextAreaUtils
|
public class JTextAreaUtils
|
||||||
{
|
{
|
||||||
private static final DefaultHighlighter.DefaultHighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 62, 150));
|
private static final DefaultHighlighter.DefaultHighlightPainter PAINTER = new DefaultHighlighter.DefaultHighlightPainter(new Color(255, 62, 150));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This was really interesting to write.
|
* This was really interesting to write.
|
||||||
|
@ -163,7 +163,7 @@ public class JTextAreaUtils
|
||||||
{
|
{
|
||||||
// Create highlighter using private painter and apply around
|
// Create highlighter using private painter and apply around
|
||||||
// pattern
|
// pattern
|
||||||
highlighter.addHighlight(pos, pos + pattern.length(), painter);
|
highlighter.addHighlight(pos, pos + pattern.length(), PAINTER);
|
||||||
pos += pattern.length();
|
pos += pattern.length();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ import java.util.zip.ZipEntry;
|
||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
import java.util.zip.ZipInputStream;
|
import java.util.zip.ZipInputStream;
|
||||||
|
|
||||||
import static the.bytecode.club.bytecodeviewer.Constants.fs;
|
import static the.bytecode.club.bytecodeviewer.Constants.FS;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loading and saving jars
|
* Loading and saving jars
|
||||||
|
@ -384,7 +384,7 @@ public class JarUtils
|
||||||
ClassWriter cw = new ClassWriter(0);
|
ClassWriter cw = new ClassWriter(0);
|
||||||
cn.accept(cw);
|
cn.accept(cw);
|
||||||
|
|
||||||
String name = dir + fs + cn.name + ".class";
|
String name = dir + FS + cn.name + ".class";
|
||||||
File f = new File(name);
|
File f = new File(name);
|
||||||
f.mkdirs();
|
f.mkdirs();
|
||||||
|
|
||||||
|
|
|
@ -31,28 +31,28 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class LazyNameUtil
|
public class LazyNameUtil
|
||||||
{
|
{
|
||||||
public static boolean SAME_NAME_JAR_WORKSPACE = false;
|
public static boolean sameNameJarWorkspace = false;
|
||||||
private static final Map<String, SeqAndCount> nameMap = new HashMap<>();
|
private static final Map<String, SeqAndCount> NAME_MAP = new HashMap<>();
|
||||||
|
|
||||||
public static void reset()
|
public static void reset()
|
||||||
{
|
{
|
||||||
nameMap.clear();
|
NAME_MAP.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String applyNameChanges(String name)
|
public static String applyNameChanges(String name)
|
||||||
{
|
{
|
||||||
if (nameMap.containsKey(name))
|
if (NAME_MAP.containsKey(name))
|
||||||
{
|
{
|
||||||
if (!SAME_NAME_JAR_WORKSPACE)
|
if (!sameNameJarWorkspace)
|
||||||
SAME_NAME_JAR_WORKSPACE = true;
|
sameNameJarWorkspace = true;
|
||||||
|
|
||||||
SeqAndCount seqAndCount = nameMap.get(name);
|
SeqAndCount seqAndCount = NAME_MAP.get(name);
|
||||||
nameMap.put(name, seqAndCount.incrSeqAndCount());
|
NAME_MAP.put(name, seqAndCount.incrSeqAndCount());
|
||||||
return FilenameUtils.removeExtension(name) + "#" + seqAndCount.getSeq() + "." + FilenameUtils.getExtension(name);
|
return FilenameUtils.removeExtension(name) + "#" + seqAndCount.getSeq() + "." + FilenameUtils.getExtension(name);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
nameMap.put(name, SeqAndCount.init());
|
NAME_MAP.put(name, SeqAndCount.init());
|
||||||
}
|
}
|
||||||
|
|
||||||
return name;
|
return name;
|
||||||
|
@ -66,15 +66,15 @@ public class LazyNameUtil
|
||||||
if (name.contains("#"))
|
if (name.contains("#"))
|
||||||
name = name.substring(0, name.indexOf("#")) + name.substring(name.indexOf("."));
|
name = name.substring(0, name.indexOf("#")) + name.substring(name.indexOf("."));
|
||||||
|
|
||||||
SeqAndCount seqAndCount = nameMap.get(name);
|
SeqAndCount seqAndCount = NAME_MAP.get(name);
|
||||||
if (seqAndCount == null)
|
if (seqAndCount == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// sequence remain the same and decrease the count
|
// sequence remain the same and decrease the count
|
||||||
// still the count become 1
|
// still the count become 1
|
||||||
if (seqAndCount.getCount() == 1)
|
if (seqAndCount.getCount() == 1)
|
||||||
nameMap.remove(name);
|
NAME_MAP.remove(name);
|
||||||
else
|
else
|
||||||
nameMap.put(name, seqAndCount.decrCount());
|
NAME_MAP.put(name, seqAndCount.decrCount());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,26 +51,26 @@ public class MethodParser
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Pattern regex = Pattern.compile("\\s*(?:static|public|private|protected|final|abstract)" + "[\\w\\s.<>\\[\\]]*\\s+(?<name>[\\w.]+)\\s*\\((?<params>[\\w\\s,.<>\\[\\]$?]*)\\)");
|
public static final Pattern REGEX = Pattern.compile("\\s*(?:static|public|private|protected|final|abstract)"
|
||||||
|
+ "[\\w\\s.<>\\[\\]]*\\s+(?<name>[\\w.]+)\\s*\\((?<params>[\\w\\s,.<>\\[\\]$?]*)\\)");
|
||||||
|
|
||||||
private final TreeMap<Integer, Method> methods = new TreeMap<>();
|
private final TreeMap<Integer, Method> methods = new TreeMap<>();
|
||||||
|
|
||||||
private static String removeBrackets(String string)
|
private static String removeBrackets(String string)
|
||||||
{
|
{
|
||||||
if (string.indexOf('<') != -1 && string.indexOf('>') != -1)
|
if (string.indexOf('<') != -1 && string.indexOf('>') != -1)
|
||||||
{
|
|
||||||
return removeBrackets(string.replaceAll("<[^<>]*>", ""));
|
return removeBrackets(string.replaceAll("<[^<>]*>", ""));
|
||||||
}
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getLastPart(String string, int character)
|
private static String getLastPart(String string, int character)
|
||||||
{
|
{
|
||||||
int ch = string.lastIndexOf(character);
|
int ch = string.lastIndexOf(character);
|
||||||
|
|
||||||
if (ch != -1)
|
if (ch != -1)
|
||||||
{
|
|
||||||
string = string.substring(ch + 1);
|
string = string.substring(ch + 1);
|
||||||
}
|
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +80,7 @@ public class MethodParser
|
||||||
{
|
{
|
||||||
name = getLastPart(name, '.');
|
name = getLastPart(name, '.');
|
||||||
String[] args = {};
|
String[] args = {};
|
||||||
|
|
||||||
if (!params.isEmpty())
|
if (!params.isEmpty())
|
||||||
{
|
{
|
||||||
params = removeBrackets(params);
|
params = removeBrackets(params);
|
||||||
|
@ -87,15 +88,18 @@ public class MethodParser
|
||||||
for (int i = 0; i < args.length; i++)
|
for (int i = 0; i < args.length; i++)
|
||||||
{
|
{
|
||||||
args[i] = args[i].trim();
|
args[i] = args[i].trim();
|
||||||
|
|
||||||
if (args[i].indexOf(' ') != -1)
|
if (args[i].indexOf(' ') != -1)
|
||||||
{
|
{
|
||||||
String[] strings = args[i].split(" ");
|
String[] strings = args[i].split(" ");
|
||||||
args[i] = strings[strings.length - 2];
|
args[i] = strings[strings.length - 2];
|
||||||
}
|
}
|
||||||
|
|
||||||
args[i] = getLastPart(args[i], '.');
|
args[i] = getLastPart(args[i], '.');
|
||||||
args[i] = getLastPart(args[i], '$');
|
args[i] = getLastPart(args[i], '$');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Method method = new Method(name, Arrays.asList(args));
|
Method method = new Method(name, Arrays.asList(args));
|
||||||
methods.put(line, method);
|
methods.put(line, method);
|
||||||
}
|
}
|
||||||
|
@ -120,22 +124,26 @@ public class MethodParser
|
||||||
public String getMethodName(int line)
|
public String getMethodName(int line)
|
||||||
{
|
{
|
||||||
Method method = methods.get(line);
|
Method method = methods.get(line);
|
||||||
|
|
||||||
if (method != null)
|
if (method != null)
|
||||||
{
|
{
|
||||||
if (!method.name.isEmpty())
|
if (!method.name.isEmpty())
|
||||||
return method.name;
|
return method.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getMethodParams(int line)
|
public List<String> getMethodParams(int line)
|
||||||
{
|
{
|
||||||
Method method = methods.get(line);
|
Method method = methods.get(line);
|
||||||
|
|
||||||
if (method != null)
|
if (method != null)
|
||||||
{
|
{
|
||||||
if (!method.params.isEmpty())
|
if (!method.params.isEmpty())
|
||||||
return method.params;
|
return method.params;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -151,11 +159,10 @@ public class MethodParser
|
||||||
if (name.equals(entry.getValue().name) && params.size() == entry.getValue().params.size())
|
if (name.equals(entry.getValue().name) && params.size() == entry.getValue().params.size())
|
||||||
{
|
{
|
||||||
if (params.equals(entry.getValue().params))
|
if (params.equals(entry.getValue().params))
|
||||||
{
|
|
||||||
return entry.getKey();
|
return entry.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,10 +172,9 @@ public class MethodParser
|
||||||
{
|
{
|
||||||
Map.Entry<Integer, Method> low = methods.floorEntry(line);
|
Map.Entry<Integer, Method> low = methods.floorEntry(line);
|
||||||
if (low != null)
|
if (low != null)
|
||||||
{
|
|
||||||
return low.getKey();
|
return low.getKey();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,16 +190,14 @@ public class MethodParser
|
||||||
{
|
{
|
||||||
Map.Entry<Integer, Method> low = methods.floorEntry(line);
|
Map.Entry<Integer, Method> low = methods.floorEntry(line);
|
||||||
Map.Entry<Integer, Method> high = methods.ceilingEntry(line);
|
Map.Entry<Integer, Method> high = methods.ceilingEntry(line);
|
||||||
|
|
||||||
if (low != null && high != null)
|
if (low != null && high != null)
|
||||||
{
|
|
||||||
return Math.abs(line - low.getKey()) < Math.abs(line - high.getKey()) ? low.getKey() : high.getKey();
|
return Math.abs(line - low.getKey()) < Math.abs(line - high.getKey()) ? low.getKey() : high.getKey();
|
||||||
}
|
|
||||||
else if (low != null || high != null)
|
else if (low != null || high != null)
|
||||||
{
|
|
||||||
return low != null ? low.getKey() : high.getKey();
|
return low != null ? low.getKey() : high.getKey();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,8 @@ public class MiscUtils
|
||||||
{
|
{
|
||||||
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
private static final String AB = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
private static final String AN = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
|
||||||
private static final Random rnd = new Random();
|
private static final Random RND = new Random();
|
||||||
private static final Set<String> createdRandomizedNames = new HashSet<>();
|
private static final Set<String> CREATED_RANDOMIZED_NAMES = new HashSet<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a random string without numbers
|
* Returns a random string without numbers
|
||||||
|
@ -57,7 +57,7 @@ public class MiscUtils
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(len);
|
StringBuilder sb = new StringBuilder(len);
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
sb.append(AB.charAt(rnd.nextInt(AB.length())));
|
sb.append(AB.charAt(RND.nextInt(AB.length())));
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ public class MiscUtils
|
||||||
while (!generated)
|
while (!generated)
|
||||||
{
|
{
|
||||||
String randomizedName = MiscUtils.randomString(25);
|
String randomizedName = MiscUtils.randomString(25);
|
||||||
if (!createdRandomizedNames.contains(randomizedName))
|
if (!CREATED_RANDOMIZED_NAMES.contains(randomizedName))
|
||||||
{
|
{
|
||||||
createdRandomizedNames.add(randomizedName);
|
CREATED_RANDOMIZED_NAMES.add(randomizedName);
|
||||||
name = randomizedName;
|
name = randomizedName;
|
||||||
generated = true;
|
generated = true;
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,8 @@ public class MiscUtils
|
||||||
public static void printProcess(Process process) throws Exception
|
public static void printProcess(Process process) throws Exception
|
||||||
{
|
{
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
try (InputStream is = process.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getInputStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
|
@ -95,7 +96,9 @@ public class MiscUtils
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try (InputStream is = process.getErrorStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr))
|
try (InputStream is = process.getErrorStream();
|
||||||
|
InputStreamReader isr = new InputStreamReader(is);
|
||||||
|
BufferedReader br = new BufferedReader(isr))
|
||||||
{
|
{
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null)
|
while ((line = br.readLine()) != null)
|
||||||
|
@ -115,7 +118,7 @@ public class MiscUtils
|
||||||
{
|
{
|
||||||
StringBuilder sb = new StringBuilder(len);
|
StringBuilder sb = new StringBuilder(len);
|
||||||
for (int i = 0; i < len; i++)
|
for (int i = 0; i < len; i++)
|
||||||
sb.append(AN.charAt(rnd.nextInt(AN.length())));
|
sb.append(AN.charAt(RND.nextInt(AN.length())));
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,7 @@
|
||||||
package the.bytecode.club.bytecodeviewer.util;
|
package the.bytecode.club.bytecodeviewer.util;
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import the.bytecode.club.bytecodeviewer.Constants;
|
||||||
|
|
||||||
import java.io.FilterOutputStream;
|
import java.io.FilterOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -42,7 +43,7 @@ public class NewlineOutputStream extends FilterOutputStream
|
||||||
super(os);
|
super(os);
|
||||||
if (newline == null)
|
if (newline == null)
|
||||||
{
|
{
|
||||||
String s = System.getProperty("line.separator");
|
String s = Constants.NL;
|
||||||
if (s == null || s.length() <= 0)
|
if (s == null || s.length() <= 0)
|
||||||
s = "\n";
|
s = "\n";
|
||||||
newline = s.getBytes(StandardCharsets.ISO_8859_1); // really us-ascii
|
newline = s.getBytes(StandardCharsets.ISO_8859_1); // really us-ascii
|
||||||
|
|
|
@ -41,8 +41,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public class SecurityMan extends SecurityManager
|
public class SecurityMan extends SecurityManager
|
||||||
{
|
{
|
||||||
private static final boolean disableExecSandbox = true;
|
private static final boolean DISABLE_EXEC_SANDBOX = true;
|
||||||
private static final boolean disableDiskWriteSandbox = true;
|
private static final boolean DISABLE_DISK_WRITE_SANDBOX = true;
|
||||||
|
|
||||||
private final AtomicInteger silentExec = new AtomicInteger(1);
|
private final AtomicInteger silentExec = new AtomicInteger(1);
|
||||||
private boolean printing = false;
|
private boolean printing = false;
|
||||||
|
@ -77,11 +77,17 @@ public class SecurityMan extends SecurityManager
|
||||||
public void checkExec(String cmd)
|
public void checkExec(String cmd)
|
||||||
{
|
{
|
||||||
//This was disabled on 02-13-2022, at some point in the future I will fix the compatibility issues and re-enable it.
|
//This was disabled on 02-13-2022, at some point in the future I will fix the compatibility issues and re-enable it.
|
||||||
if (disableExecSandbox)
|
if (DISABLE_EXEC_SANDBOX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//incoming command must contain the following or it will be automatically denied
|
//incoming command must contain the following, or it will be automatically denied
|
||||||
String[] execWhitelist = {"attrib", "python", "pypy", "java", "brut_util",};
|
String[] execWhitelist = {
|
||||||
|
"attrib",
|
||||||
|
"python",
|
||||||
|
"pypy",
|
||||||
|
"java",
|
||||||
|
"brut_util"
|
||||||
|
};
|
||||||
|
|
||||||
//the goal is to make this true
|
//the goal is to make this true
|
||||||
boolean allow = false;
|
boolean allow = false;
|
||||||
|
@ -108,7 +114,7 @@ public class SecurityMan extends SecurityManager
|
||||||
blocked = true;
|
blocked = true;
|
||||||
|
|
||||||
//block anything executing in system temp
|
//block anything executing in system temp
|
||||||
else if (normalizedPath.startsWith(Constants.systemTempDirectory.toLowerCase()))
|
else if (normalizedPath.startsWith(Constants.SYSTEM_TEMP_DIRECTORY.toLowerCase()))
|
||||||
blocked = true;
|
blocked = true;
|
||||||
|
|
||||||
//can only write into BCV dir, so anything executing from here has probably been dropped
|
//can only write into BCV dir, so anything executing from here has probably been dropped
|
||||||
|
@ -170,7 +176,19 @@ public class SecurityMan extends SecurityManager
|
||||||
*/
|
*/
|
||||||
private boolean canClassExecute(String fullyQualifiedClassName)
|
private boolean canClassExecute(String fullyQualifiedClassName)
|
||||||
{
|
{
|
||||||
return fullyQualifiedClassName.equals(KrakatauDecompiler.class.getCanonicalName()) || fullyQualifiedClassName.equals(KrakatauDisassembler.class.getCanonicalName()) || fullyQualifiedClassName.equals(CFRDecompiler.class.getCanonicalName()) || fullyQualifiedClassName.equals(ProcyonDecompiler.class.getCanonicalName()) || fullyQualifiedClassName.equals(FernFlowerDecompiler.class.getCanonicalName()) || fullyQualifiedClassName.equals(JDGUIDecompiler.class.getCanonicalName()) || fullyQualifiedClassName.equals(KrakatauAssembler.class.getCanonicalName()) || fullyQualifiedClassName.equals(ExternalResources.class.getCanonicalName()) || fullyQualifiedClassName.equals(Enjarify.class.getCanonicalName()) || fullyQualifiedClassName.equals(APKTool.class.getCanonicalName()) || fullyQualifiedClassName.equals(BytecodeViewer.class.getCanonicalName()) || fullyQualifiedClassName.equals(Constants.class.getCanonicalName()) || fullyQualifiedClassName.equals(JavaCompiler.class.getCanonicalName());
|
return fullyQualifiedClassName.equals(KrakatauDecompiler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(KrakatauDisassembler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(CFRDecompiler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(ProcyonDecompiler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(FernFlowerDecompiler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(JDGUIDecompiler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(KrakatauAssembler.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(ExternalResources.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(Enjarify.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(APKTool.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(BytecodeViewer.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(Constants.class.getCanonicalName())
|
||||||
|
|| fullyQualifiedClassName.equals(JavaCompiler.class.getCanonicalName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -334,13 +352,24 @@ public class SecurityMan extends SecurityManager
|
||||||
System.out.println("Writing: " + file);
|
System.out.println("Writing: " + file);
|
||||||
|
|
||||||
//This was disabled on 02-13-2022, at some point in the future I will fix the compatibility issues and re-enable it.
|
//This was disabled on 02-13-2022, at some point in the future I will fix the compatibility issues and re-enable it.
|
||||||
if (disableDiskWriteSandbox)
|
if (DISABLE_DISK_WRITE_SANDBOX)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
//can only export as the following extensions
|
//can only export as the following extensions
|
||||||
if (file.endsWith(".zip") || file.endsWith(".jar") || file.endsWith(".apk") || file.endsWith(".dex") || file.endsWith(".class") || file.endsWith("js") || file.endsWith(".java") || file.endsWith(".gy") || file.endsWith(".bcv") || file.endsWith(".json") || file.endsWith(".txt") || file.endsWith(".log"))
|
if (file.endsWith(".zip")
|
||||||
|
|| file.endsWith(".jar")
|
||||||
|
|| file.endsWith(".apk")
|
||||||
|
|| file.endsWith(".dex")
|
||||||
|
|| file.endsWith(".class")
|
||||||
|
|| file.endsWith("js")
|
||||||
|
|| file.endsWith(".java")
|
||||||
|
|| file.endsWith(".gy")
|
||||||
|
|| file.endsWith(".bcv")
|
||||||
|
|| file.endsWith(".json")
|
||||||
|
|| file.endsWith(".txt")
|
||||||
|
|| file.endsWith(".log"))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//can only write into BCV dir
|
//can only write into BCV dir
|
||||||
|
@ -348,7 +377,7 @@ public class SecurityMan extends SecurityManager
|
||||||
return;
|
return;
|
||||||
|
|
||||||
//can only write into system temp
|
//can only write into system temp
|
||||||
if (file.startsWith(Constants.systemTempDirectory))
|
if (file.startsWith(Constants.SYSTEM_TEMP_DIRECTORY))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
catch (IOException e)
|
catch (IOException e)
|
||||||
|
|
|
@ -30,7 +30,10 @@ import java.util.function.BiFunction;
|
||||||
*/
|
*/
|
||||||
public enum SyntaxLanguage
|
public enum SyntaxLanguage
|
||||||
{
|
{
|
||||||
XML(SyntaxConstants.SYNTAX_STYLE_XML, (n, c) -> n.endsWith(".xml") || c.startsWith("<?xml") || c.startsWith("<xml")), PYTHON(SyntaxConstants.SYNTAX_STYLE_PYTHON, (n, c) -> n.endsWith(".py") || n.endsWith(".python")), RUBY(SyntaxConstants.SYNTAX_STYLE_RUBY, (n, c) -> n.endsWith(".rb") || n.endsWith(".ruby")), JAVA(SyntaxConstants.SYNTAX_STYLE_JAVA, (n, c) -> n.endsWith(".java")), HTML(SyntaxConstants.SYNTAX_STYLE_HTML, (n, c) -> n.endsWith(".html")), CSS(SyntaxConstants.SYNTAX_STYLE_CSS, (n, c) -> n.endsWith(".css")), PROPERTIES(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE, (n, c) -> n.endsWith(".properties") || n.endsWith(".mf") || n.endsWith(".sf") || n.endsWith(".plugin") || n.endsWith(".attachprovider") || n.endsWith(".transportservice") || n.endsWith(".connector")), PHP(SyntaxConstants.SYNTAX_STYLE_PHP, (n, c) -> n.endsWith(".php") || c.startsWith("<?php")), JS(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, (n, c) -> n.endsWith(".js")), BATCH(SyntaxConstants.SYNTAX_STYLE_WINDOWS_BATCH, (n, c) -> n.endsWith(".bat")), SHELL(SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL, (n, c) -> n.endsWith(".sh")), C(SyntaxConstants.SYNTAX_STYLE_C, (n, c) -> n.endsWith(".c") || n.endsWith(".h")), CPP(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS, (n, c) -> n.endsWith(".cpp") || n.endsWith(".hpp")), SCALA(SyntaxConstants.SYNTAX_STYLE_SCALA, (n, c) -> n.endsWith(".scala")), CLOJURE(SyntaxConstants.SYNTAX_STYLE_CLOJURE, (n, c) -> n.endsWith(".clojure")), GROOVY(SyntaxConstants.SYNTAX_STYLE_GROOVY, (n, c) -> n.endsWith(".groovy") || n.endsWith(".gradle")), LUA(SyntaxConstants.SYNTAX_STYLE_LUA, (n, c) -> n.endsWith(".lua")), SQL(SyntaxConstants.SYNTAX_STYLE_SQL, (n, c) -> n.endsWith(".sql")), JSON(SyntaxConstants.SYNTAX_STYLE_JSON, (n, c) -> n.endsWith(".json")), JSP(SyntaxConstants.SYNTAX_STYLE_JSP, (n, c) -> n.endsWith(".jsp")), YAML(SyntaxConstants.SYNTAX_STYLE_YAML, (n, c) -> n.endsWith(".yml") || n.endsWith(".yaml")), CS(SyntaxConstants.SYNTAX_STYLE_CSHARP, (n, c) -> n.endsWith(".cs")), CSV(SyntaxConstants.SYNTAX_STYLE_CSV, (n, c) -> n.endsWith(".csv")), DOCKER(SyntaxConstants.SYNTAX_STYLE_DOCKERFILE, (n, c) -> n.endsWith(".dockerfile")), DART(SyntaxConstants.SYNTAX_STYLE_DART, (n, c) -> n.endsWith(".dart")), GO(SyntaxConstants.SYNTAX_STYLE_GO, (n, c) -> n.endsWith(".go")), HTACCESS(SyntaxConstants.SYNTAX_STYLE_HTACCESS, (n, c) -> n.endsWith(".htaccess")), INI(SyntaxConstants.SYNTAX_STYLE_INI, (n, c) -> n.endsWith(".ini")), KOTLIN(SyntaxConstants.SYNTAX_STYLE_KOTLIN, (n, c) -> n.endsWith(".kt") || n.endsWith(".kts")), LATEX(SyntaxConstants.SYNTAX_STYLE_LATEX, (n, c) -> n.endsWith(".tex")), MARKDOWN(SyntaxConstants.SYNTAX_STYLE_MARKDOWN, (n, c) -> n.endsWith(".md")), PERL(SyntaxConstants.SYNTAX_STYLE_PERL, (n, c) -> n.endsWith(".pl")), TYPESCRIPT(SyntaxConstants.SYNTAX_STYLE_TYPESCRIPT, (n, c) -> n.endsWith(".ts")), NONE(SyntaxConstants.SYNTAX_STYLE_NONE, (n, c) -> false);
|
XML(SyntaxConstants.SYNTAX_STYLE_XML, (n, c) -> n.endsWith(".xml") || c.startsWith("<?xml") || c.startsWith("<xml")),
|
||||||
|
PYTHON(SyntaxConstants.SYNTAX_STYLE_PYTHON, (n, c) -> n.endsWith(".py") || n.endsWith(".python")),
|
||||||
|
RUBY(SyntaxConstants.SYNTAX_STYLE_RUBY, (n, c) -> n.endsWith(".rb") || n.endsWith(".ruby")),
|
||||||
|
JAVA(SyntaxConstants.SYNTAX_STYLE_JAVA, (n, c) -> n.endsWith(".java")), HTML(SyntaxConstants.SYNTAX_STYLE_HTML, (n, c) -> n.endsWith(".html")), CSS(SyntaxConstants.SYNTAX_STYLE_CSS, (n, c) -> n.endsWith(".css")), PROPERTIES(SyntaxConstants.SYNTAX_STYLE_PROPERTIES_FILE, (n, c) -> n.endsWith(".properties") || n.endsWith(".mf") || n.endsWith(".sf") || n.endsWith(".plugin") || n.endsWith(".attachprovider") || n.endsWith(".transportservice") || n.endsWith(".connector")), PHP(SyntaxConstants.SYNTAX_STYLE_PHP, (n, c) -> n.endsWith(".php") || c.startsWith("<?php")), JS(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT, (n, c) -> n.endsWith(".js")), BATCH(SyntaxConstants.SYNTAX_STYLE_WINDOWS_BATCH, (n, c) -> n.endsWith(".bat")), SHELL(SyntaxConstants.SYNTAX_STYLE_UNIX_SHELL, (n, c) -> n.endsWith(".sh")), C(SyntaxConstants.SYNTAX_STYLE_C, (n, c) -> n.endsWith(".c") || n.endsWith(".h")), CPP(SyntaxConstants.SYNTAX_STYLE_CPLUSPLUS, (n, c) -> n.endsWith(".cpp") || n.endsWith(".hpp")), SCALA(SyntaxConstants.SYNTAX_STYLE_SCALA, (n, c) -> n.endsWith(".scala")), CLOJURE(SyntaxConstants.SYNTAX_STYLE_CLOJURE, (n, c) -> n.endsWith(".clojure")), GROOVY(SyntaxConstants.SYNTAX_STYLE_GROOVY, (n, c) -> n.endsWith(".groovy") || n.endsWith(".gradle")), LUA(SyntaxConstants.SYNTAX_STYLE_LUA, (n, c) -> n.endsWith(".lua")), SQL(SyntaxConstants.SYNTAX_STYLE_SQL, (n, c) -> n.endsWith(".sql")), JSON(SyntaxConstants.SYNTAX_STYLE_JSON, (n, c) -> n.endsWith(".json")), JSP(SyntaxConstants.SYNTAX_STYLE_JSP, (n, c) -> n.endsWith(".jsp")), YAML(SyntaxConstants.SYNTAX_STYLE_YAML, (n, c) -> n.endsWith(".yml") || n.endsWith(".yaml")), CS(SyntaxConstants.SYNTAX_STYLE_CSHARP, (n, c) -> n.endsWith(".cs")), CSV(SyntaxConstants.SYNTAX_STYLE_CSV, (n, c) -> n.endsWith(".csv")), DOCKER(SyntaxConstants.SYNTAX_STYLE_DOCKERFILE, (n, c) -> n.endsWith(".dockerfile")), DART(SyntaxConstants.SYNTAX_STYLE_DART, (n, c) -> n.endsWith(".dart")), GO(SyntaxConstants.SYNTAX_STYLE_GO, (n, c) -> n.endsWith(".go")), HTACCESS(SyntaxConstants.SYNTAX_STYLE_HTACCESS, (n, c) -> n.endsWith(".htaccess")), INI(SyntaxConstants.SYNTAX_STYLE_INI, (n, c) -> n.endsWith(".ini")), KOTLIN(SyntaxConstants.SYNTAX_STYLE_KOTLIN, (n, c) -> n.endsWith(".kt") || n.endsWith(".kts")), LATEX(SyntaxConstants.SYNTAX_STYLE_LATEX, (n, c) -> n.endsWith(".tex")), MARKDOWN(SyntaxConstants.SYNTAX_STYLE_MARKDOWN, (n, c) -> n.endsWith(".md")), PERL(SyntaxConstants.SYNTAX_STYLE_PERL, (n, c) -> n.endsWith(".pl")), TYPESCRIPT(SyntaxConstants.SYNTAX_STYLE_TYPESCRIPT, (n, c) -> n.endsWith(".ts")), NONE(SyntaxConstants.SYNTAX_STYLE_NONE, (n, c) -> false);
|
||||||
|
|
||||||
public static final SyntaxLanguage[] VALUES = values();
|
public static final SyntaxLanguage[] VALUES = values();
|
||||||
|
|
||||||
|
|
|
@ -55,32 +55,26 @@ public class JTabbedPanePopupMenuTabsCloser extends AbstractJTabbedPanePopupMenu
|
||||||
{
|
{
|
||||||
JPopupMenu popUpMenu = new JPopupMenu();
|
JPopupMenu popUpMenu = new JPopupMenu();
|
||||||
if (closeConfiguration.isClose())
|
if (closeConfiguration.isClose())
|
||||||
{
|
|
||||||
addItemCloseTab(popUpMenu, popupOnTab);
|
addItemCloseTab(popUpMenu, popupOnTab);
|
||||||
}
|
|
||||||
if (closeConfiguration.isCloseOthers())
|
if (closeConfiguration.isCloseOthers())
|
||||||
{
|
|
||||||
addItemCloseOtherTabs(popUpMenu, popupOnTab);
|
addItemCloseOtherTabs(popUpMenu, popupOnTab);
|
||||||
}
|
|
||||||
if (closeConfiguration.isCloseAll())
|
if (closeConfiguration.isCloseAll())
|
||||||
{
|
|
||||||
addItemCloseAllTabs(popUpMenu);
|
addItemCloseAllTabs(popUpMenu);
|
||||||
}
|
|
||||||
if (closeConfiguration.isCloseLefts())
|
if (closeConfiguration.isCloseLefts())
|
||||||
{
|
|
||||||
addItemCloseLeftTabs(popUpMenu, popupOnTab);
|
addItemCloseLeftTabs(popUpMenu, popupOnTab);
|
||||||
}
|
|
||||||
if (closeConfiguration.isCloseRights())
|
if (closeConfiguration.isCloseRights())
|
||||||
{
|
|
||||||
addItemCloseRightTabs(popUpMenu, popupOnTab);
|
addItemCloseRightTabs(popUpMenu, popupOnTab);
|
||||||
}
|
|
||||||
return popUpMenu;
|
return popUpMenu;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addItemCloseTab(JPopupMenu popUpMenu, Component popupOnTab)
|
protected void addItemCloseTab(JPopupMenu popUpMenu, Component popupOnTab)
|
||||||
{
|
{
|
||||||
addMenuItem(popUpMenu, "Close", e ->
|
addMenuItem(popUpMenu, "Close", e -> tabbedPaneCloser.removeComponent(popupOnTab));
|
||||||
{tabbedPaneCloser.removeComponent(popupOnTab);});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addItemCloseOtherTabs(JPopupMenu popUpMenu, Component popupOnTab)
|
protected void addItemCloseOtherTabs(JPopupMenu popUpMenu, Component popupOnTab)
|
||||||
|
@ -91,20 +85,17 @@ public class JTabbedPanePopupMenuTabsCloser extends AbstractJTabbedPanePopupMenu
|
||||||
|
|
||||||
protected void addItemCloseAllTabs(JPopupMenu popUpMenu)
|
protected void addItemCloseAllTabs(JPopupMenu popUpMenu)
|
||||||
{
|
{
|
||||||
addMenuItem(popUpMenu, "Close All", e ->
|
addMenuItem(popUpMenu, "Close All", e -> tabbedPaneCloser.removeAllComponents());
|
||||||
{tabbedPaneCloser.removeAllComponents();});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addItemCloseLeftTabs(JPopupMenu popUpMenu, Component popupOnTab)
|
protected void addItemCloseLeftTabs(JPopupMenu popUpMenu, Component popupOnTab)
|
||||||
{
|
{
|
||||||
addMenuItem(popUpMenu, "Close Lefts", e ->
|
addMenuItem(popUpMenu, "Close Lefts", e -> tabbedPaneCloser.removeLeftComponents(popupOnTab));
|
||||||
{tabbedPaneCloser.removeLeftComponents(popupOnTab);});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addItemCloseRightTabs(JPopupMenu popUpMenu, Component popupOnTab)
|
protected void addItemCloseRightTabs(JPopupMenu popUpMenu, Component popupOnTab)
|
||||||
{
|
{
|
||||||
addMenuItem(popUpMenu, "Close Rights", e ->
|
addMenuItem(popUpMenu, "Close Rights", e -> tabbedPaneCloser.removeRightComponents(popupOnTab));
|
||||||
{tabbedPaneCloser.removeRightComponents(popupOnTab);});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addMenuItem(JPopupMenu popUpMenu, String item, ActionListener listener)
|
protected void addMenuItem(JPopupMenu popUpMenu, String item, ActionListener listener)
|
||||||
|
|
|
@ -46,7 +46,7 @@ public class PopupMenuTabsCloseConfiguration
|
||||||
return close;
|
return close;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Close(boolean close)
|
public void close(boolean close)
|
||||||
{
|
{
|
||||||
this.close = close;
|
this.close = close;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user