Package soot.toDex
Class DexPrinter
- java.lang.Object
-
- soot.toDex.DexPrinter
-
public class DexPrinter extends Object
Creates
apkorjarfile with compileddexclasses. Main entry point for the "dex" output format.Use
add(SootClass)to add classes that should be printed as dex output andprint()to finally print the classes.If the printer has found the original
APKof an added class (viaSourceLocator#classContainerFileClassIndex()), the files in theAPKare copied to a new one, replacing it'sclasses.dexand excluding the signature files. Note that you have to sign and align the APK yourself, with jarsigner and zipalign, respectively.If
Options.output_jarflag is set, the printer producesJARfile.If there is no original
APKandOptions.output_jarflag is not set the printer just emits aclasses.dex.- See Also:
- jarsigner documentation, zipalign documentation
-
-
Field Summary
Fields Modifier and Type Field Description protected MultiDexBuilderdexBuilderprotected FileoriginalApkstatic PatternSIGNATURE_FILE_PATTERN
-
Constructor Summary
Constructors Constructor Description DexPrinter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(SootClass c)protected voidaddClassDefinition(org.jf.dexlib2.iface.ClassDef classDef)protected Set<org.jf.dexlib2.iface.Annotation>buildClassAnnotations(SootClass c)protected StmtVisitorbuildStmtVisitor(SootMethod belongingMethod, DexArrayInitDetector arrayInitDetector)Creates a statement visitor to build code for each statement.protected List<org.jf.dexlib2.immutable.ImmutableAnnotation>buildVisibilityAnnotationTag(VisibilityAnnotationTag t, Set<String> skipList)protected MultiDexBuildercreateDexBuilder()Creates theMultiDexBuilderthat shall be used for creating potentially multiple dex files.protected booleanisIgnored(SootField sf)Checks whether the given field shall be ignored, i.e., not written out to dexprotected booleanisIgnored(SootMethod sm)Checks whether the given method shall be ignored, i.e., not written out to dexprotected org.jf.dexlib2.iface.value.EncodedValuemakeConstantItem(SootField sf, Tag t)voidprint()protected static org.jf.dexlib2.iface.reference.FieldReferencetoFieldReference(SootField f)protected static org.jf.dexlib2.iface.reference.FieldReferencetoFieldReference(SootFieldRef ref)protected voidtoInstructions(Collection<Unit> units, StmtVisitor stmtV, Set<Unit> trapReferences)protected org.jf.dexlib2.iface.MethodImplementationtoMethodImplementation(SootMethod m)protected static org.jf.dexlib2.iface.reference.MethodReferencetoMethodReference(SootMethodRef m)protected Collection<org.jf.dexlib2.iface.Method>toMethods(SootClass clazz)protected voidtoTries(Collection<Trap> traps, org.jf.dexlib2.builder.MethodImplementationBuilder builder, LabelAssigner labelAssigner)static org.jf.dexlib2.iface.reference.TypeReferencetoTypeReference(Type t)protected voidwriteMemberClasses(SootClass c, Set<String> skipList, Set<org.jf.dexlib2.iface.Annotation> annotations)protected voidwriteTagsForStatement(org.jf.dexlib2.builder.MethodImplementationBuilder builder, Stmt stmt)Writes out the information stored in the tags associated with the given statement
-
-
-
Field Detail
-
SIGNATURE_FILE_PATTERN
public static final Pattern SIGNATURE_FILE_PATTERN
-
dexBuilder
protected MultiDexBuilder dexBuilder
-
originalApk
protected File originalApk
-
-
Method Detail
-
createDexBuilder
protected MultiDexBuilder createDexBuilder()
Creates theMultiDexBuilderthat shall be used for creating potentially multiple dex files. This method makes sure that users of Soot can overwrite theMultiDexBuilderwith custom strategies.- Returns:
- The new
MultiDexBuilder
-
toFieldReference
protected static org.jf.dexlib2.iface.reference.FieldReference toFieldReference(SootField f)
-
toFieldReference
protected static org.jf.dexlib2.iface.reference.FieldReference toFieldReference(SootFieldRef ref)
-
toMethodReference
protected static org.jf.dexlib2.iface.reference.MethodReference toMethodReference(SootMethodRef m)
-
toTypeReference
public static org.jf.dexlib2.iface.reference.TypeReference toTypeReference(Type t)
-
makeConstantItem
protected org.jf.dexlib2.iface.value.EncodedValue makeConstantItem(SootField sf, Tag t)
-
addClassDefinition
protected void addClassDefinition(org.jf.dexlib2.iface.ClassDef classDef)
-
buildClassAnnotations
protected Set<org.jf.dexlib2.iface.Annotation> buildClassAnnotations(SootClass c)
-
writeMemberClasses
protected void writeMemberClasses(SootClass c, Set<String> skipList, Set<org.jf.dexlib2.iface.Annotation> annotations)
-
buildVisibilityAnnotationTag
protected List<org.jf.dexlib2.immutable.ImmutableAnnotation> buildVisibilityAnnotationTag(VisibilityAnnotationTag t, Set<String> skipList)
-
toMethods
protected Collection<org.jf.dexlib2.iface.Method> toMethods(SootClass clazz)
-
isIgnored
protected boolean isIgnored(SootMethod sm)
Checks whether the given method shall be ignored, i.e., not written out to dex- Parameters:
sm- The method to check- Returns:
- True to ignore the method while writing the dex file, false to write it out as normal
-
isIgnored
protected boolean isIgnored(SootField sf)
Checks whether the given field shall be ignored, i.e., not written out to dex- Parameters:
sf- The field to check- Returns:
- True to ignore the field while writing the dex file, false to write it out as normal
-
toMethodImplementation
protected org.jf.dexlib2.iface.MethodImplementation toMethodImplementation(SootMethod m)
-
buildStmtVisitor
protected StmtVisitor buildStmtVisitor(SootMethod belongingMethod, DexArrayInitDetector arrayInitDetector)
Creates a statement visitor to build code for each statement. Allows subclasses to use own implementations- Parameters:
belongingMethod- the methodarrayInitDetector- auxilliary class for detecting array initializations- Returns:
- the statement visitor
-
writeTagsForStatement
protected void writeTagsForStatement(org.jf.dexlib2.builder.MethodImplementationBuilder builder, Stmt stmt)Writes out the information stored in the tags associated with the given statement- Parameters:
builder- The builder used to generate the Dalvik method implementationstmt- The statement for which to write out the tags
-
toInstructions
protected void toInstructions(Collection<Unit> units, StmtVisitor stmtV, Set<Unit> trapReferences)
-
toTries
protected void toTries(Collection<Trap> traps, org.jf.dexlib2.builder.MethodImplementationBuilder builder, LabelAssigner labelAssigner)
-
add
public void add(SootClass c)
-
print
public void print()
-
-