feat: hook readOption for fast api

This commit is contained in:
novice.li 2024-06-25 21:25:46 +08:00
parent fac5feab85
commit 9823d58d00
1 changed files with 12 additions and 1 deletions

View File

@ -28,6 +28,17 @@ public class VMOptionsTransformer implements MyTransformer {
list.add(new InsnNode(ARETURN)); list.add(new InsnNode(ARETURN));
list.add(labelNode); list.add(labelNode);
m.instructions.insert(list); m.instructions.insert(list);
} else if ("readOption".equals(m.name) && "(Ljava/lang/String;Z)Ljava/lang/String;".equals(m.desc)) {
InsnList list = new InsnList();
LabelNode continueLabel = new LabelNode();
list.add(new VarInsnNode(ALOAD, 0));
list.add(new LdcInsnNode("javaagent"));
list.add(new MethodInsnNode(INVOKEVIRTUAL, "java/lang/String", "contains", "(Ljava/lang/CharSequence;)Z", false));
list.add(new JumpInsnNode(IFEQ, continueLabel));
list.add(new InsnNode(ACONST_NULL));
list.add(new InsnNode(ARETURN));
list.add(continueLabel);
m.instructions.insert(list);
} }
} }
ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);