mirror of
https://github.com/SuspiciousActivity/ByteEdit.git
synced 2026-08-13 17:56:17 +00:00
Added signatures, fixed accessm, enum and frame bugs
This commit is contained in:
1 parent
96cb81a8ac
commit
b98750bae9
3 files changed
+31
-6
No files matched your search
@@ -94,16 +94,18 @@ public class Assembler {
|
||||
case "class":
|
||||
break;
|
||||
case "enum":
|
||||
clazz.access ^= ClassUtil.ACC_ABSTRACT;
|
||||
clazz.access ^= ClassUtil.ACC_ENUM;
|
||||
break;
|
||||
case "interface":
|
||||
clazz.access = 0;
|
||||
clazz.access ^= ClassUtil.ACC_ABSTRACT;
|
||||
clazz.access ^= ClassUtil.ACC_INTERFACE;
|
||||
break;
|
||||
case "@interface":
|
||||
clazz.access = 0;
|
||||
clazz.access ^= ClassUtil.ACC_ABSTRACT;
|
||||
clazz.access ^= ClassUtil.ACC_ANNOTATION;
|
||||
clazz.access ^= ClassUtil.ACC_INTERFACE;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -134,6 +136,8 @@ public class Assembler {
|
||||
clazz.fields = new ArrayList<>();
|
||||
clazz.methods = new ArrayList<>();
|
||||
|
||||
String signature = null;
|
||||
|
||||
ArrayList<String> annotationsForNext = new ArrayList<>();
|
||||
while (!(s = read.readLine()).equals("// #Methods")) {
|
||||
s = s.trim();
|
||||
@@ -141,6 +145,9 @@ public class Assembler {
|
||||
continue;
|
||||
if (s.startsWith("@")) {
|
||||
annotationsForNext.add(s);
|
||||
} else {
|
||||
if (s.startsWith("// #Signature: ")) {
|
||||
signature = s.substring(15);
|
||||
} else {
|
||||
String[] split = s.split(" ");
|
||||
boolean hasValue = false;
|
||||
@@ -209,7 +216,7 @@ public class Assembler {
|
||||
access ^= ClassUtil.ACC_MANDATED;
|
||||
}
|
||||
}
|
||||
FieldNode node = new FieldNode(access, name, desc, null, value);
|
||||
FieldNode node = new FieldNode(access, name, desc, signature, value);
|
||||
if (!annotationsForNext.isEmpty()) {
|
||||
if (node.visibleAnnotations == null) {
|
||||
node.visibleAnnotations = new ArrayList<>();
|
||||
@@ -220,6 +227,8 @@ public class Assembler {
|
||||
annotationsForNext.clear();
|
||||
}
|
||||
clazz.fields.add(node);
|
||||
signature = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -253,6 +262,8 @@ public class Assembler {
|
||||
localVarsToParse.clear();
|
||||
tryCatchBlocksToParse.clear();
|
||||
stage = 0;
|
||||
} else if (s.startsWith("// #Signature: ")) {
|
||||
node.signature = s.substring(15);
|
||||
} else if (s.equals("// #TryCatch:")) {
|
||||
stage = 1;
|
||||
} else if (s.equals("// #LocalVars:")) {
|
||||
@@ -278,7 +289,8 @@ public class Assembler {
|
||||
for (String st : localVarsToParse) {
|
||||
String[] sp = st.split(":");
|
||||
int start = Integer.parseInt(sp[3].substring(0, sp[3].length() - 2));
|
||||
int end = Integer.parseInt(sp[4]);
|
||||
int end = Integer.parseInt(sp[4].substring(0, sp[4].length() - 4));
|
||||
String signat = sp[5].equals("null") ? null : sp[5];
|
||||
LabelNode _start = null;
|
||||
LabelNode _end = null;
|
||||
for (Entry<Label, Integer> entry : methodLabelMap.entrySet()) {
|
||||
@@ -290,7 +302,7 @@ public class Assembler {
|
||||
}
|
||||
}
|
||||
node.localVariables.add(new LocalVariableNode(sp[0], sp[1].substring(1, sp[1].length() - 2),
|
||||
null, _start, _end, Integer.parseInt(sp[2].substring(0, sp[2].length() - 2))));
|
||||
signat, _start, _end, Integer.parseInt(sp[2].substring(0, sp[2].length() - 2))));
|
||||
}
|
||||
|
||||
for (String st : tryCatchBlocksToParse) {
|
||||
@@ -315,6 +327,7 @@ public class Assembler {
|
||||
node.tryCatchBlocks.add(new TryCatchBlockNode(_start, _end, _handler, sp[0]));
|
||||
}
|
||||
clazz.methods.add(node);
|
||||
// signature = null;
|
||||
} else if (!s.startsWith("\t")) {
|
||||
s = s.substring(0, s.length() - 2);
|
||||
if (s.contains(" throws ")) {
|
||||
@@ -554,6 +567,9 @@ public class Assembler {
|
||||
local = new Object[0];
|
||||
} else {
|
||||
String l = str.substring(3, str.indexOf("s:") - 2);
|
||||
if (l.isEmpty()) {
|
||||
local = new Object[0];
|
||||
} else {
|
||||
for (String asd : l.split(", ")) {
|
||||
if (!asd.startsWith("(")) {
|
||||
arr.add(asd);
|
||||
@@ -584,11 +600,15 @@ public class Assembler {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
arr.clear();
|
||||
if (str.endsWith("s:null")) {
|
||||
stack = new Object[0];
|
||||
} else {
|
||||
String st = str.substring(str.indexOf("s:") + 3, str.length() - 1);
|
||||
if (st.isEmpty()) {
|
||||
stack = new Object[0];
|
||||
} else {
|
||||
for (String asd : st.split(", ")) {
|
||||
if (!asd.startsWith("(")) {
|
||||
arr.add(asd);
|
||||
@@ -619,6 +639,7 @@ public class Assembler {
|
||||
c++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return new FrameNode(Integer.parseInt(str1.split(" ")[0]), local != null ? local.length : 0, local,
|
||||
stack != null ? stack.length : 0, stack);
|
||||
} else {
|
||||
|
||||
@@ -124,6 +124,8 @@ public class Disassembler {
|
||||
+ "\n\n// #Fields\n";
|
||||
|
||||
for (FieldNode fn : classNode.fields) {
|
||||
if (fn.signature != null)
|
||||
s += "\t// #Signature: " + fn.signature + "\n";
|
||||
if (fn.visibleAnnotations != null && !fn.visibleAnnotations.isEmpty()) {
|
||||
for (AnnotationNode annotationNode : fn.visibleAnnotations) {
|
||||
s += "\t@" + annotationNode.desc;
|
||||
@@ -191,6 +193,8 @@ public class Disassembler {
|
||||
for (MethodNode mn : classNode.methods) {
|
||||
try {
|
||||
s += "\t// #Max: l:" + mn.maxLocals + " s:" + mn.maxStack + "\n";
|
||||
if (mn.signature != null)
|
||||
s += "\t// #Signature: " + mn.signature + "\n";
|
||||
|
||||
String[] dis = disassembleMethod(classNode.name, mn);
|
||||
s += dis[2];
|
||||
@@ -297,7 +301,8 @@ public class Disassembler {
|
||||
if (mn.localVariables != null) {
|
||||
for (LocalVariableNode lvn : mn.localVariables) {
|
||||
localVarTable += "\t// " + lvn.name + ": " + lvn.desc + " i:" + lvn.index + " s:"
|
||||
+ labels.get(lvn.start.getLabel()) + " e:" + labels.get(lvn.end.getLabel()) + "\n";
|
||||
+ labels.get(lvn.start.getLabel()) + " e:" + labels.get(lvn.end.getLabel()) + " sig:"
|
||||
+ lvn.signature + "\n";
|
||||
}
|
||||
}
|
||||
if (mn.tryCatchBlocks != null) {
|
||||
|
||||
@@ -219,7 +219,6 @@ public class Main extends JFrame {
|
||||
}
|
||||
}
|
||||
}, ctrlS, JComponent.WHEN_FOCUSED);
|
||||
textArea.setFont(new Font("Consolas", 0, 10));
|
||||
textArea.setEditable(true);
|
||||
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA_DISASSEMBLE);
|
||||
textArea.setCodeFoldingEnabled(true);
|
||||
|
||||
Reference in new issue
Block a user