Added better frame support

This commit is contained in:
SuspiciousActivity committed 2019-02-12 19:51:38 +01:00
1 parent 6e1a0a26b3
commit 0cb4461cc2
3 files changed
+74 -6

No files matched your search

+16 -2
View File
@@ -581,7 +581,14 @@ public class Assembler {
} else { } else {
for (String asd : l.split(", ")) { for (String asd : l.split(", ")) {
if (!asd.startsWith("(")) { if (!asd.startsWith("(")) {
arr.add(UnicodeUtils.unescape(asd)); int frameType = ClassUtil.getFrameTypeByName(asd);
if (frameType != -1)
arr.add(new Integer(frameType));
else {
String frame = UnicodeUtils.unescape(asd);
frame = frame.substring(1, frame.length() - 1);
arr.add(frame);
}
} else { } else {
if (asd.startsWith("(label) ")) { if (asd.startsWith("(label) ")) {
int labelNr = Integer.parseInt(asd.split(" ")[1]); int labelNr = Integer.parseInt(asd.split(" ")[1]);
@@ -620,7 +627,14 @@ public class Assembler {
} else { } else {
for (String asd : st.split(", ")) { for (String asd : st.split(", ")) {
if (!asd.startsWith("(")) { if (!asd.startsWith("(")) {
arr.add(UnicodeUtils.unescape(asd)); int frameType = ClassUtil.getFrameTypeByName(asd);
if (frameType != -1)
arr.add(new Integer(frameType));
else {
String frame = UnicodeUtils.unescape(asd);
frame = frame.substring(1, frame.length() - 1);
arr.add(frame);
}
} else { } else {
if (asd.startsWith("(label) ")) { if (asd.startsWith("(label) ")) {
int labelNr = Integer.parseInt(asd.split(" ")[1]); int labelNr = Integer.parseInt(asd.split(" ")[1]);
+14 -2
View File
@@ -421,9 +421,15 @@ public class Disassembler {
arr.add(null); arr.add(null);
} else { } else {
if (o instanceof String) { if (o instanceof String) {
arr.add(UnicodeUtils.escapeWithSpaces((String) o)); arr.add("L" + UnicodeUtils.escapeWithSpaces((String) o) + ";");
} else if (o instanceof LabelNode) { } else if (o instanceof LabelNode) {
arr.add("(label) " + labels.get(((LabelNode) o).getLabel())); arr.add("(label) " + labels.get(((LabelNode) o).getLabel()));
} else if (o instanceof Integer) {
String frameType = ClassUtil.getFrameTypeByID(((Integer) o).intValue());
if (frameType != null)
arr.add(frameType);
else
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
} else { } else {
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o); arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
} }
@@ -441,9 +447,15 @@ public class Disassembler {
arr.add(null); arr.add(null);
} else { } else {
if (o instanceof String) { if (o instanceof String) {
arr.add(UnicodeUtils.escapeWithSpaces((String) o)); arr.add("L" + UnicodeUtils.escapeWithSpaces((String) o) + ";");
} else if (o instanceof LabelNode) { } else if (o instanceof LabelNode) {
arr.add("(label) " + labels.get(((LabelNode) o).getLabel())); arr.add("(label) " + labels.get(((LabelNode) o).getLabel()));
} else if (o instanceof Integer) {
String frameType = ClassUtil.getFrameTypeByID(((Integer) o).intValue());
if (frameType != null)
arr.add(frameType);
else
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
} else { } else {
arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o); arr.add("(" + o.getClass().getName().replace(".", "/") + ") " + o);
} }
+44 -2
View File
@@ -184,6 +184,46 @@ public class ClassUtil {
} }
} }
public static String getFrameTypeByID(int type) {
switch (type) {
case 0:
return "top";
case 1:
return "int";
case 2:
return "float";
case 3:
return "double";
case 4:
return "long";
case 5:
return "null";
case 6:
return "uninitializedThis";
}
return null;
}
public static int getFrameTypeByName(String type) {
switch (type) {
case "top":
return 0;
case "int":
return 1;
case "float":
return 2;
case "double":
return 3;
case "long":
return 4;
case "null":
return 5;
case "uninitializedThis":
return 6;
}
return -1;
}
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) {
@@ -192,7 +232,8 @@ public class ClassUtil {
if ((ACC_FINAL & access) != 0) { if ((ACC_FINAL & access) != 0) {
s += "final "; s += "final ";
} }
if ((ACC_ABSTRACT & access) != 0 && (ACC_ANNOTATION & access) == 0 && (ACC_ENUM & access) == 0 && (ACC_INTERFACE & access) == 0) { if ((ACC_ABSTRACT & access) != 0 && (ACC_ANNOTATION & access) == 0 && (ACC_ENUM & access) == 0
&& (ACC_INTERFACE & access) == 0) {
s += "abstract "; s += "abstract ";
} }
if ((ACC_SYNTHETIC & access) != 0) { if ((ACC_SYNTHETIC & access) != 0) {
@@ -484,7 +525,8 @@ public class ClassUtil {
public static String getDecompiledValue(Object o, String desc, boolean escapeSpaces) { public static String getDecompiledValue(Object o, String desc, boolean escapeSpaces) {
switch (o.getClass().getName()) { switch (o.getClass().getName()) {
case "java.lang.String": { case "java.lang.String": {
return "\"" + (escapeSpaces ? UnicodeUtils.escapeWithSpaces((String) o) : UnicodeUtils.escape((String) o)) + "\""; return "\"" + (escapeSpaces ? UnicodeUtils.escapeWithSpaces((String) o) : UnicodeUtils.escape((String) o))
+ "\"";
} }
case "java.lang.Integer": { case "java.lang.Integer": {
if (desc.equals("Z")) { if (desc.equals("Z")) {