当前位置: 首页>>代码示例>>Java>>正文


Java DexFileFactory.loadDexFile方法代码示例

本文整理汇总了Java中org.jf.dexlib2.DexFileFactory.loadDexFile方法的典型用法代码示例。如果您正苦于以下问题:Java DexFileFactory.loadDexFile方法的具体用法?Java DexFileFactory.loadDexFile怎么用?Java DexFileFactory.loadDexFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jf.dexlib2.DexFileFactory的用法示例。


在下文中一共展示了DexFileFactory.loadDexFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: scanClasses

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
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;
    }
 
开发者ID:alibaba,项目名称:atlas,代码行数:25,代码来源:SmaliDiffUtils.java

示例2: test1

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public static void test1(String argv[]){
		try{
			DexBackedDexFile dexFile = DexFileFactory.loadDexFile(search_path, 16);
			for (ClassDef classDef: dexFile.getClasses()){
				if (classDef.getType().startsWith("Landroid") ||
						classDef.getType().startsWith("Ljava") ||
						classDef.getType().startsWith("Ldalvik")) {
					continue;
				}
				for (Method method: classDef.getMethods()){
//					if (method.getDefiningClass().equals("Lcom/cc/test/MainActivity;")
//							&& method.getName().equals("onCreate")){
					if (method.getImplementation() == null)
						continue;
					Grapher grapher = new Grapher(method.getImplementation());
					grapher.visitConstant();
					grapher.search();
//						grapher.printInfo();
//					}
				}
			}
			MethodConfig.printInfo();
		} catch (Exception e){
			e.printStackTrace();
		}
	}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:27,代码来源:Test.java

示例3: customize

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
void customize() throws IOException {
    nRedirected = nRemoved = nNotRedirected = 0;
    final List<ClassDef> classes;
    if (customClasses != null)
        classes = new ArrayList<>(customClasses);
    else
        classes = new ArrayList<>();
    DexFile dexFile = DexFileFactory.loadDexFile(inputFile, 19, false);
    for (ClassDef classDef : dexFile.getClasses())
        classes.add(customizeClass(classDef));
    if (!onlyAdsRemoving) {
        if (nNotRedirected == 0)
            out.printf(IOutput.Level.VERBOSE,
                    "Removed %d invocation(s) and redirected %d (no NOT redirected)\n",
                    nRemoved,
                    nRedirected);
        else
            out.printf(IOutput.Level.ERROR,
                    "Removed %d invocation(s), redirected %d, NOT redirected %d\n",
                    nRemoved,
                    nRedirected,
                    nNotRedirected);
    }
    writeDexFile(classes);
}
 
开发者ID:packmad,项目名称:RmPerm,代码行数:26,代码来源:BytecodeCustomizer.java

示例4: decode

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
private void decode() throws AndrolibException {
	try {
		baksmaliOptions options = new baksmaliOptions();
		options.useImplicitReferences = true;
		DexBackedDexFile dexFile = DexFileFactory.loadDexFile(mApkFile, options.apiLevel, false);
		baksmali.disassembleDexFile(dexFile, options);
		
		//ojo
		
		/*baksmali.disassembleDexFile(mApkFile.getAbsolutePath(),
				new DexFile(mApkFile), false, mOutDir.getAbsolutePath(),
				null, null, null, false, true, true, mBakDeb, false, false,
				0, false, false, null, false);*/
		
	} catch (IOException ex) {
		throw new AndrolibException(ex);
	}
}
 
开发者ID:Sukelluskello,项目名称:VectorAttackScanner,代码行数:19,代码来源:SmaliDecoder.java

示例5: scanBaseDexFile

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
/**
 * 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);
        }
    }
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:15,代码来源:DexDiffer.java

示例6: loadDex

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public boolean loadDex(String absfilename) {
    try {
        dexfile = DexFileFactory.loadDexFile(absfilename, API);
        return true;
    } catch (IOException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:CvvT,项目名称:andbg,代码行数:10,代码来源:Context.java

示例7: initialize

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public void initialize() {

        try {
            int api = 1; // TODO:
            this.dexFile = DexFileFactory.loadDexFile(inputDexFile, api, false);
        } catch (Exception e) {
            throw new RuntimeException(e.toString());
        }

        if (dexFile instanceof DexBackedDexFile) {
            DexBackedDexFile dbdf = (DexBackedDexFile)dexFile;
            for (int i = 0; i < dbdf.getTypeCount(); i++) {
            	String t = dbdf.getType(i);

            	Type st = DexType.toSoot(t);
            	if (st instanceof ArrayType) {
            		st = ((ArrayType) st).baseType;
            	}
            	Debug.printDbg("Type: ", t ," soot type:", st);
            	String sootTypeName = st.toString();
            	if (!Scene.v().containsClass(sootTypeName)) {
            		if (st instanceof PrimType || st instanceof VoidType || systemAnnotationNames.contains(sootTypeName)) {
            			// dex files contain references to the Type IDs of void / primitive types - we obviously do not want them to be resolved
            			/*
            			 * dex files contain references to the Type IDs of the system annotations.
            			 * They are only visible to the Dalvik VM (for reflection, see vm/reflect/Annotations.cpp), and not to
            			 * the user - so we do not want them to be resolved.
            			 */
            			continue;
            		}
            		SootResolver.v().makeClassRef(sootTypeName);
            	}
            	SootResolver.v().resolveClass(sootTypeName, SootClass.SIGNATURES);
            }
        } else {
            System.out.println("Warning: DexFile not instance of DexBackedDexFile! Not resolving types!");
            System.out.println("type: "+ dexFile.getClass());
        }
    }
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:40,代码来源:DexlibWrapper.java

示例8: classesOfDex

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
/**
 * Return names of classes in dex/apk file.
 *
 * @param file
 *            file to dex/apk file. Can be the path of a zip file.
 *
 * @return set of class names
 */
public static Set<String> classesOfDex(File file) throws IOException {
	Set<String> classes = new HashSet<String>();
	// TODO (SA): Go for API 1 because DexlibWrapper does so, but needs more attention
	DexBackedDexFile d = DexFileFactory.loadDexFile(file, 1, false);
	for (ClassDef c : d.getClasses()) {
		String name = Util.dottedClassName(c.getType());
		classes.add(name);
	}
	return classes;
}
 
开发者ID:flankerhqd,项目名称:JAADAS,代码行数:19,代码来源:DexClassProvider.java

示例9: getDexClasses

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
private Set<String> getDexClasses()
{	
		Set<String> dexClasses = new HashSet<String>();
		
		try {
			DexFile dexFile = DexFileFactory.loadDexFile(new File(apk.getAbsolutePath()), targetSdkVersion());
			for (ClassDef classDef: dexFile.getClasses()) 
			{
				String cls = classDef.getType();
				if (cls.contains("$"))
				{
					//do not consider sub-classes
					continue;
				}
				
				cls = cls.replace("/", ".").substring(1, cls.length()-1);
				
				dexClasses.add(cls);
			}
		} 
		catch (IOException e) 
		{
			e.printStackTrace();
		}
		
		return dexClasses;
 	}
 
开发者ID:serval-snt-uni-lu,项目名称:DroidRA,代码行数:28,代码来源:ProcessManifest.java

示例10: MergeDex

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public MergeDex(Configure configure, String addpath) throws IOException{
	this.config = configure;
	this.add_path = addpath;
	if (configure.hasModifed) {
		dexfile = DexFileFactory.loadDexFile(configure.outPath, configure.API_LEVEL);
	}else{
		dexfile = DexFileFactory.loadDexFile(configure.inPath, configure.API_LEVEL);
	}
}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:10,代码来源:MergeDex.java

示例11: merge

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public void merge(){
	try {
		DexBackedDexFile addfile = DexFileFactory.loadDexFile(add_path, config.API_LEVEL);
		dexfile.setaddDexFile(addfile, new FilterClassDef() {
			
			@Override
			public DexBackedClassDef rewrite(DexBackedClassDef classDef) {
				// TODO Auto-generated method stub
				String className = classDef.getType();
				if (ADD_ALL) {
					if (!className.startsWith("Landroid") && 
							!className.startsWith("Ljava") &&
							!className.startsWith("Ldalvik")) {
							return classDef;
					}else{
						return null;
					}
				}
				
				if (internedItem.containsKey(className)) {
					System.out.println("contain " + className);
					return classDef;
				}
				return null;
			}
		});

		DexRewriter rewriter = new DexRewriter(new RewriterModule());
		DexFile rewrittenDexFile = rewriter.rewriteDexFile(dexfile);
		DexPool.writeTo(config.outPath, rewrittenDexFile);
		config.hasModifed = true;
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:37,代码来源:MergeDex.java

示例12: MethodWithoutParams

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public MethodWithoutParams(Configure config) throws IOException{
	this.config = config;
	if (config.hasModifed) {
		this.dexFile = DexFileFactory.loadDexFile(config.outPath, config.API_LEVEL);
	}else{
		this.dexFile = DexFileFactory.loadDexFile(config.inPath, config.API_LEVEL);
	}
}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:9,代码来源:MethodWithoutParams.java

示例13: search

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
private static void search(Options options){
	try{
		for (Packer packer: options.getPacker()){
			for (MethodConfig config: packer.getMethod()){
				MethodConfig.addtoCollection(config);
			}
		}
		DexBackedDexFile dexFile = DexFileFactory.loadDexFile(search_path, 16);
		for (ClassDef classDef: dexFile.getClasses()){
			if (classDef.getType().startsWith("Landroid") ||
					classDef.getType().startsWith("Ljava") ||
					classDef.getType().startsWith("Ldalvik")) {
				continue;
			}
			for (Method method: classDef.getMethods()){
				if (method.getImplementation() == null)
					continue;
				Grapher grapher = new Grapher(method.getImplementation());
				grapher.visitConstant();
				grapher.search();
			}
		}
		MethodConfig.printInfo();
	} catch (Exception e){
		e.printStackTrace();
	}
}
 
开发者ID:CvvT,项目名称:DexTamper,代码行数:28,代码来源:Main.java

示例14: disassembleDexFile

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
/**
 * Uses baksmali, an disassembler for Android's dex format.
 * Source code and more information: https://bitbucket.org/JesusFreke/smali/overview
 *
 * @param dexFilePath
 * @param outputDir
 * @throws java.io.IOException
 */
public static void disassembleDexFile(String dexFilePath, String outputDir) throws IOException {
    DexBackedDexFile dexBackedDexFile = DexFileFactory.loadDexFile(new File(dexFilePath), 19);
    baksmaliOptions options = new baksmaliOptions();
    options.outputDirectory = outputDir;

    // default value -1 will lead to an exception
    // this setup is copied from Baksmali project
    options.jobs = Runtime.getRuntime().availableProcessors();
    if (options.jobs > 6) {
        options.jobs = 6;
    }

    baksmali.disassembleDexFile(dexBackedDexFile, options);
}
 
开发者ID:bunnyblue,项目名称:Java2SmaliStudio,代码行数:23,代码来源:Dex2SmaliHelper.java

示例15: fromFramework

import org.jf.dexlib2.DexFileFactory; //导入方法依赖的package包/类
public static SmaliClassDetailLoader fromFramework(File frameworkClassesFolder, int apiLevel) {
    File f = new File(frameworkClassesFolder, "android-" + apiLevel + ".dex");
    if (!f.exists())
        throw new RuntimeException("framework file not available");
    DexFile dex;
    try {
        dex = DexFileFactory.loadDexFile(f, apiLevel);
    } catch (IOException e) {
        throw new RuntimeException("failed to load framework classes");
    }
    return new SmaliClassDetailLoader(new DexFile[] {dex}, false, true);
}
 
开发者ID:mingyuan-xia,项目名称:PATDroid,代码行数:13,代码来源:SmaliClassDetailLoader.java


注:本文中的org.jf.dexlib2.DexFileFactory.loadDexFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。