當前位置: 首頁>>代碼示例>>Java>>正文


Java InsnList.insertBefore方法代碼示例

本文整理匯總了Java中org.objectweb.asm.tree.InsnList.insertBefore方法的典型用法代碼示例。如果您正苦於以下問題:Java InsnList.insertBefore方法的具體用法?Java InsnList.insertBefore怎麽用?Java InsnList.insertBefore使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.objectweb.asm.tree.InsnList的用法示例。


在下文中一共展示了InsnList.insertBefore方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: callLast

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public ImagineMethod callLast(final String owner, final String methodName) {
    final InsnList instructions = this.mMethod.instructions;
    final InsnList methodCall = methodCall(this, owner, methodName, owner != null, false);
    for (final AbstractInsnNode node : instructions) {
        switch (node.getOpcode()) {
            case 172:
            case 173:
            case 174:
            case 175:
            case 176:
            case 177: {
                instructions.insertBefore(node, methodCall);
                continue;
            }
        }
    }
    return this;
}
 
開發者ID:CyberdyneCC,項目名稱:ThermosRebased,代碼行數:19,代碼來源:ImagineMethod.java

示例2: addTraceReturn

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void addTraceReturn() {

        InsnList il = this.mn.instructions;

        Iterator<AbstractInsnNode> it = il.iterator();
        while (it.hasNext()) {
            AbstractInsnNode abstractInsnNode = it.next();

            switch (abstractInsnNode.getOpcode()) {
                case Opcodes.RETURN:
                    il.insertBefore(abstractInsnNode, getVoidReturnTraceInstructions());
                    break;
                case Opcodes.IRETURN:
                case Opcodes.LRETURN:
                case Opcodes.FRETURN:
                case Opcodes.ARETURN:
                case Opcodes.DRETURN:
                    il.insertBefore(abstractInsnNode, getReturnTraceInstructions());
            }
        }
    }
 
開發者ID:brutusin,項目名稱:instrumentation,代碼行數:22,代碼來源:Instrumentator.java

示例3: addTraceThrow

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
private void addTraceThrow() {

        InsnList il = this.mn.instructions;

        Iterator<AbstractInsnNode> it = il.iterator();
        while (it.hasNext()) {
            AbstractInsnNode abstractInsnNode = it.next();

            switch (abstractInsnNode.getOpcode()) {
                case Opcodes.ATHROW:
                    il.insertBefore(abstractInsnNode, getThrowTraceInstructions());
                    break;
            }
        }

    }
 
開發者ID:brutusin,項目名稱:instrumentation,代碼行數:17,代碼來源:Instrumentator.java

示例4: insertPushNull

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Insert a call to the isNull helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushNull(int opcode, JumpInsnNode position, InsnList list) {
	int branchId = getBranchID(currentMethodNode, position);
	logger.info("Inserting instrumentation for NULL check at branch " + branchId
	        + " in method " + currentMethodNode.name);

	MethodInsnNode nullCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "isNull",
	        Type.getMethodDescriptor(Type.INT_TYPE,
	                                 new Type[] { Type.getType(Object.class),
	                                         Type.INT_TYPE }), false);
	list.insertBefore(position, new InsnNode(Opcodes.DUP));
	list.insertBefore(position, new LdcInsnNode(opcode));
	list.insertBefore(position, nullCheck);
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position, branchId);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:31,代碼來源:BooleanTestabilityTransformation.java

示例5: insertPushEquals

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Insert a call to the reference equality check helper function
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPushEquals(int opcode, JumpInsnNode position, InsnList list) {
	MethodInsnNode equalCheck = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "isEqual",
	        Type.getMethodDescriptor(Type.INT_TYPE,
	                                 new Type[] { Type.getType(Object.class),
	                                         Type.getType(Object.class),
	                                         Type.INT_TYPE }), false);
	list.insertBefore(position, new InsnNode(Opcodes.DUP2));
	list.insertBefore(position, new LdcInsnNode(opcode));
	list.insertBefore(position, equalCheck);
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:28,代碼來源:BooleanTestabilityTransformation.java

示例6: insertPush

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Insert a call to the distance function for unary comparison
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPush(int opcode, JumpInsnNode position, InsnList list) {
	list.insertBefore(position, new InsnNode(Opcodes.DUP));
	// TODO: We have to put a placeholder here instead of the actual branch ID
	// TODO: And then later add another transformation where we replace this with
	//       actual branch IDs
	//list.insertBefore(position,
	//                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	insertBranchIdPlaceholder(currentMethodNode, position);
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:23,代碼來源:BooleanTestabilityTransformation.java

示例7: insertPush2

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Insert a call to the distance function for binary comparison
 * 
 * @param opcode
 * @param position
 * @param list
 */
public void insertPush2(int opcode, JumpInsnNode position, InsnList list) {
	list.insertBefore(position, new InsnNode(Opcodes.DUP2));
	//list.insertBefore(position, new InsnNode(Opcodes.ISUB));
	MethodInsnNode sub = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "intSub",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, sub);
	insertBranchIdPlaceholder(currentMethodNode, position);

	//		list.insertBefore(position,
	//		                  new LdcInsnNode(getBranchID(currentMethodNode, position)));
	MethodInsnNode push = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "pushPredicate",
	        Type.getMethodDescriptor(Type.VOID_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE }), false);
	list.insertBefore(position, push);

}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:27,代碼來源:BooleanTestabilityTransformation.java

示例8: 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;
}
 
開發者ID:Guichaguri,項目名稱:SkinFixer,代碼行數:28,代碼來源:SkinTransformer.java

示例9: moveUp

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Moves the insns up one in the list.
 * 
 * @param list
 *            Complete list of opcodes.
 * @param insn
 *            Sublist to be moved.
 */
public static void moveUp(InsnList list, List<AbstractInsnNode> insns) {
	AbstractInsnNode prev = insns.get(0).getPrevious();
	if (prev == null) return;
	InsnList x = new InsnList();
	for (AbstractInsnNode ain : insns) {
		list.remove(ain);
		x.add(ain);
	}
	list.insertBefore(prev, x);
}
 
開發者ID:Col-E,項目名稱:Recaf,代碼行數:19,代碼來源:Asm.java

示例10: 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();
      }
   }
}
 
開發者ID:runelite,項目名稱:runelite,代碼行數:37,代碼來源:MethodModInstruction.java

示例11: insertBefore

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
protected boolean insertBefore(InsnList nodes, Predicate<AbstractInsnNode> validator, InsnList insert, boolean last) {
    AbstractInsnNode node = last ? this.getNodeLast(nodes, validator) : this.getNode(nodes, validator);
    if (node != null) {
        nodes.insertBefore(node, insert);
        return true;
    }
    return false;
}
 
開發者ID:gegy1000,項目名稱:BlockSystems,代碼行數:9,代碼來源:Transformer.java

示例12: insertGetBefore

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
/**
 * Insert a call that takes a boolean from the stack, and returns the
 * appropriate distance
 * 
 * @param position
 * @param list
 */
public void insertGetBefore(AbstractInsnNode position, InsnList list) {
	logger.info("Inserting get call before");
	// Here, branchId is the first control dependency
	//list.insertBefore(position,
	//                  new LdcInsnNode(getControlDependentBranchID(currentMethodNode,
	//                                                              position)));
	// insertControlDependencyPlaceholder(currentMethodNode, position);

	// branch
	// approx
	// value

	Label label = new Label();
	LabelNode labelNode = new LabelNode(label);
	//BooleanTestabilityPlaceholderTransformer.addControlDependencyPlaceholder(label,
	//                                                                         insnNode);
	currentMethodNode.instructions.insertBefore(position, labelNode);
	//instructions.insertBefore(insnNode, new LdcInsnNode(0));
	//mn.instructions.insertBefore(insnNode, new LdcInsnNode(0));
	currentMethodNode.instructions.insertBefore(position, new LdcInsnNode(
	        getControlDependentBranchID(currentMethodNode, position)));
	currentMethodNode.instructions.insertBefore(position, new InsnNode(Opcodes.SWAP));
	currentMethodNode.instructions.insertBefore(position, new LdcInsnNode(
	        getApproximationLevel(currentMethodNode, position)));
	currentMethodNode.instructions.insertBefore(position, new InsnNode(Opcodes.SWAP));

	MethodInsnNode get = new MethodInsnNode(Opcodes.INVOKESTATIC,
	        Type.getInternalName(BooleanHelper.class), "getDistance",
	        Type.getMethodDescriptor(Type.INT_TYPE, new Type[] { Type.INT_TYPE,
	                Type.INT_TYPE, Type.INT_TYPE }), false);
	list.insertBefore(position, get);
}
 
開發者ID:EvoSuite,項目名稱:evosuite,代碼行數:40,代碼來源:BooleanTestabilityTransformation.java

示例13: inject

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public byte[] inject(byte[] classfileBuffer) {
	try {
		ClassReader cr = new ClassReader(classfileBuffer);
		ClassNode cn = new ClassNode();
		cr.accept(cn, 0);
		
		ArrayList<AbstractInsnNode> injectPos = new ArrayList<AbstractInsnNode>();
		
		@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);
               		
               		if (min.owner.equals("java/net/Socket") && min.name.equals("<init>") && min.desc.equals("()V")) {
               			min.desc = "(Ljava/net/Proxy;)V";
               			injectPos.add(min);
               		}
                   }
            }
            
	        for (int k = 0; k < injectPos.size(); k++) {
	        	AbstractInsnNode pos = injectPos.get(k);
	        	MethodInsnNode newMin = new MethodInsnNode(
	        			Opcodes.INVOKESTATIC,
	        			"ht/misc/injectsocks/ProxyManager",
	        			"getProxy",
	        			"()Ljava/net/Proxy;",
	        			false);
	        	instructions.insertBefore(pos, newMin);
	        }
	        
        }
        
        ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS);
        cn.accept(cw);
		byte[] injectedClassfileBuffer = cw.toByteArray();
		System.out.printf("INFO: classfileBuffer.legnth=%d, injectedClassfileBuffer.length=%d\n", 
				classfileBuffer.length, injectedClassfileBuffer.length);
		
		return injectedClassfileBuffer;
	} catch (Throwable e) {
		e.printStackTrace();
		return classfileBuffer;
	}
}
 
開發者ID:ralgond,項目名稱:injectsocks,代碼行數:57,代碼來源:InjectSockstTransformerImpl.java

示例14: callFirst

import org.objectweb.asm.tree.InsnList; //導入方法依賴的package包/類
public ImagineMethod callFirst(final String owner, final String methodName) {
    final InsnList instructions = this.mMethod.instructions;
    instructions.insertBefore(instructions.getFirst(), methodCall(this, owner, methodName, owner != null, false));
    return this;
}
 
開發者ID:CyberdyneCC,項目名稱:ThermosRebased,代碼行數:6,代碼來源:ImagineMethod.java


注:本文中的org.objectweb.asm.tree.InsnList.insertBefore方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。