|
|
@ -19,82 +19,78 @@ |
|
|
|
package jode.obfuscator; |
|
|
|
package jode.obfuscator; |
|
|
|
import jode.Obfuscator; |
|
|
|
import jode.Obfuscator; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
import jode.bytecode.ClassInfo; |
|
|
|
|
|
|
|
import java.io.*; |
|
|
|
import java.util.*; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
|
|
|
|
public class ClassBundle { |
|
|
|
public class ClassBundle { |
|
|
|
|
|
|
|
|
|
|
|
Hashtable loadedClasses = new Hashtable(); |
|
|
|
int preserveRule; |
|
|
|
|
|
|
|
PackageIdentifier basePackage; |
|
|
|
|
|
|
|
|
|
|
|
public ClassReachability getLoadedClass(String name) { |
|
|
|
public ClassBundle() { |
|
|
|
return (ClassReachability) loadedClasses.get(name); |
|
|
|
basePackage = new PackageIdentifier(this, null, "", false); |
|
|
|
|
|
|
|
basePackage.setReachable(); |
|
|
|
|
|
|
|
basePackage.setPreserved(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void loadClass(ClassInfo clazz) { |
|
|
|
public String getTypeAlias(String typeSig) { |
|
|
|
if (loadedClasses.get(clazz.getName()) != null) { |
|
|
|
StringBuffer newSig = new StringBuffer(); |
|
|
|
Decompiler.err.println("warning: ignoring double class: " |
|
|
|
int index = 0, nextindex; |
|
|
|
+ clazz.getName()); |
|
|
|
while ((nextindex = typeSig.indexOf('L', index)) != -1) { |
|
|
|
return; |
|
|
|
newSig.append(typeSig.substring(index, nextindex+1)); |
|
|
|
|
|
|
|
index = typeSig.indexOf(';', nextindex); |
|
|
|
|
|
|
|
String alias = basePackage.findAlias |
|
|
|
|
|
|
|
(typeSig.substring(nextindex+1, index).replace('/','.')); |
|
|
|
|
|
|
|
newSig.append(alias.replace('.', '/')); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return newSig.append(typeSig.substring(index)).toString(); |
|
|
|
} |
|
|
|
} |
|
|
|
loadedClasses.put(clazz.getName(), |
|
|
|
|
|
|
|
new ClassReachability(this, clazz)); |
|
|
|
public Identifier getIdentifier(String name) { |
|
|
|
|
|
|
|
return basePackage.getIdentifier(name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void loadClasses(String packageOrClass) { |
|
|
|
public void loadClasses(String packageOrClass) { |
|
|
|
if (ClassInfo.isPackage(packageOrClass)) { |
|
|
|
basePackage.loadClasses(packageOrClass); |
|
|
|
Enumeration enum = ClassInfo.getClasses(packageOrClass); |
|
|
|
|
|
|
|
while (enum.hasMoreElements()) |
|
|
|
|
|
|
|
loadClass((ClassInfo)enum.nextElement()); |
|
|
|
|
|
|
|
} else |
|
|
|
|
|
|
|
loadClass(ClassInfo.forName(packageOrClass)); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void markReachableField(String className, Type type, String name) { |
|
|
|
public void reachableIdentifier(String fqn, boolean isVirtual) { |
|
|
|
ClassReachability cr = getLoadedClass(className); |
|
|
|
basePackage.reachableIdentifier(fqn, isVirtual); |
|
|
|
if (cr != null) |
|
|
|
|
|
|
|
cr.markReachableField(type, name); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void markReachable(String className) { |
|
|
|
public void setPreserved(int preserveRule, Vector fullqualifiednames) { |
|
|
|
ClassReachability cr = getLoadedClass(className); |
|
|
|
this.preserveRule = preserveRule; |
|
|
|
if (cr != null) |
|
|
|
|
|
|
|
cr.markReachableField(type, name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void markPreservedField(String className, Type type, String name) { |
|
|
|
Enumeration enum = fullqualifiednames.elements(); |
|
|
|
ClassReachability cr = getLoadedClass(className); |
|
|
|
|
|
|
|
if (cr != null) |
|
|
|
|
|
|
|
cr.markPreservedField(type, name); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void markPreserved(int preserveRule, |
|
|
|
|
|
|
|
Vector classnames, Vector methodnames) { |
|
|
|
|
|
|
|
Enumeration enum = loadedClasses.elements(); |
|
|
|
|
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
((ClassReachability) enum.nextElement()) |
|
|
|
basePackage.preserveIdentifier((String) enum.nextElement()); |
|
|
|
.postInitialize(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (preserveRule != Obfuscator.PRESERVE_NONE) { |
|
|
|
|
|
|
|
enum = loadedClasses.elements(); |
|
|
|
|
|
|
|
while (enum.hasMoreElements()) { |
|
|
|
|
|
|
|
((ClassReachability) enum.nextElement()) |
|
|
|
|
|
|
|
.doPreserveRule(preserveRule); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/*XXX*/ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void strip() { |
|
|
|
public void strip() { |
|
|
|
|
|
|
|
basePackage.strip(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void buildTable(int renameRule) { |
|
|
|
public void buildTable(int renameRule) { |
|
|
|
|
|
|
|
basePackage.buildTable(renameRule); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void readTable(String filename) { |
|
|
|
public void readTable(String filename) { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void writeTable(String filename) { |
|
|
|
public void writeTable(String filename) { |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
PrintWriter out = new PrintWriter(new FileOutputStream(filename)); |
|
|
|
|
|
|
|
basePackage.writeTable(out); |
|
|
|
|
|
|
|
out.close(); |
|
|
|
|
|
|
|
} catch (java.io.IOException ex) { |
|
|
|
|
|
|
|
Obfuscator.err.println("Can't write rename table "+filename); |
|
|
|
|
|
|
|
ex.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void storeClasses(String destination) { |
|
|
|
public void storeClasses(String destination) { |
|
|
|
|
|
|
|
basePackage.storeClasses(new File(destination)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|