Code Cleanup

This commit is contained in:
Konloch 2024-09-29 19:47:50 -06:00
parent fb825589c3
commit 5dab52bfd3

AI 샘플 코드 생성 중입니다

Loading...
22 changed files with 126 additions and 67 deletions

View File

@ -42,7 +42,11 @@ public class Configuration
public static boolean python3Extra = false;
public static String rt = "";
public static String library = "";
public static String java = Constants.JAVA_BINARY.exists() ? Constants.JAVA_BINARY.getAbsolutePath() : Constants.JAVA_BINARY_NIX.exists() ? Constants.JAVA_BINARY_NIX.getAbsolutePath() : "";
public static String java = Constants.JAVA_BINARY.exists()
? Constants.JAVA_BINARY.getAbsolutePath()
: Constants.JAVA_BINARY_NIX.exists()
? Constants.JAVA_BINARY_NIX.getAbsolutePath()
: "";
public static String javac = "";
public static String javaTools = "";
public static File krakatauTempDir;

View File

@ -60,8 +60,11 @@ public class Constants
//version is set via maven
public static final String VERSION = getVersion(BytecodeViewer.class.getPackage().getImplementationVersion());
//CHECKSTYLE:OFF
//dev mode is just a check for running via IDE
public static boolean DEV_MODE;
//CHECKSTYLE:ON
//if true the version checker will prompt and ask how you would like to proceed
public static final boolean FORCE_VERSION_CHECKER_PROMPT = false;
@ -71,7 +74,7 @@ public class Constants
public static final String[] SUPPORTED_FILE_EXTENSIONS = ResourceType.SUPPORTED_BCV_EXTENSION_MAP.keySet().toArray(new String[0]);
public static final int ASM_VERSION = Opcodes.ASM9;
public static final File BCVDir = resolveBCVRoot();
public static final File BCV_DIR = 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");
@ -119,18 +122,18 @@ public class Constants
*/
public static String getBCVDirectory()
{
while (!BCVDir.exists())
BCVDir.mkdirs();
while (!BCV_DIR.exists())
BCV_DIR.mkdirs();
//hides the BCV directory
if (isWindows() && !BCVDir.isHidden())
if (isWindows() && !BCV_DIR.isHidden())
{
new Thread(() ->
{
try
{
// Hide file by running attrib system command (on Windows)
Process p = new ProcessBuilder("attrib", "+H", BCVDir.getAbsolutePath()).start();
Process p = new ProcessBuilder("attrib", "+H", BCV_DIR.getAbsolutePath()).start();
}
catch (Exception e)
{
@ -139,7 +142,7 @@ public class Constants
}, "Hide BCV Dir").start();
}
return BCVDir.getAbsolutePath();
return BCV_DIR.getAbsolutePath();
}
/**

View File

@ -141,7 +141,9 @@ public class ExceptionUI extends JFrameConsole
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");
+ "\nBytecode Viewer Version: " + VERSION + fatJar
+ ", OS: " + System.getProperty("os.name")
+ ", Java: " + System.getProperty("java.version");
}
private static final long serialVersionUID = -5230501978224926296L;

View File

@ -331,7 +331,8 @@ public class Boot
while (temp.exists())
temp.delete();
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" + krakatauVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp))
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("Krakatau-" + krakatauVersion + ".zip");
FileOutputStream baos = new FileOutputStream(temp))
{
int r;
byte[] buffer = new byte[8192];
@ -368,7 +369,8 @@ public class Boot
while (temp.exists())
temp.delete();
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("enjarify-" + Constants.enjarifyVersion + ".zip"); FileOutputStream baos = new FileOutputStream(temp))
try (InputStream is = BytecodeViewer.class.getClassLoader().getResourceAsStream("enjarify-" + Constants.enjarifyVersion + ".zip");
FileOutputStream baos = new FileOutputStream(temp))
{
int r;
byte[] buffer = new byte[8192];
@ -405,7 +407,8 @@ public class Boot
setState("Bytecode Viewer Boot Screen - 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);
byte[] buffer = new byte[8192];

View File

@ -118,7 +118,8 @@ public class UpdateCheck implements Runnable
if (Desktop.isDesktopSupported())
Desktop.getDesktop().browse(new URI("https://github.com/Konloch/bytecode-viewer/releases"));
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)
{
@ -234,7 +235,8 @@ public class UpdateCheck implements Runnable
private static void download(String url, File saveTo, Runnable onFinish) throws Exception
{
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))
{

View File

@ -178,7 +178,15 @@ public class CommandLineInput
//if its zip/jar/apk/dex attempt unzip as whole zip
//if its just class allow any
if (decompiler != null && !decompiler.equalsIgnoreCase("procyon") && !decompiler.equalsIgnoreCase("cfr") && !decompiler.equalsIgnoreCase("fernflower") && !decompiler.equalsIgnoreCase("krakatau") && !decompiler.equalsIgnoreCase("krakatau-bytecode") && !decompiler.equalsIgnoreCase("jd-gui") && !decompiler.equalsIgnoreCase("smali") && !decompiler.equalsIgnoreCase("asmifier"))
if (decompiler != null
&& !decompiler.equalsIgnoreCase("procyon")
&& !decompiler.equalsIgnoreCase("cfr")
&& !decompiler.equalsIgnoreCase("fernflower")
&& !decompiler.equalsIgnoreCase("krakatau")
&& !decompiler.equalsIgnoreCase("krakatau-bytecode")
&& !decompiler.equalsIgnoreCase("jd-gui")
&& !decompiler.equalsIgnoreCase("smali")
&& !decompiler.equalsIgnoreCase("asmifier"))
{
System.out.println("Error, no decompiler called '" + decompiler + "' found. Type -list" + " for the list");
}

View File

@ -69,6 +69,7 @@ public class InstructionPrinter implements Opcodes
this(m, args);
InstructionSearcher searcher = new InstructionSearcher(m.instructions, pattern);
match = searcher.search();
if (match)
{
for (AbstractInsnNode[] ains : searcher.getMatches())
@ -102,6 +103,7 @@ public class InstructionPrinter implements Opcodes
{
firstLabel = false;
info.clear();
for (AbstractInsnNode ain : mNode.instructions)
{
String line = printInstruction(ain);
@ -114,8 +116,10 @@ public class InstructionPrinter implements Opcodes
info.add(line);
}
}
if (firstLabel && BytecodeViewer.viewer.appendBracketsToLabels.isSelected())
info.add("}");
return info;
}
@ -169,18 +173,14 @@ public class InstructionPrinter implements Opcodes
if (BytecodeViewer.viewer.debugHelpers.isSelected())
{
if (vin.var == 0 && !Modifier.isStatic(mNode.access))
{
sb.append(" // reference to self");
}
else
{
final int refIndex = vin.var - (Modifier.isStatic(mNode.access) ? 0 : 1);
if (refIndex >= 0 && refIndex < args.length - 1)
{
sb.append(" // reference to ").append(args[refIndex].name);
}
}
}
return sb.toString();
}
@ -229,9 +229,11 @@ public class InstructionPrinter implements Opcodes
protected String printLdcInsnNode(LdcInsnNode ldc)
{
if (ldc.cst instanceof String)
return nameOpcode(ldc.getOpcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString()) + "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
return nameOpcode(ldc.getOpcode()) + " \"" + StringEscapeUtils.escapeJava(ldc.cst.toString())
+ "\" (" + ldc.cst.getClass().getCanonicalName() + ")";
return nameOpcode(ldc.getOpcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString()) + " (" + ldc.cst.getClass().getCanonicalName() + ")";
return nameOpcode(ldc.getOpcode()) + " " + StringEscapeUtils.escapeJava(ldc.cst.toString())
+ " (" + ldc.cst.getClass().getCanonicalName() + ")";
}
protected String printInsnNode(InsnNode in)
@ -270,6 +272,7 @@ public class InstructionPrinter implements Opcodes
String starting = tcbs.stream().filter(tcb -> tcb.start == label).map(tcb -> "start TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
String ending = tcbs.stream().filter(tcb -> tcb.end == label).map(tcb -> "end TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
String handlers = tcbs.stream().filter(tcb -> tcb.handler == label).map(tcb -> "handle TCB" + tcbs.indexOf(tcb)).collect(Collectors.joining(", "));
if (!ending.isEmpty())
info.add("// " + ending);
if (!starting.isEmpty())
@ -325,10 +328,12 @@ public class InstructionPrinter implements Opcodes
StringBuilder line = new StringBuilder(nameOpcode(tin.getOpcode()) + " \n");
List<?> labels = tin.labels;
int count = 0;
for (int i = tin.min; i < tin.max + 1; i++)
{
line.append(" val: ").append(i).append(" -> ").append("L").append(resolveLabel((LabelNode) labels.get(count++))).append("\n");
}
line.append(" default" + " -> L").append(resolveLabel(tin.dflt));
return line.toString();
}
@ -408,6 +413,7 @@ public class InstructionPrinter implements Opcodes
{
if (obj instanceof LabelNode)
return "label [L" + resolveLabel((LabelNode) obj) + "]";
if (obj instanceof Integer)
{
switch ((int) obj)
@ -430,8 +436,10 @@ public class InstructionPrinter implements Opcodes
return "unknown";
}
}
if (obj instanceof String)
return obj.toString();
return "unknown [" + obj.toString() + "]";
}

View File

@ -44,6 +44,5 @@ public class ASMTextifierDisassembler extends InternalDecompiler
@Override
public void decompileToZip(String sourceJar, String zipName)
{
}
}

View File

@ -59,7 +59,7 @@ public class HTMLPane extends JEditorPane
text = text.replace("{fatJar}", String.valueOf(FAT_JAR));
text = text.replace("{java}", Configuration.java);
text = text.replace("{javac}", Configuration.javac);
text = text.replace("{bcvDir}", BCVDir.getAbsolutePath());
text = text.replace("{bcvDir}", BCV_DIR.getAbsolutePath());
text = text.replace("{python}", Configuration.python2 + " " + (Configuration.python2Extra ? "-2" : ""));
text = text.replace("{python3}", Configuration.python3 + " " + (Configuration.python3Extra ? "-3" : ""));
text = text.replace("{rt}", Configuration.rt);

View File

@ -49,8 +49,7 @@ public enum LAFTheme
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),
;
HIGH_CONTRAST_LIGHT("High Contrast Light Theme", RSTATheme.THEME_MATCH, TranslatedComponents.HIGH_CONTRAST_LIGHT_THEME);
private final String readableName;
private final RSTATheme rstaTheme;

View File

@ -38,7 +38,12 @@ public enum RSTATheme
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
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 file;

View File

@ -45,7 +45,8 @@ public class RenameFields extends JavaObfuscator
{
FieldNode f = (FieldNode) o;
String newName = generateUniqueName(stringLength);
ASMResourceUtil.renameFieldNode(c.name, f.name, f.desc, null, newName, null);
ASMResourceUtil.renameFieldNode(c.name, f.name, f.desc,
null, newName, null);
f.name = newName;
}
}

View File

@ -50,7 +50,8 @@ public class RenameMethods extends JavaObfuscator
if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>"))
{
String newName = generateUniqueName(stringLength);
ASMResourceUtil.renameMethodNode(c.name, m.name, m.desc, null, newName, null);
ASMResourceUtil.renameMethodNode(c.name, m.name, m.desc,
null, newName, null);
}
}
}

View File

@ -176,7 +176,11 @@ public abstract class Remapper extends org.objectweb.asm.commons.Remapper
if (value instanceof Handle)
{
Handle h = (Handle) value;
return new Handle(h.getTag(), mapType(h.getOwner()), mapMethodName(h.getOwner(), h.getName(), h.getDesc()), mapMethodDesc(h.getDesc()), h.getTag() == Opcodes.H_INVOKEINTERFACE);
return new Handle(h.getTag(),
mapType(h.getOwner()),
mapMethodName(h.getOwner(), h.getName(), h.getDesc()),
mapMethodDesc(h.getDesc()),
h.getTag() == Opcodes.H_INVOKEINTERFACE);
}
return value;

View File

@ -39,7 +39,7 @@ public class RenameClasses extends JavaObfuscator
{
if (Configuration.runningObfuscation)
{
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" + ".");
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
return;
}
@ -75,9 +75,6 @@ public class RenameClasses extends JavaObfuscator
String newName = generateUniqueName(stringLength);
BytecodeViewer.refactorer.getHooks().addClass(new MappingData(c.name, newName));
/*ASMUtil_OLD.renameClassNode(c.name, newName);
c.name = newName;*/
}
System.out.println("Obfuscated class names.");

View File

@ -64,9 +64,6 @@ public class RenameFields extends JavaObfuscator
String newName = generateUniqueName(stringLength);
BytecodeViewer.refactorer.getHooks().addField(new FieldMappingData(c.name, new MappingData(f.name, newName), f.desc));
/*ASMUtil_OLD.renameFieldNode(c.name, f.name, f.desc, null, newName, null);
f.name = newName;*/
}
}

View File

@ -40,7 +40,7 @@ public class RenameMethods extends JavaObfuscator
{
if (Configuration.runningObfuscation)
{
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish" + ".");
BytecodeViewer.showMessage("You're currently running an obfuscation task, wait for this to finish.");
return;
}
@ -66,16 +66,20 @@ public class RenameMethods extends JavaObfuscator
if ((m.access & Opcodes.ACC_NATIVE) != 0)
continue;
if (m.access != Opcodes.ACC_ABSTRACT && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PRIVATE && m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PROTECTED)
if (m.access != Opcodes.ACC_ABSTRACT
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PUBLIC
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PRIVATE
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_STATIC + Opcodes.ACC_PROTECTED
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PUBLIC
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PRIVATE
&& m.access != Opcodes.ACC_ABSTRACT + Opcodes.ACC_PROTECTED)
{
if (!m.name.equals("main") && !m.name.equals("<init>") && !m.name.equals("<clinit>"))
{
String newName = generateUniqueName(stringLength);
BytecodeViewer.refactorer.getHooks().addMethod(new MethodMappingData(c.name, new MappingData(m.name, newName), m.desc));
/*ASMUtil_OLD.renameMethodNode(c.name, m.name, m.desc,
null, newName, null);*/
}
}
}

View File

@ -45,9 +45,9 @@ import java.util.*;
public final class PluginManager
{
private static final Map<String, PluginLaunchStrategy> launchStrategies = new HashMap<>();
private static final PluginFileFilter filter = new PluginFileFilter();
private static final List<Plugin> pluginInstances = new ArrayList<>();
private static final Map<String, PluginLaunchStrategy> LAUNCH_STRATEGIES = new HashMap<>();
private static final PluginFileFilter FILTER = new PluginFileFilter();
private static final List<Plugin> PLUGIN_INSTANCES = new ArrayList<>();
//TODO this system needs to be redone, currently it will conflict if more than one plugin is ran at the same time
// the solution is to tie the plugin object into the plugin console,
@ -63,21 +63,21 @@ public final class PluginManager
static
{
launchStrategies.put("jar", new CompiledJavaPluginLaunchStrategy());
launchStrategies.put("java", new JavaPluginLaunchStrategy());
launchStrategies.put("js", new JavascriptPluginLaunchStrategy());
LAUNCH_STRATEGIES.put("jar", new CompiledJavaPluginLaunchStrategy());
LAUNCH_STRATEGIES.put("java", new JavaPluginLaunchStrategy());
LAUNCH_STRATEGIES.put("js", new JavascriptPluginLaunchStrategy());
GroovyPluginLaunchStrategy groovy = new GroovyPluginLaunchStrategy();
launchStrategies.put("gy", groovy);
launchStrategies.put("groovy", groovy);
LAUNCH_STRATEGIES.put("gy", groovy);
LAUNCH_STRATEGIES.put("groovy", groovy);
PythonPluginLaunchStrategy python = new PythonPluginLaunchStrategy();
launchStrategies.put("py", python);
launchStrategies.put("python", python);
LAUNCH_STRATEGIES.put("py", python);
LAUNCH_STRATEGIES.put("python", python);
RubyPluginLaunchStrategy ruby = new RubyPluginLaunchStrategy();
launchStrategies.put("rb", ruby);
launchStrategies.put("ruby", ruby);
LAUNCH_STRATEGIES.put("rb", ruby);
LAUNCH_STRATEGIES.put("ruby", ruby);
}
/**
@ -106,10 +106,10 @@ public final class PluginManager
activePlugin = newPluginInstance;
//clean the plugin list from dead threads
pluginInstances.removeIf(Plugin::isFinished);
PLUGIN_INSTANCES.removeIf(Plugin::isFinished);
//add to the list of running instances
pluginInstances.add(newPluginInstance);
PLUGIN_INSTANCES.add(newPluginInstance);
//start the plugin thread
newPluginInstance.start();
@ -124,10 +124,11 @@ public final class PluginManager
public static void runPlugin(File f) throws Throwable
{
String ext = f.getName().substring(f.getName().lastIndexOf('.') + 1);
PluginLaunchStrategy strategy = launchStrategies.get(ext);
PluginLaunchStrategy strategy = LAUNCH_STRATEGIES.get(ext);
if (strategy == null)
throw new RuntimeException(String.format("No launch strategy for extension %s (%s)", ext, f.getAbsolutePath()));
throw new RuntimeException(String.format("No launch strategy for extension %s (%s)",
ext, f.getAbsolutePath()));
Plugin p = strategy.run(f);
@ -147,7 +148,9 @@ public final class PluginManager
return;
}
final String name = activePlugin.activeContainer == null ? "#" + (activeTabbedException.getTabbedPane().getTabCount() + 1) : activePlugin.activeContainer.name;
final String name = activePlugin.activeContainer == null
? "#" + (activeTabbedException.getTabbedPane().getTabCount() + 1)
: activePlugin.activeContainer.name;
ExceptionUI existingUI = exceptionTabs.get(name);
@ -198,22 +201,22 @@ public final class PluginManager
public static void register(String name, PluginLaunchStrategy strat)
{
launchStrategies.put(name, strat);
LAUNCH_STRATEGIES.put(name, strat);
}
public static Set<String> pluginExtensions()
{
return launchStrategies.keySet();
return LAUNCH_STRATEGIES.keySet();
}
public static Map<String, PluginLaunchStrategy> getLaunchStrategies()
{
return launchStrategies;
return LAUNCH_STRATEGIES;
}
public static FileFilter fileFilter()
{
return filter;
return FILTER;
}
public static class PluginFileFilter extends FileFilter

View File

@ -13,6 +13,17 @@ public class TokenUtil
public static Token getToken(final RSyntaxTextArea textArea, final @NotNull Token token)
{
String lexeme = token.getLexeme();
return lexeme.isEmpty() || lexeme.equals(".") || lexeme.equals("(") || lexeme.equals(")") || lexeme.equals("[") || lexeme.equals("~") || lexeme.equals("-") || lexeme.equals("+") || lexeme.equals(" ") || lexeme.equals(";") || lexeme.equals(",") || lexeme.equals(">") ? textArea.modelToToken(textArea.getCaretPosition() - 1) : token;
return lexeme.isEmpty()
|| lexeme.equals(".")
|| lexeme.equals("(")
|| lexeme.equals(")")
|| lexeme.equals("[")
|| lexeme.equals("~")
|| lexeme.equals("-")
|| lexeme.equals("+")
|| lexeme.equals(" ")
|| lexeme.equals(";")
|| lexeme.equals(",")
|| lexeme.equals(">") ? textArea.modelToToken(textArea.getCaretPosition() - 1) : token;
}
}

View File

@ -72,7 +72,8 @@ public class APKExport implements Exporter
//if theres only one file in the container don't bother asking
if (validContainers.size() >= 2)
{
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Select APK", "Which file would you like to export as an APK?", validContainersNames.toArray(new String[0]));
MultipleChoiceDialog dialog = new MultipleChoiceDialog("Bytecode Viewer - Select APK",
"Which file would you like to export as an APK?", validContainersNames.toArray(new String[0]));
//TODO may be off by one
container = (ResourceContainer) containers.stream().skip(dialog.promptChoice());
@ -80,7 +81,8 @@ public class APKExport implements Exporter
}
else
{
BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure Settings>Decode Resources is ticked on." + "\n\nTip: Try exporting as DEX, it doesn't rely on decoded APK resources");
BytecodeViewer.showMessage("You can only export as APK from a valid APK file. Make sure Settings>Decode Resources is ticked on."
+ "\n\nTip: Try exporting as DEX, it doesn't rely on decoded APK resources");
return;
}
@ -114,11 +116,14 @@ public class APKExport implements Exporter
APKTool.buildAPK(new File(input), file, finalContainer);
BytecodeViewer.updateBusyStatus(false);
}, "Process APK");
buildAPKThread.start();
}, "Jar Export");
saveThread.start();
}
}, "Resource Export");
exportThread.start();
}
}

View File

@ -81,11 +81,14 @@ public class DexExport implements Exporter
BytecodeViewer.updateBusyStatus(false);
}, "Process DEX");
saveAsDex.start();
}, "Jar Export");
saveAsJar.start();
}
}, "Resource Export");
exportThread.start();
}
}

View File

@ -120,7 +120,7 @@ public class SecurityMan extends SecurityManager
//can only write into BCV dir, so anything executing from here has probably been dropped
try
{
if (normalizedPath.startsWith(Constants.BCVDir.getCanonicalPath().toLowerCase()))
if (normalizedPath.startsWith(Constants.BCV_DIR.getCanonicalPath().toLowerCase()))
blocked = true;
}
catch (IOException e)
@ -373,7 +373,7 @@ public class SecurityMan extends SecurityManager
return;
//can only write into BCV dir
if (file.startsWith(Constants.BCVDir.getCanonicalPath()))
if (file.startsWith(Constants.BCV_DIR.getCanonicalPath()))
return;
//can only write into system temp