本文整理了Java中org.objectweb.asm.tree.InsnList.set()
方法的一些代码示例,展示了InsnList.set()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。InsnList.set()
方法的具体详情如下:
包路径:org.objectweb.asm.tree.InsnList
类名称:InsnList
方法名:set
[英]Replaces an instruction of this list with another instruction.
[中]将此列表的一条指令替换为另一条指令。
代码示例来源:origin: kilim/kilim
void setInstruction(int pos, AbstractInsnNode insn) {
flow.instructions.set(getInstruction(pos), insn);
}
代码示例来源:origin: org.ow2.asm/asm-debug-all
public void set(Object o) {
if (remove != null) {
InsnList.this.set(remove, (AbstractInsnNode) o);
if (remove == prev) {
prev = (AbstractInsnNode) o;
} else {
next = (AbstractInsnNode) o;
}
} else {
throw new IllegalStateException();
}
}
}
代码示例来源:origin: org.ow2.asm/asm-tree
@Override
public void set(final Object o) {
if (remove != null) {
InsnList.this.set(remove, (AbstractInsnNode) o);
if (remove == previousInsn) {
previousInsn = (AbstractInsnNode) o;
} else {
nextInsn = (AbstractInsnNode) o;
}
} else {
throw new IllegalStateException();
}
}
}
代码示例来源:origin: org.renjin/gcc-bridge-compiler
public void replace(int offset, AbstractInsnNode node) {
list.set(get(offset), node);
}
代码示例来源:origin: ValkyrienWarfare/Valkyrien-Warfare-Revamped
public static SpecificMethodNodeTransformer instructionsNodesTransformer(String target, int priority, Function<AbstractInsnNode, AbstractInsnNode> insnOld2new) {
return instructionsTransformer(priority, target, instructions -> {
for (AbstractInsnNode node : instructions.toArray()) {
AbstractInsnNode res = insnOld2new.apply(node);
if (res != null) instructions.set(node, res);
else instructions.remove(node);
}
});
}
代码示例来源:origin: CalebWhiting/java-asm-obfuscator
private void scramble(ClassNode cn, MethodNode mn) {
List<LdcInsnNode> ldcNodes = new LinkedList<>();
BytecodeHelper.forEach(mn.instructions, LdcInsnNode.class, ldcNodes::add);
for (LdcInsnNode node : ldcNodes) {
if (node.cst instanceof String) {
int index = stringList.indexOf(node.cst);
if (index == -1)
continue;
log.debug("Replacing string constant \"{}\" at {}.{}{}", node.cst, cn.name, mn.name, mn.desc);
MethodInsnNode call = new MethodInsnNode(Opcodes.INVOKESTATIC, unscrambleClass.name, CALL_NAME, CALL_DESC, false);
mn.instructions.set(node, call);
mn.instructions.insertBefore(call, BytecodeHelper.newIntegerNode(index));
}
}
}
代码示例来源:origin: CalebWhiting/java-asm-obfuscator
private void replace(int opcode, ClassNode owner, FieldNode field, MethodNode m) {
if (Modifier.isStatic(field.access))
opcode -= 2;
for (ClassNode cn : classMap.values()) {
for (MethodNode mn : cn.methods) {
AbstractInsnNode[] instructions = mn.instructions.toArray();
for (AbstractInsnNode node : instructions) {
if (node.getType() != AbstractInsnNode.METHOD_INSN) {
continue;
}
MethodInsnNode min = (MethodInsnNode) node;
List<String> owners = getChildNames(owner);
if (owners.contains(min.owner) && min.name.equals(m.name) && min.desc.equals(m.desc)) {
FieldInsnNode fin = new FieldInsnNode(opcode, min.owner, field.name, field.desc);
log.debug(" replace {}.{}.{}, insn: {}",
cn.name, mn.name, mn.desc, QueryUtil.query(fin, "index"));
mn.instructions.set(min, fin);
}
}
}
}
}
代码示例来源:origin: org.parboiled/parboiled-java
private void replaceWithActionWrapper(InstructionGraphNode node) {
MethodInsnNode insn = createActionWrappingInsn();
method.instructions.set(node.getInstruction(), insn);
node.setIsActionRoot();
node.setInstruction(insn);
}
代码示例来源:origin: fge/grappa
private void replaceWithActionWrapper(final InstructionGraphNode node)
{
final MethodInsnNode insn = createActionWrappingInsn();
method.instructions.set(node.getInstruction(), insn);
node.setIsActionRoot();
node.setInstruction(insn);
}
代码示例来源:origin: ItzSomebody/Radon
@Override
public void transform() {
AtomicInteger count = new AtomicInteger();
long current = System.currentTimeMillis();
getClassWrappers().parallelStream().filter(classWrapper -> !excluded(classWrapper)).forEach(classWrapper ->
classWrapper.methods.parallelStream().filter(methodWrapper -> !excluded(methodWrapper)
&& hasInstructions(methodWrapper.methodNode)).forEach(methodWrapper -> {
MethodNode methodNode = methodWrapper.methodNode;
for (AbstractInsnNode insn : methodNode.instructions.toArray()) {
if (insn.getOpcode() == GOTO) {
JumpInsnNode gotoJump = (JumpInsnNode) insn;
AbstractInsnNode insnAfterTarget = gotoJump.label.getNext();
if (insnAfterTarget != null && BytecodeUtils.isReturn(insnAfterTarget.getOpcode())) {
methodNode.instructions.set(insn, new InsnNode(insnAfterTarget.getOpcode()));
count.incrementAndGet();
}
}
}
}));
LoggerUtils.stdOut(String.format("Normalized %d GOTO->RETURN sequences. [%dms]", count.get(),
tookThisLong(current)));
}
代码示例来源:origin: org.renjin/gcc-bridge-compiler
@Override
public boolean apply(NodeIt it) {
if(it.matches(Pattern.LOAD, Pattern.LOAD)) {
VarInsnNode load1 = it.get(0);
VarInsnNode load2 = it.get(1);
if(load1.var == load2.var) {
it.getList().set(load2, dup(load2));
return true;
}
}
return false;
}
代码示例来源:origin: fge/grappa
method.instructions.set(current, insn);
current = insn;
代码示例来源:origin: org.parboiled/parboiled-java
protected void convertXLoads(InstructionGroup group) {
String owner = group.getGroupClassType().getInternalName();
for (InstructionGraphNode node : group.getNodes()) {
if (!node.isXLoad()) continue;
VarInsnNode insn = (VarInsnNode) node.getInstruction();
FieldNode field = group.getFields().get(insn.var);
// insert the correct GETFIELD after the xLoad
group.getInstructions().insert(insn, new FieldInsnNode(GETFIELD, owner, field.name, field.desc));
// change the load to ALOAD 0
group.getInstructions().set(insn, new VarInsnNode(ALOAD, 0));
}
}
代码示例来源:origin: ItzSomebody/Radon
classWrapper.classNode.name, fieldName, "[Ljava/lang/String;"));
methodNode.instructions.insertBefore(insn, BytecodeUtils.getNumberInsn(indexNumber));
methodNode.instructions.set(insn, new InsnNode(AALOAD));
counter.incrementAndGet();
代码示例来源:origin: fge/grappa
protected static void convertXLoads(final InstructionGroup group)
{
final String owner = group.getGroupClassType().getInternalName();
InsnList insnList;
for (final InstructionGraphNode node : group.getNodes()) {
if (!node.isXLoad())
continue;
final VarInsnNode insn = (VarInsnNode) node.getInstruction();
final FieldNode field = group.getFields().get(insn.var);
final FieldInsnNode fieldNode = new FieldInsnNode(GETFIELD, owner,
field.name, field.desc);
insnList = group.getInstructions();
// insert the correct GETFIELD after the xLoad
insnList.insert(insn, fieldNode);
// change the load to ALOAD 0
insnList.set(insn, new VarInsnNode(ALOAD, 0));
}
}
}
代码示例来源:origin: ItzSomebody/Radon
encrypt(methodInsnNode.name, 2038),
encrypt(methodInsnNode.desc, 1928));
methodNode.instructions.set(insn, indy);
if (returnType.getSort() == Type.ARRAY) {
methodNode.instructions.insert(indy, new TypeInsnNode(CHECKCAST,
代码示例来源:origin: ItzSomebody/Radon
@Override
public void transform() {
AtomicInteger counter = new AtomicInteger();
this.getClassWrappers().parallelStream().filter(classWrapper ->
!excluded(classWrapper)).forEach(classWrapper -> {
ClassNode classNode = classWrapper.classNode;
String fieldName = StringUtils.randomSpacesString(RandomUtils.getRandomInt(10));
classWrapper.methods.parallelStream().filter(methodWrapper -> !excluded(methodWrapper)
&& hasInstructions(methodWrapper.methodNode)).forEach(methodWrapper -> {
MethodNode methodNode = methodWrapper.methodNode;
int leeway = getSizeLeeway(methodNode);
for (AbstractInsnNode insn : methodNode.instructions.toArray()) {
if (leeway < 10000) {
break;
}
if (insn.getOpcode() == GOTO) {
methodNode.instructions.insertBefore(insn, new FieldInsnNode(GETSTATIC, classNode.name,
fieldName, "Z"));
methodNode.instructions.insert(insn, new InsnNode(ATHROW));
methodNode.instructions.insert(insn, new InsnNode(ACONST_NULL));
methodNode.instructions.set(insn, new JumpInsnNode(IFEQ, ((JumpInsnNode) insn).label));
leeway -= 7;
counter.incrementAndGet();
}
}
});
classNode.fields.add(new FieldNode(ACC_PUBLIC + ACC_STATIC + ACC_FINAL, fieldName, "Z", null, null));
});
LoggerUtils.stdOut(String.format("Added %d fake throw-null sequences", counter.get()));
}
代码示例来源:origin: ItzSomebody/Radon
methodNode.instructions.insert(insn, new InsnNode(ATHROW));
methodNode.instructions.insert(insn, new InsnNode(ACONST_NULL));
methodNode.instructions.set(insn, new JumpInsnNode(IFEQ, ((JumpInsnNode) insn).label));
leeway -= 7;
counter.incrementAndGet();
代码示例来源:origin: org.parboiled/parboiled-java
public void process(ParserClassNode classNode, RuleMethod method) throws Exception {
checkArgNotNull(classNode, "classNode");
checkArgNotNull(method, "method");
if (method.getNumberOfReturns() == 1) return;
checkState(method.getNumberOfReturns() > 1);
AbstractInsnNode current = method.instructions.getLast();
// find last return
while (current.getOpcode() != ARETURN) {
current = current.getPrevious();
}
LabelNode lastReturnLabel = new LabelNode();
method.instructions.insertBefore(current, lastReturnLabel);
// iterate backwards up to first instructions
while ((current = current.getPrevious()) != null) {
// replace returns with gotos
if (current.getOpcode() == ARETURN) {
JumpInsnNode gotoInstruction = new JumpInsnNode(GOTO, lastReturnLabel);
method.instructions.set(current, gotoInstruction);
current = gotoInstruction;
}
}
}
代码示例来源:origin: co.paralleluniverse/quasar
insnList.set(newValue.insn, new OmittedInstruction(newValue.insn));
内容来源于网络,如有侵权,请联系作者删除!