Use computeFrames option in dex2jar

This yields more accurate outputs and circumvents bugs
This commit is contained in:
Nico Mexis 2024-04-09 11:59:14 +02:00
parent 41fea8fb8d
commit c5240e718e
No known key found for this signature in database
GPG Key ID: 27D6E17CE092AB78

AI 샘플 코드 생성 중입니다

Loading...

View File

@ -1,11 +1,13 @@
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.DexExceptionHandler;
import com.googlecode.d2j.Method;
import com.googlecode.d2j.node.DexMethodNode;
import org.objectweb.asm.MethodVisitor;
import com.googlecode.dex2jar.tools.Jar2Dex;
import java.io.File;
import org.objectweb.asm.MethodVisitor;
import the.bytecode.club.bytecodeviewer.BytecodeViewer;
/***************************************************************************
@ -43,17 +45,19 @@ public class Dex2Jar {
public static synchronized void dex2Jar(File input, File output) {
try {
Dex2jar d2Jar = Dex2jar.from(input)
.withExceptionHandler(new DexExceptionHandler() {
public void handleFileException(Exception e) {
e.printStackTrace();
}
.computeFrames(true)
.withExceptionHandler(new DexExceptionHandler() {
public void handleFileException(Exception e) {
e.printStackTrace();
}
public void handleMethodTranslateException(Method method, DexMethodNode methodNode, MethodVisitor mv, Exception e) {
e.printStackTrace();
}
});
public void handleMethodTranslateException(Method method, DexMethodNode methodNode,
MethodVisitor mv, Exception e) {
e.printStackTrace();
}
});
d2Jar.to(output.toPath());
} catch (com.googlecode.d2j.DexException e) {
} catch (DexException e) {
e.printStackTrace();
} catch (Exception e) {
BytecodeViewer.handleException(e);
@ -72,7 +76,8 @@ public class Dex2Jar {
public static synchronized void saveAsDex(File input, File output, boolean delete) {
try {
com.googlecode.dex2jar.tools.Jar2Dex.main(input.getAbsolutePath(),
Jar2Dex.main(input.getAbsolutePath(),
"-f",
"-o", output.getAbsolutePath(),
"-s", BytecodeViewer.viewer.getMinSdkVersion() + "");
if (delete)
@ -81,4 +86,5 @@ public class Dex2Jar {
BytecodeViewer.handleException(e);
}
}
}