init of deob
This commit is contained in:
19
src/main/java/info/sigterm/deob/pool/Class.java
Normal file
19
src/main/java/info/sigterm/deob/pool/Class.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Class extends PoolEntry
|
||||
{
|
||||
private int index;
|
||||
|
||||
public Class(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.CLASS);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
index = is.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
43
src/main/java/info/sigterm/deob/pool/ConstantType.java
Normal file
43
src/main/java/info/sigterm/deob/pool/ConstantType.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
public enum ConstantType
|
||||
{
|
||||
CLASS(7, Class.class),
|
||||
FIELDREF(9, Field.class),
|
||||
METHODREF(10, Method.class),
|
||||
INTERFACE_METHOD_REF(11, InterfaceMethod.class),
|
||||
STRING(8, String.class),
|
||||
INTEGER(3, Integer.class),
|
||||
FLOAT(4, Float.class),
|
||||
LONG(5, Long.class),
|
||||
DOUBLE(6, Double.class),
|
||||
NAME_AND_TYPE(12, NameAndType.class),
|
||||
UTF8(1, UTF8.class);
|
||||
|
||||
private int value;
|
||||
private java.lang.Class<? extends PoolEntry> clazz;
|
||||
|
||||
ConstantType(int value, java.lang.Class<? extends PoolEntry> clazz)
|
||||
{
|
||||
this.value = value;
|
||||
this.clazz = clazz;
|
||||
}
|
||||
|
||||
public int getType()
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
public java.lang.Class<? extends PoolEntry> getPoolClass()
|
||||
{
|
||||
return clazz;
|
||||
}
|
||||
|
||||
public static ConstantType findFromType(int type)
|
||||
{
|
||||
for (ConstantType t : ConstantType.values())
|
||||
if (t.getType() == type)
|
||||
return t;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
26
src/main/java/info/sigterm/deob/pool/Double.java
Normal file
26
src/main/java/info/sigterm/deob/pool/Double.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Double extends PoolEntry
|
||||
{
|
||||
private double value;
|
||||
|
||||
public Double(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.DOUBLE);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readDouble();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
22
src/main/java/info/sigterm/deob/pool/Field.java
Normal file
22
src/main/java/info/sigterm/deob/pool/Field.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Field extends PoolEntry
|
||||
{
|
||||
private int classIndex;
|
||||
private int nameAndTypeIndex;
|
||||
|
||||
public Field(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.FIELDREF);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
classIndex = is.readUnsignedShort();
|
||||
nameAndTypeIndex = is.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
20
src/main/java/info/sigterm/deob/pool/Float.java
Normal file
20
src/main/java/info/sigterm/deob/pool/Float.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Float extends PoolEntry
|
||||
{
|
||||
private float value;
|
||||
|
||||
public Float(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.FLOAT);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readFloat();
|
||||
}
|
||||
}
|
||||
20
src/main/java/info/sigterm/deob/pool/Integer.java
Normal file
20
src/main/java/info/sigterm/deob/pool/Integer.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Integer extends PoolEntry
|
||||
{
|
||||
private int value;
|
||||
|
||||
public Integer(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.INTEGER);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readInt();
|
||||
}
|
||||
}
|
||||
22
src/main/java/info/sigterm/deob/pool/InterfaceMethod.java
Normal file
22
src/main/java/info/sigterm/deob/pool/InterfaceMethod.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class InterfaceMethod extends PoolEntry
|
||||
{
|
||||
private int classIndex;
|
||||
private int nameAndTypeIndex;
|
||||
|
||||
public InterfaceMethod(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.INTERFACE_METHOD_REF);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
classIndex = is.readUnsignedShort();
|
||||
nameAndTypeIndex = is.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
26
src/main/java/info/sigterm/deob/pool/Long.java
Normal file
26
src/main/java/info/sigterm/deob/pool/Long.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Long extends PoolEntry
|
||||
{
|
||||
private long value;
|
||||
|
||||
public Long(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.LONG);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
value = is.readLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
22
src/main/java/info/sigterm/deob/pool/Method.java
Normal file
22
src/main/java/info/sigterm/deob/pool/Method.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class Method extends PoolEntry
|
||||
{
|
||||
private int classIndex;
|
||||
private int nameAndTypeIndex;
|
||||
|
||||
public Method(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.METHODREF);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
classIndex = is.readUnsignedShort();
|
||||
nameAndTypeIndex = is.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
22
src/main/java/info/sigterm/deob/pool/NameAndType.java
Normal file
22
src/main/java/info/sigterm/deob/pool/NameAndType.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class NameAndType extends PoolEntry
|
||||
{
|
||||
private int nameIndex;
|
||||
private int descriptorIndex;
|
||||
|
||||
public NameAndType(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.NAME_AND_TYPE);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
nameIndex = is.readUnsignedShort();
|
||||
descriptorIndex = is.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
20
src/main/java/info/sigterm/deob/pool/PoolEntry.java
Normal file
20
src/main/java/info/sigterm/deob/pool/PoolEntry.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
public abstract class PoolEntry
|
||||
{
|
||||
private ConstantPool pool;
|
||||
private ConstantType type;
|
||||
|
||||
protected PoolEntry(ConstantPool pool, ConstantType type)
|
||||
{
|
||||
this.pool = pool;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getSlots()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
20
src/main/java/info/sigterm/deob/pool/String.java
Normal file
20
src/main/java/info/sigterm/deob/pool/String.java
Normal file
@@ -0,0 +1,20 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class String extends PoolEntry
|
||||
{
|
||||
private int stringIndex;
|
||||
|
||||
public String(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.STRING);
|
||||
|
||||
DataInputStream is = pool.getClassFile().getStream();
|
||||
|
||||
stringIndex = is.readUnsignedShort();
|
||||
}
|
||||
}
|
||||
48
src/main/java/info/sigterm/deob/pool/UTF8.java
Normal file
48
src/main/java/info/sigterm/deob/pool/UTF8.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package info.sigterm.deob.pool;
|
||||
|
||||
import info.sigterm.deob.ConstantPool;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
public class UTF8 extends PoolEntry
|
||||
{
|
||||
private StringBuilder sb = new StringBuilder();
|
||||
|
||||
public UTF8(ConstantPool pool) throws IOException
|
||||
{
|
||||
super(pool, ConstantType.UTF8);
|
||||
|
||||
DataInputStream ios = pool.getClassFile().getStream();
|
||||
|
||||
short length = ios.readShort();
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
int a = ios.read();
|
||||
if ((a & 0x80) == 0)
|
||||
{
|
||||
sb.append((char)a);
|
||||
}
|
||||
else if ((a & 0x20) == 0)
|
||||
{
|
||||
int b = ios.read();
|
||||
char c = (char)(((a & 0x1f) << 6) + (b & 0x3f));
|
||||
sb.append(c);
|
||||
i++;
|
||||
}
|
||||
else
|
||||
{
|
||||
int b = ios.read();
|
||||
int c = ios.read();
|
||||
char ch = (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
|
||||
sb.append(ch);
|
||||
i += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public java.lang.String getValue()
|
||||
{
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user