bug fixes for v2.9.16
This commit is contained in:
parent
fbb9ee9b97
commit
93f38a27d0
9 changed files with 109 additions and 31 deletions
|
@ -28,7 +28,9 @@ public class APKTool {
|
||||||
try {
|
try {
|
||||||
File dir = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "Decoded Resources");
|
File dir = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + "Decoded Resources");
|
||||||
FileUtils.deleteDirectory(dir);
|
FileUtils.deleteDirectory(dir);
|
||||||
brut.apktool.Main.main(new String[]{"-s", "-f", "-o", dir.getAbsolutePath(), "decode", input.getAbsolutePath()});
|
File temp = new File(BytecodeViewer.tempDirectory + BytecodeViewer.fs + MiscUtils.randomString(12));
|
||||||
|
temp.mkdirs();
|
||||||
|
brut.apktool.Main.main(new String[]{"--frame-path", temp.getAbsolutePath(), "-s", "-f", "-o", dir.getAbsolutePath(), "decode", input.getAbsolutePath()});
|
||||||
File original = new File(dir.getAbsolutePath() + BytecodeViewer.fs + "original");
|
File original = new File(dir.getAbsolutePath() + BytecodeViewer.fs + "original");
|
||||||
FileUtils.deleteDirectory(original);
|
FileUtils.deleteDirectory(original);
|
||||||
File classes = new File(dir.getAbsolutePath() + BytecodeViewer.fs + "classes.dex");
|
File classes = new File(dir.getAbsolutePath() + BytecodeViewer.fs + "classes.dex");
|
||||||
|
|
|
@ -142,6 +142,7 @@ public class BytecodeViewer
|
||||||
public static int krakatauHash;
|
public static int krakatauHash;
|
||||||
public static boolean currentlyDumping = false;
|
public static boolean currentlyDumping = false;
|
||||||
public static boolean needsReDump = true;
|
public static boolean needsReDump = true;
|
||||||
|
public static boolean warnForEditing = false;
|
||||||
public static ArrayList<FileContainer> files = new ArrayList<FileContainer>(); //all of BCV's loaded files/classes/etc
|
public static ArrayList<FileContainer> files = new ArrayList<FileContainer>(); //all of BCV's loaded files/classes/etc
|
||||||
private static int maxRecentFiles = 25;
|
private static int maxRecentFiles = 25;
|
||||||
public static String fs = System.getProperty("file.separator");
|
public static String fs = System.getProperty("file.separator");
|
||||||
|
|
|
@ -179,8 +179,8 @@ public class Settings {
|
||||||
|
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.refreshOnChange.isSelected()), false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.isMaximized), false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileSmali.isSelected()), false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "deprecated", false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, "deprecated", false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.lastDirectory, false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.lastDirectory, false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python, false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python, false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.rt, false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.rt, false);
|
||||||
|
@ -214,6 +214,8 @@ public class Settings {
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python3, false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.python3, false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.javac, false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.javac, false);
|
||||||
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.java, false);
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, BytecodeViewer.java, false);
|
||||||
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileSmali.isSelected()), false);
|
||||||
|
DiskWriter.writeNewLine(BytecodeViewer.settingsName, String.valueOf(BytecodeViewer.viewer.autoCompileOnRefresh.isSelected()), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
new the.bytecode.club.bytecodeviewer.api.ExceptionUI(e);
|
||||||
}
|
}
|
||||||
|
@ -374,8 +376,6 @@ public class Settings {
|
||||||
BytecodeViewer.viewer.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
BytecodeViewer.viewer.setExtendedState(JFrame.MAXIMIZED_BOTH);
|
||||||
BytecodeViewer.viewer.isMaximized = true;
|
BytecodeViewer.viewer.isMaximized = true;
|
||||||
}
|
}
|
||||||
BytecodeViewer.viewer.autoCompileSmali.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 86, false)));
|
|
||||||
BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 87, false)));
|
|
||||||
BytecodeViewer.lastDirectory = DiskReader.loadString(BytecodeViewer.settingsName, 88, false);
|
BytecodeViewer.lastDirectory = DiskReader.loadString(BytecodeViewer.settingsName, 88, false);
|
||||||
BytecodeViewer.python = DiskReader.loadString(BytecodeViewer.settingsName, 89, false);
|
BytecodeViewer.python = DiskReader.loadString(BytecodeViewer.settingsName, 89, false);
|
||||||
BytecodeViewer.rt = DiskReader.loadString(BytecodeViewer.settingsName, 90, false);
|
BytecodeViewer.rt = DiskReader.loadString(BytecodeViewer.settingsName, 90, false);
|
||||||
|
@ -410,6 +410,8 @@ public class Settings {
|
||||||
BytecodeViewer.python3 = DiskReader.loadString(BytecodeViewer.settingsName, 115, false);
|
BytecodeViewer.python3 = DiskReader.loadString(BytecodeViewer.settingsName, 115, false);
|
||||||
BytecodeViewer.javac = DiskReader.loadString(BytecodeViewer.settingsName, 116, false);
|
BytecodeViewer.javac = DiskReader.loadString(BytecodeViewer.settingsName, 116, false);
|
||||||
BytecodeViewer.java = DiskReader.loadString(BytecodeViewer.settingsName, 117, false);
|
BytecodeViewer.java = DiskReader.loadString(BytecodeViewer.settingsName, 117, false);
|
||||||
|
BytecodeViewer.viewer.autoCompileSmali.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 118, false)));
|
||||||
|
BytecodeViewer.viewer.autoCompileOnRefresh.setSelected(Boolean.parseBoolean(DiskReader.loadString(BytecodeViewer.settingsName, 119, false)));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
//ignore because errors are expected, first start up and outdated settings.
|
//ignore because errors are expected, first start up and outdated settings.
|
||||||
//e.printStackTrace();
|
//e.printStackTrace();
|
||||||
|
|
|
@ -86,12 +86,42 @@ public class JavaCompiler extends Compiler {
|
||||||
Process process = pb.start();
|
Process process = pb.start();
|
||||||
BytecodeViewer.createdProcesses.add(process);
|
BytecodeViewer.createdProcesses.add(process);
|
||||||
|
|
||||||
|
Thread failSafe = new Thread()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
long started = System.currentTimeMillis();
|
||||||
|
while(System.currentTimeMillis()-started <= 10_000)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Thread.sleep(100);
|
||||||
|
}
|
||||||
|
catch (InterruptedException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(process.isAlive())
|
||||||
|
{
|
||||||
|
System.out.println("Force killing javac process, assuming it's gotten stuck");
|
||||||
|
process.destroyForcibly().destroy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
failSafe.start();
|
||||||
|
|
||||||
|
int exitValue = process.waitFor();
|
||||||
|
|
||||||
//Read out dir output
|
//Read out dir output
|
||||||
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);
|
||||||
String line;
|
String line;
|
||||||
while ((line = br.readLine()) != null) {
|
while ((line = br.readLine()) != null)
|
||||||
|
{
|
||||||
log += BytecodeViewer.nl + line;
|
log += BytecodeViewer.nl + line;
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
|
@ -105,7 +135,6 @@ public class JavaCompiler extends Compiler {
|
||||||
}
|
}
|
||||||
br.close();
|
br.close();
|
||||||
|
|
||||||
int exitValue = process.waitFor();
|
|
||||||
log += BytecodeViewer.nl + BytecodeViewer.nl + "Exit Value is " + exitValue;
|
log += BytecodeViewer.nl + BytecodeViewer.nl + "Exit Value is " + exitValue;
|
||||||
System.out.println(log);
|
System.out.println(log);
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,7 @@ public class FernFlowerDecompiler extends Decompiler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String decompileClassNode(final ClassNode cn, byte[] b) {
|
public String decompileClassNode(final ClassNode cn, byte[] b) {
|
||||||
String start = MiscUtils.getUniqueName("", ".class");
|
String start = BytecodeViewer.tempDirectory + BytecodeViewer.fs+MiscUtils.getUniqueName("", ".class");
|
||||||
|
|
||||||
final File tempClass = new File(start + ".class");
|
final File tempClass = new File(start + ".class");
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ public class FernFlowerDecompiler extends Decompiler {
|
||||||
try {
|
try {
|
||||||
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
|
ProcessBuilder pb = new ProcessBuilder(ArrayUtils.addAll(
|
||||||
new String[]{BytecodeViewer.getJavaCommand(), "-jar", Resources.findLibrary("fernflower")},
|
new String[]{BytecodeViewer.getJavaCommand(), "-jar", Resources.findLibrary("fernflower")},
|
||||||
generateMainMethod(tempClass.getAbsolutePath(), ".")
|
generateMainMethod(tempClass.getAbsolutePath(), new File(BytecodeViewer.tempDirectory).getAbsolutePath())
|
||||||
));
|
));
|
||||||
BytecodeViewer.sm.stopBlocking();
|
BytecodeViewer.sm.stopBlocking();
|
||||||
Process p = pb.start();
|
Process p = pb.start();
|
||||||
|
@ -106,12 +106,23 @@ public class FernFlowerDecompiler extends Decompiler {
|
||||||
} finally {
|
} finally {
|
||||||
BytecodeViewer.sm.setBlocking();
|
BytecodeViewer.sm.setBlocking();
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(
|
else
|
||||||
generateMainMethod(tempClass.getAbsolutePath(), "."));
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
org.jetbrains.java.decompiler.main.decompiler.ConsoleDecompiler.main(generateMainMethod(tempClass.getAbsolutePath(), new File(BytecodeViewer.tempDirectory).getAbsolutePath()));
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tempClass.delete();
|
tempClass.delete();
|
||||||
|
|
||||||
|
System.out.println(start + ".java");
|
||||||
|
|
||||||
final File outputJava = new File(start + ".java");
|
final File outputJava = new File(start + ".java");
|
||||||
if (outputJava.exists()) {
|
if (outputJava.exists()) {
|
||||||
String s;
|
String s;
|
||||||
|
|
|
@ -43,7 +43,7 @@ public class SmaliDisassembler extends Decompiler {
|
||||||
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
String fileStart = BytecodeViewer.tempDirectory + BytecodeViewer.fs
|
||||||
+ "temp";
|
+ "temp";
|
||||||
|
|
||||||
String start = MiscUtils.getUniqueName(fileStart, ".class");
|
String start = BytecodeViewer.tempDirectory + BytecodeViewer.fs+MiscUtils.getUniqueName(fileStart, ".class");
|
||||||
|
|
||||||
final File tempClass = new File(start + ".class");
|
final File tempClass = new File(start + ".class");
|
||||||
final File tempZip = new File(start + ".jar");
|
final File tempZip = new File(start + ".jar");
|
||||||
|
|
|
@ -628,6 +628,7 @@ public class ClassViewer extends Viewer {
|
||||||
} catch (InterruptedException e1) {
|
} catch (InterruptedException e1) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final byte[] b = cw.toByteArray();
|
final byte[] b = cw.toByteArray();
|
||||||
Thread t1 = new PaneUpdaterThread() {
|
Thread t1 = new PaneUpdaterThread() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -1722,6 +1723,18 @@ public class ClassViewer extends Viewer {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
t.start();
|
t.start();
|
||||||
|
|
||||||
|
if(isPanel1Editable() || isPanel2Editable() || isPanel3Editable())
|
||||||
|
{
|
||||||
|
if(!BytecodeViewer.warnForEditing)
|
||||||
|
{
|
||||||
|
BytecodeViewer.warnForEditing = true;
|
||||||
|
if(!BytecodeViewer.viewer.autoCompileOnRefresh.isSelected() && !BytecodeViewer.viewer.autoCompileSmali.isSelected())
|
||||||
|
{
|
||||||
|
BytecodeViewer.showMessage("Make sure to File>Compile (Ctrl + T) whenever you want to test or export your changes.\nYou can set compile automatically on refresh or on save in the settings menu.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object[] getSmali() {
|
public Object[] getSmali() {
|
||||||
|
|
|
@ -92,8 +92,12 @@ public class FileNavigationPane extends VisibleComponent implements
|
||||||
final String qt = quickSearch.getText();
|
final String qt = quickSearch.getText();
|
||||||
quickSearch.setText("");
|
quickSearch.setText("");
|
||||||
|
|
||||||
|
if(qt.isEmpty()) //NOPE
|
||||||
|
return;
|
||||||
|
|
||||||
|
|
||||||
String[] path = null;
|
String[] path = null;
|
||||||
|
int found = 0;
|
||||||
|
|
||||||
if (qt.contains(".")) {
|
if (qt.contains(".")) {
|
||||||
path = qt.split("\\.");
|
path = qt.split("\\.");
|
||||||
|
@ -122,12 +126,18 @@ public class FileNavigationPane extends VisibleComponent implements
|
||||||
if (((String) child.getUserObject()).equals(pathName)) {
|
if (((String) child.getUserObject()).equals(pathName)) {
|
||||||
curNode = child;
|
curNode = child;
|
||||||
if (isLast) {
|
if (isLast) {
|
||||||
|
System.out.println("Found! " + curNode);
|
||||||
|
found++;
|
||||||
|
if(found >= 30)
|
||||||
|
{
|
||||||
|
BytecodeViewer.showMessage("Uh oh, there could be more results but you've triggered the 30 classes at once limit. Try refining your search.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
final TreePath pathn = new TreePath(curNode.getPath());
|
final TreePath pathn = new TreePath(curNode.getPath());
|
||||||
tree.setSelectionPath(pathn);
|
tree.setSelectionPath(pathn);
|
||||||
tree.makeVisible(pathn);
|
tree.makeVisible(pathn);
|
||||||
tree.scrollPathToVisible(pathn);
|
tree.scrollPathToVisible(pathn);
|
||||||
openPath(pathn); //auto open
|
openPath(pathn); //auto open
|
||||||
System.out.println("Found! " + curNode);
|
|
||||||
break pathLoop;
|
break pathLoop;
|
||||||
}
|
}
|
||||||
continue pathLoop;
|
continue pathLoop;
|
||||||
|
@ -161,6 +171,12 @@ public class FileNavigationPane extends VisibleComponent implements
|
||||||
String fullPathString = fullPath.toString();
|
String fullPathString = fullPath.toString();
|
||||||
if (fullPathString != null && fullPathString.toLowerCase().contains(qt.toLowerCase())) {
|
if (fullPathString != null && fullPathString.toLowerCase().contains(qt.toLowerCase())) {
|
||||||
System.out.println("Found! " + node);
|
System.out.println("Found! " + node);
|
||||||
|
found++;
|
||||||
|
if(found >= 30)
|
||||||
|
{
|
||||||
|
BytecodeViewer.showMessage("Uh oh, there could be more results but you've triggered the 30 classes at once limit. Try refining your search.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
final TreePath pathn = new TreePath(node.getPath());
|
final TreePath pathn = new TreePath(node.getPath());
|
||||||
tree.setSelectionPath(pathn.getParentPath());
|
tree.setSelectionPath(pathn.getParentPath());
|
||||||
tree.setSelectionPath(pathn);
|
tree.setSelectionPath(pathn);
|
||||||
|
@ -221,29 +237,33 @@ public class FileNavigationPane extends VisibleComponent implements
|
||||||
|
|
||||||
this.tree.addKeyListener(new KeyListener() {
|
this.tree.addKeyListener(new KeyListener() {
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent arg0) {
|
public void keyReleased(KeyEvent e) {
|
||||||
if (arg0.getKeyCode() == KeyEvent.VK_ENTER) {
|
|
||||||
if (arg0.getSource() instanceof MyTree) {
|
|
||||||
MyTree tree = (MyTree) arg0.getSource();
|
|
||||||
openPath(tree.getSelectionPath());
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
cancel = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyTyped(KeyEvent e) {
|
public void keyTyped(KeyEvent e) {
|
||||||
quickSearch.grabFocus();
|
|
||||||
quickSearch.setText("" + e.getKeyChar()); // fuck
|
|
||||||
cancel = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
quickSearch.grabFocus();
|
if (e.getKeyCode() == KeyEvent.VK_ENTER)
|
||||||
quickSearch.setText("" + e.getKeyChar()); // fuck
|
{
|
||||||
cancel = true;
|
if (e.getSource() instanceof MyTree)
|
||||||
|
{
|
||||||
|
MyTree tree = (MyTree) e.getSource();
|
||||||
|
openPath(tree.getSelectionPath());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if((int)e.getKeyChar() != 0 && (int)e.getKeyChar() != 65535)
|
||||||
|
{
|
||||||
|
quickSearch.grabFocus();
|
||||||
|
quickSearch.setText("" + e.getKeyChar());
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cancel = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -1601,10 +1601,10 @@ public class MainViewerGUI extends JFrame implements FileChangeNotifier {
|
||||||
mnPane_1.add(panel3Hexcode);
|
mnPane_1.add(panel3Hexcode);
|
||||||
|
|
||||||
menuBar.add(mnSettings);
|
menuBar.add(mnSettings);
|
||||||
autoCompileSmali.setSelected(true);
|
autoCompileSmali.setSelected(false);
|
||||||
|
|
||||||
mnSettings.add(autoCompileSmali);
|
mnSettings.add(autoCompileSmali);
|
||||||
autoCompileOnRefresh.setSelected(true);
|
autoCompileOnRefresh.setSelected(false);
|
||||||
|
|
||||||
mnSettings.add(autoCompileOnRefresh);
|
mnSettings.add(autoCompileOnRefresh);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue