Search in sources :

Example 1 with BaksmaliFormatter

use of org.jf.baksmali.formatter.BaksmaliFormatter in project smali by JesusFreke.

the class ListFieldOffsetsCommand method run.

@Override
public void run() {
    if (help || inputList == null || inputList.isEmpty()) {
        usage();
        return;
    }
    if (inputList.size() > 1) {
        System.err.println("Too many files specified");
        usage();
        return;
    }
    String input = inputList.get(0);
    loadDexFile(input);
    BaksmaliOptions options = getOptions();
    BaksmaliFormatter formatter = new BaksmaliFormatter();
    try {
        for (ClassDef classDef : dexFile.getClasses()) {
            ClassProto classProto = (ClassProto) options.classPath.getClass(classDef);
            SparseArray<FieldReference> fields = classProto.getInstanceFields();
            String className = "Class " + formatter.getType(classDef.getType()) + " : " + fields.size() + " instance fields\n";
            System.out.write(className.getBytes());
            for (int i = 0; i < fields.size(); i++) {
                String field = fields.keyAt(i) + ":" + fields.valueAt(i).getType() + " " + fields.valueAt(i).getName() + "\n";
                System.out.write(field.getBytes());
            }
            System.out.write("\n".getBytes());
        }
        System.out.close();
    } catch (IOException ex) {
        throw new RuntimeException(ex);
    }
}
Also used : ClassProto(org.jf.dexlib2.analysis.ClassProto) ClassDef(org.jf.dexlib2.iface.ClassDef) FieldReference(org.jf.dexlib2.iface.reference.FieldReference) BaksmaliFormatter(org.jf.baksmali.formatter.BaksmaliFormatter) IOException(java.io.IOException)

Example 2 with BaksmaliFormatter

use of org.jf.baksmali.formatter.BaksmaliFormatter in project smali by JesusFreke.

the class ListReferencesCommand method run.

@Override
public void run() {
    if (help || inputList == null || inputList.isEmpty()) {
        usage();
        return;
    }
    if (inputList.size() > 1) {
        System.err.println("Too many files specified");
        usage();
        return;
    }
    String input = inputList.get(0);
    loadDexFile(input);
    BaksmaliFormatter formatter = new BaksmaliFormatter();
    for (Reference reference : dexFile.getReferences(referenceType)) {
        System.out.println(formatter.getReference(reference));
    }
}
Also used : Reference(org.jf.dexlib2.iface.reference.Reference) BaksmaliFormatter(org.jf.baksmali.formatter.BaksmaliFormatter)

Example 3 with BaksmaliFormatter

use of org.jf.baksmali.formatter.BaksmaliFormatter in project smali by JesusFreke.

the class ListClassesCommand method run.

@Override
public void run() {
    if (help || inputList == null || inputList.isEmpty()) {
        usage();
        return;
    }
    if (inputList.size() > 1) {
        System.err.println("Too many files specified");
        usage();
        return;
    }
    String input = inputList.get(0);
    loadDexFile(input);
    BaksmaliFormatter formatter = new BaksmaliFormatter();
    for (ClassDef classDef : dexFile.getClasses()) {
        System.out.println(formatter.getType(classDef.getType()));
    }
}
Also used : ClassDef(org.jf.dexlib2.iface.ClassDef) BaksmaliFormatter(org.jf.baksmali.formatter.BaksmaliFormatter)

Aggregations

BaksmaliFormatter (org.jf.baksmali.formatter.BaksmaliFormatter)3 ClassDef (org.jf.dexlib2.iface.ClassDef)2 IOException (java.io.IOException)1 ClassProto (org.jf.dexlib2.analysis.ClassProto)1 FieldReference (org.jf.dexlib2.iface.reference.FieldReference)1 Reference (org.jf.dexlib2.iface.reference.Reference)1