Examples of JarMapping


Examples of net.md_5.specialsource.JarMapping

    private void deobfJar(File inJar, File outJar, File srg, Collection<File> ats) throws IOException
    {
        getLogger().debug("INPUT: " + inJar);
        getLogger().debug("OUTPUT: " + outJar);
        // load mapping
        JarMapping mapping = new JarMapping();
        mapping.loadMappings(srg);

        final Map<String, String> renames = Maps.newHashMap();
        for (File f : new File[]{ getFieldCsv(), getMethodCsv() })
        {
            if (f == null) continue;
            Files.readLines(f, Charsets.UTF_8, new LineProcessor<String>()
            {
                @Override
                public boolean processLine(String line) throws IOException
                {
                    String[] pts = line.split(",");
                    if (!"searge".equals(pts[0]))
                    {
                        renames.put(pts[0], pts[1]);
                    }

                    return true;
                }

                @Override public String getResult() { return null; }
            });
        }

        // load in ATs
        AccessMap accessMap = new AccessMap() {
            @Override
            public void addAccessChange(String symbolString, String accessString)
            {
                String[] pts = symbolString.split(" ");
                if (pts.length >= 2)
                {
                    int idx = pts[1].indexOf('(');

                    String start = pts[1];
                    String end = "";

                    if (idx != -1)
                    {
                        start = pts[1].substring(0, idx);
                        end = pts[1].substring(idx);
                    }

                    String rename = renames.get(start);
                    if (rename != null)
                    {
                        pts[1] = rename + end;
                    }
                }
                String joinedString = Joiner.on('.').join(pts);
                super.addAccessChange(joinedString, accessString);
            }
        };
        getLogger().info("Using AccessTransformers...");
        for (File at : ats)
        {
            getLogger().info("" + at);
            accessMap.loadAccessTransformer(at);
        }

        // make a processor out of the ATS and mappings.
        RemapperProcessor srgProcessor = new RemapperProcessor(null, mapping, null);

        RemapperProcessor atProcessor = new RemapperProcessor(null, null, accessMap);
        // make remapper
        JarRemapper remapper = new JarRemapper(srgProcessor, mapping, atProcessor);

        // load jar
        Jar input = Jar.init(inJar);

        // ensure that inheritance provider is used
        JointProvider inheritanceProviders = new JointProvider();
        inheritanceProviders.add(new JarProvider(input));
        mapping.setFallbackInheritanceProvider(inheritanceProviders);

        // remap jar
        remapper.remapJar(input, outJar);
    }
View Full Code Here

Examples of net.md_5.specialsource.JarMapping

    }
   
    private void applySpecialSource(File input, File output, File srg, File extraSrg) throws IOException
    {
        // load mapping
        JarMapping mapping = new JarMapping();
        mapping.loadMappings(srg);
        mapping.loadMappings(extraSrg);

        // make remapper
        JarRemapper remapper = new JarRemapper(null, mapping);

        // load jar
        Jar inputJar = Jar.init(input);

        // ensure that inheritance provider is used
        JointProvider inheritanceProviders = new JointProvider();
        inheritanceProviders.add(new JarProvider(inputJar));
        if (classpath != null)
            inheritanceProviders.add(new ClassLoaderProvider(new URLClassLoader(ObfuscateTask.toUrls(classpath))));
        mapping.setFallbackInheritanceProvider(inheritanceProviders);

        // remap jar
        remapper.remapJar(inputJar, output);
    }
View Full Code Here

Examples of net.md_5.specialsource.JarMapping

    }

    private void obfuscate(File inJar, FileCollection classpath, File srg) throws FileNotFoundException, IOException
    {
        // load mapping
        JarMapping mapping = new JarMapping();
        mapping.loadMappings(Files.newReader(srg, Charset.defaultCharset()), null, null, reverse);

        // make remapper
        JarRemapper remapper = new JarRemapper(null, mapping);

        // load jar
        Jar input = Jar.init(inJar);

        // ensure that inheritance provider is used
        JointProvider inheritanceProviders = new JointProvider();
        inheritanceProviders.add(new JarProvider(input));

        if (classpath != null)
            inheritanceProviders.add(new ClassLoaderProvider(new URLClassLoader(toUrls(classpath))));

        mapping.setFallbackInheritanceProvider(inheritanceProviders);

        File out = getOutJar();
        if (!out.getParentFile().exists()) //Needed because SS doesn't create it.
        {
            out.getParentFile().mkdirs();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.