Search in sources :

Example 26 with FieldInfo

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

the class ReSugarCode method checkEnumMapAccess.

public static EnumMapInfo checkEnumMapAccess(MethodNode mth, InsnNode checkInsn) {
    InsnArg sgetArg = checkInsn.getArg(0);
    InsnArg invArg = checkInsn.getArg(1);
    if (!sgetArg.isInsnWrap() || !invArg.isInsnWrap()) {
        return null;
    }
    InsnNode invInsn = ((InsnWrapArg) invArg).getWrapInsn();
    InsnNode sgetInsn = ((InsnWrapArg) sgetArg).getWrapInsn();
    if (invInsn.getType() != InsnType.INVOKE || sgetInsn.getType() != InsnType.SGET) {
        return null;
    }
    InvokeNode inv = (InvokeNode) invInsn;
    if (!inv.getCallMth().getShortId().equals("ordinal()I")) {
        return null;
    }
    ClassNode enumCls = mth.dex().resolveClass(inv.getCallMth().getDeclClass());
    if (enumCls == null || !enumCls.isEnum()) {
        return null;
    }
    Object index = ((IndexInsnNode) sgetInsn).getIndex();
    if (!(index instanceof FieldInfo)) {
        return null;
    }
    FieldNode enumMapField = mth.dex().resolveField((FieldInfo) index);
    if (enumMapField == null || !enumMapField.getAccessFlags().isSynthetic()) {
        return null;
    }
    return new EnumMapInfo(inv.getArg(0), enumMapField);
}
Also used : IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) ClassNode(jadx.core.dex.nodes.ClassNode) FieldNode(jadx.core.dex.nodes.FieldNode) InsnArg(jadx.core.dex.instructions.args.InsnArg) InvokeNode(jadx.core.dex.instructions.InvokeNode) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) FieldInfo(jadx.core.dex.info.FieldInfo)

Example 27 with FieldInfo

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

the class ReSugarCode method addToEnumMap.

private static void addToEnumMap(MethodNode mth, EnumMapAttr mapAttr, InsnNode aputInsn) {
    InsnArg litArg = aputInsn.getArg(2);
    if (!litArg.isLiteral()) {
        return;
    }
    EnumMapInfo mapInfo = checkEnumMapAccess(mth, aputInsn);
    if (mapInfo == null) {
        return;
    }
    InsnArg enumArg = mapInfo.getArg();
    FieldNode field = mapInfo.getMapField();
    if (field == null || !enumArg.isInsnWrap()) {
        return;
    }
    InsnNode sget = ((InsnWrapArg) enumArg).getWrapInsn();
    if (!(sget instanceof IndexInsnNode)) {
        return;
    }
    Object index = ((IndexInsnNode) sget).getIndex();
    if (!(index instanceof FieldInfo)) {
        return;
    }
    FieldNode fieldNode = mth.dex().resolveField((FieldInfo) index);
    if (fieldNode == null) {
        return;
    }
    int literal = (int) ((LiteralArg) litArg).getLiteral();
    mapAttr.add(field, literal, fieldNode);
}
Also used : IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) InsnNode(jadx.core.dex.nodes.InsnNode) FieldNode(jadx.core.dex.nodes.FieldNode) InsnArg(jadx.core.dex.instructions.args.InsnArg) InsnWrapArg(jadx.core.dex.instructions.args.InsnWrapArg) IndexInsnNode(jadx.core.dex.instructions.IndexInsnNode) FieldInfo(jadx.core.dex.info.FieldInfo)

Example 28 with FieldInfo

use of jadx.core.dex.info.FieldInfo 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 29 with FieldInfo

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

the class ShadowFieldVisitor method init.

@Override
public void init(RootNode root) {
    Map<String, FieldFixInfo> map = new HashMap<>();
    for (ClassNode cls : root.getClasses(true)) {
        Map<FieldInfo, FieldFixType> fieldFixMap = searchShadowedFields(cls);
        if (!fieldFixMap.isEmpty()) {
            FieldFixInfo fixInfo = new FieldFixInfo();
            fixInfo.fieldFixMap = fieldFixMap;
            map.put(cls.getRawName(), fixInfo);
        }
    }
    this.fixInfoMap = map;
}
Also used : ClassNode(jadx.core.dex.nodes.ClassNode) HashMap(java.util.HashMap) FieldInfo(jadx.core.dex.info.FieldInfo)

Example 30 with FieldInfo

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

the class ShadowFieldVisitor method processInsn.

private static void processInsn(MethodNode mth, InsnNode insn, Map<String, FieldFixInfo> fixInfoMap) {
    FieldInfo fieldInfo = getFieldInfo(insn);
    if (fieldInfo == null) {
        return;
    }
    InsnArg arg = insn.getArg(insn.getArgsCount() - 1);
    ArgType type = arg.getType();
    if (!type.isTypeKnown() || !type.isObject()) {
        return;
    }
    FieldFixInfo fieldFixInfo = fixInfoMap.get(type.getObject());
    if (fieldFixInfo == null) {
        return;
    }
    FieldFixType fieldFixType = fieldFixInfo.fieldFixMap.get(fieldInfo);
    if (fieldFixType == null) {
        return;
    }
    fixFieldAccess(mth, fieldInfo, fieldFixType, arg);
}
Also used : ArgType(jadx.core.dex.instructions.args.ArgType) InsnArg(jadx.core.dex.instructions.args.InsnArg) FieldInfo(jadx.core.dex.info.FieldInfo)

Aggregations

FieldInfo (jadx.core.dex.info.FieldInfo)41 FieldNode (jadx.core.dex.nodes.FieldNode)24 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)20 InsnNode (jadx.core.dex.nodes.InsnNode)16 InsnArg (jadx.core.dex.instructions.args.InsnArg)15 InsnWrapArg (jadx.core.dex.instructions.args.InsnWrapArg)8 ClassNode (jadx.core.dex.nodes.ClassNode)8 ArgType (jadx.core.dex.instructions.args.ArgType)7 ArrayList (java.util.ArrayList)7 InsnType (jadx.core.dex.instructions.InsnType)6 MethodNode (jadx.core.dex.nodes.MethodNode)6 Nullable (org.jetbrains.annotations.Nullable)6 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)5 ConstStringNode (jadx.core.dex.instructions.ConstStringNode)5 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)5 BlockNode (jadx.core.dex.nodes.BlockNode)5 HashMap (java.util.HashMap)5 List (java.util.List)5 EncodedValue (jadx.api.plugins.input.data.annotations.EncodedValue)4 MethodInfo (jadx.core.dex.info.MethodInfo)4