Make isSame sanity check more in set/put field and invokes
This commit is contained in:
@@ -176,7 +176,37 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
||||
@Override
|
||||
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
|
||||
{
|
||||
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
|
||||
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
|
||||
return false;
|
||||
|
||||
InvokeInterface thisIi = (InvokeInterface) thisIc.getInstruction(),
|
||||
otherIi = (InvokeInterface) otherIc.getInstruction();
|
||||
|
||||
List<net.runelite.deob.Method> thisMethods = thisIi.getMethods(),
|
||||
otherMethods = otherIi.getMethods();
|
||||
|
||||
if ((thisMethods != null) != (otherMethods != null))
|
||||
return false;
|
||||
|
||||
if (thisMethods == null || otherMethods == null)
|
||||
return true; // we don't map these anyway
|
||||
|
||||
if (thisMethods.size() != otherMethods.size())
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < thisMethods.size(); ++i)
|
||||
{
|
||||
net.runelite.deob.Method m1 = thisMethods.get(i),
|
||||
m2 = otherMethods.get(i);
|
||||
|
||||
if (!m1.getMethods().getClassFile().getPoolClass().equals(m2.getMethods().getClassFile().getPoolClass()))
|
||||
return false;
|
||||
|
||||
if (!m1.getNameAndType().getDescriptor().equals(m2.getNameAndType().getDescriptor()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.io.IOException;
|
||||
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;
|
||||
@@ -177,7 +176,40 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
|
||||
@Override
|
||||
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
|
||||
{
|
||||
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
|
||||
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
|
||||
return false;
|
||||
|
||||
InvokeSpecial thisIi = (InvokeSpecial) thisIc.getInstruction(),
|
||||
otherIi = (InvokeSpecial) otherIc.getInstruction();
|
||||
|
||||
List<net.runelite.deob.Method> thisMethods = thisIi.getMethods(),
|
||||
otherMethods = otherIi.getMethods();
|
||||
|
||||
if ((thisMethods != null) != (otherMethods != null))
|
||||
return false;
|
||||
|
||||
if (thisMethods == null || otherMethods == null)
|
||||
return true; // we don't map these anyway
|
||||
|
||||
if (thisMethods.size() != otherMethods.size())
|
||||
return false;
|
||||
|
||||
assert thisMethods.size() == 1;
|
||||
assert otherMethods.size() == 1;
|
||||
|
||||
for (int i = 0; i < thisMethods.size(); ++i)
|
||||
{
|
||||
net.runelite.deob.Method m1 = thisMethods.get(i),
|
||||
m2 = otherMethods.get(i);
|
||||
|
||||
if (!m1.getMethods().getClassFile().getPoolClass().equals(m2.getMethods().getClassFile().getPoolClass()))
|
||||
return false;
|
||||
|
||||
if (!m1.getNameAndType().getDescriptor().equals(m2.getNameAndType().getDescriptor()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.io.IOException;
|
||||
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;
|
||||
@@ -179,7 +178,39 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
||||
@Override
|
||||
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
|
||||
{
|
||||
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
|
||||
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
|
||||
return false;
|
||||
|
||||
InvokeStatic thisIi = (InvokeStatic) thisIc.getInstruction(),
|
||||
otherIi = (InvokeStatic) otherIc.getInstruction();
|
||||
|
||||
List<net.runelite.deob.Method> thisMethods = thisIi.getMethods(),
|
||||
otherMethods = otherIi.getMethods();
|
||||
|
||||
if ((thisMethods != null) != (otherMethods != null))
|
||||
return false;
|
||||
|
||||
if (thisMethods == null || otherMethods == null)
|
||||
return true; // we don't map these anyway
|
||||
|
||||
if (thisMethods.size() != otherMethods.size())
|
||||
return false;
|
||||
|
||||
assert thisMethods.size() == 1;
|
||||
assert otherMethods.size() == 1;
|
||||
|
||||
for (int i = 0; i < thisMethods.size(); ++i)
|
||||
{
|
||||
net.runelite.deob.Method m1 = thisMethods.get(i),
|
||||
m2 = otherMethods.get(i);
|
||||
|
||||
/* The class names are random */
|
||||
|
||||
if (!m1.getNameAndType().getDescriptor().equals(m2.getNameAndType().getDescriptor()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -199,7 +199,37 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||
@Override
|
||||
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
|
||||
{
|
||||
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
|
||||
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
|
||||
return false;
|
||||
|
||||
InvokeVirtual thisIi = (InvokeVirtual) thisIc.getInstruction(),
|
||||
otherIi = (InvokeVirtual) otherIc.getInstruction();
|
||||
|
||||
List<net.runelite.deob.Method> thisMethods = thisIi.getMethods(),
|
||||
otherMethods = otherIi.getMethods();
|
||||
|
||||
if ((thisMethods != null) != (otherMethods != null))
|
||||
return false;
|
||||
|
||||
if (thisMethods == null || otherMethods == null)
|
||||
return true; // we don't map these anyway
|
||||
|
||||
if (thisMethods.size() != otherMethods.size())
|
||||
return false;
|
||||
|
||||
for (int i = 0; i < thisMethods.size(); ++i)
|
||||
{
|
||||
net.runelite.deob.Method m1 = thisMethods.get(i),
|
||||
m2 = otherMethods.get(i);
|
||||
|
||||
if (!m1.getMethods().getClassFile().getPoolClass().equals(m2.getMethods().getClassFile().getPoolClass()))
|
||||
return false;
|
||||
|
||||
if (!m1.getNameAndType().getDescriptor().equals(m2.getNameAndType().getDescriptor()))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -109,16 +109,7 @@ public class PutField extends Instruction implements SetFieldInstruction
|
||||
net.runelite.deob.Field myField = this.getMyField(),
|
||||
otherField = ((PutField) other.getInstruction()).getMyField();
|
||||
|
||||
// it appears ConstantValue field attributes are inlined into the constructor
|
||||
// and their orders scrambled, so don't accept constant value assignments?
|
||||
// if (ctx.getFrame().getMethod().getName().equals("<init>"))
|
||||
// {
|
||||
// //assert isConstantAssignment(ctx) == isConstantAssignment(other);
|
||||
// //if (isConstantAssignment(ctx))
|
||||
// return;
|
||||
// }
|
||||
|
||||
// XXX field types must be the same
|
||||
assert myField.getType().equals(otherField.getType());
|
||||
|
||||
mapping.map(myField, otherField);
|
||||
}
|
||||
@@ -126,7 +117,14 @@ public class PutField extends Instruction implements SetFieldInstruction
|
||||
@Override
|
||||
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
|
||||
{
|
||||
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
|
||||
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
|
||||
return false;
|
||||
|
||||
PutField thisPf = (PutField) thisIc.getInstruction(),
|
||||
otherPf = (PutField) otherIc.getInstruction();
|
||||
|
||||
return thisPf.getField().getClassEntry().equals(otherPf.getField().getClassEntry())
|
||||
&& thisPf.getField().getNameAndType().getDescriptorType().equals(otherPf.getField().getNameAndType().getDescriptorType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -102,13 +102,22 @@ public class PutStatic extends Instruction implements SetFieldInstruction
|
||||
net.runelite.deob.Field myField = this.getMyField(),
|
||||
otherField = ((PutStatic) other.getInstruction()).getMyField();
|
||||
|
||||
assert myField.getType().equals(otherField.getType());
|
||||
|
||||
mapping.map(myField, otherField);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSame(InstructionContext thisIc, InstructionContext otherIc)
|
||||
{
|
||||
return thisIc.getInstruction().getClass() == otherIc.getInstruction().getClass();
|
||||
if (thisIc.getInstruction().getClass() != otherIc.getInstruction().getClass())
|
||||
return false;
|
||||
|
||||
PutStatic thisPf = (PutStatic) thisIc.getInstruction(),
|
||||
otherPf = (PutStatic) otherIc.getInstruction();
|
||||
|
||||
/* The class names are random */
|
||||
return thisPf.getField().getNameAndType().getDescriptorType().equals(otherPf.getField().getNameAndType().getDescriptorType());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user