Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ClassReader reader = new ClassReader(basicClass);
- ClassNode node = new ClassNode();
- reader.accept(node, 0);
- boolean didAnything = false;
- for(MethodNode method : node.methods) if (!method.name.startsWith("<") && (method.access & ACC_ABSTRACT) == 0){
- InsnList list = new InsnList();
- if ((method.access & ACC_STATIC) == 0)
- list.add(new VarInsnNode(ALOAD, 0));
- else
- list.add(new InsnNode(ACONST_NULL));
- list.add(new LdcInsnNode(name + "." + method.name + method.desc));
- list.add(new MethodInsnNode(INVOKESTATIC, ASM_HOOKS, "methodHook",
- "(Ljava/lang/Object;Ljava/lang/String;)V", false));
- method.access |= ACC_PUBLIC;
- method.access &= ~(ACC_PROTECTED | ACC_PRIVATE | ACC_FINAL);
- method.instructions.insertBefore(method.instructions.getFirst(), list);
- didAnything = true;
- }
- if (didAnything) {
- ClassWriter writer = new ClassWriter(ClassWriter.COMPUTE_MAXS | ClassWriter.COMPUTE_FRAMES);
- node.accept(writer);
- return writer.toByteArray();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement