org.jf.dexlib2.immutable.ImmutableMethod Java Examples
The following examples show how to use
org.jf.dexlib2.immutable.ImmutableMethod.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PatchFieldTool.java From atlas with Apache License 2.0 | 6 votes |
private static List<Method> reDexMethods(@Nonnull ClassDef classDef) { List<Method> taintedMethods = Lists.newArrayList(); for (Method method : classDef.getMethods()) { MethodImplementation implementation = method.getImplementation(); MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation); taintedMethods.add(new ImmutableMethod( method.getDefiningClass(), method.getName(), method.getParameters(), method.getReturnType(), method.getAccessFlags(), method.getAnnotations(), mutableImplementation)); } return taintedMethods; }
Example #2
Source File: InlineMethodResolver.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name, @Nonnull String params, @Nonnull String returnType) { ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params)); return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null); }
Example #3
Source File: MethodReIClassDef.java From atlas with Apache License 2.0 | 4 votes |
@Override public Method reMethod(Method method) { String newType = null; boolean isBasic = false; boolean isInit = false; boolean changeOpcode = false; String methodName = method.getName(); String returnType = method.getReturnType(); MethodImplementation methodImplementation = method.getImplementation(); List<? extends MethodParameter> paramters = method.getParameters(); if (methodName.equals("<init>") || methodName.equals("<cinit>")) { isInit = true; } if (basicType.containsKey(returnType)) { newType = returnType; isBasic = true; } else { newType = classProcessor.classProcess(DefineUtils.getDalvikClassName(returnType)).className; } String[] argsOringn = new String[paramters.size()]; String[] args = new String[paramters.size()]; for (int i = 0; i < paramters.size(); i++) { //型参数不混淆 if (basicType.containsKey(paramters.get(i).getType())) { argsOringn[i] = basicType.get(paramters.get(i).getType()); args[i] = argsOringn[i]; continue; } argsOringn[i] = DefineUtils.getDalvikClassName(paramters.get(i).getType()); args[i] = classProcessor.classProcess(DefineUtils.getDalvikClassName(paramters.get(i).getType())).className; } String type = method.getReturnType(); return new ImmutableMethod(reType, classProcessor.methodProcess(isInit ? methodName : DefineUtils.getDalvikClassName(method.getDefiningClass()), methodName, isBasic ? basicType.get(returnType) : DefineUtils.getDalvikClassName(returnType), StringUtils.join(argsOringn, ",")).methodName, reParameters(paramters), isBasic ? newType: DefineUtils.getDefineClassName(newType,type.startsWith("[")), method.getAccessFlags(), getAnnotation(method.getAnnotations()), reMethodImpl(methodImplementation)); }
Example #4
Source File: PatchMethodTool.java From atlas with Apache License 2.0 | 4 votes |
public static void modifyMethod(String srcDexFile, String outDexFile, boolean isAndFix) throws IOException { DexFile dexFile = DexFileFactory.loadDexFile(srcDexFile, Opcodes.getDefault()); final Set<ClassDef> classes = Sets.newConcurrentHashSet(); for (ClassDef classDef : dexFile.getClasses()) { Set<Method> methods = Sets.newConcurrentHashSet(); boolean modifiedMethod = false; for (Method method : classDef.getMethods()) { MethodImplementation implementation = method.getImplementation(); if (implementation != null&&(methodNeedsModification(classDef, method, isAndFix))) { modifiedMethod = true; methods.add(new ImmutableMethod( method.getDefiningClass(), method.getName(), method.getParameters(), method.getReturnType(), method.getAccessFlags(), method.getAnnotations(), isAndFix ? modifyMethodAndFix(implementation, method) : modifyMethodTpatch(implementation, method))); } else { methods.add(method); } } if (!modifiedMethod) { classes.add(classDef); } else { classes.add(new ImmutableClassDef( classDef.getType(), classDef.getAccessFlags(), classDef.getSuperclass(), classDef.getInterfaces(), classDef.getSourceFile(), classDef.getAnnotations(), classDef.getFields(), methods)); } } DexFileFactory.writeDexFile(outDexFile, new DexFile() { @Nonnull @Override public Set<? extends ClassDef> getClasses() { return new AbstractSet<ClassDef>() { @Nonnull @Override public Iterator<ClassDef> iterator() { return classes.iterator(); } @Override public int size() { return classes.size(); } }; } @Nonnull @Override public Opcodes getOpcodes() { return Opcodes.getDefault(); } }); }
Example #5
Source File: InlineMethodResolver.java From zjdroid with Apache License 2.0 | 4 votes |
@Nonnull private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name, @Nonnull String params, @Nonnull String returnType) { ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params)); return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null); }
Example #6
Source File: InlineMethodResolver.java From HeyGirl with Apache License 2.0 | 4 votes |
@Nonnull private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name, @Nonnull String params, @Nonnull String returnType) { ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params)); return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null); }
Example #7
Source File: InlineMethodResolver.java From ZjDroid with Apache License 2.0 | 4 votes |
@Nonnull private static Method inlineMethod(int accessFlags, @Nonnull String cls, @Nonnull String name, @Nonnull String params, @Nonnull String returnType) { ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params)); return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null); }
Example #8
Source File: PatchMethodTool.java From atlas with Apache License 2.0 | 2 votes |
public static void addMethod(String srcDexFile, String outDexFile, DexBackedClassDef dexBackedClassDef, ImmutableMethod immutableMethod) throws IOException { }