Search in sources :

Example 1 with NameMappings

use of net.runelite.deob.util.NameMappings in project runelite by runelite.

the class RenameUnique method run.

@Override
public void run(ClassGroup group) {
    group.buildClassGraph();
    group.lookup();
    NameMappings mappings = new NameMappings();
    this.generateClassNames(mappings, group);
    this.generateFieldNames(mappings, group);
    this.generateMethodNames(mappings, group);
    renamer = new Renamer(mappings);
    renamer.run(group);
}
Also used : NameMappings(net.runelite.deob.util.NameMappings)

Example 2 with NameMappings

use of net.runelite.deob.util.NameMappings in project runelite by runelite.

the class HookImporter method importHooks.

@Test
@Ignore
public void importHooks() {
    int classes = 0, fields = 0, methods = 0;
    NameMappings mappings = new NameMappings();
    for (HookClass hc : hooks) {
        ClassFile cf = findClassWithObfuscatedName(hc.name);
        assert cf != null;
        String implementsName = getAnnotation(cf.getAnnotations(), IMPLEMENTS);
        if (implementsName.isEmpty()) {
            String deobfuscatedClassName = hc.clazz;
            cf.getAnnotations().addAnnotation(IMPLEMENTS, "value", deobfuscatedClassName);
            mappings.map(cf.getPoolClass(), deobfuscatedClassName);
            ++classes;
        }
        for (HookField fh : hc.fields) {
            ClassFile cf2 = findClassWithObfuscatedName(fh.owner);
            assert cf2 != null;
            Field f = findFieldWithObfuscatedName(cf2, fh.name);
            if (f == null) {
                // inlined constant maybe?
                logger.warn("Missing field {}", fh);
                continue;
            }
            String exportedName = getAnnotation(f.getAnnotations(), EXPORT);
            if (exportedName.isEmpty()) {
                String deobfuscatedFieldName = fh.field;
                Field other = cf2.findField(deobfuscatedFieldName);
                if (other != null) {
                    logger.warn("Name collision for field {}", deobfuscatedFieldName);
                    continue;
                }
                f.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedFieldName);
                mappings.map(f.getPoolField(), deobfuscatedFieldName);
                ++fields;
            }
        }
        outer: for (HookMethod hm : hc.methods) {
            ClassFile cf2 = findClassWithObfuscatedName(hm.owner);
            assert cf2 != null;
            Method m = findMethodWithObfuscatedName(cf2, hm.name, hm.descriptor);
            assert m != null;
            // maybe only the base class method is exported
            List<Method> virtualMethods = VirtualMethods.getVirtualMethods(m);
            for (Method method : virtualMethods) {
                String exportedName = getAnnotation(method.getAnnotations(), EXPORT);
                if (!exportedName.isEmpty()) {
                    continue outer;
                }
            }
            String deobfuscatedMethodName = hm.method;
            m.getAnnotations().addAnnotation(EXPORT, "value", deobfuscatedMethodName);
            mappings.map(m.getPoolMethod(), deobfuscatedMethodName);
            ++methods;
        }
    }
    Renamer renamer = new Renamer(mappings);
    renamer.run(group);
    logger.info("Imported {} classes, {} fields, {} methods", classes, fields, methods);
}
Also used : Renamer(net.runelite.deob.deobfuscators.Renamer) Field(net.runelite.asm.Field) ClassFile(net.runelite.asm.ClassFile) List(java.util.List) Method(net.runelite.asm.Method) NameMappings(net.runelite.deob.util.NameMappings) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with NameMappings

use of net.runelite.deob.util.NameMappings in project runelite by runelite.

the class AnnotationRenamer method run.

public void run() {
    NameMappings mappings = buildMappings();
    Renamer renamer = new Renamer(mappings);
    renamer.run(group);
}
Also used : Renamer(net.runelite.deob.deobfuscators.Renamer) NameMappings(net.runelite.deob.util.NameMappings)

Aggregations

NameMappings (net.runelite.deob.util.NameMappings)3 Renamer (net.runelite.deob.deobfuscators.Renamer)2 List (java.util.List)1 ClassFile (net.runelite.asm.ClassFile)1 Field (net.runelite.asm.Field)1 Method (net.runelite.asm.Method)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1