private static String baksmali(DexBackedClassDef def) throws IOException { baksmaliOptions opts = new baksmaliOptions(); opts.outputDebugInfo = false; opts.syntheticAccessorResolver = new SyntheticAccessorResolver(Collections.EMPTY_LIST); ClassDefinition classDefinition = new ClassDefinition(opts, def); StringWriter bufWriter = new StringWriter(); IndentingWriter writer = new IndentingWriter(bufWriter); classDefinition.writeTo((IndentingWriter) writer); writer.flush(); return bufWriter.toString(); } }
public void writeTo(IndentingWriter writer) throws IOException { writeClass(writer); writeSuper(writer); writeSourceFile(writer); writeInterfaces(writer); writeAnnotations(writer); Set<String> staticFields = writeStaticFields(writer); writeInstanceFields(writer, staticFields); Set<String> directMethods = writeDirectMethods(writer); writeVirtualMethods(writer, directMethods); }
private static ClassDefinition toClassDefinition(DexBackedMethodImplementation dexBackedMethodImplementation) { ClassDefinition classDefinition = new ClassDefinition(createBaksmaliOptions(dexBackedMethodImplementation.method.classDef), dexBackedMethodImplementation.method.classDef); return classDefinition; }
private void writeClass(IndentingWriter writer) throws IOException { writer.write(".class "); writeAccessFlags(writer); writer.write(classDef.getType()); writer.write('\n'); }
public ClassDefinition(@Nonnull BaksmaliOptions options, @Nonnull ClassDef classDef) { this.options = options; this.classDef = classDef; fieldsSetInStaticConstructor = findFieldsSetInStaticConstructor(classDef); }
public void writeTo(IndentingWriter writer) throws IOException { writeClass(writer); writeSuper(writer); writeSourceFile(writer); writeInterfaces(writer); writeAnnotations(writer); Set<String> staticFields = writeStaticFields(writer); writeInstanceFields(writer, staticFields); Set<String> directMethods = writeDirectMethods(writer); writeVirtualMethods(writer, directMethods); }
private static ClassDefinition toClassDefinition(ClassDef classDef) { ClassDefinition classDefinition = new ClassDefinition(createBaksmaliOptions(classDef), classDef); return classDefinition; }
private void writeClass(IndentingWriter writer) throws IOException { writer.write(".class "); writeAccessFlags(writer); writer.write(classDef.getType()); writer.write('\n'); }
public ClassDefinition(@Nonnull BaksmaliOptions options, @Nonnull ClassDef classDef) { this.options = options; this.classDef = classDef; fieldsSetInStaticConstructor = findFieldsSetInStaticConstructor(classDef); }
public void writeTo(IndentingWriter writer) throws IOException { writeClass(writer); writeSuper(writer); writeSourceFile(writer); writeInterfaces(writer); writeAnnotations(writer); Set<String> staticFields = writeStaticFields(writer); writeInstanceFields(writer, staticFields); Set<String> directMethods = writeDirectMethods(writer); writeVirtualMethods(writer, directMethods); }
public static void writeSmaliContent(@Nonnull String type, @Nonnull ClassPath classPath, @Nonnull java.io.Writer outWriter) { final org.jf.baksmali.BaksmaliOptions options = new org.jf.baksmali.BaksmaliOptions(); final org.jf.dexlib2.iface.ClassDef classDef = classPath.getClassDef(type); options.apiLevel = VersionMap.mapArtVersionToApi(classPath.oatVersion); options.allowOdex = true; options.classPath = classPath; final ClassDefinition cd = new ClassDefinition(options, classDef); try { org.jf.util.IndentingWriter writer = new org.jf.util.IndentingWriter(outWriter); cd.writeTo(writer); } catch (IOException ex) { LLog.ex(ex); } }
private void writeClass(IndentingWriter writer) throws IOException { writer.write(".class "); writeAccessFlags(writer); writer.write(classDef.getType()); writer.write('\n'); }
public ClassDefinition(@Nonnull baksmaliOptions options, @Nonnull ClassDef classDef) { this.options = options; this.classDef = classDef; fieldsSetInStaticConstructor = findFieldsSetInStaticConstructor(); }
ClassDefinition classDefinition = new ClassDefinition(options, classDef); classDefinition.writeTo((IndentingWriter)writer); } catch (Exception ex) { System.err.println("\n\nError occurred while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
ClassDefinition classDefinition = new ClassDefinition(options, classDef); classDefinition.writeTo((IndentingWriter)writer); } catch (Exception ex) { System.err.println("\n\nError occurred while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
ClassDefinition classDefinition = new ClassDefinition(options, classDef); classDefinition.writeTo((IndentingWriter)writer); } catch (Exception ex) { System.err.println("\n\nError occurred while disassembling class " + classDescriptor.replace('/', '.') + " - skipping class");
@Nonnull public static String getNormalizedSmali(@Nonnull ClassDef classDef, @Nonnull BaksmaliOptions options, boolean stripComments) throws IOException { StringWriter stringWriter = new StringWriter(); IndentingWriter writer = new IndentingWriter(stringWriter); ClassDefinition classDefinition = new ClassDefinition(options, classDef); classDefinition.writeTo(writer); writer.close(); return normalizeSmali(stringWriter.toString(), stripComments); }
ClassDefinition classDefinition = new ClassDefinition(options, classDef); classDefinition.writeTo((IndentingWriter) writer); } catch (Exception ex) { Logger.log("\n\nError occurred while disassembling class "
public void runTest(String test, boolean registerInfo, boolean isArt) throws IOException, URISyntaxException { String dexFilePath = String.format("%s%sclasses.dex", test, File.separatorChar); DexFile dexFile = DexFileFactory.loadDexFile(findResource(dexFilePath), Opcodes.getDefault()); BaksmaliOptions options = new BaksmaliOptions(); if (registerInfo) { options.registerInfo = BaksmaliOptions.ALL | BaksmaliOptions.FULLMERGE; if (isArt) { options.classPath = new ClassPath(new ArrayList<ClassProvider>(), true, 56); } else { options.classPath = new ClassPath(); } } options.implicitReferences = false; for (ClassDef classDef: dexFile.getClasses()) { StringWriter stringWriter = new StringWriter(); IndentingWriter writer = new IndentingWriter(stringWriter); ClassDefinition classDefinition = new ClassDefinition(options, classDef); classDefinition.writeTo(writer); writer.close(); String className = classDef.getType(); String smaliPath = String.format("%s%s%s.smali", test, File.separatorChar, className.substring(1, className.length() - 1)); String smaliContents = readResource(smaliPath); Assert.assertEquals(BaksmaliTestUtils.normalizeWhitespace(smaliContents), BaksmaliTestUtils.normalizeWhitespace((stringWriter.toString()))); } }