本文整理汇总了Java中org.objectweb.asm.tree.InsnList.size方法的典型用法代码示例。如果您正苦于以下问题:Java InsnList.size方法的具体用法?Java InsnList.size怎么用?Java InsnList.size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.objectweb.asm.tree.InsnList
的用法示例。
在下文中一共展示了InsnList.size方法的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: getEntryPoints
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private static BitSet getEntryPoints(MethodNode asmNode, Map<AbstractInsnNode, int[]> exitPoints) {
InsnList il = asmNode.instructions;
BitSet entryPoints = new BitSet(il.size());
for (int[] eps : exitPoints.values()) {
if (eps != null) {
for (int ep : eps) entryPoints.set(ep);
}
}
for (TryCatchBlockNode n : asmNode.tryCatchBlocks) {
entryPoints.set(il.indexOf(n.handler));
}
return entryPoints;
}
示例3: transformCode
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public byte[] transformCode(byte[] b1, String className) throws IOException {
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
ClassReader cr = new ClassReader(b1);
ClassNode classNode = new ClassNode();
Map<String, Boolean> methodInstructionTypeMap = new HashMap<>();
cr.accept(classNode, 0);
final List<MethodNode> methods = classNode.methods;
for (MethodNode m : methods) {
InsnList inList = m.instructions;
boolean isMethodInvoke = false;
for (int i = 0; i < inList.size(); i++) {
if (inList.get(i).getType() == AbstractInsnNode.METHOD_INSN) {
isMethodInvoke = true;
}
}
methodInstructionTypeMap.put(m.name + m.desc, isMethodInvoke);
}
InsertMethodBodyAdapter insertMethodBodyAdapter = new InsertMethodBodyAdapter(cw, className, methodInstructionTypeMap);
cr.accept(insertMethodBodyAdapter, ClassReader.EXPAND_FRAMES);
return cw.toByteArray();
}
示例4: 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);
}
}
}
}
}
示例5: viewByteCode
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
/**
* 格式化输出字节码
* @param bytecode
*/
public static void viewByteCode(byte[] bytecode) {
ClassReader cr = new ClassReader(bytecode);
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
final List<MethodNode> mns = cn.methods;
Printer printer = new Textifier();
TraceMethodVisitor mp = new TraceMethodVisitor(printer);
for (MethodNode mn : mns) {
InsnList inList = mn.instructions;
System.out.println(mn.name);
for (int i = 0; i < inList.size(); i++) {
inList.get(i).accept(mp);
StringWriter sw = new StringWriter();
printer.print(new PrintWriter(sw));
printer.getText().clear();
System.out.print(sw.toString());
}
}
}
示例6: 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);
}
}
}
}
示例7: getImportantList
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList getImportantList(InsnList list) {
if (list.size() == 0) {
return list;
}
HashMap<LabelNode, LabelNode> labels = new HashMap<>();
for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
if (insn instanceof LabelNode) {
labels.put((LabelNode) insn, (LabelNode) insn);
}
}
InsnList importantNodeList = new InsnList();
for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
if (insn instanceof LabelNode || insn instanceof LineNumberNode) {
continue;
}
importantNodeList.add(insn.clone(labels));
}
return importantNodeList;
}
示例8: 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);
}
示例9: 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;
}
示例10: 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;
}
示例11: 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;
}
示例12: injectFieldsIn
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
private void injectFieldsIn(MethodNode rootNode)
{
InsnList instructions = rootNode.instructions;
if (instructions.size() == 0)
{
return;
}
AbstractInsnNode node = instructions.getFirst();
while (node != null)
{
while (! (node instanceof FieldInsnNode) || ! AsmUtils.isPutField(node.getOpcode()))
{
node = node.getNext();
if (node == null)
{
return;
}
}
this.trackFieldToInject((FieldInsnNode) node, rootNode.instructions);
node = node.getNext();
}
}
示例13: getImportantList
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static InsnList getImportantList(InsnList list) {
if (list.size() == 0) {
return list;
}
HashMap<LabelNode, LabelNode> labels = new HashMap<LabelNode, LabelNode>();
for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
if (insn instanceof LabelNode) {
labels.put((LabelNode) insn, (LabelNode) insn);
}
}
InsnList importantNodeList = new InsnList();
for (AbstractInsnNode insn = list.getFirst(); insn != null; insn = insn.getNext()) {
if (insn instanceof LabelNode || insn instanceof LineNumberNode) {
continue;
}
importantNodeList.add(insn.clone(labels));
}
return importantNodeList;
}
示例14: 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);
}
示例15: viewByteCode
import org.objectweb.asm.tree.InsnList; //导入方法依赖的package包/类
public static void viewByteCode(byte[] bytecode) {
ClassReader cr = new ClassReader(bytecode);
ClassNode cn = new ClassNode();
cr.accept(cn, 0);
final List<MethodNode> mns = cn.methods;
Printer printer = new Textifier();
TraceMethodVisitor mp = new TraceMethodVisitor(printer);
for (MethodNode mn : mns) {
InsnList inList = mn.instructions;
System.out.println(mn.name);
for (int i = 0; i < inList.size(); i++) {
inList.get(i).accept(mp);
StringWriter sw = new StringWriter();
printer.print(new PrintWriter(sw));
printer.getText().clear();
System.out.print(sw.toString());
}
}
}