well this gets further

This commit is contained in:
Adam
2016-02-01 20:14:57 -05:00
parent 949ce54fb9
commit 4aa8b23dfd
10 changed files with 103 additions and 25 deletions

View File

@@ -78,6 +78,7 @@ public abstract class If extends Instruction implements JumpingInstruction, Comp
Frame other = frame.dup();
other.created = this;
other.forking = ins;
other.jump(ins, to);
ins.branch(other);

View File

@@ -79,6 +79,7 @@ public abstract class If0 extends Instruction implements JumpingInstruction, Com
Frame other = frame.dup();
other.created = this;
other.forking = ins;
other.jump(ins, to);
ins.branch(other);

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Value;
@@ -181,6 +182,6 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
@Override
public boolean canMap()
{
return true;
return MappingExecutorUtil.isMappable(this);
}
}

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Value;
@@ -182,6 +183,6 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
@Override
public boolean canMap()
{
return true;
return MappingExecutorUtil.isMappable(this);
}
}

View File

@@ -23,6 +23,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import net.runelite.deob.attributes.code.instruction.types.MappableInstruction;
import net.runelite.deob.deobfuscators.rename.MappingExecutorUtil;
import net.runelite.deob.deobfuscators.rename.ParallelExecutorMapping;
import net.runelite.deob.execution.Execution;
import net.runelite.deob.execution.Value;
@@ -184,6 +185,6 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
@Override
public boolean canMap()
{
return true;
return MappingExecutorUtil.isMappable(this);
}
}

View File

@@ -118,12 +118,16 @@ public class LookupSwitch extends Instruction implements JumpingInstruction
StackContext value = stack.pop();
ins.pop(value);
for (Instruction i : branchi)
if (!frame.getExecution().step)
{
Frame other = frame.dup();
other.jump(ins, i);
ins.branch(other);
for (Instruction i : branchi)
{
Frame other = frame.dup();
other.forking = ins;
other.jump(ins, i);
ins.branch(other);
}
}
frame.jump(ins, defi);

View File

@@ -113,13 +113,16 @@ public class TableSwitch extends Instruction implements JumpingInstruction
StackContext value = stack.pop();
ins.pop(value);
for (Instruction i : branchi)
if (!frame.getExecution().step)
{
Frame other = frame.dup();
other.jump(ins, i);
ins.branch(other);
for (Instruction i : branchi)
{
Frame other = frame.dup();
other.jump(ins, i);
ins.branch(other);
}
}
frame.jump(ins, defi);

View File

@@ -120,8 +120,23 @@ public class MappingExecutorUtil
public static boolean isMappable(InvokeInstruction ii)
{
net.runelite.deob.pool.Method m = (net.runelite.deob.pool.Method) ii.getMethod();
String className = m.getClassEntry().getName();
String className;
if (ii.getMethod() instanceof net.runelite.deob.pool.Method)
{
net.runelite.deob.pool.Method m = (net.runelite.deob.pool.Method) ii.getMethod();
className = m.getClassEntry().getName();
}
else if (ii.getMethod() instanceof net.runelite.deob.pool.InterfaceMethod)
{
net.runelite.deob.pool.InterfaceMethod m = (net.runelite.deob.pool.InterfaceMethod) ii.getMethod();
className = m.getClassEntry().getName();
}
else
{
assert false;
return false;
}
if (className.startsWith("java/") || className.startsWith("netscape/"))
return false;

View File

@@ -33,6 +33,9 @@ public class Frame
public Frame returnTo; // is this the same as caller?
public Frame otherStatic;
public Instruction created;
public InstructionContext forking;
public boolean initial;
public boolean isdup,iscopy;
public Frame(Execution execution, Method method)
{
@@ -57,7 +60,8 @@ public class Frame
}
public void initialize()
{
{
initial = true;
// initialize LVT
int pos = 0;
if (!method.isStatic())
@@ -76,6 +80,7 @@ public class Frame
public void initialize(InstructionContext ctx)
{
created = ctx.getInstruction();
// initialize frame from invoking context
assert ctx.getInstruction() instanceof InvokeInstruction;
@@ -111,6 +116,7 @@ public class Frame
protected Frame(Frame other)
{
iscopy=true;
this.execution = other.execution;
this.method = other.method;
this.executing = other.executing;
@@ -121,12 +127,18 @@ public class Frame
this.nonStatic = other.nonStatic;
this.caller = other.caller;
if (other.returnTo != null)
{
this.returnTo = new Frame(other.returnTo);
this.returnTo.instructions.addAll(other.returnTo.instructions);
}
this.created = other.created;
this.forking = other.forking;
}
public Frame dup()
{
Frame other = new Frame(this);
other.isdup=true;
execution.frames.add(other);
return other;
}

View File

@@ -25,7 +25,7 @@ public class ParallellMappingExecutor
++count;
if (count == 685)
if (count == 18223)
{
int i = 5;
}
@@ -55,12 +55,36 @@ public class ParallellMappingExecutor
assert f1.returnTo == null || !e.frames.contains(f1.returnTo);
assert f2.returnTo == null || !e2.frames.contains(f2.returnTo);
// Due to jump ob one side can stop while the other side jumps
if (f1.getInstructions().size() > 0)
InstructionContext fork1 = f1.getInstructions().isEmpty() ? f1.forking : f1.getInstructions().get(f1.getInstructions().size() - 1);
InstructionContext fork2 = f2.getInstructions().isEmpty() ? f2.forking : f2.getInstructions().get(f2.getInstructions().size() - 1);
assert fork1 != null;
assert fork2 != null;
if (!(f1.getInstructions().isEmpty() == f2.getInstructions().isEmpty()))
{
p1 = f1.getInstructions().get(f1.getInstructions().size() - 1);
int i = 5;
}
// Due to jump ob one side can stop while the other side jumps
//if (f1.getInstructions().size() > 0)
if (fork1 == f1.forking)
{
assert fork1.getBranches().size() == 1;
//assert fork1.getBranches().get(0) == f1;
int i1 = e.frames.indexOf(fork1.getFrame());
int i2 = e.frames.indexOf(fork1.getBranches().get(0));
// remove fork1.frame
e.frames.remove(fork1.getFrame());
//e.frames.remove(fork1.getBranches().get(0));
}
else
{
//p1 = f1.getInstructions().get(f1.getInstructions().size() - 1);
for (Frame branch : p1.getBranches())
for (Frame branch : fork1.getBranches())
{
e.frames.remove(branch);
}
@@ -68,11 +92,23 @@ public class ParallellMappingExecutor
// this is empty but should be removing a branch, because of the map other, theres no prev instruction.
// should always populate prev instruction
if (f2.getInstructions().size() > 0)
//if (f2.getInstructions().size() > 0)
if (fork2 == f2.forking)
{
p2 = f2.getInstructions().get(f2.getInstructions().size() - 1);
assert fork2.getBranches().size() == 1;
//assert fork2.getBranches().get(0) == f2;
for (Frame branch : p2.getBranches())
int i1 = e2.frames.indexOf(fork2.getFrame());
int i2 = e2.frames.indexOf(fork2.getBranches().get(0));
e2.frames.remove(fork2.getFrame());
//e.frames.remove(fork2.getBranches().get(0));
}
else
{
//p2 = f2.getInstructions().get(f2.getInstructions().size() - 1);
for (Frame branch : fork2.getBranches())
{
e2.frames.remove(branch);
}
@@ -267,6 +303,7 @@ public class ParallellMappingExecutor
Method to = methods.get(0);
Frame f2 = new Frame(e, to);
f2.created = is;
f2.initialize(i);
e.frames.remove(0); // old frame goes away
@@ -280,6 +317,8 @@ public class ParallellMappingExecutor
f.other = null;
f2.returnTo = new Frame(f); // where to go when we're done
assert f.getInstructions().isEmpty() == false;
f2.returnTo.getInstructions().addAll(f.getInstructions());
return f2;
}