Search in sources :

Example 26 with MethodInfo

use of jadx.core.dex.info.MethodInfo in project jadx by skylot.

the class Deobfuscator method processClass.

private void processClass(DexNode dex, ClassNode cls) {
    ClassInfo clsInfo = cls.getClassInfo();
    String fullName = getClassFullName(clsInfo);
    if (!fullName.equals(clsInfo.getFullName())) {
        clsInfo.rename(dex, fullName);
    }
    for (FieldNode field : cls.getFields()) {
        FieldInfo fieldInfo = field.getFieldInfo();
        String alias = getFieldAlias(field);
        if (alias != null) {
            fieldInfo.setAlias(alias);
        }
    }
    for (MethodNode mth : cls.getMethods()) {
        MethodInfo methodInfo = mth.getMethodInfo();
        String alias = getMethodAlias(mth);
        if (alias != null) {
            methodInfo.setAlias(alias);
        }
        if (mth.isVirtual()) {
            resolveOverriding(dex, cls, mth);
        }
    }
}
Also used : FieldNode(jadx.core.dex.nodes.FieldNode) MethodNode(jadx.core.dex.nodes.MethodNode) MethodInfo(jadx.core.dex.info.MethodInfo) FieldInfo(jadx.core.dex.info.FieldInfo) ClassInfo(jadx.core.dex.info.ClassInfo)

Example 27 with MethodInfo

use of jadx.core.dex.info.MethodInfo in project jadx by skylot.

the class Deobfuscator method postProcess.

private void postProcess() {
    int id = 1;
    for (OverridedMethodsNode o : ovrd) {
        Iterator<MethodInfo> it = o.getMethods().iterator();
        if (it.hasNext()) {
            MethodInfo mth = it.next();
            if (mth.isRenamed() && !mth.isAliasFromPreset()) {
                mth.setAlias(String.format("mo%d%s", id, makeName(mth.getName())));
            }
            String firstMethodAlias = mth.getAlias();
            while (it.hasNext()) {
                mth = it.next();
                if (!mth.getAlias().equals(firstMethodAlias)) {
                    mth.setAlias(firstMethodAlias);
                }
            }
        }
        id++;
    }
}
Also used : MethodInfo(jadx.core.dex.info.MethodInfo)

Example 28 with MethodInfo

use of jadx.core.dex.info.MethodInfo in project jadx by skylot.

the class Deobfuscator method resolveOverriding.

private void resolveOverriding(DexNode dex, ClassNode cls, MethodNode mth) {
    Set<MethodInfo> overrideSet = new HashSet<MethodInfo>();
    resolveOverridingInternal(dex, cls, mth.getMethodInfo().makeSignature(false), overrideSet, cls);
    if (overrideSet.size() > 1) {
        OverridedMethodsNode overrideNode = null;
        for (MethodInfo _mth : overrideSet) {
            if (ovrdMap.containsKey(_mth)) {
                overrideNode = ovrdMap.get(_mth);
                break;
            }
        }
        if (overrideNode == null) {
            overrideNode = new OverridedMethodsNode(overrideSet);
            ovrd.add(overrideNode);
        }
        for (MethodInfo _mth : overrideSet) {
            if (!ovrdMap.containsKey(_mth)) {
                ovrdMap.put(_mth, overrideNode);
                if (!overrideNode.contains(_mth)) {
                    overrideNode.add(_mth);
                }
            }
        }
    } else {
        overrideSet.clear();
        overrideSet = null;
    }
}
Also used : MethodInfo(jadx.core.dex.info.MethodInfo) HashSet(java.util.HashSet)

Example 29 with MethodInfo

use of jadx.core.dex.info.MethodInfo in project jadx by skylot.

the class LoopRegionVisitor method checkInvoke.

/**
	 * Check if instruction is a interface invoke with corresponding parameters.
	 */
private static boolean checkInvoke(InsnNode insn, String declClsFullName, String mthId, int argsCount) {
    if (insn.getType() == InsnType.INVOKE) {
        InvokeNode inv = (InvokeNode) insn;
        MethodInfo callMth = inv.getCallMth();
        if (callMth.getArgsCount() == argsCount && callMth.getShortId().equals(mthId) && inv.getInvokeType() == InvokeType.INTERFACE) {
            return declClsFullName == null || callMth.getDeclClass().getFullName().equals(declClsFullName);
        }
    }
    return false;
}
Also used : InvokeNode(jadx.core.dex.instructions.InvokeNode) MethodInfo(jadx.core.dex.info.MethodInfo)

Example 30 with MethodInfo

use of jadx.core.dex.info.MethodInfo in project jadx by skylot.

the class InsnDecoder method invoke.

private InsnNode invoke(InsnData insn, InvokeType type, boolean isRange) {
    IMethodRef mthRef = InsnDataUtils.getMethodRef(insn);
    if (mthRef == null) {
        throw new JadxRuntimeException("Failed to load method reference for insn: " + insn);
    }
    MethodInfo mthInfo = MethodInfo.fromRef(root, mthRef);
    return new InvokeNode(mthInfo, insn, type, isRange);
}
Also used : IMethodRef(jadx.api.plugins.input.data.IMethodRef) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) MethodInfo(jadx.core.dex.info.MethodInfo)

Aggregations

MethodInfo (jadx.core.dex.info.MethodInfo)39 MethodNode (jadx.core.dex.nodes.MethodNode)13 ArgType (jadx.core.dex.instructions.args.ArgType)10 InvokeNode (jadx.core.dex.instructions.InvokeNode)9 InsnArg (jadx.core.dex.instructions.args.InsnArg)9 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)8 InsnNode (jadx.core.dex.nodes.InsnNode)8 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)6 ConstructorInsn (jadx.core.dex.instructions.mods.ConstructorInsn)6 ClassInfo (jadx.core.dex.info.ClassInfo)4 FieldInfo (jadx.core.dex.info.FieldInfo)4 ClassNode (jadx.core.dex.nodes.ClassNode)4 FieldNode (jadx.core.dex.nodes.FieldNode)4 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)4 ArrayList (java.util.ArrayList)4 BaseInvokeNode (jadx.core.dex.instructions.BaseInvokeNode)3 IMethodRef (jadx.api.plugins.input.data.IMethodRef)2 InvokeType (jadx.core.dex.instructions.InvokeType)2 IMethodDetails (jadx.core.dex.nodes.IMethodDetails)2 HashSet (java.util.HashSet)2