Search in sources :

Example 36 with MethodInfo

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

the class InsnGen method makeRefLambda.

private void makeRefLambda(ICodeWriter code, InvokeCustomNode customNode) {
    InsnNode callInsn = customNode.getCallInsn();
    if (callInsn instanceof ConstructorInsn) {
        MethodInfo callMth = ((ConstructorInsn) callInsn).getCallMth();
        useClass(code, callMth.getDeclClass());
        code.add("::new");
        return;
    }
    if (callInsn instanceof InvokeNode) {
        InvokeNode invokeInsn = (InvokeNode) callInsn;
        MethodInfo callMth = invokeInsn.getCallMth();
        if (customNode.getHandleType() == MethodHandleType.INVOKE_STATIC) {
            useClass(code, callMth.getDeclClass());
        } else {
            code.add("this");
        }
        code.add("::").add(callMth.getAlias());
    }
}
Also used : IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) BaseInvokeNode(jadx.core.dex.instructions.BaseInvokeNode) InvokeNode(jadx.core.dex.instructions.InvokeNode) MethodInfo(jadx.core.dex.info.MethodInfo) ConstructorInsn(jadx.core.dex.instructions.mods.ConstructorInsn)

Example 37 with MethodInfo

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

the class InsnGen method makeSimpleLambda.

private void makeSimpleLambda(ICodeWriter code, InvokeCustomNode customNode) {
    try {
        InsnNode callInsn = customNode.getCallInsn();
        MethodInfo implMthInfo = customNode.getImplMthInfo();
        int implArgsCount = implMthInfo.getArgsCount();
        if (implArgsCount == 0) {
            code.add("()");
        } else {
            code.add('(');
            int callArgsCount = callInsn.getArgsCount();
            int startArg = callArgsCount - implArgsCount;
            if (customNode.getHandleType() != MethodHandleType.INVOKE_STATIC && customNode.getArgsCount() > 0 && customNode.getArg(0).isThis()) {
                callInsn.getArg(0).add(AFlag.THIS);
            }
            if (startArg >= 0) {
                for (int i = startArg; i < callArgsCount; i++) {
                    if (i != startArg) {
                        code.add(", ");
                    }
                    addArg(code, callInsn.getArg(i));
                }
            } else {
                code.add("/* ERROR: " + startArg + " */");
            }
            code.add(')');
        }
        code.add(" -> {");
        if (fallback) {
            code.add(" // ").add(implMthInfo.toString());
        }
        code.incIndent();
        code.startLine();
        if (!implMthInfo.getReturnType().isVoid()) {
            code.add("return ");
        }
        makeInsn(callInsn, code, Flags.INLINE);
        code.add(";");
        code.decIndent();
        code.startLine('}');
    } catch (Exception e) {
        throw new JadxRuntimeException("Failed to generate 'invoke-custom' instruction: " + e.getMessage(), e);
    }
}
Also used : IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) MethodInfo(jadx.core.dex.info.MethodInfo) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) CodegenException(jadx.core.utils.exceptions.CodegenException) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException)

Example 38 with MethodInfo

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

the class ClsSet method writeMethod.

private static void writeMethod(DataOutputStream out, ClspMethod method, Map<String, ClspClass> names) throws IOException {
    MethodInfo methodInfo = method.getMethodInfo();
    writeString(out, methodInfo.getName());
    writeArgTypesList(out, methodInfo.getArgumentsTypes(), names);
    writeArgType(out, methodInfo.getReturnType(), names);
    writeArgTypesList(out, method.containsGenericArgs() ? method.getArgTypes() : Collections.emptyList(), names);
    writeArgType(out, method.getReturnType(), names);
    writeArgTypesList(out, method.getTypeParameters(), names);
    out.writeInt(method.getRawAccessFlags());
    writeArgTypesList(out, method.getThrows(), names);
}
Also used : MethodInfo(jadx.core.dex.info.MethodInfo)

Example 39 with MethodInfo

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

the class Deobfuscator method setSingleMethodAlias.

private void setSingleMethodAlias(MethodNode mth, String alias) {
    MethodInfo mthInfo = mth.getMethodInfo();
    mthInfo.setAlias(alias);
    mthMap.put(mthInfo, alias);
    mthProcessQueue.remove(mth);
}
Also used : 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