mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Improved functionality with newarray
This commit is contained in:
1 parent
2b87a0c772
commit
297a3d99c1
5 files changed
+1298
-1167
No files matched your search
@@ -516,6 +516,7 @@ URL = (((https?|f(tp|ile))"://"|"www.")({URLCharacters}{URLEndCharacter})?)
|
|||||||
"return" { addToken(Token.RESERVED_WORD_2); }
|
"return" { addToken(Token.RESERVED_WORD_2); }
|
||||||
|
|
||||||
/* Data types. */
|
/* Data types. */
|
||||||
|
"V" |
|
||||||
"Z" |
|
"Z" |
|
||||||
"B" |
|
"B" |
|
||||||
"C" |
|
"C" |
|
||||||
|
|||||||
@@ -706,7 +706,8 @@ public class Assembler {
|
|||||||
Constructor<Type> constr = Type.class.getDeclaredConstructor(int.class, char[].class, int.class,
|
Constructor<Type> constr = Type.class.getDeclaredConstructor(int.class, char[].class, int.class,
|
||||||
int.class);
|
int.class);
|
||||||
constr.setAccessible(true);
|
constr.setAccessible(true);
|
||||||
val = constr.newInstance(new Object[] { Integer.parseInt(split2[0].substring(7)),
|
String type = split2[0].substring(7);
|
||||||
|
val = constr.newInstance(new Object[] { ClassUtil.getIDFromClassNameForType(type),
|
||||||
split2[3].substring(6, split2[3].length() - 1).toCharArray(),
|
split2[3].substring(6, split2[3].length() - 1).toCharArray(),
|
||||||
Integer.parseInt(split2[1].substring(5)), Integer.parseInt(split2[2].substring(5)) });
|
Integer.parseInt(split2[1].substring(5)), Integer.parseInt(split2[2].substring(5)) });
|
||||||
} else if (str.startsWith("\"") && str.endsWith("\"")) {
|
} else if (str.startsWith("\"") && str.endsWith("\"")) {
|
||||||
@@ -1422,7 +1423,7 @@ public class Assembler {
|
|||||||
return new TypeInsnNode(187, split[1]);
|
return new TypeInsnNode(187, split[1]);
|
||||||
}
|
}
|
||||||
case "newarray": {
|
case "newarray": {
|
||||||
return new IntInsnNode(188, Integer.parseInt(split[1]));
|
return new IntInsnNode(188, ClassUtil.getArrayIDByType(split[1]));
|
||||||
}
|
}
|
||||||
case "anewarray": {
|
case "anewarray": {
|
||||||
return new TypeInsnNode(189, split[1]);
|
return new TypeInsnNode(189, split[1]);
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringEscapeUtils;
|
import org.apache.commons.lang3.StringEscapeUtils;
|
||||||
|
import org.objectweb.asm.Type;
|
||||||
|
|
||||||
public class ClassUtil {
|
public class ClassUtil {
|
||||||
|
|
||||||
@@ -26,6 +27,130 @@ public class ClassUtil {
|
|||||||
public static final int ACC_ENUM = 0x4000;
|
public static final int ACC_ENUM = 0x4000;
|
||||||
public static final int ACC_MANDATED = 0x8000;
|
public static final int ACC_MANDATED = 0x8000;
|
||||||
|
|
||||||
|
public static int getIDFromClassNameForType(String s) {
|
||||||
|
s = s.toUpperCase();
|
||||||
|
switch (s) {
|
||||||
|
case "V": {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
case "Z": {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
case "C": {
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
case "B": {
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
|
case "S": {
|
||||||
|
return 4;
|
||||||
|
}
|
||||||
|
case "I": {
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
case "F": {
|
||||||
|
return 6;
|
||||||
|
}
|
||||||
|
case "J": {
|
||||||
|
return 7;
|
||||||
|
}
|
||||||
|
case "D": {
|
||||||
|
return 8;
|
||||||
|
}
|
||||||
|
case "NAME": {
|
||||||
|
return 10;
|
||||||
|
}
|
||||||
|
default: {
|
||||||
|
return Integer.parseInt(s);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getClassNameFromType(Type type) {
|
||||||
|
switch (type.getSort()) {
|
||||||
|
case 0: {
|
||||||
|
return "V";
|
||||||
|
}
|
||||||
|
case 1: {
|
||||||
|
return "Z";
|
||||||
|
}
|
||||||
|
case 2: {
|
||||||
|
return "C";
|
||||||
|
}
|
||||||
|
case 3: {
|
||||||
|
return "B";
|
||||||
|
}
|
||||||
|
case 4: {
|
||||||
|
return "S";
|
||||||
|
}
|
||||||
|
case 5: {
|
||||||
|
return "I";
|
||||||
|
}
|
||||||
|
case 6: {
|
||||||
|
return "F";
|
||||||
|
}
|
||||||
|
case 7: {
|
||||||
|
return "J";
|
||||||
|
}
|
||||||
|
case 8: {
|
||||||
|
return "D";
|
||||||
|
}
|
||||||
|
case 9: {
|
||||||
|
return getClassNameFromType(type.getElementType());
|
||||||
|
}
|
||||||
|
case 10: {
|
||||||
|
return "Name";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Integer.toString(type.getSort());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getArrayTypeByID(int id) {
|
||||||
|
switch (id) {
|
||||||
|
case 4:
|
||||||
|
return "Z";
|
||||||
|
case 5:
|
||||||
|
return "C";
|
||||||
|
case 6:
|
||||||
|
return "F";
|
||||||
|
case 7:
|
||||||
|
return "D";
|
||||||
|
case 8:
|
||||||
|
return "B";
|
||||||
|
case 9:
|
||||||
|
return "S";
|
||||||
|
case 10:
|
||||||
|
return "I";
|
||||||
|
case 11:
|
||||||
|
return "J";
|
||||||
|
default:
|
||||||
|
return Integer.toString(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getArrayIDByType(String type) {
|
||||||
|
switch (type) {
|
||||||
|
case "Z":
|
||||||
|
return 4;
|
||||||
|
case "C":
|
||||||
|
return 5;
|
||||||
|
case "F":
|
||||||
|
return 6;
|
||||||
|
case "D":
|
||||||
|
return 7;
|
||||||
|
case "B":
|
||||||
|
return 8;
|
||||||
|
case "S":
|
||||||
|
return 9;
|
||||||
|
case "I":
|
||||||
|
return 10;
|
||||||
|
case "J":
|
||||||
|
return 11;
|
||||||
|
default:
|
||||||
|
return Integer.parseInt(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static String getAccessFlagsClass(int access) {
|
public static String getAccessFlagsClass(int access) {
|
||||||
String s = "";
|
String s = "";
|
||||||
if ((ACC_PUBLIC & access) != 0) {
|
if ((ACC_PUBLIC & access) != 0) {
|
||||||
|
|||||||
@@ -401,8 +401,8 @@ public class Disassembler {
|
|||||||
buf = (char[]) f_buf.get(type);
|
buf = (char[]) f_buf.get(type);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
s += "\t\t\t\tType: [\n\t\t\t\t\tsort: " + type.getSort() + "\n\t\t\t\t\toff: " + off
|
s += "\t\t\t\tType: [\n\t\t\t\t\ttype: " + ClassUtil.getClassNameFromType(type)
|
||||||
+ "\n\t\t\t\t\tlen: " + len + "\n\t\t\t\t\tbuf: "
|
+ "\n\t\t\t\t\toff: " + off + "\n\t\t\t\t\tlen: " + len + "\n\t\t\t\t\tbuf: "
|
||||||
+ ClassUtil.getDecompiledValue(new String(buf), "");
|
+ ClassUtil.getDecompiledValue(new String(buf), "");
|
||||||
s += "\n\t\t\t\t]\n";
|
s += "\n\t\t\t\t]\n";
|
||||||
} else if (l.getClass().getName().equals("org.objectweb.asm.Handle")) {
|
} else if (l.getClass().getName().equals("org.objectweb.asm.Handle")) {
|
||||||
@@ -463,9 +463,9 @@ public class Disassembler {
|
|||||||
buf = (char[]) f_buf.get(type);
|
buf = (char[]) f_buf.get(type);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
s += "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " Type: [\n\t\t\tsort: "
|
s += "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " Type: [\n\t\t\ttype: "
|
||||||
+ type.getSort() + "\n\t\t\toff: " + off + "\n\t\t\tlen: " + len + "\n\t\t\tbuf: "
|
+ ClassUtil.getClassNameFromType(type) + "\n\t\t\toff: " + off + "\n\t\t\tlen: " + len
|
||||||
+ ClassUtil.getDecompiledValue(new String(buf), "");
|
+ "\n\t\t\tbuf: " + ClassUtil.getDecompiledValue(new String(buf), "");
|
||||||
s += "\n\t\t]\n";
|
s += "\n\t\t]\n";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -489,7 +489,12 @@ public class Disassembler {
|
|||||||
}
|
}
|
||||||
case "IntInsnNode": {
|
case "IntInsnNode": {
|
||||||
IntInsnNode node = (IntInsnNode) n;
|
IntInsnNode node = (IntInsnNode) n;
|
||||||
s += "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.operand + "\n";
|
if (n.getOpcode() == 188) {
|
||||||
|
s += "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " "
|
||||||
|
+ ClassUtil.getArrayTypeByID(node.operand) + "\n";
|
||||||
|
} else {
|
||||||
|
s += "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.operand + "\n";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case "JumpInsnNode": {
|
case "JumpInsnNode": {
|
||||||
|
|||||||
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user