More Translations & Cleanup

This commit is contained in:
Konloch 2021-07-17 13:51:00 -07:00
parent d8c5d935b2
commit 31cef469d4
19 changed files with 245 additions and 147 deletions

View file

@ -54,8 +54,19 @@ public class Constants
while (!BCVDir.exists()) while (!BCVDir.exists())
BCVDir.mkdirs(); BCVDir.mkdirs();
//hides the BCV directory
if (!BCVDir.isHidden() && isWindows()) if (!BCVDir.isHidden() && isWindows())
hideFile(BCVDir); {
try {
BytecodeViewer.sm.pauseBlocking();
// Hide file by running attrib system command (on Windows)
Runtime.getRuntime().exec("attrib +H " + BCVDir.getAbsolutePath());
} catch (Exception e) {
//ignore
} finally {
BytecodeViewer.sm.resumeBlocking();
}
}
return BCVDir.getAbsolutePath(); return BCVDir.getAbsolutePath();
} }
@ -69,22 +80,4 @@ public class Constants
{ {
return System.getProperty("os.name").toLowerCase().contains("win"); return System.getProperty("os.name").toLowerCase().contains("win");
} }
/**
* Runs the windows command to hide files
*
* @param f file you want hidden
*/
private static void hideFile(File f)
{
try {
BytecodeViewer.sm.pauseBlocking();
// Hide file by running attrib system command (on Windows)
Runtime.getRuntime().exec("attrib +H " + f.getAbsolutePath());
} catch (Exception e) {
BytecodeViewer.handleException(e);
} finally {
BytecodeViewer.sm.resumeBlocking();
}
}
} }

View file

@ -378,7 +378,7 @@ public class SettingsSerializer
//line 130 is used for preload //line 130 is used for preload
if(Configuration.language != Language.ENGLISH) if(Configuration.language != Language.ENGLISH)
Configuration.language.loadLanguage(); //load language translations Configuration.language.setLanguageTranslations(); //load language translations
Settings.hasSetLanguageAsSystemLanguage = true; Settings.hasSetLanguageAsSystemLanguage = true;
BytecodeViewer.viewer.viewPane1.setPaneEditable(asBoolean(131)); BytecodeViewer.viewer.viewPane1.setPaneEditable(asBoolean(131));

View file

@ -10,6 +10,7 @@ import the.bytecode.club.bytecodeviewer.BytecodeViewer;
import the.bytecode.club.bytecodeviewer.Configuration; import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler; import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -124,7 +125,7 @@ public class JavaCompiler extends InternalCompiler
br.close(); br.close();
log.append(nl).append(nl).append("Error:").append(nl).append(nl); log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
is = process.getErrorStream(); is = process.getErrorStream();
isr = new InputStreamReader(is); isr = new InputStreamReader(is);
br = new BufferedReader(isr); br = new BufferedReader(isr);
@ -134,7 +135,7 @@ public class JavaCompiler extends InternalCompiler
br.close(); br.close();
log.append(nl).append(nl).append("Exit Value is ").append(exitValue); log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").append(exitValue);
System.out.println(log); System.out.println(log);
if (!clazz.exists()) if (!clazz.exists())

View file

@ -14,6 +14,7 @@ import the.bytecode.club.bytecodeviewer.Configuration;
import the.bytecode.club.bytecodeviewer.Constants; import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler; import the.bytecode.club.bytecodeviewer.compilers.InternalCompiler;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
@ -97,7 +98,7 @@ public class KrakatauAssembler extends InternalCompiler
br.close(); br.close();
log.append(nl).append(nl).append("Error:").append(nl).append(nl); log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
is = process.getErrorStream(); is = process.getErrorStream();
isr = new InputStreamReader(is); isr = new InputStreamReader(is);
br = new BufferedReader(isr); br = new BufferedReader(isr);
@ -108,7 +109,7 @@ public class KrakatauAssembler extends InternalCompiler
br.close(); br.close();
int exitValue = process.waitFor(); int exitValue = process.waitFor();
log.append(nl).append(nl).append("Exit Value is ").append(exitValue); log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").append(exitValue);
System.err.println(log); System.err.println(log);
byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull( byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull(

View file

@ -86,7 +86,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
if (LAUNCH_DECOMPILERS_IN_NEW_PROCESS) if (LAUNCH_DECOMPILERS_IN_NEW_PROCESS)
{ {
try /*try
{ {
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll( ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
@ -101,7 +101,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
BytecodeViewer.handleException(e); BytecodeViewer.handleException(e);
} finally { } finally {
BytecodeViewer.sm.resumeBlocking(); BytecodeViewer.sm.resumeBlocking();
} }*/
} }
else else
{ {

View file

@ -17,6 +17,7 @@ import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils; import the.bytecode.club.bytecodeviewer.util.ZipUtils;
@ -70,7 +71,7 @@ public class KrakatauDecompiler extends InternalDecompiler
public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn) public String decompileClassNode(File krakatauTempJar, File krakatauTempDir, ClassNode cn)
{ {
if(!ExternalResources.getSingleton().hasSetPython2Command()) if(!ExternalResources.getSingleton().hasSetPython2Command())
return "You need to set your Python 2.7 (or PyPy 2.7 for speed) executable path!"; return TranslatedStrings.YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH.toString();
ExternalResources.getSingleton().rtCheck(); ExternalResources.getSingleton().rtCheck();
if (Configuration.rt.isEmpty()) { if (Configuration.rt.isEmpty()) {
@ -118,14 +119,14 @@ public class KrakatauDecompiler extends InternalDecompiler
InputStream is = process.getInputStream(); InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is); InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
StringBuilder log = new StringBuilder("Process:" + nl + nl); StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
log.append(nl).append(line); log.append(nl).append(line);
} }
br.close(); br.close();
log.append(nl).append(nl).append("Error:").append(nl).append(nl); log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
is = process.getErrorStream(); is = process.getErrorStream();
isr = new InputStreamReader(is); isr = new InputStreamReader(is);
br = new BufferedReader(isr); br = new BufferedReader(isr);
@ -135,7 +136,7 @@ public class KrakatauDecompiler extends InternalDecompiler
br.close(); br.close();
int exitValue = process.waitFor(); int exitValue = process.waitFor();
log.append(nl).append(nl).append("Exit Value is ").append(exitValue); log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").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.
@ -158,7 +159,7 @@ public class KrakatauDecompiler extends InternalDecompiler
//TODO look into transforming through krakatau as a zip rather than direct classfile //TODO look into transforming through krakatau as a zip rather than direct classfile
if(!ExternalResources.getSingleton().hasSetPython2Command()) if(!ExternalResources.getSingleton().hasSetPython2Command())
return "You need to set your Python 2.7 (or PyPy 2.7 for speed) executable path!"; return TranslatedStrings.YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH.toString();
if (Configuration.rt.isEmpty()) { if (Configuration.rt.isEmpty()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library." + BytecodeViewer.showMessage("You need to set your JRE RT Library." +
@ -206,14 +207,14 @@ public class KrakatauDecompiler extends InternalDecompiler
InputStream is = process.getInputStream(); InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is); InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
StringBuilder log = new StringBuilder("Process:" + nl + nl); StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
log.append(nl).append(line); log.append(nl).append(line);
} }
br.close(); br.close();
log.append(nl).append(nl).append("Error:").append(nl) log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl)
.append(nl); .append(nl);
is = process.getErrorStream(); is = process.getErrorStream();
isr = new InputStreamReader(is); isr = new InputStreamReader(is);
@ -224,7 +225,7 @@ public class KrakatauDecompiler extends InternalDecompiler
br.close(); br.close();
int exitValue = process.waitFor(); int exitValue = process.waitFor();
log.append(nl).append(nl).append("Exit Value is ").append(exitValue); log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").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.

View file

@ -15,6 +15,7 @@ import the.bytecode.club.bytecodeviewer.Constants;
import the.bytecode.club.bytecodeviewer.api.ExceptionUI; import the.bytecode.club.bytecodeviewer.api.ExceptionUI;
import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler; import the.bytecode.club.bytecodeviewer.decompilers.InternalDecompiler;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources; import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.util.JarUtils; import the.bytecode.club.bytecodeviewer.util.JarUtils;
import the.bytecode.club.bytecodeviewer.util.MiscUtils; import the.bytecode.club.bytecodeviewer.util.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils; import the.bytecode.club.bytecodeviewer.util.ZipUtils;
@ -50,7 +51,7 @@ public class KrakatauDisassembler extends InternalDecompiler
@Override @Override
public String decompileClassNode(ClassNode cn, byte[] b) { public String decompileClassNode(ClassNode cn, byte[] b) {
if(!ExternalResources.getSingleton().hasSetPython2Command()) if(!ExternalResources.getSingleton().hasSetPython2Command())
return "You need to set your Python 2.7 (or PyPy 2.7 for speed) executable path!"; return TranslatedStrings.YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH.toString();
String s = ExceptionUI.SEND_STACKTRACE_TO_NL; String s = ExceptionUI.SEND_STACKTRACE_TO_NL;
@ -84,14 +85,14 @@ public class KrakatauDisassembler extends InternalDecompiler
InputStream is = process.getInputStream(); InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is); InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr); BufferedReader br = new BufferedReader(isr);
StringBuilder log = new StringBuilder("Process:" + nl + nl); StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
String line; String line;
while ((line = br.readLine()) != null) { while ((line = br.readLine()) != null) {
log.append(nl).append(line); log.append(nl).append(line);
} }
br.close(); br.close();
log.append(nl).append(nl).append("Error:").append(nl).append(nl); log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl).append(nl);
is = process.getErrorStream(); is = process.getErrorStream();
isr = new InputStreamReader(is); isr = new InputStreamReader(is);
br = new BufferedReader(isr); br = new BufferedReader(isr);
@ -101,7 +102,7 @@ public class KrakatauDisassembler extends InternalDecompiler
br.close(); br.close();
int exitValue = process.waitFor(); int exitValue = process.waitFor();
log.append(nl).append(nl).append("Exit Value is ").append(exitValue); log.append(nl).append(nl).append(TranslatedStrings.EXIT_VALUE_IS + " ").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.

View file

@ -850,7 +850,7 @@ public class MainViewerGUI extends JFrame
final File file = DialogueUtils.fileChooser("Select External Plugin", final File file = DialogueUtils.fileChooser("Select External Plugin",
"External Plugin", "External Plugin",
PluginManager.fileFilter(), PluginManager.fileFilter(),
"everything"); FileChooser.EVERYTHING);
if(file == null) if(file == null)
return; return;

View file

@ -14,6 +14,8 @@ import java.util.HashSet;
*/ */
public class FileChooser extends JFileChooser public class FileChooser extends JFileChooser
{ {
public static final String EVERYTHING = "everything";
public FileChooser(File filePath, String title, String description, String... extensions) public FileChooser(File filePath, String title, String description, String... extensions)
{ {
HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions)); HashSet<String> extensionSet = new HashSet<>(Arrays.asList(extensions));
@ -35,7 +37,7 @@ public class FileChooser extends JFileChooser
if (f.isDirectory()) if (f.isDirectory())
return true; return true;
if(extensions[0].equals("everything")) if(extensions[0].equals(EVERYTHING))
return true; return true;
return extensionSet.contains(MiscUtils.extension(f.getAbsolutePath())); return extensionSet.contains(MiscUtils.extension(f.getAbsolutePath()));

View file

@ -455,7 +455,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
quickSearch.addFocusListener(new FocusListener() { quickSearch.addFocusListener(new FocusListener() {
@Override @Override
public void focusGained(final FocusEvent arg0) { public void focusGained(final FocusEvent arg0) {
if (quickSearch.getText().equals(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.getText())) { if (quickSearch.getText().equals(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString())) {
quickSearch.setText(""); quickSearch.setText("");
quickSearch.setForeground(Color.black); quickSearch.setForeground(Color.black);
} }
@ -464,7 +464,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
@Override @Override
public void focusLost(final FocusEvent arg0) { public void focusLost(final FocusEvent arg0) {
if (quickSearch.getText().isEmpty()) { if (quickSearch.getText().isEmpty()) {
quickSearch.setText(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.getText()); quickSearch.setText(TranslatedStrings.QUICK_FILE_SEARCH_NO_FILE_EXTENSION.toString());
quickSearch.setForeground(Color.gray); quickSearch.setForeground(Color.gray);
} }
} }

View file

@ -45,7 +45,7 @@ class PerformSearch extends BackgroundSearchThread
searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected()); searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected());
BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true); BytecodeViewer.viewer.searchBoxPane.search.setEnabled(true);
BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.getText()); BytecodeViewer.viewer.searchBoxPane.search.setText(TranslatedStrings.SEARCH.toString());
searchBoxPane.tree.expandPath(new TreePath(searchBoxPane.tree.getModel().getRoot())); searchBoxPane.tree.expandPath(new TreePath(searchBoxPane.tree.getModel().getRoot()));
searchBoxPane.tree.updateUI(); searchBoxPane.tree.updateUI();

View file

@ -60,8 +60,12 @@ public class BytecodeViewPanel extends JPanel
removeAll(); removeAll();
textArea = null; textArea = null;
if(viewer.resource == null || viewer.resource.getResourceClassNode() == null) if(viewer.resource == null)
add(new JLabel("ERROR: Resource Viewer Corrupt ClassNode")); add(new JLabel("ERROR: Resource Viewer Missing Resource"));
//TODO remove when bcel support is added
else if(viewer.resource.getResourceClassNode() == null)
add(new JLabel("ERROR: Resource Viewer Missing ClassNode"));
} }
public void updatePane(ClassViewer cv, byte[] b, JButton button, boolean isPanelEditable) public void updatePane(ClassViewer cv, byte[] b, JButton button, boolean isPanelEditable)
@ -74,9 +78,9 @@ public class BytecodeViewPanel extends JPanel
if(textArea == null || !textArea.isEditable()) if(textArea == null || !textArea.isEditable())
return true; return true;
SystemConsole errConsole = new SystemConsole("Java Compile Issues"); SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString());
errConsole.setText("Error compiling class: " + viewer.resource.getResourceClassNode().name + errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS.toString() + " " + viewer.resource.getResourceClassNode().name +
nl + "Keep in mind most decompilers cannot produce compilable classes" + nl + TranslatedStrings.COMPILER_TIP.toString() +
nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR + nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR +
nl + nl); nl + nl);

View file

@ -5,10 +5,11 @@ import com.github.weisj.darklaf.theme.*;
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.gui.components.VisibleComponent; import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.BytecodeViewPanel;
import the.bytecode.club.bytecodeviewer.translation.Translation; import the.bytecode.club.bytecodeviewer.translation.Translation;
import javax.swing.*; import javax.swing.*;
import java.util.Map;
import java.util.Set;
/** /**
* @author Konloch * @author Konloch

View file

@ -3,6 +3,8 @@ 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.SettingsSerializer; import the.bytecode.club.bytecodeviewer.SettingsSerializer;
import the.bytecode.club.bytecodeviewer.gui.components.FileChooser;
import the.bytecode.club.bytecodeviewer.translation.TranslatedStrings;
import the.bytecode.club.bytecodeviewer.util.DialogueUtils; import the.bytecode.club.bytecodeviewer.util.DialogueUtils;
import the.bytecode.club.bytecodeviewer.util.JRTExtractor; import the.bytecode.club.bytecodeviewer.util.JRTExtractor;
@ -123,7 +125,6 @@ public class ExternalResources
if(!Configuration.python2.isEmpty()) if(!Configuration.python2.isEmpty())
return Configuration.python2; return Configuration.python2;
//check using python CLI flag //check using python CLI flag
testCommand(new String[]{"python", "-2", "--version"}, "python 2", ()->{ testCommand(new String[]{"python", "-2", "--version"}, "python 2", ()->{
Configuration.python2 = "python"; Configuration.python2 = "python";
@ -132,7 +133,6 @@ public class ExternalResources
if(!Configuration.python2.isEmpty()) if(!Configuration.python2.isEmpty())
return Configuration.python2; return Configuration.python2;
//check if 'python' command is bound as python 2.X //check if 'python' command is bound as python 2.X
testCommand(new String[]{"python", "--version"}, "python 2", ()->{ testCommand(new String[]{"python", "--version"}, "python 2", ()->{
Configuration.python2 = "python"; Configuration.python2 = "python";
@ -140,12 +140,11 @@ public class ExternalResources
if(!Configuration.python2.isEmpty()) if(!Configuration.python2.isEmpty())
return Configuration.python2; return Configuration.python2;
//TODO auto-detect the Python path (C:/Program Files/Python) //TODO auto-detect the Python path (C:/Program Files/Python)
boolean block = true; boolean block = true;
while (Configuration.python2.isEmpty() && block) while (Configuration.python2.isEmpty() && block)
{ {
BytecodeViewer.showMessage("You need to set your Python 2.7 (or PyPy 2.7 for speed) executable path."); BytecodeViewer.showMessage(TranslatedStrings.YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH.toString());
selectPython2(); selectPython2();
block = !blockTillSelected; //signal block flag off block = !blockTillSelected; //signal block flag off
} }
@ -195,7 +194,7 @@ public class ExternalResources
boolean block = true; boolean block = true;
while (Configuration.python3.isEmpty() && block) while (Configuration.python3.isEmpty() && block)
{ {
BytecodeViewer.showMessage("You need to set your Python 3.x (or PyPy 3.x for speed) executable path."); BytecodeViewer.showMessage(TranslatedStrings.YOU_NEED_TO_SET_YOUR_PYTHON_3_PATH.toString());
selectPython3(); selectPython3();
block = !blockTillSelected; //signal block flag off block = !blockTillSelected; //signal block flag off
} }
@ -223,9 +222,9 @@ public class ExternalResources
public void selectPython2() public void selectPython2()
{ {
final File file = DialogueUtils.fileChooser("Select Python 2.7 Executable", final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_2.toString(),
"Python 2.7 (Or PyPy 2.7 for speed) Executable", TranslatedStrings.PYTHON_2_EXECUTABLE.toString(),
"everything"); FileChooser.EVERYTHING);
if(file == null) if(file == null)
return; return;
@ -237,9 +236,9 @@ public class ExternalResources
public void selectPython3() public void selectPython3()
{ {
final File file = DialogueUtils.fileChooser("Select Python 3.x Executable", final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_3.toString(),
"Python 3.x (Or PyPy 3.x for speed) Executable", TranslatedStrings.PYTHON_3_EXECUTABLE.toString(),
"everything"); FileChooser.EVERYTHING);
if(file == null) if(file == null)
return; return;
@ -249,24 +248,11 @@ public class ExternalResources
SettingsSerializer.saveSettingsAsync(); SettingsSerializer.saveSettingsAsync();
} }
public void selectJavac()
{
final File file = DialogueUtils.fileChooser("Select Javac Executable",
"Javac Executable (Requires JDK 'C:/Program Files/Java/JDK_xx/bin/javac.exe)",
"everything");
if(file == null)
return;
Configuration.javac = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJava() public void selectJava()
{ {
final File file = DialogueUtils.fileChooser("Select Java Executable", final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA.toString(),
"Java Executable (Inside Of JRE/JDK 'C:/Program Files/Java/JDK_xx/bin/java.exe')", TranslatedStrings.JAVA_EXECUTABLE.toString(),
"everything"); FileChooser.EVERYTHING);
if(file == null) if(file == null)
return; return;
@ -275,11 +261,37 @@ public class ExternalResources
SettingsSerializer.saveSettingsAsync(); SettingsSerializer.saveSettingsAsync();
} }
public void selectJavac()
{
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVAC.toString(),
TranslatedStrings.JAVAC_EXECUTABLE.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
Configuration.javac = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJRERTLibrary()
{
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA_RT.toString(),
TranslatedStrings.JAVA_RT_JAR.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
Configuration.rt = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
public void selectJavaTools() public void selectJavaTools()
{ {
final File file = DialogueUtils.fileChooser("Select Java Tools Jar", final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA_TOOLS.toString(),
"Java Tools Jar (Inside Of JDK 'C:/Program Files/Java/JDK_xx/lib/tools.jar')", TranslatedStrings.JAVA_TOOLS_JAR.toString(),
"everything"); FileChooser.EVERYTHING);
if(file == null) if(file == null)
return; return;
@ -290,9 +302,9 @@ public class ExternalResources
public void selectOptionalLibraryFolder() public void selectOptionalLibraryFolder()
{ {
final File file = DialogueUtils.fileChooser("Select Library Folder", final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_LIBRARY_FOLDER.toString(),
"Optional Library Folder", TranslatedStrings.OPTIONAL_LIBRARY_FOLDER.toString(),
"everything"); FileChooser.EVERYTHING);
if(file == null) if(file == null)
return; return;
@ -301,19 +313,6 @@ public class ExternalResources
SettingsSerializer.saveSettingsAsync(); SettingsSerializer.saveSettingsAsync();
} }
public void selectJRERTLibrary()
{
final File file = DialogueUtils.fileChooser("Select JRE RT Jar",
"JRE RT Library",
"everything");
if(file == null)
return;
Configuration.rt = file.getAbsolutePath();
SettingsSerializer.saveSettingsAsync();
}
/** /**
* Finds a library from the library folder * Finds a library from the library folder
*/ */
@ -353,8 +352,13 @@ public class ExternalResources
/** /**
* Used to test the command-line for compatibility * Used to test the command-line for compatibility
*/ */
public void testCommand(String[] command, String matchingText, Runnable onMatch) private void testCommand(String[] command, String matchingText, Runnable onMatch)
{ {
//prevents reflection calls, the stacktrace can be faked to bypass this, so it's not perfect
String executedClass = Thread.currentThread().getStackTrace()[2].getClassName();
if(!executedClass.equals(ExternalResources.class.getCanonicalName()))
return;
try try
{ {
BytecodeViewer.sm.pauseBlocking(); BytecodeViewer.sm.pauseBlocking();
@ -366,10 +370,8 @@ public class ExternalResources
//check for matching text //check for matching text
if(readProcess(p).toLowerCase().contains(matchingText)) if(readProcess(p).toLowerCase().contains(matchingText))
{
onMatch.run(); onMatch.run();
} }
}
catch (Exception e) { } //ignore catch (Exception e) { } //ignore
finally finally
{ {

View file

@ -92,6 +92,7 @@ public enum Language
private final String readableName; private final String readableName;
private final String htmlIdentifier; private final String htmlIdentifier;
private final LinkedHashSet<String> languageCode; private final LinkedHashSet<String> languageCode;
private HashMap<String, String> translationMap;
Language(String resourcePath, String readableName, String htmlIdentifier, String... languageCodes) Language(String resourcePath, String readableName, String htmlIdentifier, String... languageCodes)
{ {
@ -101,13 +102,11 @@ public enum Language
this.languageCode = new LinkedHashSet<>(Arrays.asList(languageCodes)); this.languageCode = new LinkedHashSet<>(Arrays.asList(languageCodes));
} }
public void loadLanguage() throws IOException public void setLanguageTranslations() throws IOException
{ {
printMissingLanguageKeys(); printMissingLanguageKeys();
HashMap<String, String> translationMap = BytecodeViewer.gson.fromJson( HashMap<String, String> translationMap = getTranslation();
IconResources.loadResourceAsString(resourcePath),
new TypeToken<HashMap<String, String>>(){}.getType());
for(Translation translation : Translation.values()) for(Translation translation : Translation.values())
{ {
@ -143,6 +142,18 @@ public enum Language
} }
} }
public HashMap<String, String> getTranslation() throws IOException
{
if(translationMap == null)
{
translationMap = BytecodeViewer.gson.fromJson(
IconResources.loadResourceAsString(resourcePath),
new TypeToken<HashMap<String, String>>() {}.getType());
}
return translationMap;
}
//TODO //TODO
// When adding new Translation Components: // When adding new Translation Components:
// 1) start by adding the strings into the english.json // 1) start by adding the strings into the english.json

View file

@ -1,7 +1,26 @@
package the.bytecode.club.bytecodeviewer.translation; package the.bytecode.club.bytecodeviewer.translation;
import java.io.IOException;
import java.util.HashSet; import java.util.HashSet;
/***************************************************************************
* Bytecode Viewer (BCV) - Java & Android Reverse Engineering Suite *
* Copyright (C) 2014 Kalen 'Konloch' Kinloch - http://bytecodeviewer.com *
* *
* This program is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation, either version 3 of the License, or *
* (at your option) any later version. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program. If not, see <http://www.gnu.org/licenses/>. *
***************************************************************************/
/** /**
* Constant-like strings not associated with any specific JComponent * Constant-like strings not associated with any specific JComponent
* *
@ -11,27 +30,49 @@ import java.util.HashSet;
public enum TranslatedStrings public enum TranslatedStrings
{ {
EDITABLE("Editable"), EDITABLE,
JAVA("Java"), JAVA,
PROCYON("Procyon"), PROCYON,
CFR("CFR"), CFR,
FERNFLOWER("FernFlower"), FERNFLOWER,
KRAKATAU("Krakatau"), KRAKATAU,
JDGUI("JD-GUI"), JDGUI,
JADX("JADX"), JADX,
SMALI("Smali"), SMALI,
SMALI_DEX("Smali/DEX"), SMALI_DEX,
HEXCODE("Hexcode"), HEXCODE,
BYTECODE("Bytecode"), BYTECODE,
ASM_TEXTIFY("ASM Textify"), ASM_TEXTIFY,
ERROR("Error"), ERROR,
DISASSEMBLER("Disassembler"), DISASSEMBLER,
RESULTS("Results"), RESULTS,
SEARCH("Search"), SEARCH,
QUICK_FILE_SEARCH_NO_FILE_EXTENSION("Quick file search (no file extension)"), ERROR2,
SUGGESTED_FIX_DECOMPILER_ERROR("Suggested Fix: Click refresh class, if it fails again try another decompiler."), PROCESS2,
SUGGESTED_FIX_COMPILER_ERROR("Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable."), EXIT_VALUE_IS,
DRAG_CLASS_JAR("Drag class/jar/zip/APK/DEX here"), ERROR_COMPILING_CLASS,
COMPILER_TIP,
JAVA_COMPILE_FAILED,
SELECT_LIBRARY_FOLDER,
SELECT_JAVA_RT,
SELECT_JAVA,
SELECT_JAVAC,
SELECT_JAVA_TOOLS,
SELECT_PYTHON_2,
SELECT_PYTHON_3,
PYTHON_2_EXECUTABLE,
PYTHON_3_EXECUTABLE,
YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH,
YOU_NEED_TO_SET_YOUR_PYTHON_3_PATH,
JAVA_EXECUTABLE,
JAVAC_EXECUTABLE,
JAVA_TOOLS_JAR,
JAVA_RT_JAR,
OPTIONAL_LIBRARY_FOLDER,
QUICK_FILE_SEARCH_NO_FILE_EXTENSION,
SUGGESTED_FIX_DECOMPILER_ERROR,
SUGGESTED_FIX_COMPILER_ERROR,
DRAG_CLASS_JAR,
; ;
public static final HashSet<String> nameSet = new HashSet<>(); public static final HashSet<String> nameSet = new HashSet<>();
@ -44,21 +85,27 @@ public enum TranslatedStrings
private String text; private String text;
TranslatedStrings(String text) {this.text = text;} TranslatedStrings()
{
//load english translations by default
try
{
this.text = Language.ENGLISH.getTranslation().get(name());
}
catch (IOException e)
{
e.printStackTrace();
}
}
public void setText(String text) public void setText(String text)
{ {
this.text = text; this.text = text;
} }
public String getText()
{
return text;
}
@Override @Override
public String toString() public String toString()
{ {
return getText(); return text;
} }
} }

View file

@ -253,8 +253,8 @@ public class MiscUtils
try try
{ {
Language.ENGLISH.loadLanguage(); //load english first incase the translation file is missing anything Language.ENGLISH.setLanguageTranslations(); //load english first incase the translation file is missing anything
language.loadLanguage(); //load translation file and swap text around as needed language.setLanguageTranslations(); //load translation file and swap text around as needed
SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer); SwingUtilities.updateComponentTreeUI(BytecodeViewer.viewer);
} }
catch (Exception ex) catch (Exception ex)

View file

@ -1,6 +1,12 @@
package the.bytecode.club.bytecodeviewer.util; package the.bytecode.club.bytecodeviewer.util;
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.compilers.impl.JavaCompiler;
import the.bytecode.club.bytecodeviewer.compilers.impl.KrakatauAssembler;
import the.bytecode.club.bytecodeviewer.decompilers.impl.*;
import the.bytecode.club.bytecodeviewer.resources.ExternalResources;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.net.InetAddress; import java.net.InetAddress;
@ -45,23 +51,28 @@ public class SecurityMan extends SecurityManager
blocking++; blocking++;
} }
public void pauseBlocking() { //slightly safer security system than just a public static boolean being toggled //slightly safer security system than just a public static boolean being toggled
public void pauseBlocking()
{
String executedClass = Thread.currentThread().getStackTrace()[2].getClassName(); String executedClass = Thread.currentThread().getStackTrace()[2].getClassName();
if (executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.KrakatauDecompiler") || if (executedClass.equals(KrakatauDecompiler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.KrakatauDisassembler") || executedClass.equals(KrakatauDisassembler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.CFRDecompiler") || executedClass.equals(CFRDecompiler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.ProcyonDecompiler") || executedClass.equals(ProcyonDecompiler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.FernFlowerDecompiler") || executedClass.equals(FernFlowerDecompiler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.JDGUIDecompiler") || executedClass.equals(JDGUIDecompiler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.impl.KrakatauAssembler") || executedClass.equals(KrakatauAssembler.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.resources.ExternalResources") || executedClass.equals(ExternalResources.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.Enjarify") || executedClass.equals(Enjarify.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") || executedClass.equals(APKTool.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") || executedClass.equals(BytecodeViewer.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.Constants") || executedClass.equals(Constants.class.getCanonicalName()) ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.impl.JavaCompiler")) { executedClass.equals(JavaCompiler.class.getCanonicalName()))
{
blocking--; blocking--;
} else for (StackTraceElement stackTraceElements : Thread.currentThread().getStackTrace()) { }
else for (StackTraceElement stackTraceElements : Thread.currentThread().getStackTrace())
{
System.out.println(stackTraceElements.getClassName()); System.out.println(stackTraceElements.getClassName());
} }
} }

View file

@ -120,6 +120,29 @@
"SUGGESTED_FIX_COMPILER_ERROR": "Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable.", "SUGGESTED_FIX_COMPILER_ERROR": "Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable.",
"DRAG_CLASS_JAR": "Drag class/jar/zip/APK/DEX here", "DRAG_CLASS_JAR": "Drag class/jar/zip/APK/DEX here",
"ERROR2": "Error:",
"PROCESS2": "Process:",
"EXIT_VALUE_IS": "Exit Value is:",
"JAVA_COMPILE_FAILED": "Java Compile Failed",
"ERROR_COMPILING_CLASS": "Error compiling class",
"COMPILER": "Keep in mind most decompilers cannot produce compilable classes",
"SELECT_LIBRARY_FOLDER": "Select Library Folder",
"SELECT_JAVA_RT": "Select JRE RT Jar",
"SELECT_JAVA": "Select Java Executable",
"SELECT_JAVAC": "Select Javac Executable",
"SELECT_JAVA_TOOLS": "Select Java Tools Jar",
"SELECT_PYTHON_2": "Select Python 2.7 Executable",
"SELECT_PYTHON_3": "Select Python 3.x Executable",
"PYTHON_2_EXECUTABLE": "Python 2.7 (Or PyPy 2.7 for speed) Executable",
"PYTHON_3_EXECUTABLE": "Python 3.x (Or PyPy 3.x for speed) Executable",
"YOU_NEED_TO_SET_YOUR_PYTHON_2_PATH": "You need to set your Python 2.7 (or PyPy 2.7 for speed) executable path.",
"YOU_NEED_TO_SET_YOUR_PYTHON_3_PATH": "You need to set your Python 3.x (or PyPy 3.x for speed) executable path.",
"JAVA_EXECUTABLE": "Java Executable (Inside Of JRE C:/Program Files/Java/JRE_xx/bin/java.exe)",
"JAVAC_EXECUTABLE": "Javac Executable (Requires JDK C:/Program Files/Java/JDK_xx/bin/javac.exe)",
"JAVA_TOOLS_JAR": "Java Tools Jar (Inside Of JDK C:/Program Files/Java/JDK_xx/lib/tools.jar)",
"JAVA_RT_JAR": "Java RT Jar (Inside Of JRE C:/Program Files/Java/JRE_xx/lib/rt.jar)",
"OPTIONAL_LIBRARY_FOLDER": "Optional Library Folder (Compiler & Krakatau)",
"FILES": "Files", "FILES": "Files",
"QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)", "QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)",
"WORK_SPACE": "Work Space", "WORK_SPACE": "Work Space",