Updated frames

This commit is contained in:
SuspiciousActivity committed 2019-02-10 00:07:32 +01:00
1 parent 8c94bb4497
commit 6e1a0a26b3
4 files changed
+162 -89

No files matched your search

+60 -25
View File
@@ -15,6 +15,7 @@ import javax.swing.text.BadLocationException;
import org.objectweb.asm.Handle; import org.objectweb.asm.Handle;
import org.objectweb.asm.Label; import org.objectweb.asm.Label;
import org.objectweb.asm.Opcodes;
import org.objectweb.asm.Type; import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode; import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.AnnotationNode; import org.objectweb.asm.tree.AnnotationNode;
@@ -79,9 +80,10 @@ public class Assembler {
clazz.innerClasses = new ArrayList<>(); clazz.innerClasses = new ArrayList<>();
} else { } else {
String split[] = s.split(" "); String split[] = s.split(" ");
clazz.innerClasses clazz.innerClasses.add(new InnerClassNode(UnicodeUtils.unescape(split[1]),
.add(new InnerClassNode(UnicodeUtils.unescape(split[1]), split[2].equals("null") ? null : UnicodeUtils.unescape(split[2]), split[2].equals("null") ? null : UnicodeUtils.unescape(split[2]),
split[3].equals("null") ? null : UnicodeUtils.unescape(split[3]), Integer.parseInt(split[4].substring(2), 16))); split[3].equals("null") ? null : UnicodeUtils.unescape(split[3]),
Integer.parseInt(split[4].substring(2), 16)));
} }
} }
{ {
@@ -135,7 +137,8 @@ public class Assembler {
} }
s = read.readLine(); s = read.readLine();
clazz.sourceFile = s.substring(16).equals("null") ? null : UnicodeUtils.unescape(s.substring(16)); clazz.sourceFile = s.substring(16).equals("null") ? null : UnicodeUtils.unescape(s.substring(16));
while (!(s = read.readLine()).equals("// #Fields")) {} while (!(s = read.readLine()).equals("// #Fields")) {
}
clazz.fields = new ArrayList<>(); clazz.fields = new ArrayList<>();
clazz.methods = new ArrayList<>(); clazz.methods = new ArrayList<>();
String signature = null; String signature = null;
@@ -297,8 +300,9 @@ public class Assembler {
_end = new LabelNode(entry.getKey()); _end = new LabelNode(entry.getKey());
} }
} }
node.localVariables.add(new LocalVariableNode(sp[0], UnicodeUtils.unescape(sp[1].substring(1, sp[1].length() - 2)), node.localVariables.add(new LocalVariableNode(sp[0],
signat, _start, _end, Integer.parseInt(sp[2].substring(0, sp[2].length() - 2)))); UnicodeUtils.unescape(sp[1].substring(1, sp[1].length() - 2)), signat, _start, _end,
Integer.parseInt(sp[2].substring(0, sp[2].length() - 2))));
} }
for (String st : tryCatchBlocksToParse) { for (String st : tryCatchBlocksToParse) {
String[] sp = st.split(" "); String[] sp = st.split(" ");
@@ -319,8 +323,8 @@ public class Assembler {
_handler = new LabelNode(entry.getKey()); _handler = new LabelNode(entry.getKey());
} }
} }
node.tryCatchBlocks node.tryCatchBlocks.add(new TryCatchBlockNode(_start, _end, _handler,
.add(new TryCatchBlockNode(_start, _end, _handler, sp[0].equals("null") ? null : UnicodeUtils.unescape(sp[0]))); sp[0].equals("null") ? null : UnicodeUtils.unescape(sp[0])));
} }
clazz.methods.add(node); clazz.methods.add(node);
} else if (!s.startsWith("\t")) { } else if (!s.startsWith("\t")) {
@@ -427,7 +431,8 @@ public class Assembler {
} finally { } finally {
try { try {
read.close(); read.close();
} catch (Exception e) {} } catch (Exception e) {
}
} }
} }
@@ -458,7 +463,8 @@ public class Assembler {
list.add(rofl.substring(1, index)); list.add(rofl.substring(1, index));
} else if (!rofl.startsWith("(")) { } else if (!rofl.startsWith("(")) {
int index = rofl.indexOf(";"); int index = rofl.indexOf(";");
list.add(new String[] { rofl.substring(0, index) + ";", rofl.substring(index).substring(2) }); list.add(new String[] { rofl.substring(0, index) + ";",
rofl.substring(index).substring(2) });
} else { } else {
list.add(ClassUtil.getCastedValue(rofl.split(" ")[1], rofl.split("\\) ")[0].substring(1))); list.add(ClassUtil.getCastedValue(rofl.split(" ")[1], rofl.split("\\) ")[0].substring(1)));
} }
@@ -471,9 +477,11 @@ public class Assembler {
node.values.add(value.substring(1, index)); node.values.add(value.substring(1, index));
} else if (!value.startsWith("(")) { } else if (!value.startsWith("(")) {
int index = value.indexOf(";"); int index = value.indexOf(";");
node.values.add(new String[] { value.substring(0, index) + ";", value.substring(index).substring(2) }); node.values.add(
new String[] { value.substring(0, index) + ";", value.substring(index).substring(2) });
} else { } else {
node.values.add(ClassUtil.getCastedValue(value.split(" ")[1], value.split("\\) ")[0].substring(1))); node.values.add(
ClassUtil.getCastedValue(value.split(" ")[1], value.split("\\) ")[0].substring(1)));
} }
} }
} }
@@ -559,8 +567,8 @@ public class Assembler {
labels.put(l, labelNr); labels.put(l, labelNr);
return new LineNumberNode(Integer.parseInt(s.split(" ")[0]), new LabelNode(l)); return new LineNumberNode(Integer.parseInt(s.split(" ")[0]), new LabelNode(l));
} else if (s.startsWith("// frame ")) { } else if (s.startsWith("// frame ")) {
String str1 = s.substring(9); String str1 = s.substring(7);
String str = str1.substring(2); String str = str1.substring(str1.indexOf(' ', 3) + 1);
Object[] local; Object[] local;
Object[] stack; Object[] stack;
ArrayList<Object> arr = new ArrayList<>(); ArrayList<Object> arr = new ArrayList<>();
@@ -641,8 +649,28 @@ public class Assembler {
} }
} }
} }
return new FrameNode(Integer.parseInt(str1.split(" ")[0]), local != null ? local.length : 0, local, stack != null ? stack.length : 0, int type = 0;
stack); switch (str1.substring(str1.indexOf(' ', 1) + 1, str1.indexOf(' ', 3))) {
case "NEW":
type = Opcodes.F_NEW;
break;
case "FULL":
type = Opcodes.F_FULL;
break;
case "APPEND":
type = Opcodes.F_APPEND;
break;
case "CHOP":
type = Opcodes.F_CHOP;
break;
case "SAME":
type = Opcodes.F_SAME;
break;
case "SAME1":
type = Opcodes.F_SAME1;
break;
}
return new FrameNode(type, local.length, local, stack.length, stack);
} else { } else {
String[] split = s.split(" "); String[] split = s.split(" ");
String command = split[0]; String command = split[0];
@@ -692,11 +720,12 @@ public class Assembler {
if (str.startsWith("Type: ")) { if (str.startsWith("Type: ")) {
str = str.substring(8, str.length() - 2); str = str.substring(8, str.length() - 2);
String[] split2 = str.split("\n\t"); String[] split2 = str.split("\n\t");
Constructor<Type> constr = Type.class.getDeclaredConstructor(int.class, String.class, int.class, int.class); Constructor<Type> constr = Type.class.getDeclaredConstructor(int.class, String.class, int.class,
int.class);
constr.setAccessible(true); constr.setAccessible(true);
String type = split2[0].substring(7); String type = split2[0].substring(7);
val = constr.newInstance( val = constr.newInstance(new Object[] { ClassUtil.getIDFromClassNameForType(type),
new Object[] { ClassUtil.getIDFromClassNameForType(type), split2[3].substring(6, split2[3].length() - 1), split2[3].substring(6, split2[3].length() - 1),
Integer.parseInt(split2[1].substring(7)), Integer.parseInt(split2[2].substring(5)) }); Integer.parseInt(split2[1].substring(7)), Integer.parseInt(split2[2].substring(5)) });
} else if (str.startsWith("\"") && str.endsWith("\"")) { } else if (str.startsWith("\"") && str.endsWith("\"")) {
val = UnicodeUtils.unescape(str.substring(1, str.length() - 1)); val = UnicodeUtils.unescape(str.substring(1, str.length() - 1));
@@ -1224,7 +1253,8 @@ public class Assembler {
arr[counter] = ln; arr[counter] = ln;
counter++; counter++;
} }
return new TableSwitchInsnNode(Integer.parseInt(split2[0].substring(5)), Integer.parseInt(split2[1].substring(5)), dflt, arr); return new TableSwitchInsnNode(Integer.parseInt(split2[0].substring(5)),
Integer.parseInt(split2[1].substring(5)), dflt, arr);
} }
case "lookupswitch": { case "lookupswitch": {
String str = s.substring(15, s.length() - 2).replace("\t", ""); String str = s.substring(15, s.length() - 2).replace("\t", "");
@@ -1372,17 +1402,21 @@ public class Assembler {
if (st.equals("]")) { if (st.equals("]")) {
if (stage == 1) { if (stage == 1) {
try { try {
Constructor<Type> constr = Type.class.getDeclaredConstructor(int.class, String.class, int.class, int.class); Constructor<Type> constr = Type.class.getDeclaredConstructor(int.class, String.class,
int.class, int.class);
constr.setAccessible(true); constr.setAccessible(true);
args.add(constr.newInstance(new Object[] { Integer.parseInt(vals.get(0).substring(6)), args.add(constr.newInstance(new Object[] { Integer.parseInt(vals.get(0).substring(6)),
UnicodeUtils.unescape(vals.get(3).substring(6, vals.get(3).length() - 1)), UnicodeUtils.unescape(vals.get(3).substring(6, vals.get(3).length() - 1)),
Integer.parseInt(vals.get(1).substring(7)), Integer.parseInt(vals.get(2).substring(5)) })); Integer.parseInt(vals.get(1).substring(7)),
Integer.parseInt(vals.get(2).substring(5)) }));
} catch (Exception e) { } catch (Exception e) {
throw e; throw e;
} }
} else if (stage == 2) { } else if (stage == 2) {
args.add(new Handle(Integer.parseInt(vals.get(4).substring(5)), UnicodeUtils.unescape(vals.get(1).substring(7)), args.add(new Handle(Integer.parseInt(vals.get(4).substring(5)),
UnicodeUtils.unescape(vals.get(0).substring(6)), UnicodeUtils.unescape(vals.get(2).substring(6)), UnicodeUtils.unescape(vals.get(1).substring(7)),
UnicodeUtils.unescape(vals.get(0).substring(6)),
UnicodeUtils.unescape(vals.get(2).substring(6)),
Boolean.parseBoolean(vals.get(3).substring(13)))); Boolean.parseBoolean(vals.get(3).substring(13))));
vals.clear(); vals.clear();
} }
@@ -1406,7 +1440,8 @@ public class Assembler {
_args[stage] = o; _args[stage] = o;
stage++; stage++;
} }
return new InvokeDynamicInsnNode(UnicodeUtils.unescape(sp[0].substring(7)), UnicodeUtils.unescape(sp[1].substring(6)), return new InvokeDynamicInsnNode(UnicodeUtils.unescape(sp[0].substring(7)),
UnicodeUtils.unescape(sp[1].substring(6)),
new Handle(Integer.parseInt(sp[7].substring(6)), UnicodeUtils.unescape(sp[4].substring(8)), new Handle(Integer.parseInt(sp[7].substring(6)), UnicodeUtils.unescape(sp[4].substring(8)),
UnicodeUtils.unescape(sp[3].substring(7)), UnicodeUtils.unescape(sp[5].substring(7)), UnicodeUtils.unescape(sp[3].substring(7)), UnicodeUtils.unescape(sp[5].substring(7)),
Boolean.parseBoolean(sp[6].substring(14))), Boolean.parseBoolean(sp[6].substring(14))),
+88 -45
View File
@@ -139,16 +139,18 @@ public class Disassembler {
} }
s += "// #Class v:" + classNode.version + "\n"; s += "// #Class v:" + classNode.version + "\n";
s += "// #Signature: " + UnicodeUtils.escapeWithSpaces(classNode.signature) + "\n"; s += "// #Signature: " + UnicodeUtils.escapeWithSpaces(classNode.signature) + "\n";
s += "// #OuterMethod: " s += "// #OuterMethod: " + (classNode.outerMethod == null ? "null"
+ (classNode.outerMethod == null ? "null" : (UnicodeUtils.escapeWithSpaces(classNode.outerMethod) + " "
: (UnicodeUtils.escapeWithSpaces(classNode.outerMethod) + " " + UnicodeUtils.escapeWithSpaces(classNode.outerMethodDesc))) + UnicodeUtils.escapeWithSpaces(classNode.outerMethodDesc)))
+ "\n"; + "\n";
s += "// #OuterClass: " + UnicodeUtils.escapeWithSpaces(classNode.outerClass) + "\n"; s += "// #OuterClass: " + UnicodeUtils.escapeWithSpaces(classNode.outerClass) + "\n";
s += "// #InnerClasses:\n"; s += "// #InnerClasses:\n";
if (classNode.innerClasses != null) { if (classNode.innerClasses != null) {
for (InnerClassNode icn : classNode.innerClasses) { for (InnerClassNode icn : classNode.innerClasses) {
s += "// " + UnicodeUtils.escapeWithSpaces(icn.name) + " " + UnicodeUtils.escapeWithSpaces(icn.outerName) + " " s += "// " + UnicodeUtils.escapeWithSpaces(icn.name) + " "
+ UnicodeUtils.escapeWithSpaces(icn.innerName) + " 0x" + Integer.toHexString(icn.access) + "\n"; + UnicodeUtils.escapeWithSpaces(icn.outerName) + " "
+ UnicodeUtils.escapeWithSpaces(icn.innerName) + " 0x" + Integer.toHexString(icn.access)
+ "\n";
} }
} }
s += ClassUtil.getAccessFlagsClass(classNode.access) + UnicodeUtils.escapeWithSpaces(classNode.name) + " "; s += ClassUtil.getAccessFlagsClass(classNode.access) + UnicodeUtils.escapeWithSpaces(classNode.name) + " ";
@@ -165,7 +167,9 @@ public class Disassembler {
if (!interfaceStr.isEmpty()) if (!interfaceStr.isEmpty())
s += "implements " + interfaceStr + " "; s += "implements " + interfaceStr + " ";
} }
s += "{\n// #SourceFile: " + (classNode.sourceFile == null ? "null" : UnicodeUtils.escape(classNode.sourceFile)) + "\n\n// #Fields\n"; s += "{\n// #SourceFile: "
+ (classNode.sourceFile == null ? "null" : UnicodeUtils.escape(classNode.sourceFile))
+ "\n\n// #Fields\n";
for (FieldNode fn : classNode.fields) { for (FieldNode fn : classNode.fields) {
if (fn.signature != null) if (fn.signature != null)
s += "\t// #Signature: " + UnicodeUtils.escapeWithSpaces(fn.signature) + "\n"; s += "\t// #Signature: " + UnicodeUtils.escapeWithSpaces(fn.signature) + "\n";
@@ -231,8 +235,8 @@ public class Disassembler {
if (fn.equals(nodeToFind)) { if (fn.equals(nodeToFind)) {
lineFound = s.split("\\n").length; lineFound = s.split("\\n").length;
} }
s += "\t" + ClassUtil.getAccessFlagsFull(fn.access).replace("varargs", "transient") + UnicodeUtils.escapeWithSpaces(fn.desc) + " " s += "\t" + ClassUtil.getAccessFlagsFull(fn.access).replace("varargs", "transient")
+ UnicodeUtils.escapeWithSpaces(fn.name); + UnicodeUtils.escapeWithSpaces(fn.desc) + " " + UnicodeUtils.escapeWithSpaces(fn.name);
if (fn.value != null) { if (fn.value != null) {
s += " = " + ClassUtil.getDecompiledValue(fn.value, fn.desc, true); s += " = " + ClassUtil.getDecompiledValue(fn.value, fn.desc, true);
} }
@@ -327,16 +331,19 @@ public class Disassembler {
s += dis[0]; s += dis[0];
s += "\t}\n\n"; s += "\t}\n\n";
} catch (Exception e) { } catch (Exception e) {
s += "\t\t// Method couldn't be disassembled:\n\t\t// " + e.getClass().getName() + ": " + e.getMessage() + "\n" s += "\t\t// Method couldn't be disassembled:\n\t\t// "
+ Arrays.toString(e.getStackTrace()).replace(", ", "\n\t\t// \tat ").replace("[", "\t\t// \tat ").replace("]", "") + e.getClass().getName() + ": " + e.getMessage() + "\n" + Arrays.toString(e.getStackTrace())
.replace(", ", "\n\t\t// \tat ").replace("[", "\t\t// \tat ").replace("]", "")
+ "\n\t}\n\n"; + "\n\t}\n\n";
} }
} }
s += "}\n"; s += "}\n";
return new DisassembleTuple(s, lineFound); return new DisassembleTuple(s, lineFound);
} catch (Throwable e) { } catch (Throwable e) {
return new DisassembleTuple("Class couldn't be decompiled:\n" + e.getClass().getName() + ": " + e.getMessage() + "\n" return new DisassembleTuple("Class couldn't be decompiled:\n" + e.getClass().getName() + ": "
+ Arrays.toString(e.getStackTrace()).replace(", ", "\n\tat ").replace("[", "\tat ").replace("]", "") + "\n"); + e.getMessage() + "\n"
+ Arrays.toString(e.getStackTrace()).replace(", ", "\n\tat ").replace("[", "\tat ").replace("]", "")
+ "\n");
} }
} }
@@ -352,15 +359,17 @@ public class Disassembler {
} }
if (mn.localVariables != null) { if (mn.localVariables != null) {
for (LocalVariableNode lvn : mn.localVariables) { for (LocalVariableNode lvn : mn.localVariables) {
localVarTable += "\t// " + UnicodeUtils.escapeWithSpaces(lvn.name) + ": " + UnicodeUtils.escapeWithSpaces(lvn.desc) + " i:" localVarTable += "\t// " + UnicodeUtils.escapeWithSpaces(lvn.name) + ": "
+ lvn.index + " s:" + labels.get(lvn.start.getLabel()) + " e:" + labels.get(lvn.end.getLabel()) + " sig:" + UnicodeUtils.escapeWithSpaces(lvn.desc) + " i:" + lvn.index + " s:"
+ labels.get(lvn.start.getLabel()) + " e:" + labels.get(lvn.end.getLabel()) + " sig:"
+ UnicodeUtils.escapeWithSpaces(lvn.signature) + "\n"; + UnicodeUtils.escapeWithSpaces(lvn.signature) + "\n";
} }
} }
if (mn.tryCatchBlocks != null) { if (mn.tryCatchBlocks != null) {
for (TryCatchBlockNode tcbn : mn.tryCatchBlocks) { for (TryCatchBlockNode tcbn : mn.tryCatchBlocks) {
tryCatchTable += "\t// " + UnicodeUtils.escapeWithSpaces(tcbn.type) + " s:" + labels.get(tcbn.start.getLabel()) + " e:" tryCatchTable += "\t// " + UnicodeUtils.escapeWithSpaces(tcbn.type) + " s:"
+ labels.get(tcbn.end.getLabel()) + " h:" + labels.get(tcbn.handler.getLabel()) + "\n"; + labels.get(tcbn.start.getLabel()) + " e:" + labels.get(tcbn.end.getLabel()) + " h:"
+ labels.get(tcbn.handler.getLabel()) + "\n";
} }
} }
for (AbstractInsnNode n : mn.instructions.toArray()) { for (AbstractInsnNode n : mn.instructions.toArray()) {
@@ -373,8 +382,9 @@ public class Disassembler {
switch (n.getClass().getSimpleName()) { switch (n.getClass().getSimpleName()) {
case "FieldInsnNode": { case "FieldInsnNode": {
FieldInsnNode node = (FieldInsnNode) n; FieldInsnNode node = (FieldInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + " " return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.owner) + "/" + UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n"; + UnicodeUtils.escapeWithSpaces(node.desc) + " " + UnicodeUtils.escapeWithSpaces(node.owner) + "/"
+ UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n";
} }
case "LabelNode": { case "LabelNode": {
LabelNode node = (LabelNode) n; LabelNode node = (LabelNode) n;
@@ -382,7 +392,28 @@ public class Disassembler {
} }
case "FrameNode": { case "FrameNode": {
FrameNode node = (FrameNode) n; FrameNode node = (FrameNode) n;
String s = "\t\t// frame " + node.type + " l:"; String type = "";
switch (node.type) {
case Opcodes.F_NEW:
type = "NEW";
break;
case Opcodes.F_FULL:
type = "FULL";
break;
case Opcodes.F_APPEND:
type = "APPEND";
break;
case Opcodes.F_CHOP:
type = "CHOP";
break;
case Opcodes.F_SAME:
type = "SAME";
break;
case Opcodes.F_SAME1:
type = "SAME1";
break;
}
String s = "\t\t// frame " + type + " l:";
ArrayList<String> arr = new ArrayList<>(); ArrayList<String> arr = new ArrayList<>();
if (node.local != null) { if (node.local != null) {
for (Object o : node.local) { for (Object o : node.local) {
@@ -434,9 +465,10 @@ public class Disassembler {
String s = "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " [\n\t\t\tname: " String s = "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " [\n\t\t\tname: "
+ UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n\t\t\tdesc: " + UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n\t\t\tdesc: "
+ UnicodeUtils.escapeWithSpaces(node.desc) + "\n\t\t\tHandle: [\n\t\t\t\tname: " + UnicodeUtils.escapeWithSpaces(node.desc) + "\n\t\t\tHandle: [\n\t\t\t\tname: "
+ UnicodeUtils.escapeWithSpaces(node.bsm.getName()) + "\n\t\t\t\towner: " + UnicodeUtils.escapeWithSpaces(node.bsm.getOwner()) + UnicodeUtils.escapeWithSpaces(node.bsm.getName()) + "\n\t\t\t\towner: "
+ "\n\t\t\t\tdesc: " + UnicodeUtils.escapeWithSpaces(node.bsm.getDesc()) + "\n\t\t\t\tisInterface: " + node.bsm.isInterface() + UnicodeUtils.escapeWithSpaces(node.bsm.getOwner()) + "\n\t\t\t\tdesc: "
+ "\n\t\t\t\ttag: " + node.bsm.getTag() + "\n\t\t\t]\n\t\t\targs: [\n"; + UnicodeUtils.escapeWithSpaces(node.bsm.getDesc()) + "\n\t\t\t\tisInterface: "
+ node.bsm.isInterface() + "\n\t\t\t\ttag: " + node.bsm.getTag() + "\n\t\t\t]\n\t\t\targs: [\n";
for (Object l : node.bsmArgs) { for (Object l : node.bsmArgs) {
if (l.getClass().getName().equals("org.objectweb.asm.Type")) { if (l.getClass().getName().equals("org.objectweb.asm.Type")) {
Type type = (Type) l; Type type = (Type) l;
@@ -453,16 +485,19 @@ public class Disassembler {
Field f_buf = Type.class.getDeclaredField("valueBuffer"); Field f_buf = Type.class.getDeclaredField("valueBuffer");
f_buf.setAccessible(true); f_buf.setAccessible(true);
buf = (String) f_buf.get(type); buf = (String) f_buf.get(type);
} catch (Exception e) {} } catch (Exception e) {
s += "\t\t\t\tType: [\n\t\t\t\t\ttype: " + ClassUtil.getClassNameFromType(type) + "\n\t\t\t\t\tstart: " + valueBegin }
+ "\n\t\t\t\t\tend: " + valueEnd + "\n\t\t\t\t\tbuf: " + ClassUtil.getDecompiledValue(buf, ""); s += "\t\t\t\tType: [\n\t\t\t\t\ttype: " + ClassUtil.getClassNameFromType(type)
+ "\n\t\t\t\t\tstart: " + valueBegin + "\n\t\t\t\t\tend: " + valueEnd + "\n\t\t\t\t\tbuf: "
+ ClassUtil.getDecompiledValue(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")) {
Handle h = (Handle) l; Handle h = (Handle) l;
s += "\t\t\t\tHandle: [\n\t\t\t\t\tname: " + UnicodeUtils.escapeWithSpaces(h.getName()).replace("/", "\\u002F") s += "\t\t\t\tHandle: [\n\t\t\t\t\tname: "
+ "\n\t\t\t\t\towner: " + UnicodeUtils.escapeWithSpaces(h.getOwner()) + "\n\t\t\t\t\tdesc: " + UnicodeUtils.escapeWithSpaces(h.getName()).replace("/", "\\u002F") + "\n\t\t\t\t\towner: "
+ UnicodeUtils.escapeWithSpaces(h.getDesc()) + "\n\t\t\t\t\tisInterface: " + h.isInterface() + "\n\t\t\t\t\ttag: " + UnicodeUtils.escapeWithSpaces(h.getOwner()) + "\n\t\t\t\t\tdesc: "
+ h.getTag(); + UnicodeUtils.escapeWithSpaces(h.getDesc()) + "\n\t\t\t\t\tisInterface: " + h.isInterface()
+ "\n\t\t\t\t\ttag: " + h.getTag();
s += "\n\t\t\t\t]\n"; s += "\n\t\t\t\t]\n";
} else { } else {
s += "\t\t\t\t" + ClassUtil.getDecompiledValue(l, "") + "\n"; s += "\t\t\t\t" + ClassUtil.getDecompiledValue(l, "") + "\n";
@@ -473,17 +508,19 @@ public class Disassembler {
} }
case "MethodInsnNode": { case "MethodInsnNode": {
MethodInsnNode node = (MethodInsnNode) n; MethodInsnNode node = (MethodInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + " " return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.owner) + "/" + UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n"; + UnicodeUtils.escapeWithSpaces(node.desc) + " " + UnicodeUtils.escapeWithSpaces(node.owner) + "/"
+ UnicodeUtils.escapeWithSpaces(node.name).replace("/", "\\u002F") + "\n";
} }
case "TypeInsnNode": { case "TypeInsnNode": {
TypeInsnNode node = (TypeInsnNode) n; TypeInsnNode node = (TypeInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + "\n"; return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ UnicodeUtils.escapeWithSpaces(node.desc) + "\n";
} }
case "MultiANewArrayInsnNode": { case "MultiANewArrayInsnNode": {
MultiANewArrayInsnNode node = (MultiANewArrayInsnNode) n; MultiANewArrayInsnNode node = (MultiANewArrayInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + UnicodeUtils.escapeWithSpaces(node.desc) + " " + node.dims return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ "\n"; + UnicodeUtils.escapeWithSpaces(node.desc) + " " + node.dims + "\n";
} }
case "LdcInsnNode": { case "LdcInsnNode": {
LdcInsnNode node = (LdcInsnNode) n; LdcInsnNode node = (LdcInsnNode) n;
@@ -493,7 +530,8 @@ public class Disassembler {
case "Integer": case "Integer":
case "Float": case "Float":
case "Long": { case "Long": {
return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " " + ClassUtil.getDecompiledValue(node.cst, "") + "\n"; return "\t\t" + OpcodesReverse.reverseOpcode(node.getOpcode()) + " "
+ ClassUtil.getDecompiledValue(node.cst, "") + "\n";
} }
case "Type": { case "Type": {
Type type = (Type) node.cst; Type type = (Type) node.cst;
@@ -510,10 +548,11 @@ public class Disassembler {
Field f_buf = Type.class.getDeclaredField("valueBuffer"); Field f_buf = Type.class.getDeclaredField("valueBuffer");
f_buf.setAccessible(true); f_buf.setAccessible(true);
buf = (String) f_buf.get(type); buf = (String) f_buf.get(type);
} catch (Exception e) {} } catch (Exception e) {
}
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " Type: [\n\t\t\ttype: " String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " Type: [\n\t\t\ttype: "
+ ClassUtil.getClassNameFromType(type) + "\n\t\t\tstart: " + valueBegin + "\n\t\t\tend: " + valueEnd + "\n\t\t\tbuf: " + ClassUtil.getClassNameFromType(type) + "\n\t\t\tstart: " + valueBegin + "\n\t\t\tend: "
+ ClassUtil.getDecompiledValue(buf, ""); + valueEnd + "\n\t\t\tbuf: " + ClassUtil.getDecompiledValue(buf, "");
s += "\n\t\t]\n"; s += "\n\t\t]\n";
return s; return s;
} }
@@ -534,19 +573,22 @@ public class Disassembler {
case "IntInsnNode": { case "IntInsnNode": {
IntInsnNode node = (IntInsnNode) n; IntInsnNode node = (IntInsnNode) n;
if (n.getOpcode() == Opcodes.NEWARRAY) { if (n.getOpcode() == Opcodes.NEWARRAY) {
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + ClassUtil.getArrayTypeByID(node.operand) + "\n"; return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " "
+ ClassUtil.getArrayTypeByID(node.operand) + "\n";
} else { } else {
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.operand + "\n"; return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.operand + "\n";
} }
} }
case "JumpInsnNode": { case "JumpInsnNode": {
JumpInsnNode node = (JumpInsnNode) n; JumpInsnNode node = (JumpInsnNode) n;
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + labels.get(node.label.getLabel()) + "\n"; return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + labels.get(node.label.getLabel())
+ "\n";
} }
case "TableSwitchInsnNode": { case "TableSwitchInsnNode": {
TableSwitchInsnNode node = (TableSwitchInsnNode) n; TableSwitchInsnNode node = (TableSwitchInsnNode) n;
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tmin: " + node.min + "\n\t\t\tmax: " + node.max String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tmin: " + node.min
+ "\n\t\t\tdefault: " + labels.get(node.dflt.getLabel()) + "\n\t\t\tlabels: [\n"; + "\n\t\t\tmax: " + node.max + "\n\t\t\tdefault: " + labels.get(node.dflt.getLabel())
+ "\n\t\t\tlabels: [\n";
for (LabelNode l : node.labels) { for (LabelNode l : node.labels) {
s += "\t\t\t\t" + labels.get(l.getLabel()) + "\n"; s += "\t\t\t\t" + labels.get(l.getLabel()) + "\n";
} }
@@ -555,8 +597,8 @@ public class Disassembler {
} }
case "LookupSwitchInsnNode": { case "LookupSwitchInsnNode": {
LookupSwitchInsnNode node = (LookupSwitchInsnNode) n; LookupSwitchInsnNode node = (LookupSwitchInsnNode) n;
String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tdefault: " + labels.get(node.dflt.getLabel()) String s = "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " [\n\t\t\tdefault: "
+ "\n\t\t\tkeys: [\n"; + labels.get(node.dflt.getLabel()) + "\n\t\t\tkeys: [\n";
for (Integer l : node.keys) { for (Integer l : node.keys) {
s += "\t\t\t\t" + l + "\n"; s += "\t\t\t\t" + l + "\n";
} }
@@ -572,7 +614,8 @@ public class Disassembler {
return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.var + " " + node.incr + "\n"; return "\t\t" + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + node.var + " " + node.incr + "\n";
} }
default: default:
return "\t\tNOT HANDLED! " + OpcodesReverse.reverseOpcode(n.getOpcode()) + " " + n.getClass().getSimpleName() + "\n"; return "\t\tNOT HANDLED! " + OpcodesReverse.reverseOpcode(n.getOpcode()) + " "
+ n.getClass().getSimpleName() + "\n";
} }
} }
+2
View File
@@ -178,6 +178,8 @@ public class Main extends JFrame {
provider.addCompletion(new ShorthandCompletion(provider, "method", provider.addCompletion(new ShorthandCompletion(provider, "method",
"// #Max: l:0 s:0\n\t// #TryCatch:\n\t// #LocalVars:\n\tpublic static method ()V {\n\t\treturn\n\t}", "// #Max: l:0 s:0\n\t// #TryCatch:\n\t// #LocalVars:\n\tpublic static method ()V {\n\t\treturn\n\t}",
null, "<html><b><u>method</u></b><br>Creates an example method</html>")); null, "<html><b><u>method</u></b><br>Creates an example method</html>"));
provider.addCompletion(new ShorthandCompletion(provider, "frame", "frame FULL l:[] s:[]", null,
"<html><b><u>frame</u></b><br>Creates a stack map frame</html>"));
return provider; return provider;
} }
@@ -66,8 +66,8 @@ public abstract class CompletionProviderBase implements CompletionProvider {
private Segment s = new Segment(); private Segment s = new Segment();
protected static final String EMPTY_STRING = ""; protected static final String EMPTY_STRING = "";
/** /**
* Comparator used to sort completions by their relevance before sorting * Comparator used to sort completions by their relevance before sorting them
* them lexicographically. * lexicographically.
*/ */
private static final Comparator<Completion> sortByRelevanceComparator = new SortByRelevanceComparator(); private static final Comparator<Completion> sortByRelevanceComparator = new SortByRelevanceComparator();
@@ -116,10 +116,8 @@ public abstract class CompletionProviderBase implements CompletionProvider {
/** /**
* Does the dirty work of creating a list of completions. * Does the dirty work of creating a list of completions.
* *
* @param comp * @param comp The text component to look in.
* The text component to look in. * @return The list of possible completions, or an empty list if there are none.
* @return The list of possible completions, or an empty list if there
* are none.
*/ */
protected abstract List<Completion> getCompletionsImpl(JTextComponent comp); protected abstract List<Completion> getCompletionsImpl(JTextComponent comp);
@@ -189,13 +187,11 @@ public abstract class CompletionProviderBase implements CompletionProvider {
/** /**
* Sets the characters that auto-activation should occur after. A Java * Sets the characters that auto-activation should occur after. A Java
* completion provider, for example, might want to set <code>others</code> * completion provider, for example, might want to set <code>others</code> to
* to "<code>.</code>", to allow auto-activation for members of an object. * "<code>.</code>", to allow auto-activation for members of an object.
* *
* @param letters * @param letters Whether auto-activation should occur after any letter.
* Whether auto-activation should occur after any letter. * @param others A string of (non-letter) chars that auto-activation should
* @param others
* A string of (non-letter) chars that auto-activation should
* occur after. This may be <code>null</code>. * occur after. This may be <code>null</code>.
*/ */
public void setAutoActivationRules(boolean letters, String others) { public void setAutoActivationRules(boolean letters, String others) {
@@ -204,14 +200,11 @@ public abstract class CompletionProviderBase implements CompletionProvider {
} }
/** /**
* Sets the param choices provider. This is used when a user * Sets the param choices provider. This is used when a user code-completes a
* code-completes a parameterized completion, such as a function or method. * parameterized completion, such as a function or method. For any parameter to
* For any parameter to the function/method, this object can return * the function/method, this object can return possible completions.
* possible completions.
* *
* @param pcp * @param pcp The parameter choices provider, or <code>null</code> for none.
* The parameter choices provider, or <code>null</code> for
* none.
* @see #getParameterChoicesProvider() * @see #getParameterChoicesProvider()
*/ */
public void setParameterChoicesProvider(ParameterChoicesProvider pcp) { public void setParameterChoicesProvider(ParameterChoicesProvider pcp) {