Tweaks to runtime deobf

This commit is contained in:
Christian 2013-03-02 01:49:45 -05:00
parent ad582c82a0
commit f9094e3f85
4 changed files with 33 additions and 3 deletions

View file

@ -35,6 +35,7 @@ import com.google.common.collect.Multimap;
import com.google.common.io.LineProcessor;
import com.google.common.io.Resources;
import cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper;
import cpw.mods.fml.relauncher.IClassTransformer;
public class AccessTransformer implements IClassTransformer
@ -145,13 +146,35 @@ public class AccessTransformer implements IClassTransformer
@Override
public byte[] transform(String name, String transformedName, byte[] bytes)
{
if (bytes == null) { return null; }
if (!modifiers.containsKey(name)) { return bytes; }
if (bytes == null) { return null; }
boolean makeAllPublic = FMLDeobfuscatingRemapper.INSTANCE.isRemappedClass(name);
if (!makeAllPublic && !modifiers.containsKey(name)) { return bytes; }
ClassNode classNode = new ClassNode();
ClassReader classReader = new ClassReader(bytes);
classReader.accept(classNode, 0);
if (makeAllPublic)
{
// class
Modifier m = new Modifier();
m.targetAccess = ACC_PUBLIC;
m.modifyClassVisibility = true;
modifiers.put(name,m);
// fields
m = new Modifier();
m.targetAccess = ACC_PUBLIC;
m.name = "*";
modifiers.put(name,m);
// methods
m = new Modifier();
m.targetAccess = ACC_PUBLIC;
m.name = "*";
m.desc = "";
modifiers.put(name,m);
}
Collection<Modifier> mods = modifiers.get(name);
for (Modifier m : mods)
{

View file

@ -96,6 +96,12 @@ public class FMLDeobfuscatingRemapper extends Remapper {
methodNameMaps = Maps.newHashMapWithExpectedSize(rawMethodMaps.size());
fieldNameMaps = Maps.newHashMapWithExpectedSize(rawFieldMaps.size());
}
public boolean isRemappedClass(String className)
{
return classNameBiMap.containsKey(className);
}
private void parseField(String[] parts)
{
String oldSrg = parts[1];

View file

@ -17,7 +17,6 @@ public class FMLCorePlugin implements IFMLLoadingPlugin
"cpw.mods.fml.common.asm.transformers.AccessTransformer",
"cpw.mods.fml.common.asm.transformers.MarkerTransformer",
"cpw.mods.fml.common.asm.transformers.SideTransformer",
"cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer",
};
}

View file

@ -239,6 +239,8 @@ public class RelaunchLibraryManager
}
}
}
// Deobfuscation transformer, always last
actualClassLoader.registerTransformer("cpw.mods.fml.common.asm.transformers.DeobfuscationTransformer");
downloadMonitor.updateProgressString("Running coremod plugins");
Map<String,Object> data = new HashMap<String,Object>();