use of net.runelite.asm.attributes.code.instructions.LStore in project runelite by runelite.
the class MultiplicationDeobfuscatorTest method test9.
// aload 0
// aload 0
// aload 1
// invokevirtual class226/method4078()J
// ldc2_w -81013729583719545
// lmul
// dup2_x1
// ldc2_w -6236978337732675017
// lmul
// putfield class227/field3204 J
// ldc2_w -6236978337732675017
// lmul
// putfield class227/field3196 J
@Test
public void test9() {
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
Instructions ins = code.getInstructions();
code.setMaxStack(3);
Instruction[] prepareVariables = { new LDC(ins, 1L), new LStore(ins, 0) };
for (Instruction i : prepareVariables) {
ins.addInstruction(i);
}
LDC constant1 = new LDC(ins, -81013729583719545L), constant2 = new LDC(ins, -6236978337732675017L), constant3 = new LDC(ins, -6236978337732675017L);
Instruction[] body = { new LDC(ins, 0), new LLoad(ins, 0), constant1, new LMul(ins), // lmul, 0, lmul
new Dup2_X1(ins), constant2, new LMul(ins), new Pop(ins), new Pop(ins), constant3, new LMul(ins), new Pop(ins), new VReturn(ins) };
for (Instruction i : body) {
ins.addInstruction(i);
}
Execution e = new Execution(group);
e.populateInitialMethods();
e.run();
assert constant1.getConstantAsLong() * constant2.getConstantAsLong() == 1L;
Deobfuscator d = new MultiplicationDeobfuscator();
d.run(group);
Assert.assertEquals(1L, constant1.getConstantAsLong());
Assert.assertEquals(1L, constant2.getConstantAsLong());
Assert.assertEquals(1L, constant3.getConstantAsLong());
}
use of net.runelite.asm.attributes.code.instructions.LStore in project runelite by runelite.
the class LvtTest method testReuseIndex.
@Test
public void testReuseIndex() {
ClassGroup group = ClassGroupFactory.generateGroup();
Code code = group.findClass("test").findMethod("func").getCode();
Instructions ins = code.getInstructions();
Instruction[] body = { // var0 = null
new AConstNull(ins), new AStore(ins, 0), // this forces a reindex to varn
new LDC(ins, 0), new IStore(ins, 0), // var2 = null
new AConstNull(ins), new AStore(ins, 2), // this forces a reindex to varn+1
new LDC(ins, 0), new IStore(ins, 2), // var0 = 0L
new LDC(ins, 0L), new LStore(ins, 0), new VReturn(ins) };
for (Instruction i : body) {
ins.addInstruction(i);
}
Lvt lvt = new Lvt();
lvt.run(group);
AStore astore1 = (AStore) body[1];
IStore istore1 = (IStore) body[3];
AStore astore2 = (AStore) body[5];
IStore istore2 = (IStore) body[7];
LStore lstore1 = (LStore) body[9];
int astore1Idx = astore1.getVariableIndex();
int istore1Idx = istore1.getVariableIndex();
int astore2Idx = astore2.getVariableIndex();
int istore2Idx = istore2.getVariableIndex();
int lstore1Idx = lstore1.getVariableIndex();
logger.debug("{} -> {}", astore1, astore1.getVariableIndex());
logger.debug("{} -> {}", istore1, istore1.getVariableIndex());
logger.debug("{} -> {}", astore2, astore2.getVariableIndex());
logger.debug("{} -> {}", istore2, istore2.getVariableIndex());
logger.debug("{} -> {}", lstore1, lstore1.getVariableIndex());
Assert.assertNotEquals(astore1Idx, istore1Idx);
Assert.assertNotEquals(astore2Idx, istore2Idx);
// assert that the lstore doesn't overwrite an existing index
Assert.assertNotEquals(lstore1Idx + 1, astore1Idx);
Assert.assertNotEquals(lstore1Idx + 1, istore1Idx);
Assert.assertNotEquals(lstore1Idx + 1, astore2Idx);
Assert.assertNotEquals(lstore1Idx + 1, istore2Idx);
}
Aggregations