Example usage for org.objectweb.asm.tree AbstractInsnNode getNext

List of usage examples for org.objectweb.asm.tree AbstractInsnNode getNext

Introduction

In this page you can find the example usage for org.objectweb.asm.tree AbstractInsnNode getNext.

Prototype

public AbstractInsnNode getNext() 

Source Link

Document

Returns the next instruction in the list to which this instruction belongs, if any.

Usage

From source file:the.bytecode.club.bytecodeviewer.plugin.preinstalled.AllatoriStringDecrypter.java

License:Open Source License

private boolean scanDecrypter(MethodNode decryptermethodnode, int newHashCode) {
    InsnList iList = decryptermethodnode.instructions;

    AbstractInsnNode insn = null, removeInsn = null;
    for (AbstractInsnNode i : iList.toArray()) {
        if (i instanceof MethodInsnNode) {
            MethodInsnNode methodi = ((MethodInsnNode) i);
            if ("currentThread".equals(methodi.name)) { // find code form this instruction
                insn = i;//  w  ww.j a  v  a2 s.co  m
                break;
            }

        }

    }
    if (insn == null) {
        return false;
    }

    while (insn != null) {
        if (insn instanceof MethodInsnNode) {
            MethodInsnNode methodi = ((MethodInsnNode) insn);
            if ("hashCode".equals(methodi.name)) { // to this instruction
                break;
            }
        }
        removeInsn = insn;
        insn = insn.getNext();
        iList.remove(removeInsn); // and remove it
    }
    if (insn == null)
        return false;
    iList.set(insn, new LdcInsnNode(newHashCode)); // then replace it with pre-computed key LDC
    return true;
}