Simplify jump deob, just destroy and rebuld jump graph instead of trying
to update it which sucks.
This commit is contained in:
@@ -149,13 +149,18 @@ public class Instructions
|
|||||||
out.write(ba);
|
out.write(ba);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void buildJumpGraph()
|
public void clearJumpGraph()
|
||||||
{
|
{
|
||||||
for (Instruction i : instructions)
|
for (Instruction i : instructions)
|
||||||
{
|
{
|
||||||
i.jump.clear();
|
i.jump.clear();
|
||||||
i.from.clear();
|
i.from.clear();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void buildJumpGraph()
|
||||||
|
{
|
||||||
|
clearJumpGraph();
|
||||||
|
|
||||||
for (Instruction i : instructions)
|
for (Instruction i : instructions)
|
||||||
if (i instanceof JumpingInstruction)
|
if (i instanceof JumpingInstruction)
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ public class Jumps
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
for (ClassFile cf : group.getClasses())
|
for (ClassFile cf : group.getClasses())
|
||||||
{
|
{
|
||||||
|
methods:
|
||||||
for (Method m : new ArrayList<>(cf.getMethods().getMethods()))
|
for (Method m : new ArrayList<>(cf.getMethods().getMethods()))
|
||||||
{
|
{
|
||||||
if (m.getCode() == null)
|
if (m.getCode() == null)
|
||||||
@@ -50,40 +51,30 @@ public class Jumps
|
|||||||
|
|
||||||
List<Instruction> ilist = ins.getInstructions();
|
List<Instruction> ilist = ins.getInstructions();
|
||||||
|
|
||||||
// remove instructions
|
// clear jump graph
|
||||||
for (Instruction in : block.instructions)
|
//ins.clearBlocks();
|
||||||
ilist.remove(in);
|
ins.clearJumpGraph();
|
||||||
|
|
||||||
int index = ilist.indexOf(from);
|
// 'from' goes away and is replaced with block.begin
|
||||||
|
|
||||||
assert from.block != block;
|
|
||||||
from.block = null;
|
|
||||||
|
|
||||||
// move instructions which jump here to jump to block.begin
|
|
||||||
for (Instruction in : from.from)
|
|
||||||
{
|
|
||||||
assert in.jump.contains(from);
|
|
||||||
assert !in.jump.contains(block.begin);
|
|
||||||
|
|
||||||
in.jump.remove(from);
|
|
||||||
|
|
||||||
in.jump.add(block.begin);
|
|
||||||
block.begin.from.add(in);
|
|
||||||
}
|
|
||||||
from.from.clear();
|
|
||||||
|
|
||||||
// .replace ins
|
|
||||||
for (Instruction in : ilist)
|
for (Instruction in : ilist)
|
||||||
in.replace(from, block.begin);
|
in.replace(from, block.begin);
|
||||||
|
|
||||||
for (info.sigterm.deob.attributes.code.Exception e : m.getCode().getExceptions().getExceptions())
|
// remove instructions
|
||||||
e.replace(from, block.begin);
|
for (Instruction in : block.instructions)
|
||||||
|
{
|
||||||
|
boolean b = ilist.remove(in);
|
||||||
|
assert b;
|
||||||
|
}
|
||||||
|
|
||||||
ins.remove(from); // remove jump
|
// store pos of from
|
||||||
|
int index = ilist.indexOf(from);
|
||||||
|
ilist.remove(from);
|
||||||
|
|
||||||
// insert instructions from block where jump was
|
// insert instructions where 'from' was
|
||||||
for (Instruction in : block.instructions)
|
for (Instruction in : block.instructions)
|
||||||
ilist.add(index++, in);
|
ilist.add(index++, in);
|
||||||
|
|
||||||
|
continue methods;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user