Java 类cpw.mods.fml.common.asm.transformers.deobf.FMLDeobfuscatingRemapper 实例源码

项目:4Space-5    文件:CodeChickenAccessTransformer.java   
private void loadPublicConfig() {
      if(ObfMapping.obfuscated)
          return;

     makeAllPublic = CodeChickenCoreModContainer.config.getTag("dev.runtimePublic")
              .setComment("Enabling this setting will make all minecraft classes public at runtime in MCP just as they are in modloader." +
            "\nYou should ONLY use this when you are testing with a mod that relies on runtime publicity and doesn't include access transformers." +
            "\nSuch mods are doing the wrong thing and should be fixed.")
.getBooleanValue(false);

     if(!makeAllPublic)
          return;

      try
      {
          f_classNameBiMap = FMLDeobfuscatingRemapper.class.getDeclaredField("classNameBiMap");
          f_classNameBiMap.setAccessible(true);
      }
      catch(Exception e)
      {
          throw new RuntimeException(e);
      }
  }
项目:HookLib    文件:PrimaryClassTransformer.java   
static Type map(Type type) {
    if (!HookLibPlugin.getObfuscated()) return type;

    // void or primitive
    if (type.getSort() < 9) return type;

    //array
    if (type.getSort() == 9) {
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < type.getDimensions(); i++) {
            sb.append("[");
        }
        boolean isPrimitiveArray = type.getSort() < 9;
        if (!isPrimitiveArray) sb.append("L");
        sb.append(map(type.getElementType()).getInternalName());
        if (!isPrimitiveArray) sb.append(";");
        return Type.getType(sb.toString());
    } else if (type.getSort() == 10) {
        String unmappedName = FMLDeobfuscatingRemapper.INSTANCE.map(type.getInternalName());
        return Type.getType("L" + unmappedName + ";");
    } else {
        throw new IllegalArgumentException("Can not map method type!");
    }
}
项目:MCRenderCrashFix    文件:RMHandler.java   
@Override
public MethodVisitor visitMethod(int access, String name, String desc, String signature, String[] exceptions) {
    MethodVisitor mv= super.visitMethod(access, name, desc, signature, exceptions);
    String method=FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(this.name,name,desc);
    if(method.equals("func_147939_a")){
        TB tb=new TB(access,name,desc,signature,exceptions);
        tb.accept(mv);
    }
    return mv;
}
项目:McHeliPrivacyShield    文件:MethodMatcher.java   
public boolean match(final @Nonnull String methodName, final @Nonnull String methodDesc) {
    if (methodName.equals(this.refname.mcpName()))
        return true;
    if (!VisitorHelper.useSrgNames())
        return false;
    final String unmappedDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(methodDesc);
    if (!unmappedDesc.equals(this.description))
        return false;
    final String unmappedName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(this.clsName, methodName, methodDesc);
    return unmappedName.equals(this.refname.srgName());
}
项目:McHeliPrivacyShield    文件:FieldMatcher.java   
public boolean match(final @Nonnull String fieldName, final @Nonnull String fieldDesc) {
    if (!fieldDesc.equals(this.description))
        return false;
    if (fieldName.equals(this.refname.mcpName()))
        return true;
    if (!VisitorHelper.useSrgNames())
        return false;
    final String unmappedName = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(this.clsName, fieldName, fieldDesc);
    return unmappedName.equals(this.refname.srgName());
}
项目:4Space-5    文件:ClassHeirachyManager.java   
public static String getSuperClass(String name, boolean runtime) {
    name = toKey(name);
    SuperCache cache = declareClass(name);
    if (cache == null)
        return "java.lang.Object";

    cache.flatten();
    String s = cache.superclass;
    if (!runtime)
        s = FMLDeobfuscatingRemapper.INSTANCE.unmap(s);
    return s;
}
项目:4Space-5    文件:CodeChickenAccessTransformer.java   
private void restoreClassMap() {
    try
    {
        f_classNameBiMap.set(FMLDeobfuscatingRemapper.INSTANCE, emptyMap);
    }
    catch(Exception e)
    {
        throw new RuntimeException(e);
    }
}
项目:4Space-5    文件:CodeChickenAccessTransformer.java   
private void setClassMap(String name) {
    try
    {
        f_classNameBiMap.set(FMLDeobfuscatingRemapper.INSTANCE, ImmutableBiMap.of(name.replace('.', '/'), ""));
    }
    catch(Exception e)
    {
        throw new RuntimeException(e);
    }
}
项目:TRHS_Club_Mod_2016    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    liveEnv = (Boolean)data.get("runtimeDeobfuscationEnabled");
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:TRHS_Club_Mod_2016    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:SignPicture    文件:MethodMatcher.java   
public boolean match(final @Nonnull String methodName, final @Nonnull String methodDesc) {
    if (methodName.equals(this.refname.mcpName()))
        return true;
    if (!VisitorHelper.useSrgNames())
        return false;
    final String unmappedDesc = FMLDeobfuscatingRemapper.INSTANCE.mapMethodDesc(methodDesc);
    if (!unmappedDesc.equals(this.description))
        return false;
    final String unmappedName = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(this.clsName, methodName, methodDesc);
    return unmappedName.equals(this.refname.srgName());
}
项目:SignPicture    文件:FieldMatcher.java   
public boolean match(final @Nonnull String fieldName, final @Nonnull String fieldDesc) {
    if (!fieldDesc.equals(this.description))
        return false;
    if (fieldName.equals(this.refname.mcpName()))
        return true;
    if (!VisitorHelper.useSrgNames())
        return false;
    final String unmappedName = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(this.clsName, fieldName, fieldDesc);
    return unmappedName.equals(this.refname.srgName());
}
项目:CauldronGit    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:CauldronGit    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:NOVA-Core    文件:ClassHeirachyManager.java   
public static String getSuperClass(String name, boolean runtime) {
    name = toKey(name);
    SuperCache cache = declareClass(name);
    if (cache == null) {
        return "java.lang.Object";
    }

    cache.flatten();
    String s = cache.superclass;
    if (!runtime) {
        s = FMLDeobfuscatingRemapper.INSTANCE.unmap(s);
    }
    return s;
}
项目:Cauldron    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:Cauldron    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:Cauldron    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:Cauldron    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:Whodunit    文件:MethodMatcher.java   
private boolean tryMatch(String methodName, String methodDesc) {
    if (!methodDesc.equals(description))
        return false;
    if (methodName.equals(mcpName))
        return true;
    if (!VisitorHelper.useSrgNames())
        return false;
    String mapped = FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(clsName, methodName, methodDesc);
    return mapped.equals(srgName);
}
项目:RuneCraftery    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:RuneCraftery    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:RuneCraftery    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:RuneCraftery    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:BugSnag4MC    文件:BS4MCTransformer.java   
public BS4MCTransformer() {
    srgMappings.put("description", "field_71513_a");
    srgMappings.put("cause", "field_71511_b");
    srgMappings.put("populateEnvironment", "func_71504_g");
    srgMappings.put("getCompleteReport", "func_71502_e");

    this.mapper = FMLDeobfuscatingRemapper.INSTANCE;
}
项目:BetterNutritionMod    文件:FMLSanityChecker.java   
@Override
public void injectData(Map<String, Object> data)
{
    cl = (LaunchClassLoader) data.get("classLoader");
    File mcDir = (File)data.get("mcLocation");
    fmlLocation = (File)data.get("coremodLocation");
    ClassPatchManager.INSTANCE.setup(FMLLaunchHandler.side());
    FMLDeobfuscatingRemapper.INSTANCE.setup(mcDir, cl, (String) data.get("deobfuscationFileName"));
}
项目:BetterNutritionMod    文件:ObfuscationReflectionHelper.java   
public static String[] remapFieldNames(String className, String... fieldNames)
{
    String internalClassName = FMLDeobfuscatingRemapper.INSTANCE.unmap(className.replace('.', '/'));
    String[] mappedNames = new String[fieldNames.length];
    int i = 0;
    for (String fName : fieldNames)
    {
        mappedNames[i++] = FMLDeobfuscatingRemapper.INSTANCE.mapFieldName(internalClassName, fName, null);
    }
    return mappedNames;
}
项目:McHeliPrivacyShield    文件:VisitorHelper.java   
public static @Nonnull String getMappedName(final @Nonnull String clsName) {
    return useSrgNames() ? FMLDeobfuscatingRemapper.INSTANCE.unmap(clsName) : clsName;
}
项目:ExtraUtilities    文件:TestTransformer.java   
public static void performTest() {
    for (final String s : FMLDeobfuscatingRemapper.INSTANCE.getObfedClasses()) {
        LogHelper.info(s + FMLDeobfuscatingRemapper.INSTANCE.map(s), new Object[0]);
    }
}
项目:4Space-5    文件:ClassHeirachyManager.java   
public static String toKey(String name) {
    if (ObfMapping.obfuscated)
        name = FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.', '/')).replace('/', '.');
    return name;
}
项目:4Space-5    文件:ClassHeirachyManager.java   
public static String unKey(String name) {
    if (ObfMapping.obfuscated)
        name = FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/', '.');
    return name;
}
项目:4Space-5    文件:ObfMapping.java   
@Override
public String map(String typeName) {
    return FMLDeobfuscatingRemapper.INSTANCE.unmap(typeName);
}
项目:4Space-5    文件:ObfMapping.java   
public String unmap(String typeName) {
    return FMLDeobfuscatingRemapper.INSTANCE.map(typeName);
}
项目:TRHS_Club_Mod_2016    文件:GenDiffSet.java   
public static void main(String[] args) throws IOException
    {
        String sourceJar = args[0]; //Clean Vanilla jar minecraft.jar or minecraft_server.jar
        String targetDir = args[1]; //Directory containing obfed output classes, typically mcp/reobf/minecraft
        String deobfData = args[2]; //Path to FML's deobfusication_data.lzma
        String outputDir = args[3]; //Path to place generated .binpatch
        String killTarget = args[4]; //"true" if we should destroy the target file if it generated a successful .binpatch

        LogManager.getLogger("GENDIFF").log(Level.INFO, String.format("Creating patches at %s for %s from %s", outputDir, sourceJar, targetDir));
        Delta delta = new Delta();
        FMLDeobfuscatingRemapper remapper = FMLDeobfuscatingRemapper.INSTANCE;
        remapper.setupLoadOnly(deobfData, false);
        JarFile sourceZip = new JarFile(sourceJar);
        boolean kill = killTarget.equalsIgnoreCase("true");

        File f = new File(outputDir);
        f.mkdirs();

        for (String name : remapper.getObfedClasses())
        {
//            Logger.getLogger("GENDIFF").info(String.format("Evaluating path for data :%s",name));
            String fileName = name;
            String jarName = name;
            if (RESERVED_NAMES.contains(name.toUpperCase(Locale.ENGLISH)))
            {
                fileName = "_"+name;
            }
            File targetFile = new File(targetDir, fileName.replace('/', File.separatorChar) + ".class");
            jarName = jarName+".class";
            if (targetFile.exists())
            {
                String sourceClassName = name.replace('/', '.');
                String targetClassName = remapper.map(name).replace('/', '.');
                JarEntry entry = sourceZip.getJarEntry(jarName);

                byte[] vanillaBytes = entry != null ? ByteStreams.toByteArray(sourceZip.getInputStream(entry)) : new byte[0];
                byte[] patchedBytes = Files.toByteArray(targetFile);

                byte[] diff = delta.compute(vanillaBytes, patchedBytes);


                ByteArrayDataOutput diffOut = ByteStreams.newDataOutput(diff.length + 50);
                // Original name
                diffOut.writeUTF(name);
                // Source name
                diffOut.writeUTF(sourceClassName);
                // Target name
                diffOut.writeUTF(targetClassName);
                // exists at original
                diffOut.writeBoolean(entry != null);
                if (entry != null)
                {
                    diffOut.writeInt(Hashing.adler32().hashBytes(vanillaBytes).asInt());
                }
                // length of patch
                diffOut.writeInt(diff.length);
                // patch
                diffOut.write(diff);

                File target = new File(outputDir, targetClassName+".binpatch");
                target.getParentFile().mkdirs();
                Files.write(diffOut.toByteArray(), target);
                Logger.getLogger("GENDIFF").info(String.format("Wrote patch for %s (%s) at %s",name, targetClassName, target.getAbsolutePath()));
                if (kill)
                {
                    targetFile.delete();
                    Logger.getLogger("GENDIFF").info(String.format("  Deleted target: %s", targetFile.toString()));
                }
            }
        }
        sourceZip.close();
    }
项目:TRHS_Club_Mod_2016    文件:DeobfuscationTransformer.java   
@Override
public String remapClassName(String name)
{
    return FMLDeobfuscatingRemapper.INSTANCE.map(name.replace('.','/')).replace('/', '.');
}
项目:TRHS_Club_Mod_2016    文件:DeobfuscationTransformer.java   
@Override
public String unmapClassName(String name)
{
    return FMLDeobfuscatingRemapper.INSTANCE.unmap(name.replace('.', '/')).replace('/','.');
}
项目:SignPicture    文件:VisitorHelper.java   
public static @Nonnull String getMappedName(final @Nonnull String clsName) {
    return useSrgNames() ? FMLDeobfuscatingRemapper.INSTANCE.unmap(clsName) : clsName;
}
项目:AntiMatterMod    文件:AMMCoreTransformer.java   
private byte[] hookWorldTick(String name, String unTransformedName, byte[] basicClass){
    ClassNode classNode = new ClassNode();
    ClassReader classReader = new ClassReader(basicClass);
    classReader.accept(classNode,0);

    String targetMethodName = "tick";
    String targetMethoddesc = "()V";

    FMLLog.log(Level.DEBUG,"Class WorldServer was found!");

    MethodNode methodNode = null;
    for (MethodNode currentMethodNode : classNode.methods){
        if (targetMethodName.equals(currentMethodNode.name) || targetMethodName.equals(FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(name,targetMethodName,targetMethoddesc)) || targetMethodName.equals(FMLDeobfuscatingRemapper.INSTANCE.mapMethodName(unTransformedName,targetMethodName,targetMethoddesc))){
            methodNode = currentMethodNode;
            break;
        }
    }
    if(methodNode != null){
        InsnList overrideList = new InsnList();
        //テスト用のログ
        FMLLog.log(Level.DEBUG,"Method was found!");

        //メソッドコールの追加などをここで行う
        //Modding Wikiのコピペ
        /*
        overrideList.add(new VarInsnNode(ALOAD, 1));
        overrideList.add(new VarInsnNode(DLOAD, 2));
        overrideList.add(new VarInsnNode(DLOAD, 4));
        overrideList.add(new VarInsnNode(DLOAD, 6));
        overrideList
                .add(new MethodInsnNode(INVOKESTATIC, "tutorial/test", "passTestRender", "(LEntityLiving;DDD)V"));
                */
        // mnode.instructions.get(1)で、対象のメソッドの先頭を取得
        // mnode.instructions.insertで、指定した位置にバイトコードを挿入します。
        //mnode.instructions.insert(mnode.instructions.get(1), overrideList);
        // 改変したクラスファイルをバイト列に書き出します
        //ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS);
        //classNode.accept(cw);
        //return cw.toByteArray();
    }
    return basicClass;
}