Tabnine Logo
DexFileFactory.loadDexFile
Code IndexAdd Tabnine to your IDE (free)

How to use
loadDexFile
method
in
org.jf.dexlib2.DexFileFactory

Best Java code snippets using org.jf.dexlib2.DexFileFactory.loadDexFile (Showing top 20 results out of 315)

origin: JesusFreke/smali

@Nonnull
public static DexBackedDexFile loadDexFile(@Nonnull String path, @Nullable Opcodes opcodes) throws IOException {
  return loadDexFile(new File(path), opcodes);
}
origin: JesusFreke/smali

  dexFile = DexFileFactory.loadDexFile(file, opcodes);
} catch (IOException ex) {
  throw new RuntimeException(ex);
origin: pxb1988/dex2jar

private void dotest(File dexFile) throws IOException {
  DexBackedDexFile dex;
  try {
    dex = DexFileFactory.loadDexFile(dexFile, 14, false);
  } catch (DexBackedDexFile.NotADexFile ex) {
    ex.printStackTrace();
origin: com.taobao.android/dex_patch

private static DexFile readDexFile(String fileName) throws IOException {
  File srcFile = new File(fileName);
  return DexFileFactory.loadDexFile(srcFile, 15, true);
}
origin: testwhat/SmaliEx

@Nonnull
public static DexBackedDexFile loadSingleDex(@Nonnull File file,
                       @Nullable Opcodes opc) throws IOException {
  return DexFileFactory.loadDexFile(file, opc);
}
origin: org.smali/dexlib2

@Nonnull
public static DexBackedDexFile loadDexFile(@Nonnull String path, @Nullable Opcodes opcodes) throws IOException {
  return loadDexFile(new File(path), opcodes);
}
origin: com.taobao.android/dex_patch

public DexReader(List<File>files) throws IOException {
  for (File file:files){
    DexFile dexFile =DexFileFactory.loadDexFile(file,19,true);
    classDefs.addAll(dexFile.getClasses());
  }
}
origin: com.taobao.android/dex_patch

public DexReader(File file) throws IOException {
  if (file.exists()){
    org.jf.dexlib2.iface.DexFile dexFile = DexFileFactory.loadDexFile(file,19,true);
    this.classDefs = dexFile.getClasses();
  }
}
public DexReader(List<File>files) throws IOException {
origin: KB5201314/ZjDroid

@Nonnull
public static DexBackedDexFile loadDexFile(String path, int api) throws IOException {
  return loadDexFile(new File(path), new Opcodes(api));
}
origin: KB5201314/ZjDroid

@Nonnull
public static DexBackedDexFile loadDexFile(File dexFile, int api) throws IOException {
  return loadDexFile(dexFile, new Opcodes(api));
}
origin: com.taobao.android/dex_patch

private static Map<String, ClassDef> getBundleClassDef(File file) throws IOException {
  HashMap<String, ClassDef> classDefMap = new HashMap<String, ClassDef>();
  File[] dexFiles = getDexFiles(file);
  HashSet<ClassDef> classDefs = new HashSet<ClassDef>();
  for (File dexFile : dexFiles) {
    classDefs.addAll(DexFileFactory.loadDexFile(dexFile, 19, true).getClasses());
  }
  for (ClassDef classDef : classDefs) {
    classDefMap.put(classDef.getType(), classDef);
  }
  return classDefMap;
}
origin: com.ibm.wala/com.ibm.wala.dalvik

/**
 * @param f
 *            the .dex or .apk file
 */
private DexFileModule(File f, int apiLevel) throws IllegalArgumentException {
  try {
    this.f = f;
    dexfile = DexFileFactory.loadDexFile(f, apiLevel == AUTO_INFER_API_LEVEL? null : Opcodes.forApi(apiLevel));
  } catch (IOException e) {
    throw new IllegalArgumentException(e);
  }
  // create ModuleEntries from ClassDefItem
  entries = new HashSet<>();
  for (ClassDef cdefitems : dexfile.getClasses()) {
    entries.add(new DexModuleEntry(cdefitems, this));
  }
}
origin: wala/WALA

/**
 * @param f
 *            the .dex or .apk file
 */
private DexFileModule(File f, int apiLevel) throws IllegalArgumentException {
  try {
    this.f = f;
    dexfile = DexFileFactory.loadDexFile(f, apiLevel == AUTO_INFER_API_LEVEL? null : Opcodes.forApi(apiLevel));
  } catch (IOException e) {
    throw new IllegalArgumentException(e);
  }
  // create ModuleEntries from ClassDefItem
  entries = new HashSet<>();
  for (ClassDef cdefitems : dexfile.getClasses()) {
    entries.add(new DexModuleEntry(cdefitems, this));
  }
}
origin: com.taobao.android/dex_patch

/**
 * scan base Dex,get base Dex info
 */
private void scanBaseDexFile() throws IOException {
  for (File baseDexFile : baseDexFiles) {
    DexBackedDexFile baseBackedDexFile = DexFileFactory.loadDexFile(baseDexFile, apiLevel, true);
    final Set<? extends DexBackedClassDef> baseClassDefs = baseBackedDexFile.getClasses();
    dexDiffInfo.setOldClasses(baseClassDefs);
    for (DexBackedClassDef baseClassDef : baseClassDefs) {
      String className = getDalvikClassName(baseClassDef.getType());
      baseClassDefMap.put(className, baseClassDef);
    }
  }
}
origin: TACIXAT/CFGScanDroid

  dexFile = DexFileFactory.loadDexFile(dexFileFile, 15);
} catch(org.jf.util.ExceptionWithContext e) {
  System.err.println(e);
origin: com.taobao.android/dex_patch

mappingProcessor.updateFieldType();
InsTructionsReIClassDef insTructionsReDef = new InsTructionsReIClassDef(new MappingClassProcessor(mappingProcessor));
DexFile dFile = DexFileFactory.loadDexFile(inputFile.getAbsolutePath(), 19, true);
Set<ClassDef> classes = new HashSet<ClassDef>();
classes.addAll(dFile.getClasses());
origin: com.taobao.android/dex_patch

public static Set<DexBackedClassDef> scanClasses(File smaliDir, List<File> newFiles) throws PatchException {
  Set<DexBackedClassDef> classes = Sets.newHashSet();
  try {
    for (File newFile : newFiles) {
      DexBackedDexFile newDexFile = DexFileFactory.loadDexFile(newFile, 19, true);
      Set<? extends DexBackedClassDef> dexClasses = newDexFile.getClasses();
      classes.addAll(dexClasses);
    }
    final ClassFileNameHandler outFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
    final ClassFileNameHandler inFileNameHandler = new ClassFileNameHandler(smaliDir, ".smali");
    for (DexBackedClassDef classDef : classes) {
      String className = classDef.getType();
      ApkPatch.currentClassType = null;
      AfBakSmali.disassembleClass(classDef, outFileNameHandler, getBuildOption(classes, 19), true, true);
      File smaliFile = inFileNameHandler.getUniqueFilenameForClass(className);
    }
  } catch (Exception e) {
    throw new PatchException(e);
  }
  return classes;
}
origin: testwhat/SmaliEx

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())));
  }
}
origin: testwhat/SmaliEx

@Test
public void testBuilderCallSite() throws IOException {
  DexBuilder dexBuilder = new DexBuilder(Opcodes.forArtVersion(111));
  BuilderCallSiteReference callSite = dexBuilder.internCallSite(new ImmutableCallSiteReference("call_site_1",
      new ImmutableMethodHandleReference(
          MethodHandleType.INVOKE_STATIC,
          new ImmutableMethodReference("Lcls1", "loader", ImmutableList.of("Ljava/lang/invoke/Lookup;",
              "Ljava/lang/String;",
              "Ljava/lang/invoke/MethodType;"),
              "Ljava/lang/invoke/CallSite;")),
      "someMethod",
      new ImmutableMethodProtoReference(ImmutableList.of(), "V"), ImmutableList.of()));
  MethodImplementationBuilder methodImplementationBuilder = new MethodImplementationBuilder(10);
  methodImplementationBuilder.addInstruction(new BuilderInstruction35c(Opcode.INVOKE_CUSTOM, 0, 0, 0, 0, 0, 0,
      callSite));
  BuilderMethod method = dexBuilder.internMethod("Lcls1", "method1", null, "V", 0, ImmutableSet.of(),
      methodImplementationBuilder.getMethodImplementation());
  dexBuilder.internClassDef("Lcls1;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null, null,
      ImmutableSet.of(), null,
      ImmutableList.of(method));
  File tempFile = File.createTempFile("dex", ".dex");
  dexBuilder.writeTo(new FileDataStore(tempFile));
  verifyDexFile(DexFileFactory.loadDexFile(tempFile, Opcodes.forArtVersion(111)));
}
origin: testwhat/SmaliEx

@Test
public void testPoolCallSite() throws IOException {
  ClassDef class1 = new ImmutableClassDef("Lcls1;", AccessFlags.PUBLIC.getValue(), "Ljava/lang/Object;", null, null,
      null, null,
      Lists.<Method>newArrayList(
          new ImmutableMethod("Lcls1", "method1",
              ImmutableList.of(), "V", AccessFlags.PUBLIC.getValue(), null,
              new ImmutableMethodImplementation(10, ImmutableList.of(
                  new ImmutableInstruction35c(Opcode.INVOKE_CUSTOM, 0, 0, 0, 0, 0, 0,
                      new ImmutableCallSiteReference("call_site_1",
                          new ImmutableMethodHandleReference(MethodHandleType.INVOKE_STATIC,
                              new ImmutableMethodReference("Lcls1", "loader",
                                  ImmutableList.of("Ljava/lang/invoke/Lookup;",
                                      "Ljava/lang/String;",
                                      "Ljava/lang/invoke/MethodType;"),
                                  "Ljava/lang/invoke/CallSite;")),
                          "someMethod", new ImmutableMethodProtoReference(ImmutableList.of(), "V"), ImmutableList.of()))
              ), null, null))));
  File tempFile = File.createTempFile("dex", ".dex");
  DexFileFactory.writeDexFile(tempFile.getPath(),
      new ImmutableDexFile(Opcodes.forArtVersion(111), ImmutableList.of(class1)));
  verifyDexFile(DexFileFactory.loadDexFile(tempFile, Opcodes.forArtVersion(111)));
}
org.jf.dexlib2DexFileFactoryloadDexFile

Javadoc

Loads a dex/apk/odex/oat file. For oat files with multiple dex files, the first will be opened. For zip/apk files, the "classes.dex" entry will be opened.

Popular methods of DexFileFactory

  • loadDexContainer
    Loads a file containing 1 or more dex files If the given file is a dex or odex file, it will return
  • loadDexEntry
    Loads a dex entry from a container format (zip/oat) This has two modes of operation, depending on th
  • writeDexFile
    Writes a DexFile out to disk
  • loadDexFiles

Popular in Java

  • Running tasks concurrently on multiple threads
  • onCreateOptionsMenu (Activity)
  • onRequestPermissionsResult (Fragment)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Table (com.google.common.collect)
    A collection that associates an ordered pair of keys, called a row key and a column key, with a sing
  • URI (java.net)
    A Uniform Resource Identifier that identifies an abstract or physical resource, as specified by RFC
  • SQLException (java.sql)
    An exception that indicates a failed JDBC operation. It provides the following information about pro
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • Timer (java.util)
    Timers schedule one-shot or recurring TimerTask for execution. Prefer java.util.concurrent.Scheduled
  • JOptionPane (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now