本文整理汇总了Java中org.objectweb.asm.tree.InsnList.get方法的典型用法代码示例。如果您正苦于以下问题:Java InsnList.get方法的具体用法?Java InsnList.get怎么用?Java InsnList.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.InsnList
的用法示例。
在下文中一共展示了InsnList.get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: stringEncryptionTransformer
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static void stringEncryptionTransformer(ClassNode classNode) {
if (classNode.superName.equals("org/bukkit/plugin/java/JavaPlugin") || classNode.superName.equals("net/md_5/bungee/api/plugin/Plugin")) {
for (MethodNode methodNode : classNode.methods) {
InsnList nodes = methodNode.instructions;
for (int i = 0; i < nodes.size(); i++) {
AbstractInsnNode instruction = nodes.get(i);
if (instruction instanceof LdcInsnNode) {
if (instruction.getNext() instanceof MethodInsnNode) {
LdcInsnNode ldc = (LdcInsnNode) instruction;
MethodInsnNode methodinsnnode = (MethodInsnNode) ldc.getNext();
if (ldc.cst instanceof String) {
if (methodinsnnode.name.equalsIgnoreCase("\u0972") && methodinsnnode.desc.equalsIgnoreCase("(Ljava/lang/String;)Ljava/lang/String;")) {
methodNode.instructions.remove(methodinsnnode);
ldc.cst = decryptionArray((String)ldc.cst);
}
}
}
}
}
}
}
}
示例2: addDirectExits
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static void addDirectExits(InsnList il, BitSet entryPoints, Map<AbstractInsnNode, int[]> exitPoints) {
int idx = 0; // ignore 0 since it has no preceding instruction
while ((idx = entryPoints.nextSetBit(idx + 1)) != -1) {
AbstractInsnNode prev = il.get(idx - 1);
if (exitPoints.containsKey(prev)) continue;
int type = prev.getType();
if (prev.getOpcode() != Opcodes.ATHROW
&& (prev.getOpcode() < Opcodes.IRETURN || prev.getOpcode() > Opcodes.RETURN)
&& type != AbstractInsnNode.JUMP_INSN
&& type != AbstractInsnNode.TABLESWITCH_INSN
&& type != AbstractInsnNode.LOOKUPSWITCH_INSN) {
exitPoints.put(prev, new int[] { idx });
}
}
}
示例3: populateClassGraph
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public void populateClassGraph() {
String className = Type.getObjectType(classNode.name).getClassName();
logger.debug("Creating graph for class {}" , className);
for (MethodNode methodNode : classNode.methods) {
String methodName = methodNode.name;
MethodGraph caller = new MethodGraph(className, methodName);
InsnList instructions = methodNode.instructions;
for (int i = 0; i < instructions.size(); i++) {
AbstractInsnNode insnNode = instructions.get(i);
if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
MethodInsnNode methodInsnNode = (MethodInsnNode)insnNode;
String calledOwner = Type.getObjectType(methodInsnNode.owner).getClassName();
String calledName = methodInsnNode.name;
MethodGraph called = new MethodGraph(calledOwner, calledName);
Call call = new Call(caller, called);
if (!called.getOwner().equals("java.lang.Object") && !called.getName().equals("<init>")) {
logger.trace("Adding call graph: {}", call.toString());
GraphHolder.addCallGraph(call);
}
}
}
}
}
示例4: printClassByteCode
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public void printClassByteCode(byte code[]) {
ClassReader cr = new ClassReader(code);
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
@SuppressWarnings("unchecked")
List<MethodNode> methods = (List<MethodNode>)cn.methods;
for (int i = 0; i < methods.size(); ++i) {
MethodNode method = methods.get(i);
InsnList instructions = method.instructions;
if (instructions.size() <= 0)
continue;
System.out.println("Method: "+method.name+" ");
for (int j = 0; j < instructions.size(); ++j) {
AbstractInsnNode insn = (AbstractInsnNode)instructions.get(j);
System.out.println("\tInsn: opc="+OpcodeUtil.getOpcode(insn.getOpcode())+", type="+insn.getType());
if (insn.getType() == AbstractInsnNode.METHOD_INSN) {
MethodInsnNode min = (MethodInsnNode)insn;
System.out.printf("\t\towner=%s, name=%s, desc=%s\n", min.owner, min.name, min.desc);
}
}
}
}
示例5: insnListMatchesL
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static InsnListSection insnListMatchesL(InsnList haystack, InsnList needle, int start, HashSet<LabelNode> controlFlowLabels) {
int h = start, n = 0;
for (; h < haystack.size() && n < needle.size(); h++) {
AbstractInsnNode insn = haystack.get(h);
if (insn.getType() == 15) {
continue;
}
if (insn.getType() == 8 && !controlFlowLabels.contains(insn)) {
continue;
}
if (!insnEqual(haystack.get(h), needle.get(n))) {
return null;
}
n++;
}
if (n != needle.size()) {
return null;
}
return new InsnListSection(haystack, start, h - 1);
}
示例6: findConstructorInvocation
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Nullable
private static MethodInsnNode findConstructorInvocation(
@NonNull MethodNode method,
@NonNull String className) {
InsnList nodes = method.instructions;
for (int i = 0, n = nodes.size(); i < n; i++) {
AbstractInsnNode instruction = nodes.get(i);
if (instruction.getOpcode() == Opcodes.INVOKESPECIAL) {
MethodInsnNode call = (MethodInsnNode) instruction;
if (className.equals(call.owner)) {
return call;
}
}
}
return null;
}
示例7: findEnumSwitchUsage
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static MethodNode findEnumSwitchUsage(ClassNode classNode, String owner) {
String target = ENUM_SWITCH_PREFIX + owner.replace('/', '$');
@SuppressWarnings("rawtypes") // ASM API
List methodList = classNode.methods;
for (Object f : methodList) {
MethodNode method = (MethodNode) f;
InsnList nodes = method.instructions;
for (int i = 0, n = nodes.size(); i < n; i++) {
AbstractInsnNode instruction = nodes.get(i);
if (instruction.getOpcode() == Opcodes.GETSTATIC) {
FieldInsnNode field = (FieldInsnNode) instruction;
if (field.name.equals(target)) {
return method;
}
}
}
}
return null;
}
示例8: containsSimpleSdkCheck
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static boolean containsSimpleSdkCheck(@NonNull MethodNode method) {
// Look for a compiled version of "if (Build.VERSION.SDK_INT op N) {"
InsnList nodes = method.instructions;
for (int i = 0, n = nodes.size(); i < n; i++) {
AbstractInsnNode instruction = nodes.get(i);
if (isSdkVersionLookup(instruction)) {
AbstractInsnNode bipush = getNextInstruction(instruction);
if (bipush != null && bipush.getOpcode() == Opcodes.BIPUSH) {
AbstractInsnNode ifNode = getNextInstruction(bipush);
if (ifNode != null && ifNode.getType() == AbstractInsnNode.JUMP_INSN) {
return true;
}
}
}
}
return false;
}
示例9: insnListMatchesL
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static InsnListSection insnListMatchesL(InsnList haystack, InsnList needle, int start, HashSet<LabelNode> controlFlowLabels) {
int h = start, n = 0;
for (; h < haystack.size() && n < needle.size(); h++) {
AbstractInsnNode insn = haystack.get(h);
if (insn.getType() == 15) {
continue;
}
if (insn.getType() == 8 && !controlFlowLabels.contains(insn)) {
continue;
}
if (!insnEqual(haystack.get(h), needle.get(n))) {
return null;
}
n++;
}
if (n != needle.size()) {
return null;
}
return new InsnListSection(haystack, start, h - 1);
}
示例10: check
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public ClassMatch check(ClassNode classNode) {
ClassMatch match = new ClassMatch();
for(MethodNode method : classNode.methods) {
InsnList insns = method.instructions;
for(int i=0;i<insns.size();i++) {
AbstractInsnNode insn = insns.get(i);
int opcode = insn.getOpcode();
if(opcode == INVOKESPECIAL) {
MethodInsnNode call = (MethodInsnNode)insn;
if(type.equals(call.owner)) {
match.matched(true);
match.evidence("creates new " + call.owner.replace('/', '.'));
}
}
}
}
return match;
}
示例11: check
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public ClassMatch check(ClassNode clazz) {
ClassMatch match = new ClassMatch();
for(MethodNode method : clazz.methods) {
if("<init>()V".equals(method.name + method.desc)) {
continue;
}
InsnList insns = method.instructions;
for(int i=0;i<insns.size();i++) {
AbstractInsnNode insn = insns.get(i);
int opcode = insn.getOpcode();
if(opcode == INVOKESTATIC) {
MethodInsnNode call = (MethodInsnNode)insn;
match.matched(true);
match.evidence("calls static " + TypeUtil.toDisplayType(call.owner) + "." + call.name + call.desc);
}
if(opcode == GETSTATIC) {
FieldInsnNode fieldCall = (FieldInsnNode)insn;
match.matched(true);
match.evidence("uses static field " + TypeUtil.toDisplayType(fieldCall.owner) + "." + fieldCall.name +" (" + fieldCall.desc + ")");
}
}
}
return match;
}
示例12: patchNodes
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private boolean patchNodes(MethodNode method) {
InsnList list = method.instructions;
boolean patched = false;
boolean foundUrl = false;
for(int i = 0; i < list.size(); i++) {
AbstractInsnNode node = list.get(i);
if(node instanceof LdcInsnNode) {
LdcInsnNode ldc = (LdcInsnNode)node;
if(ldc.cst instanceof String && isUrl((String)ldc.cst)) {
foundUrl = true;
}
} else if(foundUrl && (node.getOpcode() == Opcodes.PUTFIELD || node.getOpcode() == Opcodes.ASTORE)) {
list.insertBefore(node, new MethodInsnNode(Opcodes.INVOKESTATIC,
"guichaguri/skinfixer/SkinWorker", "getURL", "(Ljava/lang/String;)Ljava/lang/String;", false));
foundUrl = false;
patched = true;
}
}
return patched;
}
示例13: process
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
@Override
public void process() {
for (MethodNode methodNode : getClassNode().methods) {
InsnList instructions = methodNode.instructions;
for (int i = 0; i < instructions.size(); i++) {
AbstractInsnNode insnNode = instructions.get(i);
if (insnNode.getType() == AbstractInsnNode.METHOD_INSN) {
MethodInsnNode methodInsnNode = (MethodInsnNode)insnNode;
processMethodInsnNode(methodNode, methodInsnNode);
}
}
}
}
示例14: populate
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void populate(InsnList opcodes) {
int selected = -1, labelCount = 0;;
DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
for (int i = 0; i < opcodes.size(); i++) {
AbstractInsnNode ain = opcodes.get(i);
if (ain.getType() == AbstractInsnNode.LABEL) {
LabelNode label = (LabelNode) ain;
String s = i + ".";
if (list != null) {
s += " : " + list.getLabelName(ain);
}
labels.put(s, label);
model.addElement(s);
if (label.equals(initial)) {
selected = labelCount;
}
labelCount++;
}
}
combo.setModel(model);
combo.setSelectedIndex(selected);
combo.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
updater.accept(labels.get(e.getItem()));
if (list != null) {
list.repaint();
}
}
});
}
示例15: inject
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public void inject(ClassNode var1) {
Iterator var3 = var1.methods.iterator();
while(true) {
MethodNode var2;
do {
do {
if(!var3.hasNext()) {
return;
}
var2 = (MethodNode)var3.next();
} while(!var2.name.equalsIgnoreCase(this.method));
} while(!var2.desc.equalsIgnoreCase(this.desc));
InsnList var4 = var2.instructions;
try {
AbstractInsnNode var5 = var4.get(this.startIndex);
AbstractInsnNode var6 = null;
for(int var7 = 0; var7 < this.nodes.length; ++var7) {
if(var6 == null) {
var4.insertBefore(var5, this.nodes[var7]);
} else {
var4.insert(var6, this.nodes[var7]);
}
var6 = this.nodes[var7];
}
} catch (Exception var8) {
System.err.println("Failed on " + this.startIndex + " @ " + this.owner + "." + this.method + " " + this.desc);
var8.printStackTrace();
}
}
}