use of org.objectweb.asm.tree.FieldNode in project spring-loaded by spring-projects.
the class SpringLoadedTests method getField.
@SuppressWarnings("unchecked")
private FieldNode getField(byte[] classbytes, String fieldName) {
ClassReader super_cr = new ClassReader(classbytes);
ClassNode cn = new ClassNode();
super_cr.accept(cn, 0);
List<FieldNode> fields = cn.fields;
if (fields != null) {
for (FieldNode fn : fields) {
if (fn.name.equals(fieldName)) {
return fn;
}
}
}
return null;
}
use of org.objectweb.asm.tree.FieldNode in project spring-loaded by spring-projects.
the class SpringLoadedTests method toStringField.
@SuppressWarnings("unchecked")
protected String toStringField(byte[] classdata, String fieldname) {
StringBuilder sb = new StringBuilder();
FieldNode fieldNode = getField(classdata, fieldname);
if (fieldNode == null) {
return null;
}
List<AnnotationNode> annos = fieldNode.visibleAnnotations;
if (annos != null) {
sb.append("vis(").append(toStringAnnotations(annos)).append(") ");
}
annos = fieldNode.invisibleAnnotations;
if (annos != null) {
sb.append("invis(").append(toStringAnnotations(annos)).append(") ");
}
// will need implementing at some point:
// List<Attribute> attrs = fieldNode.attrs;
// if (attrs = !null) {
// sb.append("attrs(").append(toStringAttributes(attrs)).append(") ");
// }
sb.append("0x").append(Integer.toHexString(fieldNode.access)).append("(").append(ClassPrinter.toAccessForMember(fieldNode.access)).append(") ");
sb.append(fieldNode.name).append(" ");
sb.append(fieldNode.desc).append(" ");
if (fieldNode.signature != null) {
sb.append(fieldNode.signature).append(" ");
}
if (fieldNode.value != null) {
sb.append(fieldNode.value).append(" ");
}
return sb.toString().trim();
}
use of org.objectweb.asm.tree.FieldNode in project bytecode-viewer by Konloch.
the class RenameFields method obfuscate.
@Override
public void obfuscate() {
int stringLength = getStringLength();
System.out.println("Obfuscating fields names...");
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
for (Object o : c.fields.toArray()) {
FieldNode f = (FieldNode) o;
String newName = generateUniqueName(stringLength);
ASMUtil_OLD.renameFieldNode(c.name, f.name, f.desc, null, newName, null);
f.name = newName;
}
}
System.out.println("Obfuscated field names.");
}
use of org.objectweb.asm.tree.FieldNode in project bytecode-viewer by Konloch.
the class RenameFields method obfuscate.
@Override
public void obfuscate() {
int stringLength = getStringLength();
System.out.println("Obfuscating fields names...");
for (ClassNode c : BytecodeViewer.getLoadedClasses()) {
for (Object o : c.fields.toArray()) {
FieldNode f = (FieldNode) o;
String newName = generateUniqueName(stringLength);
BytecodeViewer.refactorer.getHooks().addField(new FieldMappingData(c.name, new MappingData(f.name, newName), f.desc));
/*ASMUtil_OLD.renameFieldNode(c.name, f.name, f.desc, null, newName, null);
f.name = newName;*/
}
}
System.out.println("Obfuscated field names.");
}
Aggregations