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())
BCVDir.mkdirs();
//hides the BCV directory
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();
}
@ -69,22 +80,4 @@ public class Constants
{
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
if(Configuration.language != Language.ENGLISH)
Configuration.language.loadLanguage(); //load language translations
Configuration.language.setLanguageTranslations(); //load language translations
Settings.hasSetLanguageAsSystemLanguage = true;
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.compilers.InternalCompiler;
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.MiscUtils;
@ -124,7 +125,7 @@ public class JavaCompiler extends InternalCompiler
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();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
@ -134,7 +135,7 @@ public class JavaCompiler extends InternalCompiler
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);
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.compilers.InternalCompiler;
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.MiscUtils;
@ -97,7 +98,7 @@ public class KrakatauAssembler extends InternalCompiler
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();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
@ -108,7 +109,7 @@ public class KrakatauAssembler extends InternalCompiler
br.close();
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);
byte[] b = FileUtils.readFileToByteArray(Objects.requireNonNull(

View file

@ -86,7 +86,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
if (LAUNCH_DECOMPILERS_IN_NEW_PROCESS)
{
try
/*try
{
BytecodeViewer.sm.pauseBlocking();
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
@ -101,7 +101,7 @@ public class FernFlowerDecompiler extends InternalDecompiler
BytecodeViewer.handleException(e);
} finally {
BytecodeViewer.sm.resumeBlocking();
}
}*/
}
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.decompilers.InternalDecompiler;
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.MiscUtils;
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)
{
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();
if (Configuration.rt.isEmpty()) {
@ -118,14 +119,14 @@ public class KrakatauDecompiler extends InternalDecompiler
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuilder log = new StringBuilder("Process:" + nl + nl);
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
String line;
while ((line = br.readLine()) != null) {
log.append(nl).append(line);
}
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();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
@ -135,7 +136,7 @@ public class KrakatauDecompiler extends InternalDecompiler
br.close();
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();
//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
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()) {
BytecodeViewer.showMessage("You need to set your JRE RT Library." +
@ -206,14 +207,14 @@ public class KrakatauDecompiler extends InternalDecompiler
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuilder log = new StringBuilder("Process:" + nl + nl);
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
String line;
while ((line = br.readLine()) != null) {
log.append(nl).append(line);
}
br.close();
log.append(nl).append(nl).append("Error:").append(nl)
log.append(nl).append(nl).append(TranslatedStrings.ERROR2).append(nl)
.append(nl);
is = process.getErrorStream();
isr = new InputStreamReader(is);
@ -224,7 +225,7 @@ public class KrakatauDecompiler extends InternalDecompiler
br.close();
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();
//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.decompilers.InternalDecompiler;
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.MiscUtils;
import the.bytecode.club.bytecodeviewer.util.ZipUtils;
@ -50,7 +51,7 @@ public class KrakatauDisassembler extends InternalDecompiler
@Override
public String decompileClassNode(ClassNode cn, byte[] b) {
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;
@ -84,14 +85,14 @@ public class KrakatauDisassembler extends InternalDecompiler
InputStream is = process.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
StringBuilder log = new StringBuilder("Process:" + nl + nl);
StringBuilder log = new StringBuilder(TranslatedStrings.PROCESS2 + nl + nl);
String line;
while ((line = br.readLine()) != null) {
log.append(nl).append(line);
}
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();
isr = new InputStreamReader(is);
br = new BufferedReader(isr);
@ -101,7 +102,7 @@ public class KrakatauDisassembler extends InternalDecompiler
br.close();
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();
//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",
"External Plugin",
PluginManager.fileFilter(),
"everything");
FileChooser.EVERYTHING);
if(file == null)
return;

View file

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

View file

@ -455,7 +455,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
quickSearch.addFocusListener(new FocusListener() {
@Override
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.setForeground(Color.black);
}
@ -464,7 +464,7 @@ public class ResourceListPane extends TranslatedVisibleComponent implements File
@Override
public void focusLost(final FocusEvent arg0) {
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);
}
}

View file

@ -45,7 +45,7 @@ class PerformSearch extends BackgroundSearchThread
searchBoxPane.searchType.details.search(container, c, srn, searchBoxPane.exact.isSelected());
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.updateUI();

View file

@ -60,8 +60,12 @@ public class BytecodeViewPanel extends JPanel
removeAll();
textArea = null;
if(viewer.resource == null || viewer.resource.getResourceClassNode() == null)
add(new JLabel("ERROR: Resource Viewer Corrupt ClassNode"));
if(viewer.resource == null)
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)
@ -74,9 +78,9 @@ public class BytecodeViewPanel extends JPanel
if(textArea == null || !textArea.isEditable())
return true;
SystemConsole errConsole = new SystemConsole("Java Compile Issues");
errConsole.setText("Error compiling class: " + viewer.resource.getResourceClassNode().name +
nl + "Keep in mind most decompilers cannot produce compilable classes" +
SystemConsole errConsole = new SystemConsole(TranslatedStrings.JAVA_COMPILE_FAILED.toString());
errConsole.setText(TranslatedStrings.ERROR_COMPILING_CLASS.toString() + " " + viewer.resource.getResourceClassNode().name +
nl + TranslatedStrings.COMPILER_TIP.toString() +
nl + nl + TranslatedStrings.SUGGESTED_FIX_COMPILER_ERROR +
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.Configuration;
import the.bytecode.club.bytecodeviewer.gui.components.VisibleComponent;
import the.bytecode.club.bytecodeviewer.gui.resourceviewer.BytecodeViewPanel;
import the.bytecode.club.bytecodeviewer.translation.Translation;
import javax.swing.*;
import java.util.Map;
import java.util.Set;
/**
* @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.Configuration;
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.JRTExtractor;
@ -123,7 +125,6 @@ public class ExternalResources
if(!Configuration.python2.isEmpty())
return Configuration.python2;
//check using python CLI flag
testCommand(new String[]{"python", "-2", "--version"}, "python 2", ()->{
Configuration.python2 = "python";
@ -132,7 +133,6 @@ public class ExternalResources
if(!Configuration.python2.isEmpty())
return Configuration.python2;
//check if 'python' command is bound as python 2.X
testCommand(new String[]{"python", "--version"}, "python 2", ()->{
Configuration.python2 = "python";
@ -140,12 +140,11 @@ public class ExternalResources
if(!Configuration.python2.isEmpty())
return Configuration.python2;
//TODO auto-detect the Python path (C:/Program Files/Python)
boolean block = true;
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();
block = !blockTillSelected; //signal block flag off
}
@ -195,7 +194,7 @@ public class ExternalResources
boolean block = true;
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();
block = !blockTillSelected; //signal block flag off
}
@ -223,9 +222,9 @@ public class ExternalResources
public void selectPython2()
{
final File file = DialogueUtils.fileChooser("Select Python 2.7 Executable",
"Python 2.7 (Or PyPy 2.7 for speed) Executable",
"everything");
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_2.toString(),
TranslatedStrings.PYTHON_2_EXECUTABLE.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
@ -237,9 +236,9 @@ public class ExternalResources
public void selectPython3()
{
final File file = DialogueUtils.fileChooser("Select Python 3.x Executable",
"Python 3.x (Or PyPy 3.x for speed) Executable",
"everything");
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_PYTHON_3.toString(),
TranslatedStrings.PYTHON_3_EXECUTABLE.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
@ -249,24 +248,11 @@ public class ExternalResources
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()
{
final File file = DialogueUtils.fileChooser("Select Java Executable",
"Java Executable (Inside Of JRE/JDK 'C:/Program Files/Java/JDK_xx/bin/java.exe')",
"everything");
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA.toString(),
TranslatedStrings.JAVA_EXECUTABLE.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
@ -275,11 +261,37 @@ public class ExternalResources
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()
{
final File file = DialogueUtils.fileChooser("Select Java Tools Jar",
"Java Tools Jar (Inside Of JDK 'C:/Program Files/Java/JDK_xx/lib/tools.jar')",
"everything");
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_JAVA_TOOLS.toString(),
TranslatedStrings.JAVA_TOOLS_JAR.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
@ -290,9 +302,9 @@ public class ExternalResources
public void selectOptionalLibraryFolder()
{
final File file = DialogueUtils.fileChooser("Select Library Folder",
"Optional Library Folder",
"everything");
final File file = DialogueUtils.fileChooser(TranslatedStrings.SELECT_LIBRARY_FOLDER.toString(),
TranslatedStrings.OPTIONAL_LIBRARY_FOLDER.toString(),
FileChooser.EVERYTHING);
if(file == null)
return;
@ -301,19 +313,6 @@ public class ExternalResources
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
*/
@ -353,8 +352,13 @@ public class ExternalResources
/**
* 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
{
BytecodeViewer.sm.pauseBlocking();
@ -366,10 +370,8 @@ public class ExternalResources
//check for matching text
if(readProcess(p).toLowerCase().contains(matchingText))
{
onMatch.run();
}
}
catch (Exception e) { } //ignore
finally
{

View file

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

View file

@ -1,7 +1,26 @@
package the.bytecode.club.bytecodeviewer.translation;
import java.io.IOException;
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
*
@ -11,27 +30,49 @@ import java.util.HashSet;
public enum TranslatedStrings
{
EDITABLE("Editable"),
JAVA("Java"),
PROCYON("Procyon"),
CFR("CFR"),
FERNFLOWER("FernFlower"),
KRAKATAU("Krakatau"),
JDGUI("JD-GUI"),
JADX("JADX"),
SMALI("Smali"),
SMALI_DEX("Smali/DEX"),
HEXCODE("Hexcode"),
BYTECODE("Bytecode"),
ASM_TEXTIFY("ASM Textify"),
ERROR("Error"),
DISASSEMBLER("Disassembler"),
RESULTS("Results"),
SEARCH("Search"),
QUICK_FILE_SEARCH_NO_FILE_EXTENSION("Quick file search (no file extension)"),
SUGGESTED_FIX_DECOMPILER_ERROR("Suggested Fix: Click refresh class, if it fails again try another decompiler."),
SUGGESTED_FIX_COMPILER_ERROR("Suggested Fix: Try View>Pane>Krakatau>Bytecode and enable Editable."),
DRAG_CLASS_JAR("Drag class/jar/zip/APK/DEX here"),
EDITABLE,
JAVA,
PROCYON,
CFR,
FERNFLOWER,
KRAKATAU,
JDGUI,
JADX,
SMALI,
SMALI_DEX,
HEXCODE,
BYTECODE,
ASM_TEXTIFY,
ERROR,
DISASSEMBLER,
RESULTS,
SEARCH,
ERROR2,
PROCESS2,
EXIT_VALUE_IS,
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<>();
@ -44,21 +85,27 @@ public enum TranslatedStrings
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)
{
this.text = text;
}
public String getText()
{
return text;
}
@Override
public String toString()
{
return getText();
return text;
}
}

View file

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

View file

@ -1,6 +1,12 @@
package the.bytecode.club.bytecodeviewer.util;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
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.net.InetAddress;
@ -45,23 +51,28 @@ public class SecurityMan extends SecurityManager
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();
if (executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.KrakatauDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.KrakatauDisassembler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.CFRDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.ProcyonDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.FernFlowerDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.decompilers.impl.JDGUIDecompiler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.impl.KrakatauAssembler") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.resources.ExternalResources") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.Enjarify") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.util.APKTool") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.BytecodeViewer") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.Constants") ||
executedClass.equals("the.bytecode.club.bytecodeviewer.compilers.impl.JavaCompiler")) {
if (executedClass.equals(KrakatauDecompiler.class.getCanonicalName()) ||
executedClass.equals(KrakatauDisassembler.class.getCanonicalName()) ||
executedClass.equals(CFRDecompiler.class.getCanonicalName()) ||
executedClass.equals(ProcyonDecompiler.class.getCanonicalName()) ||
executedClass.equals(FernFlowerDecompiler.class.getCanonicalName()) ||
executedClass.equals(JDGUIDecompiler.class.getCanonicalName()) ||
executedClass.equals(KrakatauAssembler.class.getCanonicalName()) ||
executedClass.equals(ExternalResources.class.getCanonicalName()) ||
executedClass.equals(Enjarify.class.getCanonicalName()) ||
executedClass.equals(APKTool.class.getCanonicalName()) ||
executedClass.equals(BytecodeViewer.class.getCanonicalName()) ||
executedClass.equals(Constants.class.getCanonicalName()) ||
executedClass.equals(JavaCompiler.class.getCanonicalName()))
{
blocking--;
} else for (StackTraceElement stackTraceElements : Thread.currentThread().getStackTrace()) {
}
else for (StackTraceElement stackTraceElements : Thread.currentThread().getStackTrace())
{
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.",
"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",
"QUICK_FILE_SEARCH_NO_FILE_EXTENSION": "Quick file search (no file extension)",
"WORK_SPACE": "Work Space",