Remove pool entry pool reference
This commit is contained in:
@@ -52,7 +52,7 @@ public class ConstantPool
|
||||
}
|
||||
|
||||
for (PoolEntry entry : entries)
|
||||
entry.resolve();
|
||||
entry.resolve(this);
|
||||
}
|
||||
|
||||
public void reset()
|
||||
@@ -71,7 +71,7 @@ public class ConstantPool
|
||||
for (int i = 0; i < entries.size(); ++i)
|
||||
{
|
||||
PoolEntry entry = entries.get(i);
|
||||
entry.prime();
|
||||
entry.prime(this);
|
||||
}
|
||||
|
||||
int size = 0;
|
||||
@@ -152,7 +152,6 @@ public class ConstantPool
|
||||
|
||||
entries.add(entry);
|
||||
entry.id = i;
|
||||
entry.pool = this;
|
||||
return i;
|
||||
}
|
||||
|
||||
@@ -164,19 +163,19 @@ public class ConstantPool
|
||||
public int make(Object object)
|
||||
{
|
||||
if (object instanceof String)
|
||||
return make(new info.sigterm.deob.pool.String(this, (String) object));
|
||||
return make(new info.sigterm.deob.pool.String((String) object));
|
||||
|
||||
if (object instanceof Integer)
|
||||
return make(new info.sigterm.deob.pool.Integer(this, (int) object));
|
||||
return make(new info.sigterm.deob.pool.Integer((int) object));
|
||||
|
||||
if (object instanceof Float)
|
||||
return make(new info.sigterm.deob.pool.Float(this, (float) object));
|
||||
return make(new info.sigterm.deob.pool.Float((float) object));
|
||||
|
||||
if (object instanceof Long)
|
||||
return make(new info.sigterm.deob.pool.Long(this, (long) object));
|
||||
return make(new info.sigterm.deob.pool.Long((long) object));
|
||||
|
||||
if (object instanceof Double)
|
||||
return make(new info.sigterm.deob.pool.Double(this, (double) object));
|
||||
return make(new info.sigterm.deob.pool.Double((double) object));
|
||||
|
||||
System.err.println("Constant pool make with unknown object " + object + " type " + object.getClass());
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ public class InvokeInterface extends Instruction implements InvokeInstruction
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new InterfaceMethod(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
method = new InterfaceMethod(clazz, new NameAndType(nat.getName(), sig));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -139,7 +139,7 @@ public class InvokeSpecial extends Instruction implements InvokeInstruction
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new Method(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
method = new Method(clazz, new NameAndType(nat.getName(), sig));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -136,7 +136,7 @@ public class InvokeStatic extends Instruction implements InvokeInstruction
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new Method(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
method = new Method(clazz, new NameAndType(nat.getName(), sig));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -146,7 +146,7 @@ public class InvokeVirtual extends Instruction implements InvokeInstruction
|
||||
sig.remove(idx);
|
||||
|
||||
// create new method pool object
|
||||
method = new Method(method.getPool(), clazz, new NameAndType(nat.getPool(), nat.getName(), sig));
|
||||
method = new Method(clazz, new NameAndType(nat.getName(), sig));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -749,7 +749,7 @@ public class ModularArithmeticDeobfuscation
|
||||
//assert m.setter == modInverse(m.getter);
|
||||
int newConstant = constant * m.setter;
|
||||
|
||||
pc.setConstant(new info.sigterm.deob.pool.Integer(pc.getConstant().getPool(), newConstant));
|
||||
pc.setConstant(new info.sigterm.deob.pool.Integer(newConstant));
|
||||
if (newConstant != 1)
|
||||
System.out.println("new constant: " + newConstant);
|
||||
else
|
||||
@@ -777,7 +777,7 @@ public class ModularArithmeticDeobfuscation
|
||||
|
||||
// field = setter * value, solve for value by * modInverse(setter)
|
||||
int newConstant = constant * m.getter;
|
||||
pi.setConstant(new info.sigterm.deob.pool.Integer(pi.getConstant().getPool(), newConstant));
|
||||
pi.setConstant(new info.sigterm.deob.pool.Integer(newConstant));
|
||||
++replaced;
|
||||
}
|
||||
else if (value.getPushed().getInstruction() instanceof IMul)
|
||||
@@ -812,7 +812,7 @@ public class ModularArithmeticDeobfuscation
|
||||
|
||||
// field = expression * constant
|
||||
int newConstant = constant * m.getter;
|
||||
pc.setConstant(new info.sigterm.deob.pool.Integer(pc.getConstant().getPool(), newConstant));
|
||||
pc.setConstant(new info.sigterm.deob.pool.Integer(newConstant));
|
||||
++replaced;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,22 +14,22 @@ public class Class extends PoolEntry
|
||||
|
||||
public Class(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.CLASS);
|
||||
super(ConstantType.CLASS);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
index = is.readUnsignedShort();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
name = this.getPool().getUTF8(index);
|
||||
name = pool.getUTF8(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
index = this.getPool().makeUTF8(name);
|
||||
index = pool.makeUTF8(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,16 +13,16 @@ public class Double extends PoolEntry
|
||||
|
||||
public Double(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.DOUBLE);
|
||||
super(ConstantType.DOUBLE);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readDouble();
|
||||
}
|
||||
|
||||
public Double(ConstantPool pool, double d)
|
||||
public Double(double d)
|
||||
{
|
||||
super(pool, ConstantType.DOUBLE);
|
||||
super(ConstantType.DOUBLE);
|
||||
|
||||
value = d;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class Field extends PoolEntry
|
||||
|
||||
public Field(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.FIELDREF);
|
||||
super(ConstantType.FIELDREF);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
@@ -23,17 +23,17 @@ public class Field extends PoolEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
clazz = this.getPool().getClass(classIndex);
|
||||
nat = this.getPool().getNameAndType(natIndex);
|
||||
clazz = pool.getClass(classIndex);
|
||||
nat = pool.getNameAndType(natIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
classIndex = this.getPool().make(clazz);
|
||||
natIndex = this.getPool().make(nat);
|
||||
classIndex = pool.make(clazz);
|
||||
natIndex = pool.make(nat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,16 +13,16 @@ public class Float extends PoolEntry
|
||||
|
||||
public Float(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.FLOAT);
|
||||
super(ConstantType.FLOAT);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readFloat();
|
||||
}
|
||||
|
||||
public Float(ConstantPool pool, float f)
|
||||
public Float(float f)
|
||||
{
|
||||
super(pool, ConstantType.FLOAT);
|
||||
super(ConstantType.FLOAT);
|
||||
|
||||
value = f;
|
||||
}
|
||||
|
||||
@@ -13,16 +13,16 @@ public class Integer extends PoolEntry
|
||||
|
||||
public Integer(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.INTEGER);
|
||||
super(ConstantType.INTEGER);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readInt();
|
||||
}
|
||||
|
||||
public Integer(ConstantPool pool, int i)
|
||||
public Integer(int i)
|
||||
{
|
||||
super(pool, ConstantType.INTEGER);
|
||||
super(ConstantType.INTEGER);
|
||||
|
||||
value = i;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ public class InterfaceMethod extends PoolEntry
|
||||
private Class clazz;
|
||||
private NameAndType nat;
|
||||
|
||||
public InterfaceMethod(ConstantPool pool, Class clazz, NameAndType nat)
|
||||
public InterfaceMethod(Class clazz, NameAndType nat)
|
||||
{
|
||||
super(pool, ConstantType.INTERFACE_METHOD_REF);
|
||||
super(ConstantType.INTERFACE_METHOD_REF);
|
||||
|
||||
this.clazz = clazz;
|
||||
this.nat = nat;
|
||||
@@ -22,7 +22,7 @@ public class InterfaceMethod extends PoolEntry
|
||||
|
||||
public InterfaceMethod(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.INTERFACE_METHOD_REF);
|
||||
super(ConstantType.INTERFACE_METHOD_REF);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
@@ -31,17 +31,17 @@ public class InterfaceMethod extends PoolEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
clazz = this.getPool().getClass(classIndex);
|
||||
nat = this.getPool().getNameAndType(natIndex);
|
||||
clazz = pool.getClass(classIndex);
|
||||
nat = pool.getNameAndType(natIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
classIndex = this.getPool().make(clazz);
|
||||
natIndex = this.getPool().make(nat);
|
||||
classIndex = pool.make(clazz);
|
||||
natIndex = pool.make(nat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -13,16 +13,16 @@ public class Long extends PoolEntry
|
||||
|
||||
public Long(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.LONG);
|
||||
super(ConstantType.LONG);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readLong();
|
||||
}
|
||||
|
||||
public Long(ConstantPool pool, long l)
|
||||
public Long(long l)
|
||||
{
|
||||
super(pool, ConstantType.LONG);
|
||||
super(ConstantType.LONG);
|
||||
|
||||
value = l;
|
||||
}
|
||||
|
||||
@@ -12,9 +12,9 @@ public class Method extends PoolEntry
|
||||
private Class clazz;
|
||||
private NameAndType nat;
|
||||
|
||||
public Method(ConstantPool pool, Class clazz, NameAndType nat)
|
||||
public Method(Class clazz, NameAndType nat)
|
||||
{
|
||||
super(pool, ConstantType.METHODREF);
|
||||
super(ConstantType.METHODREF);
|
||||
|
||||
this.clazz = clazz;
|
||||
this.nat = nat;
|
||||
@@ -22,7 +22,7 @@ public class Method extends PoolEntry
|
||||
|
||||
public Method(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.METHODREF);
|
||||
super(ConstantType.METHODREF);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
@@ -31,17 +31,17 @@ public class Method extends PoolEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
clazz = this.getPool().getClass(classIndex);
|
||||
nat = this.getPool().getNameAndType(natIndex);
|
||||
clazz = pool.getClass(classIndex);
|
||||
nat = pool.getNameAndType(natIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
classIndex = this.getPool().make(clazz);
|
||||
natIndex = this.getPool().make(nat);
|
||||
classIndex = pool.make(clazz);
|
||||
natIndex = pool.make(nat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -20,7 +20,7 @@ public class NameAndType extends PoolEntry
|
||||
|
||||
public NameAndType(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.NAME_AND_TYPE);
|
||||
super(ConstantType.NAME_AND_TYPE);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
@@ -28,28 +28,20 @@ public class NameAndType extends PoolEntry
|
||||
descriptorIndex = is.readUnsignedShort();
|
||||
}
|
||||
|
||||
public NameAndType(ConstantPool pool, java.lang.String name, Signature sig)
|
||||
public NameAndType(java.lang.String name, Signature sig)
|
||||
{
|
||||
super(pool, ConstantType.NAME_AND_TYPE);
|
||||
super(ConstantType.NAME_AND_TYPE);
|
||||
|
||||
this.name = name;
|
||||
this.signature = sig;
|
||||
}
|
||||
|
||||
public NameAndType(java.lang.String name, Signature type)
|
||||
{
|
||||
super(null, ConstantType.NAME_AND_TYPE);
|
||||
|
||||
this.name = name;
|
||||
signature = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
name = this.getPool().getUTF8(nameIndex);
|
||||
name = pool.getUTF8(nameIndex);
|
||||
|
||||
java.lang.String sig = this.getPool().getUTF8(descriptorIndex);
|
||||
java.lang.String sig = pool.getUTF8(descriptorIndex);
|
||||
if (sig.startsWith("("))
|
||||
signature = new Signature(sig);
|
||||
else
|
||||
@@ -57,13 +49,13 @@ public class NameAndType extends PoolEntry
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
nameIndex = this.getPool().makeUTF8(name);
|
||||
nameIndex = pool.makeUTF8(name);
|
||||
if (signature != null)
|
||||
descriptorIndex = this.getPool().makeUTF8(signature.toString());
|
||||
descriptorIndex = pool.makeUTF8(signature.toString());
|
||||
else
|
||||
descriptorIndex = this.getPool().makeUTF8(type.toString());
|
||||
descriptorIndex = pool.makeUTF8(type.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,23 +8,21 @@ import info.sigterm.deob.execution.Type;
|
||||
|
||||
public abstract class PoolEntry
|
||||
{
|
||||
public ConstantPool pool;
|
||||
private ConstantType type;
|
||||
public int id;
|
||||
|
||||
protected PoolEntry(ConstantPool pool, ConstantType type)
|
||||
protected PoolEntry(ConstantType type)
|
||||
{
|
||||
this.pool = pool;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
// read objects from indexes
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
}
|
||||
|
||||
// make objects and prime indexes
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -32,11 +30,6 @@ public abstract class PoolEntry
|
||||
public abstract boolean equals(Object other);
|
||||
|
||||
public abstract void write(DataOutputStream out) throws IOException;
|
||||
|
||||
public ConstantPool getPool()
|
||||
{
|
||||
return pool;
|
||||
}
|
||||
|
||||
public ConstantType getType()
|
||||
{
|
||||
|
||||
@@ -14,30 +14,30 @@ public class String extends PoolEntry
|
||||
|
||||
public String(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.STRING);
|
||||
super(ConstantType.STRING);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
stringIndex = is.readUnsignedShort();
|
||||
}
|
||||
|
||||
public String(ConstantPool pool, java.lang.String str)
|
||||
public String(java.lang.String str)
|
||||
{
|
||||
super(pool, ConstantType.STRING);
|
||||
super(ConstantType.STRING);
|
||||
|
||||
string = str;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void resolve()
|
||||
public void resolve(ConstantPool pool)
|
||||
{
|
||||
string = this.getPool().getUTF8(stringIndex);
|
||||
string = pool.getUTF8(stringIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void prime()
|
||||
public void prime(ConstantPool pool)
|
||||
{
|
||||
stringIndex = this.getPool().makeUTF8(string);
|
||||
stringIndex = pool.makeUTF8(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,7 +12,7 @@ public class UTF8 extends PoolEntry
|
||||
|
||||
public UTF8(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.UTF8);
|
||||
super(ConstantType.UTF8);
|
||||
|
||||
DataInputStream ios = pool.getClassFile().getStream();
|
||||
string = ios.readUTF();
|
||||
@@ -20,7 +20,7 @@ public class UTF8 extends PoolEntry
|
||||
|
||||
public UTF8(java.lang.String value)
|
||||
{
|
||||
super(null, ConstantType.UTF8);
|
||||
super(ConstantType.UTF8);
|
||||
|
||||
string = value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user