import com.sun.org.apache.bcel.internal.classfile.ClassParser; import com.sun.org.apache.bcel.internal.classfile.JavaClass; import com.sun.org.apache.bcel.internal.classfile.Method; import com.sun.org.apache.bcel.internal.classfile.Field; import com.sun.org.apache.bcel.internal.classfile.Attribute; import com.sun.org.apache.bcel.internal.generic.*; import com.sun.org.apache.bcel.internal.util.InstructionFinder; import com.sun.org.apache.bcel.internal.Constants; import java.lang.instrument.ClassFileTransformer; import java.security.ProtectionDomain; import java.io.ByteArrayInputStream; import java.util.Iterator; import java.io.*; public class Transformer implements ClassFileTransformer { gui mainFrame = new gui(); public byte[] transform( ClassLoader loader, String className, Class classBeingRedefined, ProtectionDomain protectionDomain, byte[] classFileBuffer) { // Apparently our classes don't have that sign if(className.contains("/")) { return classFileBuffer; } if (true) { try { // Let's get a class generic so that we can modify / examine the class ClassGen clazz = new ClassGen(new ClassParser(new ByteArrayInputStream(classFileBuffer), null).parse()); ConstantPoolGen cpg = clazz.getConstantPool(); // Iterate through every method in the class for (Method m : clazz.getMethods()) { // For now we'll have to iterate through all the instructions, because // we don't know the name of the class. if(true) { MethodGen methodGen = new MethodGen(m, className,cpg); InstructionList il = methodGen.getInstructionList(); Iterator ilit = il.iterator(); while (ilit.hasNext()) { Instruction instruction = ilit.next().getInstruction(); if (instruction instanceof LDC2_W) { } } } } // !for } // !try catch (Exception e) { e.printStackTrace(); return classFileBuffer; } } return classFileBuffer; } // !function } // !class