From 902b1b519f8ae89910f6f0d9f077738711349324 Mon Sep 17 00:00:00 2001 From: Cuchaz Date: Mon, 23 Mar 2015 16:26:44 -0400 Subject: add protectifier! Muwahahaha!!! --- src/cuchaz/enigma/bytecode/ClassProtectifier.java | 41 +++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/cuchaz/enigma/bytecode/ClassProtectifier.java (limited to 'src/cuchaz/enigma/bytecode') diff --git a/src/cuchaz/enigma/bytecode/ClassProtectifier.java b/src/cuchaz/enigma/bytecode/ClassProtectifier.java new file mode 100644 index 0000000..49a6269 --- /dev/null +++ b/src/cuchaz/enigma/bytecode/ClassProtectifier.java @@ -0,0 +1,41 @@ +package cuchaz.enigma.bytecode; + +import javassist.CtBehavior; +import javassist.CtClass; +import javassist.CtField; +import javassist.bytecode.AccessFlag; +import javassist.bytecode.InnerClassesAttribute; + + +public class ClassProtectifier { + + public static CtClass protectify(CtClass c) { + + // protectify all the fields + for (CtField field : c.getDeclaredFields()) { + field.setModifiers(protectify(field.getModifiers())); + } + + // protectify all the methods and constructors + for (CtBehavior behavior : c.getDeclaredBehaviors()) { + behavior.setModifiers(protectify(behavior.getModifiers())); + } + + // protectify all the inner classes + InnerClassesAttribute attr = (InnerClassesAttribute)c.getClassFile().getAttribute(InnerClassesAttribute.tag); + if (attr != null) { + for (int i=0; i