Busy Status Cleanup
This commit is contained in:
parent
9e5b4527ed
commit
b99f6bf98a
20 changed files with 212 additions and 160 deletions
|
@ -18,24 +18,18 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.objectweb.asm.tree.ClassNode;
|
||||
import the.bytecode.club.bootloader.Boot;
|
||||
import the.bytecode.club.bytecodeviewer.api.ClassNodeLoader;
|
||||
import the.bytecode.club.bytecodeviewer.compilers.Compiler;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.*;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.TabbedPane;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourcelist.ResourceListPane;
|
||||
import the.bytecode.club.bytecodeviewer.gui.MainViewerGUI;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourcesearch.SearchBoxPane;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.WorkPaneMainComponent;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ResourceViewer;
|
||||
import the.bytecode.club.bytecodeviewer.obfuscators.mapping.Refactorer;
|
||||
import the.bytecode.club.bytecodeviewer.plugin.PluginManager;
|
||||
import the.bytecode.club.bytecodeviewer.util.*;
|
||||
import the.bytecode.club.bytecodeviewer.resources.importing.ImportResource;
|
||||
|
||||
import static javax.swing.JOptionPane.INFORMATION_MESSAGE;
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||
import static the.bytecode.club.bytecodeviewer.Settings.addRecentPlugin;
|
||||
import static the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent.DecompilerComponentTypes.JAVA;
|
||||
import static the.bytecode.club.bytecodeviewer.gui.components.DecompilerViewComponent.DecompilerComponentTypes.JAVA_AND_BYTECODE;
|
||||
import static the.bytecode.club.bytecodeviewer.util.MiscUtils.guessLanguage;
|
||||
|
||||
|
@ -440,7 +434,7 @@ public class BytecodeViewer
|
|||
* @return true if no errors, false if it failed to compile.
|
||||
*/
|
||||
public static boolean compile(boolean message, boolean successAlert) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
boolean noErrors = true;
|
||||
boolean actuallyTried = false;
|
||||
|
||||
|
@ -479,7 +473,7 @@ public class BytecodeViewer
|
|||
}
|
||||
}
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -499,7 +493,7 @@ public class BytecodeViewer
|
|||
SettingsSerializer.saveSettingsAsync();
|
||||
}
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Configuration.needsReDump = true;
|
||||
Thread t = new Thread(new ImportResource(files), "Import Resource");
|
||||
t.start();
|
||||
|
@ -534,13 +528,29 @@ public class BytecodeViewer
|
|||
public static void showMessage(String message) {
|
||||
BetterJOptionPane.showMessageDialog(viewer, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Alerts the user the program is running something in the background
|
||||
*/
|
||||
public static void updateBusyStatus(boolean busyStatus)
|
||||
{
|
||||
viewer.updateBusyStatus(busyStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clears all active busy status icons
|
||||
*/
|
||||
public static void clearBusyStatus()
|
||||
{
|
||||
viewer.clearBusyStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the workspace with optional user input required
|
||||
*
|
||||
* @param ask if should require user input or not
|
||||
*/
|
||||
public static void resetWorkSpace(boolean ask)
|
||||
public static void resetWorkspace(boolean ask)
|
||||
{
|
||||
if (ask)
|
||||
{
|
||||
|
@ -548,17 +558,12 @@ public class BytecodeViewer
|
|||
"Are you sure you want to reset the workspace?" +
|
||||
"\n\rIt will also reset your file navigator and search.",
|
||||
new String[]{"Yes", "No"});
|
||||
|
||||
|
||||
if (dialogue.promptChoice() != 0)
|
||||
return;
|
||||
}
|
||||
|
||||
files.clear();
|
||||
LazyNameUtil.reset();
|
||||
Objects.requireNonNull(MainViewerGUI.getComponent(ResourceListPane.class)).resetWorkspace();
|
||||
Objects.requireNonNull(MainViewerGUI.getComponent(WorkPaneMainComponent.class)).resetWorkspace();
|
||||
Objects.requireNonNull(MainViewerGUI.getComponent(SearchBoxPane.class)).resetWorkspace();
|
||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().clear();
|
||||
|
||||
BCVResourceUtils.resetWorkspace();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -579,8 +584,7 @@ public class BytecodeViewer
|
|||
|
||||
try {
|
||||
FileUtils.deleteDirectory(tempF);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
} catch (Exception ignored) { }
|
||||
|
||||
while (!tempF.exists()) // keep making dirs
|
||||
tempF.mkdir();
|
||||
|
@ -615,12 +619,12 @@ public class BytecodeViewer
|
|||
if(file == null)
|
||||
return;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
BytecodeViewer.openFiles(new File[]{file}, true);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} else if ((e.getKeyCode() == KeyEvent.VK_N) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
|
||||
Configuration.lastHotKeyExecuted = System.currentTimeMillis();
|
||||
BytecodeViewer.resetWorkSpace(true);
|
||||
BytecodeViewer.resetWorkspace(true);
|
||||
} else if ((e.getKeyCode() == KeyEvent.VK_T) && ((e.getModifiers() & KeyEvent.CTRL_MASK) != 0)) {
|
||||
Configuration.lastHotKeyExecuted = System.currentTimeMillis();
|
||||
Thread t = new Thread(() -> BytecodeViewer.compile(true, false), "Compile");
|
||||
|
@ -664,11 +668,11 @@ public class BytecodeViewer
|
|||
|
||||
final File file2 = file;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Thread jarExport = new Thread(() -> {
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(),
|
||||
file2.getAbsolutePath());
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Jar Export");
|
||||
jarExport.start();
|
||||
}
|
||||
|
@ -682,73 +686,4 @@ public class BytecodeViewer
|
|||
viewer.workPane.tabs.remove(viewer.workPane.getCurrentViewer());
|
||||
}
|
||||
}
|
||||
|
||||
public static File[] dumpTempFile(FileContainer container)
|
||||
{
|
||||
File[] files = new File[2];
|
||||
|
||||
//currently won't optimize if you've got two containers with the same name, will need to add this later
|
||||
if (!LazyNameUtil.SAME_NAME_JAR_WORKSPACE) {
|
||||
if (Configuration.krakatauTempJar != null && !Configuration.krakatauTempJar.exists()) {
|
||||
Configuration.needsReDump = true;
|
||||
}
|
||||
|
||||
if (Configuration.needsReDump && Configuration.krakatauTempJar != null) {
|
||||
Configuration.krakatauTempDir = null;
|
||||
Configuration.krakatauTempJar = null;
|
||||
}
|
||||
|
||||
boolean passes = false;
|
||||
|
||||
if (BytecodeViewer.viewer.viewPane1.getGroup().isSelected(BytecodeViewer.viewer.viewPane1.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane1.getGroup().isSelected(BytecodeViewer.viewer.viewPane1.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane2.getGroup().isSelected(BytecodeViewer.viewer.viewPane2.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane2.getGroup().isSelected(BytecodeViewer.viewer.viewPane2.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane3.getGroup().isSelected(BytecodeViewer.viewer.viewPane3.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane3.getGroup().isSelected(BytecodeViewer.viewer.viewPane3.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
|
||||
if (Configuration.krakatauTempJar != null || !passes) {
|
||||
files[0] = Configuration.krakatauTempJar;
|
||||
files[1] = Configuration.krakatauTempDir;
|
||||
return files;
|
||||
}
|
||||
}
|
||||
|
||||
Configuration.currentlyDumping = true;
|
||||
Configuration.needsReDump = false;
|
||||
Configuration.krakatauTempDir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
||||
Configuration.krakatauTempDir.mkdir();
|
||||
Configuration.krakatauTempJar = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
|
||||
//krakatauTempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils
|
||||
// .randomString(32) + ".jar."+container.name);
|
||||
JarUtils.saveAsJarClassesOnly(container.classes, Configuration.krakatauTempJar.getAbsolutePath());
|
||||
Configuration.currentlyDumping = false;
|
||||
|
||||
files[0] = Configuration.krakatauTempJar;
|
||||
files[1] = Configuration.krakatauTempDir;
|
||||
return files;
|
||||
}
|
||||
|
||||
public synchronized static void rtCheck() {
|
||||
if (Configuration.rt.isEmpty()) {
|
||||
if (RT_JAR.exists()) {
|
||||
Configuration.rt = RT_JAR.getAbsolutePath();
|
||||
} else if (RT_JAR_DUMPED.exists()) {
|
||||
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
|
||||
} else {
|
||||
try {
|
||||
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
|
||||
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -201,7 +201,7 @@ public class BytecodeViewer {
|
|||
* @param ask if it should ask the user about resetting the workspace
|
||||
*/
|
||||
public static void resetWorkSpace(boolean ask) {
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.resetWorkSpace(ask);
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.resetWorkspace(ask);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -211,7 +211,7 @@ public class BytecodeViewer {
|
|||
* @param busy if it should display the busy icon or not
|
||||
*/
|
||||
public static void setBusy(boolean busy) {
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.viewer.updateBusyStatus(busy);
|
||||
the.bytecode.club.bytecodeviewer.BytecodeViewer.updateBusyStatus(busy);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -33,7 +33,7 @@ public abstract class Plugin extends Thread
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ public abstract class Plugin extends Thread
|
|||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||
} finally {
|
||||
finished = true;
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
|||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
import the.bytecode.club.bytecodeviewer.Constants;
|
||||
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
|
||||
import the.bytecode.club.bytecodeviewer.util.BCVResourceUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.ZipUtils;
|
||||
|
@ -70,7 +71,7 @@ public class KrakatauDecompiler extends InternalDecompiler
|
|||
BytecodeViewer.viewer.selectPythonC();
|
||||
}
|
||||
|
||||
BytecodeViewer.rtCheck();
|
||||
BCVResourceUtils.rtCheck();
|
||||
if (Configuration.rt.isEmpty()) {
|
||||
BytecodeViewer.showMessage("You need to set your JRE RT Library.\r\n(C:\\Program Files (x86)"
|
||||
+ "\\Java\\jre7\\lib\\rt.jar)");
|
||||
|
@ -243,7 +244,8 @@ public class KrakatauDecompiler extends InternalDecompiler
|
|||
BytecodeViewer.showMessage("You need to set your Python (or PyPy for speed) 2.7 executable path.");
|
||||
BytecodeViewer.viewer.selectPythonC();
|
||||
}
|
||||
BytecodeViewer.rtCheck();
|
||||
|
||||
BCVResourceUtils.rtCheck();
|
||||
if (Configuration.rt.isEmpty()) {
|
||||
BytecodeViewer.showMessage("You need to set your JRE RT Library." +
|
||||
"\r\n(C:\\Program Files (x86)\\Java\\jre7\\lib\\rt.jar)");
|
||||
|
|
|
@ -332,7 +332,7 @@ public class MainViewerGUI extends JFrame
|
|||
saveAsZip.setActionCommand("");
|
||||
|
||||
addResource.addActionListener(e -> selectFile());
|
||||
newWorkSpace.addActionListener(e -> BytecodeViewer.resetWorkSpace(true));
|
||||
newWorkSpace.addActionListener(e -> BytecodeViewer.resetWorkspace(true));
|
||||
reloadResources.addActionListener(arg0 -> reloadResources());
|
||||
runButton.addActionListener(e -> runResources());
|
||||
compileButton.addActionListener(arg0 -> compileOnNewThread());
|
||||
|
@ -840,9 +840,9 @@ public class MainViewerGUI extends JFrame
|
|||
if(file == null)
|
||||
return;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
BytecodeViewer.openFiles(new File[]{file}, true);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
|
||||
public void selectPythonC()
|
||||
|
@ -932,9 +932,9 @@ public class MainViewerGUI extends JFrame
|
|||
if(file == null)
|
||||
return;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
BytecodeViewer.startPlugin(file);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
SettingsSerializer.saveSettingsAsync();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,11 +60,11 @@ public class ExportJar extends JFrame
|
|||
|
||||
btnNewButton.addActionListener(arg0 ->
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Thread t = new Thread(() ->
|
||||
{
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), jarPath, manifest.getText());
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Jar Export");
|
||||
t.start();
|
||||
dispose();
|
||||
|
|
|
@ -62,7 +62,7 @@ public class ResourceViewProcessing extends PaneUpdaterThread
|
|||
{
|
||||
try
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
if (resourceViewPanel.decompiler != Decompiler.NONE)
|
||||
{
|
||||
|
@ -138,7 +138,7 @@ public class ResourceViewProcessing extends PaneUpdaterThread
|
|||
finally
|
||||
{
|
||||
viewer.resetDivider();
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
SwingUtilities.invokeLater(() ->
|
||||
{
|
||||
if (button != null)
|
||||
|
|
|
@ -35,13 +35,13 @@ public class WorkPaneRefresh implements Runnable
|
|||
if(tabComp == null)
|
||||
return;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
if (tabComp instanceof ClassViewer)
|
||||
((ClassViewer) tabComp).startPaneUpdater(src);
|
||||
else if (tabComp instanceof FileViewer)
|
||||
((FileViewer) tabComp).refresh(src);
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.objectweb.asm.tree.ClassNode;
|
|||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
import the.bytecode.club.bytecodeviewer.SettingsSerializer;
|
||||
import the.bytecode.club.bytecodeviewer.util.BCVResourceUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.FileContainer;
|
||||
import the.bytecode.club.bytecodeviewer.util.MethodParser;
|
||||
|
||||
|
@ -155,7 +156,8 @@ public class ClassViewer extends ResourceViewer
|
|||
|
||||
Thread t = new Thread(() ->
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
while (Configuration.currentlyDumping)
|
||||
{
|
||||
//wait until it's not dumping
|
||||
|
@ -165,9 +167,10 @@ public class ClassViewer extends ResourceViewer
|
|||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
tempFiles = BytecodeViewer.dumpTempFile(container);
|
||||
|
||||
tempFiles = BCVResourceUtils.dumpTempFile(container);
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
|
||||
if (resourceViewPanel1.decompiler != Decompiler.NONE)
|
||||
resourceViewPanel1.updateThread.startNewThread();
|
||||
|
|
|
@ -33,12 +33,12 @@ public abstract class JavaObfuscator extends Thread {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Configuration.runningObfuscation = true;
|
||||
obfuscate();
|
||||
BytecodeViewer.refactorer.run();
|
||||
Configuration.runningObfuscation = false;
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
|
||||
public int getStringLength() {
|
||||
|
|
|
@ -143,7 +143,7 @@ public class EZInjection extends Plugin {
|
|||
@Override
|
||||
public void execute(ArrayList<ClassNode> classNodeList)
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
gui.setText("");
|
||||
|
||||
if (console)
|
||||
|
@ -315,6 +315,6 @@ public class EZInjection extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import the.bytecode.club.bytecodeviewer.Configuration;
|
|||
import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
|
||||
import the.bytecode.club.bytecodeviewer.decompilers.Decompiler;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
|
||||
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.viewer.ClassViewer;
|
||||
import the.bytecode.club.bytecodeviewer.util.DialogueUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.JarUtils;
|
||||
import the.bytecode.club.bytecodeviewer.util.MiscUtils;
|
||||
|
@ -72,7 +73,7 @@ public class ResourceDecompiling
|
|||
if (options[k].equals(obj))
|
||||
result = k;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
File tempZip = new File(tempDirectory + fs + "temp_" + MiscUtils.getRandomizedName() + ".jar");
|
||||
if (tempZip.exists())
|
||||
|
@ -85,7 +86,7 @@ public class ResourceDecompiling
|
|||
try {
|
||||
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-proycon.zip"));
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -93,10 +94,10 @@ public class ResourceDecompiling
|
|||
t12.start();
|
||||
Thread t2 = new Thread(() -> {
|
||||
try {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Decompiler.CFR_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-CFR.zip"));
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -104,10 +105,10 @@ public class ResourceDecompiling
|
|||
t2.start();
|
||||
Thread t3 = new Thread(() -> {
|
||||
try {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-fernflower.zip"));
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -115,10 +116,10 @@ public class ResourceDecompiling
|
|||
t3.start();
|
||||
Thread t4 = new Thread(() -> {
|
||||
try {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(),
|
||||
MiscUtils.append(javaSucks, "-kraktau.zip"));
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -129,7 +130,7 @@ public class ResourceDecompiling
|
|||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -140,7 +141,7 @@ public class ResourceDecompiling
|
|||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompiler.CFR_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -151,7 +152,7 @@ public class ResourceDecompiling
|
|||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ public class ResourceDecompiling
|
|||
Thread t12 = new Thread(() -> {
|
||||
try {
|
||||
Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileToZip(tempZip.getAbsolutePath(), path);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
|
@ -172,7 +173,7 @@ public class ResourceDecompiling
|
|||
}
|
||||
|
||||
if (result == 5) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
}
|
||||
}, "Decompile Thread");
|
||||
|
@ -181,12 +182,20 @@ public class ResourceDecompiling
|
|||
|
||||
public static void decompileSaveOpenedOnly()
|
||||
{
|
||||
if (BytecodeViewer.viewer.workPane.getCurrentViewer() == null) {
|
||||
if (BytecodeViewer.getLoadedClasses().isEmpty())
|
||||
{
|
||||
BytecodeViewer.showMessage("First open a class, jar, zip, apk or dex file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread decompileThread = new Thread(() -> {
|
||||
if (BytecodeViewer.viewer.workPane.getCurrentViewer() == null || !(BytecodeViewer.viewer.workPane.getCurrentViewer() instanceof ClassViewer))
|
||||
{
|
||||
BytecodeViewer.showMessage("First open a class file.");
|
||||
return;
|
||||
}
|
||||
|
||||
Thread decompileThread = new Thread(() ->
|
||||
{
|
||||
if (BytecodeViewer.autoCompileSuccessful())
|
||||
return;
|
||||
|
||||
|
@ -195,7 +204,6 @@ public class ResourceDecompiling
|
|||
if (s == null)
|
||||
return;
|
||||
|
||||
|
||||
JFileChooser fc = new FileChooser(Configuration.getLastDirectory(),
|
||||
"Select Java Files",
|
||||
"Java Source Files",
|
||||
|
@ -207,8 +215,8 @@ public class ResourceDecompiling
|
|||
Configuration.lastDirectory = fc.getSelectedFile().getAbsolutePath();
|
||||
File file = fc.getSelectedFile();
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
final String path = MiscUtils.append(file, ".java"); // cheap hax because string is final
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
final String path = MiscUtils.append(file, ".java");
|
||||
|
||||
if (!DialogueUtils.canOverwriteFile(path))
|
||||
return;
|
||||
|
@ -271,9 +279,9 @@ public class ResourceDecompiling
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
new ExceptionUI(e);
|
||||
}
|
||||
});
|
||||
|
@ -296,9 +304,9 @@ public class ResourceDecompiling
|
|||
}
|
||||
String contents = Decompiler.PROCYON_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
|
@ -322,9 +330,9 @@ public class ResourceDecompiling
|
|||
}
|
||||
String contents = Decompiler.CFR_DECOMPILER.getDecompiler().decompileClassNode(cn, cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
|
@ -350,9 +358,9 @@ public class ResourceDecompiling
|
|||
String contents = Decompiler.FERNFLOWER_DECOMPILER.getDecompiler().decompileClassNode(cn,
|
||||
cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
|
@ -378,9 +386,9 @@ public class ResourceDecompiling
|
|||
String contents = Decompiler.KRAKATAU_DECOMPILER.getDecompiler().decompileClassNode(cn,
|
||||
cw.toByteArray());
|
||||
DiskWriter.replaceFile(path, contents, false);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
} catch (Exception e) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
new ExceptionUI(
|
||||
e);
|
||||
}
|
||||
|
@ -388,7 +396,7 @@ public class ResourceDecompiling
|
|||
t1.start();
|
||||
}
|
||||
if (result == 5) {
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
}
|
||||
}, "Decompile Thread");
|
||||
|
|
|
@ -92,14 +92,14 @@ public class APKExport implements Exporter
|
|||
|
||||
Thread saveThread = new Thread(() ->
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||
|
||||
Thread buildAPKThread = new Thread(() ->
|
||||
{
|
||||
APKTool.buildAPK(new File(input), file2, finalContainer);
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Process APK");
|
||||
buildAPKThread.start();
|
||||
}, "Jar Export");
|
||||
|
|
|
@ -58,7 +58,7 @@ public class DexExport implements Exporter
|
|||
|
||||
Thread saveAsJar = new Thread(() ->
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
final String input = tempDirectory + fs + MiscUtils.getRandomizedName() + ".jar";
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), input);
|
||||
|
||||
|
@ -66,7 +66,7 @@ public class DexExport implements Exporter
|
|||
{
|
||||
Dex2Jar.saveAsDex(new File(input), outputPath);
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Process DEX");
|
||||
saveAsDex.start();
|
||||
}, "Jar Export");
|
||||
|
|
|
@ -50,11 +50,11 @@ public class ZipExport implements Exporter
|
|||
|
||||
final File file2 = file;
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
Thread saveThread = new Thread(() ->
|
||||
{
|
||||
JarUtils.saveAsJar(BytecodeViewer.getLoadedClasses(), file2.getAbsolutePath());
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}, "Jar Export");
|
||||
saveThread.start();
|
||||
}
|
||||
|
|
|
@ -99,7 +99,7 @@ public class ImportResource implements Runnable
|
|||
}
|
||||
finally
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
|
||||
if (update)
|
||||
try {
|
||||
|
|
|
@ -22,7 +22,7 @@ public class APKResourceImporter implements Importer
|
|||
public boolean open(File file) throws Exception
|
||||
{
|
||||
try {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".apk");
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class APKResourceImporter implements Importer
|
|||
|
||||
container.classes = JarUtils.loadClasses(output);
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
BytecodeViewer.files.add(container);
|
||||
} catch (final Exception e) {
|
||||
new ExceptionUI(e);
|
||||
|
|
|
@ -21,7 +21,7 @@ public class DEXResourceImporter implements Importer
|
|||
public boolean open(File file) throws Exception
|
||||
{
|
||||
try {
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
|
||||
File tempCopy = new File(tempDirectory + fs + MiscUtils.randomString(32) + ".dex");
|
||||
|
||||
|
@ -39,7 +39,7 @@ public class DEXResourceImporter implements Importer
|
|||
|
||||
container.classes = JarUtils.loadClasses(output);
|
||||
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
BytecodeViewer.files.add(container);
|
||||
} catch (final Exception e) {
|
||||
new ExceptionUI(e);
|
||||
|
|
|
@ -41,9 +41,9 @@ public abstract class BackgroundSearchThread extends Thread
|
|||
@Override
|
||||
public void run()
|
||||
{
|
||||
BytecodeViewer.viewer.updateBusyStatus(true);
|
||||
BytecodeViewer.updateBusyStatus(true);
|
||||
search();
|
||||
finished = true;
|
||||
BytecodeViewer.viewer.updateBusyStatus(false);
|
||||
BytecodeViewer.updateBusyStatus(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,104 @@
|
|||
package the.bytecode.club.bytecodeviewer.util;
|
||||
|
||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||
import the.bytecode.club.bytecodeviewer.Configuration;
|
||||
import the.bytecode.club.bytecodeviewer.gui.components.MultipleChoiceDialogue;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.*;
|
||||
import static the.bytecode.club.bytecodeviewer.Constants.RT_JAR_DUMPED;
|
||||
|
||||
/**
|
||||
* @author Konloch
|
||||
* @since 7/6/2021
|
||||
*/
|
||||
public class BCVResourceUtils
|
||||
{
|
||||
public static void resetWorkspace()
|
||||
{
|
||||
BytecodeViewer.files.clear();
|
||||
LazyNameUtil.reset();
|
||||
BytecodeViewer.viewer.resourcePane.resetWorkspace();
|
||||
BytecodeViewer.viewer.workPane.resetWorkspace();
|
||||
BytecodeViewer.viewer.searchBoxPane.resetWorkspace();
|
||||
the.bytecode.club.bytecodeviewer.api.BytecodeViewer.getClassNodeLoader().clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps the loaded classes as a library to be used for Krakatau
|
||||
*/
|
||||
public static File[] dumpTempFile(FileContainer container)
|
||||
{
|
||||
File[] files = new File[2];
|
||||
|
||||
//currently won't optimize if you've got two containers with the same name, will need to add this later
|
||||
if (!LazyNameUtil.SAME_NAME_JAR_WORKSPACE)
|
||||
{
|
||||
if (Configuration.krakatauTempJar != null && !Configuration.krakatauTempJar.exists())
|
||||
Configuration.needsReDump = true;
|
||||
|
||||
if (Configuration.needsReDump && Configuration.krakatauTempJar != null)
|
||||
{
|
||||
Configuration.krakatauTempDir = null;
|
||||
Configuration.krakatauTempJar = null;
|
||||
}
|
||||
|
||||
boolean passes = false;
|
||||
|
||||
if (BytecodeViewer.viewer.viewPane1.getGroup().isSelected(BytecodeViewer.viewer.viewPane1.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane1.getGroup().isSelected(BytecodeViewer.viewer.viewPane1.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
|
||||
else if (BytecodeViewer.viewer.viewPane2.getGroup().isSelected(BytecodeViewer.viewer.viewPane2.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane2.getGroup().isSelected(BytecodeViewer.viewer.viewPane2.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
|
||||
else if (BytecodeViewer.viewer.viewPane3.getGroup().isSelected(BytecodeViewer.viewer.viewPane3.getKrakatau().getJava().getModel()))
|
||||
passes = true;
|
||||
else if (BytecodeViewer.viewer.viewPane3.getGroup().isSelected(BytecodeViewer.viewer.viewPane3.getKrakatau().getBytecode().getModel()))
|
||||
passes = true;
|
||||
|
||||
if (Configuration.krakatauTempJar != null || !passes)
|
||||
{
|
||||
files[0] = Configuration.krakatauTempJar;
|
||||
files[1] = Configuration.krakatauTempDir;
|
||||
return files;
|
||||
}
|
||||
}
|
||||
|
||||
Configuration.currentlyDumping = true;
|
||||
Configuration.needsReDump = false;
|
||||
Configuration.krakatauTempDir = new File(tempDirectory + fs + MiscUtils.randomString(32) + fs);
|
||||
Configuration.krakatauTempDir.mkdir();
|
||||
Configuration.krakatauTempJar = new File(tempDirectory + fs + "temp" + MiscUtils.randomString(32) + ".jar");
|
||||
//krakatauTempJar = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "temp" + MiscUtils
|
||||
// .randomString(32) + ".jar."+container.name);
|
||||
JarUtils.saveAsJarClassesOnly(container.classes, Configuration.krakatauTempJar.getAbsolutePath());
|
||||
Configuration.currentlyDumping = false;
|
||||
|
||||
files[0] = Configuration.krakatauTempJar;
|
||||
files[1] = Configuration.krakatauTempDir;
|
||||
return files;
|
||||
}
|
||||
|
||||
//rt.jar check
|
||||
public synchronized static void rtCheck()
|
||||
{
|
||||
if (Configuration.rt.isEmpty())
|
||||
{
|
||||
if (RT_JAR.exists())
|
||||
Configuration.rt = RT_JAR.getAbsolutePath();
|
||||
else if (RT_JAR_DUMPED.exists())
|
||||
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
|
||||
else try {
|
||||
JRTExtractor.extractRT(RT_JAR_DUMPED.getAbsolutePath());
|
||||
Configuration.rt = RT_JAR_DUMPED.getAbsolutePath();
|
||||
} catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue