ise tests/cleanup. needs more optimizations.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package net.runelite.deob.deobfuscators;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import net.runelite.asm.ClassFile;
|
||||
@@ -14,10 +15,8 @@ import net.runelite.asm.attributes.code.instruction.types.JumpingInstruction;
|
||||
import net.runelite.asm.attributes.code.instructions.AThrow;
|
||||
import net.runelite.asm.attributes.code.instructions.Goto;
|
||||
import net.runelite.asm.attributes.code.instructions.If;
|
||||
import net.runelite.asm.attributes.code.instructions.If0;
|
||||
import net.runelite.asm.attributes.code.instructions.New;
|
||||
import net.runelite.asm.execution.Execution;
|
||||
import net.runelite.asm.execution.Frame;
|
||||
import net.runelite.asm.execution.InstructionContext;
|
||||
|
||||
public class IllegalStateExceptions implements Deobfuscator
|
||||
@@ -35,7 +34,7 @@ public class IllegalStateExceptions implements Deobfuscator
|
||||
if (c == null)
|
||||
continue;
|
||||
|
||||
assert execution.methods.contains(m);
|
||||
//assert execution.methods.contains(m);
|
||||
|
||||
Instructions instructions = c.getInstructions();
|
||||
instructions.buildJumpGraph();
|
||||
@@ -45,7 +44,7 @@ public class IllegalStateExceptions implements Deobfuscator
|
||||
{
|
||||
Instruction ins = ilist.get(i);
|
||||
|
||||
if (!(ins instanceof ComparisonInstruction))
|
||||
if (!(ins instanceof ComparisonInstruction)) // the if
|
||||
continue;
|
||||
|
||||
Instruction ins2 = ilist.get(i + 1);
|
||||
@@ -62,22 +61,20 @@ public class IllegalStateExceptions implements Deobfuscator
|
||||
Instruction to = jumpIns.getJumps().get(0);
|
||||
|
||||
// remove stack of if.
|
||||
Collection<InstructionContext> ics = execution.getInstructonContexts(ins);
|
||||
if (ics == null)
|
||||
continue; // never executed
|
||||
|
||||
boolean found = false;
|
||||
outer:
|
||||
for (Frame f : execution.processedFrames)
|
||||
if (f.getMethod() == m)
|
||||
{
|
||||
for (InstructionContext ic : f.getInstructions())
|
||||
if (ic.getInstruction() == ins) // this is the if
|
||||
{
|
||||
found = true;
|
||||
|
||||
if (ins instanceof If)
|
||||
ic.removeStack(1);
|
||||
ic.removeStack(0);
|
||||
break outer;
|
||||
}
|
||||
}
|
||||
for (InstructionContext ic : ics)
|
||||
{
|
||||
found = true;
|
||||
|
||||
if (ins instanceof If)
|
||||
ic.removeStack(1);
|
||||
ic.removeStack(0);
|
||||
break;
|
||||
}
|
||||
if (!found)
|
||||
{
|
||||
System.out.println("Unable to locate instruction ctx to remove stack for illegalstateexception " + ins.getType().getName() + " in method " + m.getName() + " class " + m.getMethods().getClassFile().getName());
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.runelite.deob.deobfuscators;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import net.runelite.asm.ClassGroup;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
public class IllegalStateExceptionsTest
|
||||
{
|
||||
private static final File GAMEPACK = new File(RenameUniqueTest.class.getResource("/gamepack_v16.jar").getFile());
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private ClassGroup group;
|
||||
|
||||
@Before
|
||||
public void before() throws IOException
|
||||
{
|
||||
group = JarUtil.loadJar(GAMEPACK);
|
||||
}
|
||||
|
||||
@After
|
||||
public void after() throws IOException
|
||||
{
|
||||
JarUtil.saveJar(group, folder.newFile());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRun()
|
||||
{
|
||||
IllegalStateExceptions ise = new IllegalStateExceptions();
|
||||
ise.run(group);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user