org.jf.dexlib2.iface.MethodImplementation Java Examples
The following examples show how to use
org.jf.dexlib2.iface.MethodImplementation.
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: DexBuilder.java From zjdroid with Apache License 2.0 | 6 votes |
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass, @Nonnull String name, @Nullable List<? extends MethodParameter> parameters, @Nonnull String returnType, int accessFlags, @Nonnull Set<? extends Annotation> annotations, @Nullable MethodImplementation methodImplementation) { if (parameters == null) { parameters = ImmutableList.of(); } return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType), internMethodParameters(parameters), accessFlags, context.annotationSetPool.internAnnotationSet(annotations), methodImplementation); }
Example #2
Source File: DexBuilder.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass, @Nonnull String name, @Nullable List<? extends MethodParameter> parameters, @Nonnull String returnType, int accessFlags, @Nonnull Set<? extends Annotation> annotations, @Nullable MethodImplementation methodImplementation) { if (parameters == null) { parameters = ImmutableList.of(); } return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType), internMethodParameters(parameters), accessFlags, context.annotationSetPool.internAnnotationSet(annotations), methodImplementation); }
Example #3
Source File: DexBuilder.java From ZjDroid with Apache License 2.0 | 6 votes |
@Nonnull public BuilderMethod internMethod(@Nonnull String definingClass, @Nonnull String name, @Nullable List<? extends MethodParameter> parameters, @Nonnull String returnType, int accessFlags, @Nonnull Set<? extends Annotation> annotations, @Nullable MethodImplementation methodImplementation) { if (parameters == null) { parameters = ImmutableList.of(); } return new BuilderMethod(context.methodPool.internMethod(definingClass, name, parameters, returnType), internMethodParameters(parameters), accessFlags, context.annotationSetPool.internAnnotationSet(annotations), methodImplementation); }
Example #4
Source File: SmaliClassDetailLoader.java From PATDroid with Apache License 2.0 | 6 votes |
/** * Parse an apk file and extract all classes, methods, fields and optionally instructions */ public void loadAll(Scope scope) { IdentityHashMap<MethodInfo, MethodImplementation> collector = new IdentityHashMap<MethodInfo, MethodImplementation>(); for (DexFile dexFile: dexFiles) { for (final ClassDef classDef : dexFile.getClasses()) { ClassInfo ci = Dalvik.findOrCreateClass(scope, classDef.getType()); ClassDetail detail = translateClassDef(ci, classDef, collector); setDetail(ci, detail); } } if (translateInstructions) { for (MethodInfo mi: collector.keySet()) { final MethodImplementation impl = collector.get(mi); // Decode instructions if (impl != null) { new MethodImplementationTranslator(scope).translate(mi, impl); } } } }
Example #5
Source File: SmaliClassDetailLoader.java From PATDroid with Apache License 2.0 | 6 votes |
private ClassDetail translateClassDef(ClassInfo ci, ClassDef classDef, IdentityHashMap<MethodInfo, MethodImplementation> collector) { ClassDetail.Builder builder = new ClassDetail.Builder(); if (classDef.getSuperclass() == null) { builder.setBaseType(null); // for java.lang.Object } else { builder.setBaseType(Dalvik.findOrCreateClass(ci.scope, classDef.getSuperclass())); } builder.setInterfaces(findOrCreateClasses(ci.scope, classDef.getInterfaces())); builder.setAccessFlags(translateAccessFlags(classDef.getAccessFlags())); builder.setAllMethods(translateMethods(ci, classDef.getMethods(), collector)); builder.setStaticFields(translateFields(ci.scope, classDef.getStaticFields())); HashMap<String, ClassInfo> fields = translateFields(ci.scope, classDef.getInstanceFields()); // TODO: do we need this? if (ci.isInnerClass()) { fields.put("this$0", ci.getOuterClass()); } builder.setFields(fields); builder.setIsFrameworkClass(isFramework); return builder.build(); }
Example #6
Source File: ControlFlowGraph.java From CFGScanDroid with GNU General Public License v2.0 | 6 votes |
private static List<BasicBlockInstruction> getFlatMethod(Method method) { List<BasicBlockInstruction> flatMethod = new ArrayList<BasicBlockInstruction>(); MethodImplementation impl = method.getImplementation(); //List<? extends TryBlock<? extends ExceptionHandler>> tryBlocks = null; if(impl != null) { int address = 0; for(Instruction instruction: impl.getInstructions()) { BasicBlockInstruction bbinsn = new BasicBlockInstruction(address, instruction); //System.out.print("\t" + address + "\t" + instruction.getOpcode() + "\t" + bbinsn.branch); address += instruction.getCodeUnits(); flatMethod.add(bbinsn); } //tryBlocks = impl.getTryBlocks(); } return flatMethod; }
Example #7
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Override public int getRegisterCount(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return 0; } return impl.getRegisterCount(); }
Example #8
Source File: ImmutableMethodImplementation.java From zjdroid with Apache License 2.0 | 5 votes |
@Nullable public static ImmutableMethodImplementation of(@Nullable MethodImplementation methodImplementation) { if (methodImplementation == null) { return null; } if (methodImplementation instanceof ImmutableMethodImplementation) { return (ImmutableMethodImplementation)methodImplementation; } return new ImmutableMethodImplementation( methodImplementation.getRegisterCount(), methodImplementation.getInstructions(), methodImplementation.getTryBlocks(), methodImplementation.getDebugItems()); }
Example #9
Source File: SmaliClassDetailLoader.java From PATDroid with Apache License 2.0 | 5 votes |
private MethodInfo translateMethod(ClassInfo ci, Method method, IdentityHashMap<MethodInfo, MethodImplementation> collector) { final ClassInfo retType = Dalvik.findOrCreateClass(ci.scope, method.getReturnType()); final ImmutableList<ClassInfo> paramTypes = findOrCreateClasses(ci.scope, method.getParameterTypes()); final MethodSignature signature = new MethodSignature(method.getName(), paramTypes); final FullMethodSignature fullSignature = new FullMethodSignature(retType, signature); final int accessFlags = translateAccessFlags(method.getAccessFlags()); final MethodInfo mi = new MethodInfo(ci, fullSignature, accessFlags, AccessFlags.SYNTHETIC.isSet(method.getAccessFlags())); Log.msg("Translating method: %s", mi.toString()); collector.put(mi, method.getImplementation()); return mi; }
Example #10
Source File: PatchMethodTool.java From atlas with Apache License 2.0 | 5 votes |
private static MethodImplementation modifyMethodTpatch(@Nonnull MethodImplementation implementation, Method method) { MutableMethodImplementation mutableImplementation = new MutableMethodImplementation(implementation); System.out.println(mutableImplementation.getRegisterCount()); List<BuilderInstruction> instructions = mutableImplementation.getInstructions(); boolean isModified = false; for (int i = 0; i < instructions.size(); i++) { isModified = false; if (instructions.get(i).getOpcode() == Opcode.INVOKE_DIRECT) { if (!isModified) { mutableImplementation.addInstruction(i++, new BuilderInstruction21c(Opcode.CONST_STRING, 0, new ImmutableStringReference("tpatch:" + method.getDefiningClass().replace("/", ".")))); mutableImplementation.addInstruction(i++, new BuilderInstruction35c(Opcode.INVOKE_STATIC, 1, 0, 0, 0, 0, 0, new ImmutableMethodReference("Landroid/util/Log;", "e", Lists.newArrayList("Ljava/lang/String;", "Ljava/lang/String;"), "I"))); isModified = true; break; } } // mutableImplementation.addInstruction(instructions.get(i)); } return mutableImplementation; }
Example #11
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public MutableMethodImplementation makeMutableMethodImplementation(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl instanceof MutableMethodImplementation) { return (MutableMethodImplementation)impl; } return new MutableMethodImplementation(impl); }
Example #12
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nullable @Override public Iterable<? extends Instruction> getInstructions(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return null; } return impl.getInstructions(); }
Example #13
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return ImmutableList.of(); } return impl.getTryBlocks(); }
Example #14
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public MutableMethodImplementation makeMutableMethodImplementation(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl instanceof MutableMethodImplementation) { return (MutableMethodImplementation)impl; } return new MutableMethodImplementation(impl); }
Example #15
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nullable @Override public Iterable<? extends DebugItem> getDebugItems(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return null; } return impl.getDebugItems(); }
Example #16
Source File: BuilderClassPool.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return ImmutableList.of(); } return impl.getTryBlocks(); }
Example #17
Source File: BuilderClassPool.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nullable @Override public Iterable<? extends DebugItem> getDebugItems(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return null; } return impl.getDebugItems(); }
Example #18
Source File: BuilderClassPool.java From zjdroid with Apache License 2.0 | 5 votes |
@Nullable @Override public Iterable<? extends DebugItem> getDebugItems(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return null; } return impl.getDebugItems(); }
Example #19
Source File: BuilderClassPool.java From zjdroid with Apache License 2.0 | 5 votes |
@Override public int getRegisterCount(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return 0; } return impl.getRegisterCount(); }
Example #20
Source File: BuilderClassPool.java From zjdroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return ImmutableList.of(); } return impl.getTryBlocks(); }
Example #21
Source File: BuilderClassPool.java From zjdroid with Apache License 2.0 | 5 votes |
@Nonnull @Override public MutableMethodImplementation makeMutableMethodImplementation(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl instanceof MutableMethodImplementation) { return (MutableMethodImplementation)impl; } return new MutableMethodImplementation(impl); }
Example #22
Source File: BuilderMethod.java From zjdroid with Apache License 2.0 | 5 votes |
BuilderMethod(@Nonnull BuilderMethodReference methodReference, @Nonnull List<? extends BuilderMethodParameter> parameters, int accessFlags, @Nonnull BuilderAnnotationSet annotations, @Nullable MethodImplementation methodImplementation) { this.methodReference = methodReference; this.parameters = parameters; this.accessFlags = accessFlags; this.annotations = annotations; this.methodImplementation = methodImplementation; }
Example #23
Source File: ImmutableMethodImplementation.java From ZjDroid with Apache License 2.0 | 5 votes |
@Nullable public static ImmutableMethodImplementation of(@Nullable MethodImplementation methodImplementation) { if (methodImplementation == null) { return null; } if (methodImplementation instanceof ImmutableMethodImplementation) { return (ImmutableMethodImplementation)methodImplementation; } return new ImmutableMethodImplementation( methodImplementation.getRegisterCount(), methodImplementation.getInstructions(), methodImplementation.getTryBlocks(), methodImplementation.getDebugItems()); }
Example #24
Source File: BuilderMethod.java From HeyGirl with Apache License 2.0 | 5 votes |
BuilderMethod(@Nonnull BuilderMethodReference methodReference, @Nonnull List<? extends BuilderMethodParameter> parameters, int accessFlags, @Nonnull BuilderAnnotationSet annotations, @Nullable MethodImplementation methodImplementation) { this.methodReference = methodReference; this.parameters = parameters; this.accessFlags = accessFlags; this.annotations = annotations; this.methodImplementation = methodImplementation; }
Example #25
Source File: BuilderClassPool.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nonnull @Override public MutableMethodImplementation makeMutableMethodImplementation(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl instanceof MutableMethodImplementation) { return (MutableMethodImplementation)impl; } return new MutableMethodImplementation(impl); }
Example #26
Source File: BuilderClassPool.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nonnull @Override public List<? extends TryBlock<? extends ExceptionHandler>> getTryBlocks(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return ImmutableList.of(); } return impl.getTryBlocks(); }
Example #27
Source File: BuilderClassPool.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nullable @Override public Iterable<? extends Instruction> getInstructions(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return null; } return impl.getInstructions(); }
Example #28
Source File: ImmutableMethodImplementation.java From HeyGirl with Apache License 2.0 | 5 votes |
@Nullable public static ImmutableMethodImplementation of(@Nullable MethodImplementation methodImplementation) { if (methodImplementation == null) { return null; } if (methodImplementation instanceof ImmutableMethodImplementation) { return (ImmutableMethodImplementation)methodImplementation; } return new ImmutableMethodImplementation( methodImplementation.getRegisterCount(), methodImplementation.getInstructions(), methodImplementation.getTryBlocks(), methodImplementation.getDebugItems()); }
Example #29
Source File: ImmutableMethod.java From HeyGirl with Apache License 2.0 | 5 votes |
public ImmutableMethod(@Nonnull String definingClass, @Nonnull String name, @Nullable Iterable<? extends MethodParameter> parameters, @Nonnull String returnType, int accessFlags, @Nullable Set<? extends Annotation> annotations, @Nullable MethodImplementation methodImplementation) { this.definingClass = definingClass; this.name = name; this.parameters = ImmutableMethodParameter.immutableListOf(parameters); this.returnType = returnType; this.accessFlags = accessFlags; this.annotations = ImmutableAnnotation.immutableSetOf(annotations); this.methodImplementation = ImmutableMethodImplementation.of(methodImplementation); }
Example #30
Source File: BuilderClassPool.java From HeyGirl with Apache License 2.0 | 5 votes |
@Override public int getRegisterCount(@Nonnull BuilderMethod builderMethod) { MethodImplementation impl = builderMethod.getImplementation(); if (impl == null) { return 0; } return impl.getRegisterCount(); }