This can map some but not nearly enough. Main problem seems to be the order of the packet handlers is scrambled, as well as their ids.
Maybe try detecting/treating the packet handlers as separate "functions" and compare them by seeing if PME can run over both? Maybe try hardening PME mapper to fail more easily (eg setfield of field of two different types, or invoke with wrong signatures?), and then try and brute force methods in general. Can also map methods with unique signatures that are non static method<->method. client clinit?
This commit is contained in:
@@ -48,7 +48,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "invokestatic " + method + " in " + this.getInstructions().getCode().getAttributes().getMethod();
|
||||
return "invokestatic " + method + " in " + this.getInstructions().getCode().getAttributes().getMethod() + " at pc 0x" + Integer.toHexString(this.getPc());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,7 +42,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "invokevirtual " + method + " in " + this.getInstructions().getCode().getAttributes().getMethod();
|
||||
return "invokevirtual " + method + " in " + this.getInstructions().getCode().getAttributes().getMethod() + " at pc 0x" + Integer.toHexString(this.getPc());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -117,6 +117,7 @@ public class MappingExecutorUtil
|
||||
{
|
||||
p1.getFrame().stop();
|
||||
p2.getFrame().stop();
|
||||
e.paused = e2.paused = false;
|
||||
continue;
|
||||
// if (!hit)
|
||||
// {
|
||||
@@ -168,7 +169,16 @@ public class MappingExecutorUtil
|
||||
// continue;
|
||||
}
|
||||
|
||||
mi1.map(mappings, p1, p2);
|
||||
try
|
||||
{
|
||||
mi1.map(mappings, p1, p2);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
p1.getFrame().stop();
|
||||
p2.getFrame().stop();
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
e.paused = e2.paused = false;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Execution
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasInvoked(InstructionContext from, Method to)
|
||||
public boolean hasInvoked(InstructionContext from, Method to)
|
||||
{
|
||||
// this is wrong because the called of the method of from
|
||||
// might be different, for building graph
|
||||
|
||||
@@ -278,6 +278,7 @@ public class ParallellMappingExecutor
|
||||
stepf1.otherStatic = stepf2;
|
||||
stepf2.otherStatic = stepf1;
|
||||
|
||||
doubleStep.add(stepf1.getMethod());
|
||||
System.out.println("STEP " + stepf1.getMethod() + " <-> " + stepf2.getMethod());
|
||||
|
||||
return step();
|
||||
@@ -288,6 +289,7 @@ public class ParallellMappingExecutor
|
||||
|
||||
return true;
|
||||
}
|
||||
public static Set<Method> doubleStep = new HashSet();
|
||||
|
||||
public InstructionContext getP1()
|
||||
{
|
||||
@@ -332,6 +334,9 @@ public class ParallellMappingExecutor
|
||||
|
||||
if (isLoop(f))
|
||||
return null;
|
||||
|
||||
if (e.hasInvoked(i, to))
|
||||
return null;
|
||||
//assert e.methods.contains(to) == false;
|
||||
//e.methods.add(to);
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import net.runelite.deob.ClassGroup;
|
||||
import net.runelite.deob.Deob;
|
||||
import net.runelite.deob.Field;
|
||||
import net.runelite.deob.Method;
|
||||
import net.runelite.deob.execution.ParallellMappingExecutor;
|
||||
import net.runelite.deob.util.JarUtil;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
@@ -120,6 +121,12 @@ public class MapStaticTest
|
||||
HashMap<Object, Object> all = new HashMap();
|
||||
List<ParallelExecutorMapping> pmes = new ArrayList<>();
|
||||
map(all, pmes, m1, m2);
|
||||
|
||||
ParallelExecutorMapping finalm = new ParallelExecutorMapping();
|
||||
for (ParallelExecutorMapping pme : pmes)
|
||||
finalm.merge(pme);
|
||||
|
||||
summary(finalm);
|
||||
}
|
||||
|
||||
//@Test
|
||||
@@ -141,6 +148,31 @@ public class MapStaticTest
|
||||
}
|
||||
}
|
||||
|
||||
private void summary(ParallelExecutorMapping finalm)
|
||||
{
|
||||
int fields = 0, staticMethod = 0, method = 0, total = 0;
|
||||
for (Entry<Object, Object> e : finalm.getMap().entrySet())
|
||||
{
|
||||
System.out.println(e.getKey() + " <-> " + e.getValue());
|
||||
|
||||
Object o = e.getKey();
|
||||
if (o instanceof Field)
|
||||
++fields;
|
||||
else if (o instanceof Method)
|
||||
{
|
||||
Method m = (Method) o;
|
||||
|
||||
if (m.isStatic())
|
||||
++staticMethod;
|
||||
else
|
||||
++method;
|
||||
}
|
||||
|
||||
++total;
|
||||
}
|
||||
System.out.println("Total " + total + ". " + fields + " fields, " + staticMethod + " static methods, " + method + " methods");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testAllMap() throws Exception
|
||||
{
|
||||
@@ -168,33 +200,20 @@ public class MapStaticTest
|
||||
for (ParallelExecutorMapping pme : pmes)
|
||||
finalm.merge(pme);
|
||||
|
||||
int fields = 0, staticMethod = 0, method = 0, total = 0;
|
||||
for (Entry<Object, Object> e : finalm.getMap().entrySet())
|
||||
{
|
||||
System.out.println(e.getKey() + " <-> " + e.getValue());
|
||||
|
||||
Object o = e.getKey();
|
||||
if (o instanceof Field)
|
||||
++fields;
|
||||
else if (o instanceof Method)
|
||||
{
|
||||
Method m = (Method) o;
|
||||
|
||||
if (m.isStatic())
|
||||
++staticMethod;
|
||||
else
|
||||
++method;
|
||||
}
|
||||
|
||||
++total;
|
||||
}
|
||||
System.out.println("Total " + total + ". " + fields + " fields, " + staticMethod + " static methods, " + method + " methods");
|
||||
summary(finalm);
|
||||
print(group1);
|
||||
System.out.println("db step " + ParallellMappingExecutor.doubleStep.size());
|
||||
|
||||
for (Method m : group1.findClass("client").getMethods().getMethods())
|
||||
{
|
||||
if (!finalm.getMap().containsKey(m) && !m.isStatic())
|
||||
System.out.println("missing " + m);
|
||||
}
|
||||
for (Field m : group1.findClass("client").getFields().getFields())
|
||||
{
|
||||
if (!finalm.getMap().containsKey(m))
|
||||
System.out.println("missing " + m);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Method> getInitialMethods(ClassGroup group)
|
||||
@@ -242,6 +261,15 @@ public class MapStaticTest
|
||||
if (m1.getCode() == null)
|
||||
return;
|
||||
|
||||
// XXX this is the packet stuff..
|
||||
if (m1.getName().equals("vmethod3096"))
|
||||
return;
|
||||
|
||||
if (m1.getName().equals("method32"))
|
||||
{
|
||||
int i=5;
|
||||
}
|
||||
|
||||
ParallelExecutorMapping mappings;
|
||||
try
|
||||
{
|
||||
@@ -249,6 +277,7 @@ public class MapStaticTest
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
System.err.println("Error mapping " + m1 + " to " + m2);
|
||||
//if (test)
|
||||
// throw ex;
|
||||
|
||||
Reference in New Issue
Block a user