summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/gui
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui')
-rw-r--r--src/main/java/cuchaz/enigma/gui/CodeReader.java2
-rw-r--r--src/main/java/cuchaz/enigma/gui/Gui.java66
-rw-r--r--src/main/java/cuchaz/enigma/gui/GuiController.java18
-rw-r--r--src/main/java/cuchaz/enigma/gui/node/ClassSelectorPackageNode.java4
4 files changed, 34 insertions, 56 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/CodeReader.java b/src/main/java/cuchaz/enigma/gui/CodeReader.java
index f76dc89..97deaf3 100644
--- a/src/main/java/cuchaz/enigma/gui/CodeReader.java
+++ b/src/main/java/cuchaz/enigma/gui/CodeReader.java
@@ -162,7 +162,7 @@ public class CodeReader extends JEditorPane {
162 // couldn't find the class declaration token, might be an anonymous class 162 // couldn't find the class declaration token, might be an anonymous class
163 // look for any declaration in that class instead 163 // look for any declaration in that class instead
164 for (Entry entry : sourceIndex.declarations()) { 164 for (Entry entry : sourceIndex.declarations()) {
165 if (entry.getClassEntry().equals(classEntry)) { 165 if (entry.getOwnerClassEntry().equals(classEntry)) {
166 token = sourceIndex.getDeclarationToken(entry); 166 token = sourceIndex.getDeclarationToken(entry);
167 break; 167 break;
168 } 168 }
diff --git a/src/main/java/cuchaz/enigma/gui/Gui.java b/src/main/java/cuchaz/enigma/gui/Gui.java
index 4a891cf..5d9f7cb 100644
--- a/src/main/java/cuchaz/enigma/gui/Gui.java
+++ b/src/main/java/cuchaz/enigma/gui/Gui.java
@@ -35,7 +35,6 @@ import cuchaz.enigma.mapping.*;
35import cuchaz.enigma.throwables.IllegalNameException; 35import cuchaz.enigma.throwables.IllegalNameException;
36import cuchaz.enigma.utils.Utils; 36import cuchaz.enigma.utils.Utils;
37import de.sciss.syntaxpane.DefaultSyntaxKit; 37import de.sciss.syntaxpane.DefaultSyntaxKit;
38import javassist.bytecode.Descriptor;
39 38
40import javax.swing.*; 39import javax.swing.*;
41import javax.swing.text.BadLocationException; 40import javax.swing.text.BadLocationException;
@@ -48,8 +47,10 @@ import java.awt.*;
48import java.awt.event.*; 47import java.awt.event.*;
49import java.io.File; 48import java.io.File;
50import java.io.IOException; 49import java.io.IOException;
51import java.util.*; 50import java.util.Collection;
51import java.util.Collections;
52import java.util.List; 52import java.util.List;
53import java.util.Vector;
53import java.util.function.Function; 54import java.util.function.Function;
54 55
55public class Gui { 56public class Gui {
@@ -438,14 +439,10 @@ public class Gui {
438 showFieldEntry((FieldEntry) this.reference.entry); 439 showFieldEntry((FieldEntry) this.reference.entry);
439 } else if (this.reference.entry instanceof MethodEntry) { 440 } else if (this.reference.entry instanceof MethodEntry) {
440 showMethodEntry((MethodEntry) this.reference.entry); 441 showMethodEntry((MethodEntry) this.reference.entry);
441 } else if (this.reference.entry instanceof ConstructorEntry) {
442 showConstructorEntry((ConstructorEntry) this.reference.entry);
443 } else if (this.reference.entry instanceof ArgumentEntry) {
444 showArgumentEntry((ArgumentEntry) this.reference.entry);
445 } else if (this.reference.entry instanceof LocalVariableEntry) { 442 } else if (this.reference.entry instanceof LocalVariableEntry) {
446 showLocalVariableEntry((LocalVariableEntry) this.reference.entry); 443 showLocalVariableEntry((LocalVariableEntry) this.reference.entry);
447 } else { 444 } else {
448 throw new Error("Unknown entry type: " + this.reference.entry.getClass().getName()); 445 throw new Error("Unknown entry desc: " + this.reference.entry.getClass().getName());
449 } 446 }
450 447
451 redraw(); 448 redraw();
@@ -453,10 +450,9 @@ public class Gui {
453 450
454 private void showLocalVariableEntry(LocalVariableEntry entry) { 451 private void showLocalVariableEntry(LocalVariableEntry entry) {
455 addNameValue(infoPanel, "Variable", entry.getName()); 452 addNameValue(infoPanel, "Variable", entry.getName());
456 addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); 453 addNameValue(infoPanel, "Class", entry.getOwnerClassEntry().getName());
457 addNameValue(infoPanel, "Method", entry.getBehaviorEntry().getName()); 454 addNameValue(infoPanel, "Method", entry.getOwnerEntry().getName());
458 addNameValue(infoPanel, "Index", Integer.toString(entry.getIndex())); 455 addNameValue(infoPanel, "Index", Integer.toString(entry.getIndex()));
459 addNameValue(infoPanel, "Type", entry.getType().toString());
460 } 456 }
461 457
462 private void showClassEntry(ClassEntry entry) { 458 private void showClassEntry(ClassEntry entry) {
@@ -466,32 +462,20 @@ public class Gui {
466 462
467 private void showFieldEntry(FieldEntry entry) { 463 private void showFieldEntry(FieldEntry entry) {
468 addNameValue(infoPanel, "Field", entry.getName()); 464 addNameValue(infoPanel, "Field", entry.getName());
469 addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); 465 addNameValue(infoPanel, "Class", entry.getOwnerClassEntry().getName());
470 addNameValue(infoPanel, "Type", entry.getType().toString()); 466 addNameValue(infoPanel, "TypeDescriptor", entry.getDesc().toString());
471 addModifierComboBox(infoPanel, "Modifier", entry); 467 addModifierComboBox(infoPanel, "Modifier", entry);
472 } 468 }
473 469
474 private void showMethodEntry(MethodEntry entry) { 470 private void showMethodEntry(MethodEntry entry) {
475 addNameValue(infoPanel, "Method", entry.getName()); 471 if (entry.isConstructor()) {
476 addNameValue(infoPanel, "Class", entry.getClassEntry().getName()); 472 addNameValue(infoPanel, "Constructor", entry.getOwnerClassEntry().getName());
477 addNameValue(infoPanel, "Signature", entry.getSignature().toString()); 473 } else {
478 addModifierComboBox(infoPanel, "Modifier", entry); 474 addNameValue(infoPanel, "Method", entry.getName());
479 475 addNameValue(infoPanel, "Class", entry.getOwnerClassEntry().getName());
480 }
481
482 private void showConstructorEntry(ConstructorEntry entry) {
483 addNameValue(infoPanel, "Constructor", entry.getClassEntry().getName());
484 if (!entry.isStatic()) {
485 addNameValue(infoPanel, "Signature", entry.getSignature().toString());
486 addModifierComboBox(infoPanel, "Modifier", entry);
487 } 476 }
488 } 477 addNameValue(infoPanel, "MethodDescriptor", entry.getDesc().toString());
489 478 addModifierComboBox(infoPanel, "Modifier", entry);
490 private void showArgumentEntry(ArgumentEntry entry) {
491 addNameValue(infoPanel, "Argument", entry.getName());
492 addNameValue(infoPanel, "Class", entry.getClassEntry().getName());
493 addNameValue(infoPanel, "Method", entry.getBehaviorEntry().getName());
494 addNameValue(infoPanel, "Index", Integer.toString(entry.getIndex()));
495 } 479 }
496 480
497 private void addNameValue(JPanel container, String name, String value) { 481 private void addNameValue(JPanel container, String name, String value) {
@@ -532,8 +516,8 @@ public class Gui {
532 reference = this.controller.getDeobfReference(token); 516 reference = this.controller.getDeobfReference(token);
533 boolean isClassEntry = isToken && reference.entry instanceof ClassEntry; 517 boolean isClassEntry = isToken && reference.entry instanceof ClassEntry;
534 boolean isFieldEntry = isToken && reference.entry instanceof FieldEntry; 518 boolean isFieldEntry = isToken && reference.entry instanceof FieldEntry;
535 boolean isMethodEntry = isToken && reference.entry instanceof MethodEntry; 519 boolean isMethodEntry = isToken && reference.entry instanceof MethodEntry && !((MethodEntry) reference.entry).isConstructor();
536 boolean isConstructorEntry = isToken && reference.entry instanceof ConstructorEntry; 520 boolean isConstructorEntry = isToken && reference.entry instanceof MethodEntry && ((MethodEntry) reference.entry).isConstructor();
537 boolean isInJar = isToken && this.controller.entryIsInJar(reference.entry); 521 boolean isInJar = isToken && this.controller.entryIsInJar(reference.entry);
538 boolean isRenameable = isToken && this.controller.referenceIsRenameable(reference); 522 boolean isRenameable = isToken && this.controller.referenceIsRenameable(reference);
539 523
@@ -710,16 +694,13 @@ public class Gui {
710 if (reference.entry instanceof ClassEntry) { 694 if (reference.entry instanceof ClassEntry) {
711 // look for calls to the default constructor 695 // look for calls to the default constructor
712 // TODO: get a list of all the constructors and find calls to all of them 696 // TODO: get a list of all the constructors and find calls to all of them
713 BehaviorReferenceTreeNode node = this.controller.getMethodReferences(new ConstructorEntry((ClassEntry) reference.entry, new Signature("()V"))); 697 MethodReferenceTreeNode node = this.controller.getMethodReferences(new MethodEntry((ClassEntry) reference.entry, "<init>", new MethodDescriptor("()V")));
714 callsTree.setModel(new DefaultTreeModel(node)); 698 callsTree.setModel(new DefaultTreeModel(node));
715 } else if (reference.entry instanceof FieldEntry) { 699 } else if (reference.entry instanceof FieldEntry) {
716 FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) reference.entry); 700 FieldReferenceTreeNode node = this.controller.getFieldReferences((FieldEntry) reference.entry);
717 callsTree.setModel(new DefaultTreeModel(node)); 701 callsTree.setModel(new DefaultTreeModel(node));
718 } else if (reference.entry instanceof MethodEntry) { 702 } else if (reference.entry instanceof MethodEntry) {
719 BehaviorReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) reference.entry); 703 MethodReferenceTreeNode node = this.controller.getMethodReferences((MethodEntry) reference.entry);
720 callsTree.setModel(new DefaultTreeModel(node));
721 } else if (reference.entry instanceof ConstructorEntry) {
722 BehaviorReferenceTreeNode node = this.controller.getMethodReferences((ConstructorEntry) reference.entry);
723 callsTree.setModel(new DefaultTreeModel(node)); 704 callsTree.setModel(new DefaultTreeModel(node));
724 } 705 }
725 706
@@ -790,7 +771,6 @@ public class Gui {
790 // package rename 771 // package rename
791 if (data instanceof String) { 772 if (data instanceof String) {
792 for (int i = 0; i < node.getChildCount(); i++) { 773 for (int i = 0; i < node.getChildCount(); i++) {
793 data = Descriptor.toJvmName((String) data);
794 DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) node.getChildAt(i); 774 DefaultMutableTreeNode childNode = (DefaultMutableTreeNode) node.getChildAt(i);
795 ClassEntry prevDataChild = (ClassEntry) childNode.getUserObject(); 775 ClassEntry prevDataChild = (ClassEntry) childNode.getUserObject();
796 ClassEntry dataChild = new ClassEntry(data + "/" + prevDataChild.getSimpleName()); 776 ClassEntry dataChild = new ClassEntry(data + "/" + prevDataChild.getSimpleName());
@@ -807,15 +787,15 @@ public class Gui {
807 } 787 }
808 788
809 public void moveClassTree(EntryReference<Entry, Entry> deobfReference, String newName) { 789 public void moveClassTree(EntryReference<Entry, Entry> deobfReference, String newName) {
810 String oldEntry = deobfReference.entry.getClassEntry().getPackageName(); 790 String oldEntry = deobfReference.entry.getOwnerClassEntry().getPackageName();
811 String newEntry = new ClassEntry(Descriptor.toJvmName(newName)).getPackageName(); 791 String newEntry = new ClassEntry(newName).getPackageName();
812 moveClassTree(deobfReference, newName, oldEntry == null, 792 moveClassTree(deobfReference, newName, oldEntry == null,
813 newEntry == null); 793 newEntry == null);
814 } 794 }
815 795
816 public void moveClassTree(EntryReference<Entry, Entry> deobfReference, String newName, boolean isOldOb, boolean isNewOb) { 796 public void moveClassTree(EntryReference<Entry, Entry> deobfReference, String newName, boolean isOldOb, boolean isNewOb) {
817 ClassEntry oldEntry = deobfReference.entry.getClassEntry(); 797 ClassEntry oldEntry = deobfReference.entry.getOwnerClassEntry();
818 ClassEntry newEntry = new ClassEntry(Descriptor.toJvmName(newName)); 798 ClassEntry newEntry = new ClassEntry(newName);
819 799
820 // Ob -> deob 800 // Ob -> deob
821 if (isOldOb && !isNewOb) { 801 if (isOldOb && !isNewOb) {
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java
index 6d98743..a5528a7 100644
--- a/src/main/java/cuchaz/enigma/gui/GuiController.java
+++ b/src/main/java/cuchaz/enigma/gui/GuiController.java
@@ -51,7 +51,7 @@ public class GuiController {
51 return this.isDirty; 51 return this.isDirty;
52 } 52 }
53 53
54 public void openJar(final JarFile jar) { 54 public void openJar(final JarFile jar) throws IOException {
55 this.gui.onStartOpenJar(); 55 this.gui.onStartOpenJar();
56 this.deobfuscator = new Deobfuscator(jar); 56 this.deobfuscator = new Deobfuscator(jar);
57 this.gui.onFinishOpenJar(this.deobfuscator.getJarName()); 57 this.gui.onFinishOpenJar(this.deobfuscator.getJarName());
@@ -161,24 +161,24 @@ public class GuiController {
161 161
162 public ClassInheritanceTreeNode getClassInheritance(ClassEntry deobfClassEntry) { 162 public ClassInheritanceTreeNode getClassInheritance(ClassEntry deobfClassEntry) {
163 ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry); 163 ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry);
164 ClassInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getClassInheritance(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfClassEntry); 164 ClassInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getClassInheritance(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfClassEntry);
165 return ClassInheritanceTreeNode.findNode(rootNode, obfClassEntry); 165 return ClassInheritanceTreeNode.findNode(rootNode, obfClassEntry);
166 } 166 }
167 167
168 public ClassImplementationsTreeNode getClassImplementations(ClassEntry deobfClassEntry) { 168 public ClassImplementationsTreeNode getClassImplementations(ClassEntry deobfClassEntry) {
169 ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry); 169 ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry);
170 return this.deobfuscator.getJarIndex().getClassImplementations(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfClassEntry); 170 return this.deobfuscator.getJarIndex().getClassImplementations(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfClassEntry);
171 } 171 }
172 172
173 public MethodInheritanceTreeNode getMethodInheritance(MethodEntry deobfMethodEntry) { 173 public MethodInheritanceTreeNode getMethodInheritance(MethodEntry deobfMethodEntry) {
174 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry); 174 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry);
175 MethodInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getMethodInheritance(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfMethodEntry); 175 MethodInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getMethodInheritance(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfMethodEntry);
176 return MethodInheritanceTreeNode.findNode(rootNode, obfMethodEntry); 176 return MethodInheritanceTreeNode.findNode(rootNode, obfMethodEntry);
177 } 177 }
178 178
179 public MethodImplementationsTreeNode getMethodImplementations(MethodEntry deobfMethodEntry) { 179 public MethodImplementationsTreeNode getMethodImplementations(MethodEntry deobfMethodEntry) {
180 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry); 180 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry);
181 List<MethodImplementationsTreeNode> rootNodes = this.deobfuscator.getJarIndex().getMethodImplementations(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfMethodEntry); 181 List<MethodImplementationsTreeNode> rootNodes = this.deobfuscator.getJarIndex().getMethodImplementations(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfMethodEntry);
182 if (rootNodes.isEmpty()) { 182 if (rootNodes.isEmpty()) {
183 return null; 183 return null;
184 } 184 }
@@ -190,14 +190,14 @@ public class GuiController {
190 190
191 public FieldReferenceTreeNode getFieldReferences(FieldEntry deobfFieldEntry) { 191 public FieldReferenceTreeNode getFieldReferences(FieldEntry deobfFieldEntry) {
192 FieldEntry obfFieldEntry = this.deobfuscator.obfuscateEntry(deobfFieldEntry); 192 FieldEntry obfFieldEntry = this.deobfuscator.obfuscateEntry(deobfFieldEntry);
193 FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfFieldEntry); 193 FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfFieldEntry);
194 rootNode.load(this.deobfuscator.getJarIndex(), true); 194 rootNode.load(this.deobfuscator.getJarIndex(), true);
195 return rootNode; 195 return rootNode;
196 } 196 }
197 197
198 public BehaviorReferenceTreeNode getMethodReferences(BehaviorEntry deobfBehaviorEntry) { 198 public MethodReferenceTreeNode getMethodReferences(MethodEntry deobfMethodEntry) {
199 BehaviorEntry obfBehaviorEntry = this.deobfuscator.obfuscateEntry(deobfBehaviorEntry); 199 MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry);
200 BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfBehaviorEntry); 200 MethodReferenceTreeNode rootNode = new MethodReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.DEOBFUSCATING), obfMethodEntry);
201 rootNode.load(this.deobfuscator.getJarIndex(), true); 201 rootNode.load(this.deobfuscator.getJarIndex(), true);
202 return rootNode; 202 return rootNode;
203 } 203 }
diff --git a/src/main/java/cuchaz/enigma/gui/node/ClassSelectorPackageNode.java b/src/main/java/cuchaz/enigma/gui/node/ClassSelectorPackageNode.java
index f80abba..caa985c 100644
--- a/src/main/java/cuchaz/enigma/gui/node/ClassSelectorPackageNode.java
+++ b/src/main/java/cuchaz/enigma/gui/node/ClassSelectorPackageNode.java
@@ -11,8 +11,6 @@
11 11
12package cuchaz.enigma.gui.node; 12package cuchaz.enigma.gui.node;
13 13
14import javassist.bytecode.Descriptor;
15
16import javax.swing.tree.DefaultMutableTreeNode; 14import javax.swing.tree.DefaultMutableTreeNode;
17 15
18public class ClassSelectorPackageNode extends DefaultMutableTreeNode { 16public class ClassSelectorPackageNode extends DefaultMutableTreeNode {
@@ -41,7 +39,7 @@ public class ClassSelectorPackageNode extends DefaultMutableTreeNode {
41 39
42 @Override 40 @Override
43 public String toString() { 41 public String toString() {
44 return !packageName.equals("(none)") ? Descriptor.toJavaName(this.packageName) : "(none)"; 42 return !packageName.equals("(none)") ? this.packageName : "(none)";
45 } 43 }
46 44
47 @Override 45 @Override