skip exception

This commit is contained in:
Bob Pan 2018-03-21 12:08:35 +08:00
parent 1d515072d5
commit 1238d14b14
3 changed files with 21 additions and 2 deletions

View File

@ -69,6 +69,11 @@ public class DexFileReader implements BaseDexFileReader {
*/
public static final int KEEP_CLINIT = 1 << 7;
/**
* keep clinit method when {@link #SKIP_DEBUG}
*/
public static final int SKIP_EXCEPTION = 1 << 8;
// private static final int REVERSE_ENDIAN_CONSTANT = 0x78563412;
static final int DBG_END_SEQUENCE = 0x00;
@ -1384,7 +1389,9 @@ public class DexFileReader implements BaseDexFileReader {
if ((insns & 0x01) != 0) {// skip padding
in.getShort();
}
findTryCatch(in, dcv, tries_size, insns, labelsMap, handlers);
if (0 == (config & SKIP_EXCEPTION)) {
findTryCatch(in, dcv, tries_size, insns, labelsMap, handlers);
}
}
// 处理debug信息
if (debug_info_off != 0 && (0 == (config & SKIP_DEBUG))) {

View File

@ -60,6 +60,9 @@ public class Dex2jarCmd extends BaseCmd {
@Opt(opt = "os", longOpt = "optmize-synchronized", hasArg = false, description = "optimize-synchronized")
private boolean optmizeSynchronized = false;
@Opt(longOpt = "skip-exceptions", hasArg = false, description = "skip-exceptions")
private boolean skipExceptions = false;
@Opt(opt = "nc", longOpt = "no-code", hasArg = false, description = "")
private boolean noCode = false;
@ -106,7 +109,7 @@ public class Dex2jarCmd extends BaseCmd {
BaksmaliBaseDexExceptionHandler handler = notHandleException ? null : new BaksmaliBaseDexExceptionHandler();
Dex2jar.from(reader).withExceptionHandler(handler).reUseReg(reuseReg).topoLogicalSort()
.skipDebug(!debugInfo).optimizeSynchronized(this.optmizeSynchronized).printIR(printIR)
.noCode(noCode).to(file);
.noCode(noCode).skipExceptions(skipExceptions).to(file);
if (!notHandleException) {
if (handler.hasException()) {

View File

@ -298,4 +298,13 @@ public class Dex2jar {
this.exceptionHandler = exceptionHandler;
return this;
}
public Dex2jar skipExceptions(boolean b) {
if (b) {
this.readerConfig |= DexFileReader.SKIP_EXCEPTION;
} else {
this.readerConfig &= ~DexFileReader.SKIP_EXCEPTION;
}
return this;
}
}