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();
}
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")));
}
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();
}
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));
}
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());
}
Aggregations