Skip to content

Commit

Permalink
feat: Add value and string search support to invokedynamic arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
Col-E committed May 22, 2021
1 parent 71de3bf commit 659322e
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/main/java/me/coley/recaf/search/SearchMethodVisitor.java
Expand Up @@ -6,12 +6,13 @@
import me.coley.recaf.util.InsnUtil;
import me.coley.recaf.util.Log;
import org.objectweb.asm.*;
import org.objectweb.asm.tree.*;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.MethodNode;

import java.util.List;
import java.util.stream.Collectors;

import static me.coley.recaf.search.SearchCollector.*;
import static me.coley.recaf.search.SearchCollector.ACC_NOT_FOUND;

/**
* Visitor that adds matched results in methods to a result collector.
Expand Down Expand Up @@ -222,6 +223,20 @@ public void visitInvokeDynamicInsn(String name, String descriptor, Handle handle
h.getOwner(), h.getName(), h.getDesc());
collector.addMatched(insnContext, q);
});
} else if (o instanceof String) {
String s = (String) o;
collector.queries(StringQuery.class)
.forEach(q -> {
q.match(s);
collector.addMatched(insnContext, q);
});
} else if (o instanceof Number) {
Number n = (Number) o;
collector.queries(ValueQuery.class)
.forEach(q -> {
q.match(n);
collector.addMatched(context.withInsn(last(), lastPos()), q);
});
}
}
}
Expand Down

0 comments on commit 659322e

Please sign in to comment.