Search in sources :

Example 1 with ParallelExecutorMapping

use of net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping in project runelite by runelite.

the class UpdateMappings method update.

public void update() {
    Mapper mapper = new Mapper(group1, group2);
    mapper.run();
    ParallelExecutorMapping mapping = mapper.getMapping();
    AnnotationMapper amapper = new AnnotationMapper(group1, group2, mapping);
    amapper.run();
    AnnotationIntegrityChecker aic = new AnnotationIntegrityChecker(group1, group2, mapping);
    aic.run();
    int errors = aic.getErrors();
    if (errors > 0) {
        logger.warn("Errors in annotation checker, exiting");
        System.exit(-1);
    }
    AnnotationRenamer an = new AnnotationRenamer(group2);
    an.run();
}
Also used : Mapper(net.runelite.deob.deobfuscators.mapping.Mapper) AnnotationMapper(net.runelite.deob.deobfuscators.mapping.AnnotationMapper) ParallelExecutorMapping(net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping) AnnotationMapper(net.runelite.deob.deobfuscators.mapping.AnnotationMapper) AnnotationIntegrityChecker(net.runelite.deob.deobfuscators.mapping.AnnotationIntegrityChecker)

Example 2 with ParallelExecutorMapping

use of net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping in project runelite by runelite.

the class ParallelMappingExecutorTest method testTableswitch.

@Test
public void testTableswitch() throws IOException {
    InputStream in = ParallelMappingExecutorTest.class.getResourceAsStream("tests/TableSwitch.class");
    Assert.assertNotNull(in);
    ClassGroup group = new ClassGroup();
    ClassFile cf = ClassUtil.loadClass(in);
    group.addClass(cf);
    in = ParallelMappingExecutorTest.class.getResourceAsStream("tests/TableSwitch.class");
    Assert.assertNotNull(in);
    ClassGroup group2 = new ClassGroup();
    ClassFile cf2 = ClassUtil.loadClass(in);
    group2.addClass(cf2);
    Method m1 = cf.findMethod("method");
    Method m2 = cf2.findMethod("method");
    ParallelExecutorMapping map = MappingExecutorUtil.map(m1, m2);
    Assert.assertEquals(cf2.findField("field2"), map.get(cf.findField("field2")));
}
Also used : ClassFile(net.runelite.asm.ClassFile) InputStream(java.io.InputStream) ClassGroup(net.runelite.asm.ClassGroup) Method(net.runelite.asm.Method) ParallelExecutorMapping(net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping) Test(org.junit.Test)

Example 3 with ParallelExecutorMapping

use of net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping in project runelite by runelite.

the class UpdateMappingsTest method map.

private void map(ClassGroup group1, ClassGroup group2) {
    logger.info("Mapping group1 ({}) vs group2 ({})", desc(group1), desc(group2));
    Mapper mapper = new Mapper(group1, group2);
    mapper.run();
    ParallelExecutorMapping mapping = mapper.getMapping();
    summary(mapping, group1);
    AnnotationMapper amapper = new AnnotationMapper(group1, group2, mapping);
    amapper.run();
    AnnotationIntegrityChecker aic = new AnnotationIntegrityChecker(group1, group2, mapping);
    aic.run();
    if (aic.getErrors() > 0) {
        Assert.fail("Errors in annotation integrity checker");
    }
    AnnotationRenamer an = new AnnotationRenamer(group2);
    an.run();
}
Also used : Mapper(net.runelite.deob.deobfuscators.mapping.Mapper) AnnotationMapper(net.runelite.deob.deobfuscators.mapping.AnnotationMapper) ParallelExecutorMapping(net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping) AnnotationMapper(net.runelite.deob.deobfuscators.mapping.AnnotationMapper) AnnotationIntegrityChecker(net.runelite.deob.deobfuscators.mapping.AnnotationIntegrityChecker)

Example 4 with ParallelExecutorMapping

use of net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping in project runelite by runelite.

the class ParallellMappingExecutorTest method testStaticStep.

@Test
public void testStaticStep() throws Exception {
    ClassFile cf1 = ClassUtil.loadClass(getClass().getResourceAsStream("mapper/StaticStepTest.class"));
    ClassFile cf2 = ClassUtil.loadClass(getClass().getResourceAsStream("mapper/StaticStepTest.class"));
    ClassGroup group1 = new ClassGroup();
    ClassGroup group2 = new ClassGroup();
    group1.addClass(cf1);
    group2.addClass(cf2);
    group1.buildClassGraph();
    group1.lookup();
    group2.buildClassGraph();
    group2.lookup();
    Method m1 = cf1.findMethod("entry");
    Method m2 = cf2.findMethod("entry");
    Method map1 = cf1.findMethod("map"), map2 = cf2.findMethod("map");
    Assert.assertNotNull(map1);
    Assert.assertNotNull(map2);
    ParallelExecutorMapping map = MappingExecutorUtil.map(m1, m2);
    Assert.assertEquals(map2, map.get(map1));
}
Also used : ClassFile(net.runelite.asm.ClassFile) ClassGroup(net.runelite.asm.ClassGroup) Method(net.runelite.asm.Method) ParallelExecutorMapping(net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping) Test(org.junit.Test)

Example 5 with ParallelExecutorMapping

use of net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping in project runelite by runelite.

the class IfEqTest method testIsSame.

@Test
public void testIsSame() {
    Instructions ins = mock(Instructions.class);
    Frame originalIfEqFrame = mock(Frame.class);
    Stack stack = new Stack(42);
    Variables variables = new Variables(42);
    when(originalIfEqFrame.getStack()).thenReturn(stack);
    when(originalIfEqFrame.getVariables()).thenReturn(variables);
    variables.set(9, new VariableContext(INT));
    Instruction i = new LDC(ins, 0);
    InstructionContext ctx = new InstructionContext(i, originalIfEqFrame);
    // ifeq 0
    IfEq ifeq = new IfEq(ins, InstructionType.IFEQ);
    InstructionContext ifeqCtx = new InstructionContext(ifeq, originalIfEqFrame);
    ifeqCtx.pop(new StackContext(ctx, INT, new Value(1)));
    // 
    ins = mock(Instructions.class);
    Frame originalIfIcmpNeFrame = mock(Frame.class);
    stack = new Stack(42);
    variables = new Variables(42);
    when(originalIfIcmpNeFrame.getStack()).thenReturn(stack);
    when(originalIfIcmpNeFrame.getVariables()).thenReturn(variables);
    variables.set(5, new VariableContext(INT));
    i = new LDC(ins, 1);
    InstructionContext ctx1 = new InstructionContext(i, originalIfIcmpNeFrame);
    i = new ILoad(ins, 5);
    InstructionContext ctx2 = new InstructionContext(i, originalIfIcmpNeFrame);
    // ificmpne 1
    IfICmpNe ificmpne = new IfICmpNe(ins, InstructionType.IF_ICMPNE);
    InstructionContext ificmpneCtx = new InstructionContext(ificmpne, originalIfIcmpNeFrame);
    ificmpneCtx.pop(new StackContext(ctx1, INT, new Value(1)), new StackContext(ctx2, INT, Value.UNKNOWN));
    assertEquals(ifeq.isSame(ifeqCtx, ificmpneCtx), ificmpne.isSame(ificmpneCtx, ifeqCtx));
    // check that both frames jump the same direction
    Frame ifeqBranchFrame = mock(Frame.class);
    ifeqCtx.branch(ifeqBranchFrame);
    Frame ificmpneBranchFrame = mock(Frame.class);
    ificmpneCtx.branch(ificmpneBranchFrame);
    // initially originalIfEqFrame.other == originalIfIcmpNeFrame.other
    when(originalIfEqFrame.getOther()).thenReturn(originalIfIcmpNeFrame);
    when(originalIfIcmpNeFrame.getOther()).thenReturn(originalIfEqFrame);
    ParallelExecutorMapping mapping = mock(ParallelExecutorMapping.class);
    ifeq.map(mapping, ifeqCtx, ificmpneCtx);
    // verify that ifeqBranchFrame.other = ificmpneBranchFrame
    ArgumentCaptor<Frame> frameCapture = ArgumentCaptor.forClass(Frame.class);
    verify(ifeqBranchFrame).setOther(frameCapture.capture());
    assertEquals(ificmpneBranchFrame, frameCapture.getValue());
}
Also used : InstructionContext(net.runelite.asm.execution.InstructionContext) Frame(net.runelite.asm.execution.Frame) Instructions(net.runelite.asm.attributes.code.Instructions) VariableContext(net.runelite.asm.execution.VariableContext) Instruction(net.runelite.asm.attributes.code.Instruction) ParallelExecutorMapping(net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping) Stack(net.runelite.asm.execution.Stack) Variables(net.runelite.asm.execution.Variables) StackContext(net.runelite.asm.execution.StackContext) Value(net.runelite.asm.execution.Value) Test(org.junit.Test)

Aggregations

ParallelExecutorMapping (net.runelite.deob.deobfuscators.mapping.ParallelExecutorMapping)5 Test (org.junit.Test)3 ClassFile (net.runelite.asm.ClassFile)2 ClassGroup (net.runelite.asm.ClassGroup)2 Method (net.runelite.asm.Method)2 AnnotationIntegrityChecker (net.runelite.deob.deobfuscators.mapping.AnnotationIntegrityChecker)2 AnnotationMapper (net.runelite.deob.deobfuscators.mapping.AnnotationMapper)2 Mapper (net.runelite.deob.deobfuscators.mapping.Mapper)2 InputStream (java.io.InputStream)1 Instruction (net.runelite.asm.attributes.code.Instruction)1 Instructions (net.runelite.asm.attributes.code.Instructions)1 Frame (net.runelite.asm.execution.Frame)1 InstructionContext (net.runelite.asm.execution.InstructionContext)1 Stack (net.runelite.asm.execution.Stack)1 StackContext (net.runelite.asm.execution.StackContext)1 Value (net.runelite.asm.execution.Value)1 VariableContext (net.runelite.asm.execution.VariableContext)1 Variables (net.runelite.asm.execution.Variables)1