本文整理汇总了Java中org.jf.dexlib2.immutable.ImmutableMethod类的典型用法代码示例。如果您正苦于以下问题:Java ImmutableMethod类的具体用法?Java ImmutableMethod怎么用?Java ImmutableMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ImmutableMethod类属于org.jf.dexlib2.immutable包,在下文中一共展示了ImmutableMethod类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reDexMethods
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
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;
}
示例2: customizeClass
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
private ClassDef customizeClass(ClassDef classDef) {
List<Method> methods = new ArrayList<>();
boolean modifiedMethod = false;
for (Method method : classDef.getMethods()) {
MethodImplementation implementation = method.getImplementation();
if (implementation == null) {
methods.add(method);
continue;
}
MethodImplementation customImpl = searchAndReplaceInvocations(implementation);
if (customImpl==implementation) {
methods.add(method);
continue;
}
modifiedMethod = true;
final ImmutableMethod newMethod = new ImmutableMethod(method.getDefiningClass(),
method.getName(),
method.getParameters(),
method.getReturnType(),
method.getAccessFlags(),
method.getAnnotations(),
customImpl);
methods.add(newMethod);
}
if (!modifiedMethod)
return classDef;
return new ImmutableClassDef(classDef.getType(),
classDef.getAccessFlags(),
classDef.getSuperclass(),
classDef.getInterfaces(),
classDef.getSourceFile(),
classDef.getAnnotations(),
classDef.getFields(),
methods);
}
示例3: reMethod
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
@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));
}
示例4: modifyMethod
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
public static void modifyMethod(String srcDexFile, String outDexFile, boolean isAndFix) throws IOException {
DexFile dexFile = DexFileFactory.loadDexFile(srcDexFile, 15, true);
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();
}
};
}
});
}
示例5: inlineMethod
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
@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);
}
示例6: inlineMethod
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
private static Method inlineMethod(int accessFlags, String cls, String name,
String params, String returnType) {
ImmutableList<ImmutableMethodParameter> paramList = ImmutableList.copyOf(ParamUtil.parseParamString(params));
return new ImmutableMethod(cls, name, paramList, returnType, accessFlags, null, null);
}
示例7: addMethod
import org.jf.dexlib2.immutable.ImmutableMethod; //导入依赖的package包/类
public static void addMethod(String srcDexFile, String outDexFile, DexBackedClassDef dexBackedClassDef, ImmutableMethod immutableMethod) throws IOException {
}