From 838b35e4775636d694819b990069ba60fb903e78 Mon Sep 17 00:00:00 2001 From: Ben Gruver Date: Wed, 29 Jan 2014 19:39:34 -0800 Subject: [PATCH] Fix NPE when using a custom inline method table --- .../baksmali/src/main/java/org/jf/baksmali/baksmali.java | 6 ++++++ .../src/main/java/org/jf/baksmali/baksmaliOptions.java | 2 ++ .../baksmali/src/main/java/org/jf/baksmali/main.java | 7 +++---- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java index fcc89d7a..056ff486 100644 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java +++ b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmali.java @@ -34,6 +34,7 @@ import com.google.common.collect.Lists; import com.google.common.collect.Ordering; import org.jf.baksmali.Adaptors.ClassDefinition; import org.jf.dexlib2.analysis.ClassPath; +import org.jf.dexlib2.analysis.CustomInlineMethodResolver; import org.jf.dexlib2.iface.ClassDef; import org.jf.dexlib2.iface.DexFile; import org.jf.dexlib2.util.SyntheticAccessorResolver; @@ -67,6 +68,11 @@ public class baksmali { options.classPath = ClassPath.fromClassPath(options.bootClassPathDirs, Iterables.concat(options.bootClassPathEntries, extraClassPathEntries), dexFile, options.apiLevel); + + if (options.customInlineDefinitions != null) { + options.inlineResolver = new CustomInlineMethodResolver(options.classPath, + options.customInlineDefinitions); + } } catch (Exception ex) { System.err.println("\n\nError occurred while loading boot class path files. Aborting."); ex.printStackTrace(System.err); diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java index 07a05869..1517c68d 100644 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java +++ b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/baksmaliOptions.java @@ -36,6 +36,7 @@ import org.jf.dexlib2.analysis.ClassPath; import org.jf.dexlib2.analysis.InlineMethodResolver; import org.jf.dexlib2.util.SyntheticAccessorResolver; +import java.io.File; import java.util.Arrays; import java.util.HashMap; import java.util.List; @@ -73,6 +74,7 @@ public class baksmaliOptions { public boolean deodex = false; public boolean ignoreErrors = false; public boolean checkPackagePrivateAccess = false; + public File customInlineDefinitions = null; public InlineMethodResolver inlineResolver = null; public int registerInfo = 0; public ClassPath classPath = null; diff --git a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java index a8b1e241..274f1441 100644 --- a/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java +++ b/brut.apktool.smali/baksmali/src/main/java/org/jf/baksmali/main.java @@ -31,7 +31,6 @@ package org.jf.baksmali; import com.google.common.collect.Lists; import org.apache.commons.cli.*; import org.jf.dexlib2.DexFileFactory; -import org.jf.dexlib2.analysis.CustomInlineMethodResolver; import org.jf.dexlib2.analysis.InlineMethodResolver; import org.jf.dexlib2.dexbacked.DexBackedDexFile; import org.jf.dexlib2.dexbacked.DexBackedOdexFile; @@ -217,7 +216,7 @@ public class main { options.ignoreErrors = true; break; case 'T': - options.inlineResolver = new CustomInlineMethodResolver(options.classPath, new File(commandLine.getOptionValue("T"))); + options.customInlineDefinitions = new File(commandLine.getOptionValue("T")); break; default: assert false; @@ -270,7 +269,7 @@ public class main { } } - if (options.inlineResolver == null && dexFile instanceof DexBackedOdexFile) { + if (options.customInlineDefinitions == null && dexFile instanceof DexBackedOdexFile) { options.inlineResolver = InlineMethodResolver.createInlineMethodResolver(((DexBackedOdexFile)dexFile).getOdexVersion()); } @@ -529,4 +528,4 @@ public class main { "/system/framework/apache-xml.jar"); } } -} \ No newline at end of file +}