Use computeFrames option in dex2jar
This yields more accurate outputs and circumvents bugs
This commit is contained in:
parent
41fea8fb8d
commit
c5240e718e
|
@ -1,11 +1,13 @@
|
||||||
package the.bytecode.club.bytecodeviewer.util;
|
package the.bytecode.club.bytecodeviewer.util;
|
||||||
|
|
||||||
|
import com.googlecode.d2j.DexException;
|
||||||
|
import com.googlecode.d2j.Method;
|
||||||
import com.googlecode.d2j.dex.Dex2jar;
|
import com.googlecode.d2j.dex.Dex2jar;
|
||||||
import com.googlecode.d2j.dex.DexExceptionHandler;
|
import com.googlecode.d2j.dex.DexExceptionHandler;
|
||||||
import com.googlecode.d2j.Method;
|
|
||||||
import com.googlecode.d2j.node.DexMethodNode;
|
import com.googlecode.d2j.node.DexMethodNode;
|
||||||
import org.objectweb.asm.MethodVisitor;
|
import com.googlecode.dex2jar.tools.Jar2Dex;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import org.objectweb.asm.MethodVisitor;
|
||||||
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
|
@ -43,17 +45,19 @@ public class Dex2Jar {
|
||||||
public static synchronized void dex2Jar(File input, File output) {
|
public static synchronized void dex2Jar(File input, File output) {
|
||||||
try {
|
try {
|
||||||
Dex2jar d2Jar = Dex2jar.from(input)
|
Dex2jar d2Jar = Dex2jar.from(input)
|
||||||
|
.computeFrames(true)
|
||||||
.withExceptionHandler(new DexExceptionHandler() {
|
.withExceptionHandler(new DexExceptionHandler() {
|
||||||
public void handleFileException(Exception e) {
|
public void handleFileException(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleMethodTranslateException(Method method, DexMethodNode methodNode, MethodVisitor mv, Exception e) {
|
public void handleMethodTranslateException(Method method, DexMethodNode methodNode,
|
||||||
|
MethodVisitor mv, Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
d2Jar.to(output.toPath());
|
d2Jar.to(output.toPath());
|
||||||
} catch (com.googlecode.d2j.DexException e) {
|
} catch (DexException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
BytecodeViewer.handleException(e);
|
BytecodeViewer.handleException(e);
|
||||||
|
@ -72,7 +76,8 @@ public class Dex2Jar {
|
||||||
|
|
||||||
public static synchronized void saveAsDex(File input, File output, boolean delete) {
|
public static synchronized void saveAsDex(File input, File output, boolean delete) {
|
||||||
try {
|
try {
|
||||||
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(),
|
Jar2Dex.main(input.getAbsolutePath(),
|
||||||
|
"-f",
|
||||||
"-o", output.getAbsolutePath(),
|
"-o", output.getAbsolutePath(),
|
||||||
"-s", BytecodeViewer.viewer.getMinSdkVersion() + "");
|
"-s", BytecodeViewer.viewer.getMinSdkVersion() + "");
|
||||||
if (delete)
|
if (delete)
|
||||||
|
@ -81,4 +86,5 @@ public class Dex2Jar {
|
||||||
BytecodeViewer.handleException(e);
|
BytecodeViewer.handleException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user