Search in sources :

Example 6 with JavaClass

use of jadx.api.JavaClass in project jadx by skylot.

the class CommentsIndex method getRefNode.

@Nullable
private JNode getRefNode(ICodeComment comment) {
    IJavaNodeRef nodeRef = comment.getNodeRef();
    JavaClass javaClass = wrapper.searchJavaClassByOrigClassName(nodeRef.getDeclaringClass());
    if (javaClass == null) {
        return null;
    }
    JNodeCache nodeCache = cacheObject.getNodeCache();
    switch(nodeRef.getType()) {
        case CLASS:
            return nodeCache.makeFrom(javaClass);
        case FIELD:
            for (JavaField field : javaClass.getFields()) {
                if (field.getFieldNode().getFieldInfo().getShortId().equals(nodeRef.getShortId())) {
                    return nodeCache.makeFrom(field);
                }
            }
            break;
        case METHOD:
            for (JavaMethod mth : javaClass.getMethods()) {
                if (mth.getMethodNode().getMethodInfo().getShortId().equals(nodeRef.getShortId())) {
                    return nodeCache.makeFrom(mth);
                }
            }
            break;
    }
    return null;
}
Also used : IJavaNodeRef(jadx.api.data.IJavaNodeRef) JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaMethod(jadx.api.JavaMethod) JNodeCache(jadx.gui.utils.JNodeCache) Nullable(org.jetbrains.annotations.Nullable)

Example 7 with JavaClass

use of jadx.api.JavaClass in project jadx by skylot.

the class TextSearchIndex method searchInSkippedClasses.

public Flowable<CodeNode> searchInSkippedClasses(final SearchSettings searchSettings) {
    return Flowable.create(emitter -> {
        LOG.debug("Skipped code search started: {} ...", searchSettings.getSearchString());
        for (JavaClass javaClass : skippedClasses) {
            String code = javaClass.getCode();
            int pos = 0;
            while (pos != -1) {
                searchSettings.setStartPos(pos);
                pos = searchNext(emitter, javaClass, code, searchSettings);
                if (emitter.isCancelled()) {
                    LOG.debug("Skipped Code search canceled: {}", searchSettings.getSearchString());
                    return;
                }
            }
            if (!UiUtils.isFreeMemoryAvailable()) {
                LOG.warn("Skipped code search stopped due to memory limit: {}", UiUtils.memoryInfo());
                emitter.onComplete();
                return;
            }
        }
        LOG.debug("Skipped code search complete: {}, memory usage: {}", searchSettings.getSearchString(), UiUtils.memoryInfo());
        emitter.onComplete();
    }, BackpressureStrategy.BUFFER);
}
Also used : JavaClass(jadx.api.JavaClass)

Example 8 with JavaClass

use of jadx.api.JavaClass in project jadx by skylot.

the class JNodeCache method convert.

private JNode convert(JavaNode node) {
    if (node == null) {
        return null;
    }
    if (node instanceof JavaClass) {
        return convert(((JavaClass) node));
    }
    if (node instanceof JavaMethod) {
        return new JMethod((JavaMethod) node, makeFrom(node.getDeclaringClass()));
    }
    if (node instanceof JavaField) {
        return new JField((JavaField) node, makeFrom(node.getDeclaringClass()));
    }
    if (node instanceof JavaVariable) {
        JavaVariable javaVar = (JavaVariable) node;
        JMethod jMth = (JMethod) makeFrom(javaVar.getMth());
        return new JVariable(jMth, javaVar);
    }
    throw new JadxRuntimeException("Unknown type for JavaNode: " + node.getClass());
}
Also used : JVariable(jadx.gui.treemodel.JVariable) JField(jadx.gui.treemodel.JField) JavaField(jadx.api.JavaField) JavaClass(jadx.api.JavaClass) JavaVariable(jadx.api.JavaVariable) JavaMethod(jadx.api.JavaMethod) JadxRuntimeException(jadx.core.utils.exceptions.JadxRuntimeException) JMethod(jadx.gui.treemodel.JMethod)

Example 9 with JavaClass

use of jadx.api.JavaClass in project jadx by skylot.

the class XposedAction method generateClassSnippet.

private String generateClassSnippet(JClass jc) {
    JavaClass javaClass = jc.getCls();
    String rawClassName = javaClass.getRawName();
    String shortClassName = javaClass.getName();
    return String.format("ClassLoader classLoader=lpparam.classLoader;\n" + "Class %sClass=classLoader.loadClass(\"%s\");", shortClassName, rawClassName);
}
Also used : JavaClass(jadx.api.JavaClass)

Example 10 with JavaClass

use of jadx.api.JavaClass in project jadx by skylot.

the class FridaAction method generateClassSnippet.

private String generateClassSnippet(JClass jc) {
    JavaClass javaClass = jc.getCls();
    String rawClassName = javaClass.getRawName();
    String shortClassName = javaClass.getName();
    String finalFridaCode = String.format("let %s = Java.use(\"%s\");", shortClassName, rawClassName);
    isInitial.put(rawClassName, false);
    return finalFridaCode;
}
Also used : JavaClass(jadx.api.JavaClass)

Aggregations

JavaClass (jadx.api.JavaClass)20 JavaMethod (jadx.api.JavaMethod)7 JavaField (jadx.api.JavaField)5 JavaNode (jadx.api.JavaNode)3 JNode (jadx.gui.treemodel.JNode)3 CodePosition (jadx.api.CodePosition)2 JClass (jadx.gui.treemodel.JClass)2 CodeLinesInfo (jadx.gui.utils.CodeLinesInfo)2 JNodeCache (jadx.gui.utils.JNodeCache)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 JavaVariable (jadx.api.JavaVariable)1 IJavaNodeRef (jadx.api.data.IJavaNodeRef)1 ICodeRawOffset (jadx.api.data.annotations.ICodeRawOffset)1 JadxRuntimeException (jadx.core.utils.exceptions.JadxRuntimeException)1 JadxWrapper (jadx.gui.JadxWrapper)1 CodeNode (jadx.gui.treemodel.CodeNode)1 JField (jadx.gui.treemodel.JField)1 JMethod (jadx.gui.treemodel.JMethod)1