Map field of invoked object too

This commit is contained in:
Adam
2016-02-13 18:02:20 -05:00
parent 66e9960596
commit bcc74c6256
4 changed files with 108 additions and 19 deletions

View File

@@ -166,8 +166,10 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
InvokeInterface otherIv = (InvokeInterface) other.getInstruction();
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeInterface) other.getInstruction()).getMethods();
otherMethods = otherIv.getMethods();
assert myMethods.size() == otherMethods.size();
@@ -196,6 +198,28 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
}
}
}
/* map field that was invoked on */
StackContext object1 = ctx.getPops().get(method.getNameAndType().getNumberOfArgs()),
object2 = other.getPops().get(otherIv.method.getNameAndType().getNumberOfArgs());
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(),
gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(),
f2 = gf2.getMyField();
if (f1 != null && f2 != null)
{
mapping.map(f1, f2);
}
}
}
@Override

View File

@@ -164,8 +164,10 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
InvokeSpecial otherIv = (InvokeSpecial) other.getInstruction();
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeSpecial) other.getInstruction()).getMethods();
otherMethods = otherIv.getMethods();
List<net.runelite.deob.Method> m1 = this.myMethods;
List<net.runelite.deob.Method> m2 = ((InvokeSpecial) other.getInstruction()).myMethods;
@@ -196,6 +198,28 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
}
}
}
/* map field that was invoked on */
StackContext object1 = ctx.getPops().get(method.getNameAndType().getNumberOfArgs()),
object2 = other.getPops().get(otherIv.method.getNameAndType().getNumberOfArgs());
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(),
gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(),
f2 = gf2.getMyField();
if (f1 != null && f2 != null)
{
mapping.map(f1, f2);
}
}
}
@Override

View File

@@ -183,9 +183,12 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
@Override
public void map(ParallelExecutorMapping mapping, InstructionContext ctx, InstructionContext other)
{
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = ((InvokeVirtual) other.getInstruction()).getMethods();
InvokeVirtual otherIv = (InvokeVirtual) other.getInstruction();
List<net.runelite.deob.Method> myMethods = this.getMethods(),
otherMethods = otherIv.getMethods();
assert method.getNameAndType().getDescriptor().equals(otherIv.method.getNameAndType().getDescriptor());
assert myMethods.size() == otherMethods.size();
for (int i = 0; i < myMethods.size(); ++i)
@@ -222,6 +225,28 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
}
}
}
/* map field that was invoked on */
StackContext object1 = ctx.getPops().get(method.getNameAndType().getNumberOfArgs()),
object2 = other.getPops().get(otherIv.method.getNameAndType().getNumberOfArgs());
InstructionContext base1 = MappingExecutorUtil.resolve(object1.getPushed(), object1);
InstructionContext base2 = MappingExecutorUtil.resolve(object2.getPushed(), object2);
if (base1.getInstruction() instanceof GetFieldInstruction && base2.getInstruction() instanceof GetFieldInstruction)
{
GetFieldInstruction gf1 = (GetFieldInstruction) base1.getInstruction(),
gf2 = (GetFieldInstruction) base2.getInstruction();
Field f1 = gf1.getMyField(),
f2 = gf2.getMyField();
if (f1 != null && f2 != null)
{
mapping.map(f1, f2);
}
}
}
@Override

View File

@@ -89,8 +89,8 @@ public class MapStaticTest
ClassGroup group1 = JarUtil.loadJar(new File(JAR1));
ClassGroup group2 = JarUtil.loadJar(new File(JAR2));
Method m1 = group1.findClass("class92").findMethod("method2176");
Method m2 = group2.findClass("client").findMethod("method540");
Method m1 = group1.findClass("class222").findMethod("method4107");
Method m2 = group2.findClass("class222").findMethod("method3980");
ParallelExecutorMapping mappings = MappingExecutorUtil.map(m1, m2);
@@ -161,7 +161,7 @@ public class MapStaticTest
int fields = 0, staticMethod = 0, method = 0, total = 0;
for (Entry<Object, Object> e : finalm.getMap().entrySet())
{
System.out.println(e.getKey() + " <-> " + e.getValue());
//System.out.println(e.getKey() + " <-> " + e.getValue());
Object o = e.getKey();
if (o instanceof Field)
@@ -217,6 +217,34 @@ public class MapStaticTest
finalm.merge(testStaticMapperMap(group1, group2));
finalm.merge(testMapperMap(group1, group2));
for (int i = -1; i < 250; ++i)
{
ClassFile c1;
if (i == -1)
{
c1 = group1.findClass("client");
}
else
{
c1 = group1.findClass("class" + i);
}
if (c1 == null)
continue;
for (Method m : c1.getMethods().getMethods())
{
if (!finalm.getMap().containsKey(m))
System.out.println("missing " + m);
}
for (Field m : c1.getFields().getFields())
{
if (!finalm.getMap().containsKey(m))
System.out.println("missing " + m);
}
}
summary(finalm, group1);
@@ -225,18 +253,6 @@ public class MapStaticTest
System.out.println("GROUP 1 " + sg1);
System.out.println("GROUP 2 " + sg2);
for (Method m : group1.findClass("client").getMethods().getMethods())
{
if (!finalm.getMap().containsKey(m))
System.out.println("missing " + m);
}
for (Field m : group1.findClass("client").getFields().getFields())
{
if (!finalm.getMap().containsKey(m))
System.out.println("missing " + m);
}
}
//@Test