Search in sources :

Example 6 with ClassInfo

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

the class ClassNode method addSourceFilenameAttr.

private void addSourceFilenameAttr(String fileName) {
    if (fileName == null) {
        return;
    }
    if (fileName.endsWith(".java")) {
        fileName = fileName.substring(0, fileName.length() - 5);
    }
    if (fileName.isEmpty() || fileName.equals("SourceFile") || fileName.equals("\"")) {
        return;
    }
    if (clsInfo != null) {
        String name = clsInfo.getShortName();
        if (fileName.equals(name)) {
            return;
        }
        if (fileName.contains("$") && fileName.endsWith("$" + name)) {
            return;
        }
        ClassInfo parentClass = clsInfo.getTopParentClass();
        if (parentClass != null && fileName.equals(parentClass.getShortName())) {
            return;
        }
    }
    this.addAttr(new SourceFileAttr(fileName));
    LOG.debug("Class '{}' compiled from '{}'", this, fileName);
}
Also used : SourceFileAttr(jadx.core.dex.attributes.nodes.SourceFileAttr) ClassInfo(jadx.core.dex.info.ClassInfo)

Example 7 with ClassInfo

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

the class DexNode method initInnerClasses.

void initInnerClasses() {
    // move inner classes
    List<ClassNode> inner = new ArrayList<ClassNode>();
    for (ClassNode cls : classes) {
        if (cls.getClassInfo().isInner()) {
            inner.add(cls);
        }
    }
    for (ClassNode cls : inner) {
        ClassInfo clsInfo = cls.getClassInfo();
        ClassNode parent = resolveClass(clsInfo.getParentClass());
        if (parent == null) {
            clsMap.remove(clsInfo);
            clsInfo.notInner(cls.dex());
            clsMap.put(clsInfo, cls);
        } else {
            parent.addInnerClass(cls);
        }
    }
}
Also used : ArrayList(java.util.ArrayList) ClassInfo(jadx.core.dex.info.ClassInfo)

Example 8 with ClassInfo

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

the class Deobfuscator method doClass.

private void doClass(ClassNode cls) {
    ClassInfo classInfo = cls.getClassInfo();
    String pkgFullName = classInfo.getPackage();
    PackageNode pkg = getPackageNode(pkgFullName, true);
    doPkg(pkg, pkgFullName);
    String alias = deobfPresets.getForCls(classInfo);
    if (alias != null) {
        clsMap.put(classInfo, new DeobfClsInfo(this, cls, pkg, alias));
        return;
    }
    if (clsMap.containsKey(classInfo)) {
        return;
    }
    if (shouldRename(classInfo.getShortName())) {
        makeClsAlias(cls);
    }
}
Also used : ClassInfo(jadx.core.dex.info.ClassInfo)

Example 9 with ClassInfo

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

the class Deobfuscator method getNameWithoutPackage.

String getNameWithoutPackage(ClassInfo clsInfo) {
    String prefix;
    ClassInfo parentClsInfo = clsInfo.getParentClass();
    if (parentClsInfo != null) {
        DeobfClsInfo parentDeobfClsInfo = clsMap.get(parentClsInfo);
        if (parentDeobfClsInfo != null) {
            prefix = parentDeobfClsInfo.makeNameWithoutPkg();
        } else {
            prefix = getNameWithoutPackage(parentClsInfo);
        }
        prefix += INNER_CLASS_SEPARATOR;
    } else {
        prefix = "";
    }
    return prefix + clsInfo.getShortName();
}
Also used : ClassInfo(jadx.core.dex.info.ClassInfo)

Example 10 with ClassInfo

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

the class Deobfuscator method makeClsAlias.

private String makeClsAlias(ClassNode cls) {
    ClassInfo classInfo = cls.getClassInfo();
    String alias = null;
    if (this.useSourceNameAsAlias) {
        alias = getAliasFromSourceFile(cls);
    }
    if (alias == null) {
        String clsName = classInfo.getShortName();
        alias = String.format("C%04d%s", clsIndex++, makeName(clsName));
    }
    PackageNode pkg = getPackageNode(classInfo.getPackage(), true);
    clsMap.put(classInfo, new DeobfClsInfo(this, cls, pkg, alias));
    return alias;
}
Also used : ClassInfo(jadx.core.dex.info.ClassInfo)

Aggregations

ClassInfo (jadx.core.dex.info.ClassInfo)21 ClassNode (jadx.core.dex.nodes.ClassNode)6 FieldNode (jadx.core.dex.nodes.FieldNode)5 MethodNode (jadx.core.dex.nodes.MethodNode)5 MethodInfo (jadx.core.dex.info.MethodInfo)4 ArrayList (java.util.ArrayList)4 FieldReplaceAttr (jadx.core.dex.attributes.nodes.FieldReplaceAttr)2 FieldInfo (jadx.core.dex.info.FieldInfo)2 InsnArg (jadx.core.dex.instructions.args.InsnArg)2 HashSet (java.util.HashSet)2 CatchHandler (com.android.dex.Code.CatchHandler)1 Try (com.android.dex.Code.Try)1 EnumClassAttr (jadx.core.dex.attributes.nodes.EnumClassAttr)1 EnumField (jadx.core.dex.attributes.nodes.EnumClassAttr.EnumField)1 SourceFileAttr (jadx.core.dex.attributes.nodes.SourceFileAttr)1 ConstClassNode (jadx.core.dex.instructions.ConstClassNode)1 IndexInsnNode (jadx.core.dex.instructions.IndexInsnNode)1 InvokeType (jadx.core.dex.instructions.InvokeType)1 ArgType (jadx.core.dex.instructions.args.ArgType)1 RegisterArg (jadx.core.dex.instructions.args.RegisterArg)1