diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/gui/GuiController.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/gui/GuiController.java | 212 |
1 files changed, 91 insertions, 121 deletions
diff --git a/src/main/java/cuchaz/enigma/gui/GuiController.java b/src/main/java/cuchaz/enigma/gui/GuiController.java index a6a2ec5..868e0d4 100644 --- a/src/main/java/cuchaz/enigma/gui/GuiController.java +++ b/src/main/java/cuchaz/enigma/gui/GuiController.java | |||
| @@ -24,162 +24,138 @@ import java.util.List; | |||
| 24 | import java.util.jar.JarFile; | 24 | import java.util.jar.JarFile; |
| 25 | 25 | ||
| 26 | import cuchaz.enigma.Deobfuscator; | 26 | import cuchaz.enigma.Deobfuscator; |
| 27 | import cuchaz.enigma.Deobfuscator.ProgressListener; | ||
| 28 | import cuchaz.enigma.analysis.*; | 27 | import cuchaz.enigma.analysis.*; |
| 29 | import cuchaz.enigma.gui.ProgressDialog.ProgressRunnable; | ||
| 30 | import cuchaz.enigma.mapping.*; | 28 | import cuchaz.enigma.mapping.*; |
| 31 | 29 | ||
| 32 | public class GuiController { | 30 | public class GuiController { |
| 33 | 31 | ||
| 34 | private Deobfuscator m_deobfuscator; | 32 | private Deobfuscator deobfuscator; |
| 35 | private Gui m_gui; | 33 | private Gui gui; |
| 36 | private SourceIndex m_index; | 34 | private SourceIndex index; |
| 37 | private ClassEntry m_currentObfClass; | 35 | private ClassEntry currentObfClass; |
| 38 | private boolean m_isDirty; | 36 | private boolean isDirty; |
| 39 | private Deque<EntryReference<Entry, Entry>> m_referenceStack; | 37 | private Deque<EntryReference<Entry, Entry>> referenceStack; |
| 40 | 38 | ||
| 41 | public GuiController(Gui gui) { | 39 | public GuiController(Gui gui) { |
| 42 | m_gui = gui; | 40 | this.gui = gui; |
| 43 | m_deobfuscator = null; | 41 | this.deobfuscator = null; |
| 44 | m_index = null; | 42 | this.index = null; |
| 45 | m_currentObfClass = null; | 43 | this.currentObfClass = null; |
| 46 | m_isDirty = false; | 44 | this.isDirty = false; |
| 47 | m_referenceStack = Queues.newArrayDeque(); | 45 | this.referenceStack = Queues.newArrayDeque(); |
| 48 | } | 46 | } |
| 49 | 47 | ||
| 50 | public boolean isDirty() { | 48 | public boolean isDirty() { |
| 51 | return m_isDirty; | 49 | return this.isDirty; |
| 52 | } | 50 | } |
| 53 | 51 | ||
| 54 | public void openJar(final JarFile jar) throws IOException { | 52 | public void openJar(final JarFile jar) throws IOException { |
| 55 | m_gui.onStartOpenJar(); | 53 | this.gui.onStartOpenJar(); |
| 56 | m_deobfuscator = new Deobfuscator(jar); | 54 | this.deobfuscator = new Deobfuscator(jar); |
| 57 | m_gui.onFinishOpenJar(m_deobfuscator.getJarName()); | 55 | this.gui.onFinishOpenJar(this.deobfuscator.getJarName()); |
| 58 | refreshClasses(); | 56 | refreshClasses(); |
| 59 | } | 57 | } |
| 60 | 58 | ||
| 61 | public void closeJar() { | 59 | public void closeJar() { |
| 62 | m_deobfuscator = null; | 60 | this.deobfuscator = null; |
| 63 | m_gui.onCloseJar(); | 61 | this.gui.onCloseJar(); |
| 64 | } | 62 | } |
| 65 | 63 | ||
| 66 | public void openOldMappings(File file) throws IOException, MappingParseException { | 64 | public void openOldMappings(File file) throws IOException, MappingParseException { |
| 67 | FileReader in = new FileReader(file); | 65 | FileReader in = new FileReader(file); |
| 68 | m_deobfuscator.setMappings(new MappingsReaderOld().read(in)); | 66 | this.deobfuscator.setMappings(new MappingsReaderOld().read(in)); |
| 69 | in.close(); | 67 | in.close(); |
| 70 | m_isDirty = false; | 68 | this.isDirty = false; |
| 71 | m_gui.setMappingsFile(file); | 69 | this.gui.setMappingsFile(file); |
| 72 | refreshClasses(); | 70 | refreshClasses(); |
| 73 | refreshCurrentClass(); | 71 | refreshCurrentClass(); |
| 74 | } | 72 | } |
| 75 | 73 | ||
| 76 | public void openMappings(File file) throws IOException, MappingParseException { | 74 | public void openMappings(File file) throws IOException, MappingParseException { |
| 77 | m_deobfuscator.setMappings(new MappingsReader().read(file)); | 75 | this.deobfuscator.setMappings(new MappingsReader().read(file)); |
| 78 | m_isDirty = false; | 76 | this.isDirty = false; |
| 79 | m_gui.setMappingsFile(file); | 77 | this.gui.setMappingsFile(file); |
| 80 | refreshClasses(); | 78 | refreshClasses(); |
| 81 | refreshCurrentClass(); | 79 | refreshCurrentClass(); |
| 82 | } | 80 | } |
| 83 | 81 | ||
| 84 | public void saveMappings(File file) throws IOException { | 82 | public void saveMappings(File file) throws IOException { |
| 85 | new MappingsWriter().write(file, m_deobfuscator.getMappings()); | 83 | new MappingsWriter().write(file, this.deobfuscator.getMappings()); |
| 86 | m_isDirty = false; | 84 | this.isDirty = false; |
| 87 | } | 85 | } |
| 88 | 86 | ||
| 89 | public void closeMappings() { | 87 | public void closeMappings() { |
| 90 | m_deobfuscator.setMappings(null); | 88 | this.deobfuscator.setMappings(null); |
| 91 | m_gui.setMappingsFile(null); | 89 | this.gui.setMappingsFile(null); |
| 92 | refreshClasses(); | 90 | refreshClasses(); |
| 93 | refreshCurrentClass(); | 91 | refreshCurrentClass(); |
| 94 | } | 92 | } |
| 95 | 93 | ||
| 96 | public void exportSource(final File dirOut) { | 94 | public void exportSource(final File dirOut) { |
| 97 | ProgressDialog.runInThread(m_gui.getFrame(), new ProgressRunnable() { | 95 | ProgressDialog.runInThread(this.gui.getFrame(), progress -> this.deobfuscator.writeSources(dirOut, progress)); |
| 98 | @Override | ||
| 99 | public void run(ProgressListener progress) throws Exception { | ||
| 100 | m_deobfuscator.writeSources(dirOut, progress); | ||
| 101 | } | ||
| 102 | }); | ||
| 103 | } | 96 | } |
| 104 | 97 | ||
| 105 | public void exportJar(final File fileOut) { | 98 | public void exportJar(final File fileOut) { |
| 106 | ProgressDialog.runInThread(m_gui.getFrame(), new ProgressRunnable() { | 99 | ProgressDialog.runInThread(this.gui.getFrame(), progress -> this.deobfuscator.writeJar(fileOut, progress)); |
| 107 | @Override | ||
| 108 | public void run(ProgressListener progress) { | ||
| 109 | m_deobfuscator.writeJar(fileOut, progress); | ||
| 110 | } | ||
| 111 | }); | ||
| 112 | } | 100 | } |
| 113 | 101 | ||
| 114 | public Token getToken(int pos) { | 102 | public Token getToken(int pos) { |
| 115 | if (m_index == null) { | 103 | if (this.index == null) { |
| 116 | return null; | 104 | return null; |
| 117 | } | 105 | } |
| 118 | return m_index.getReferenceToken(pos); | 106 | return this.index.getReferenceToken(pos); |
| 119 | } | 107 | } |
| 120 | 108 | ||
| 121 | public EntryReference<Entry, Entry> getDeobfReference(Token token) { | 109 | public EntryReference<Entry, Entry> getDeobfReference(Token token) { |
| 122 | if (m_index == null) { | 110 | if (this.index == null) { |
| 123 | return null; | 111 | return null; |
| 124 | } | 112 | } |
| 125 | return m_index.getDeobfReference(token); | 113 | return this.index.getDeobfReference(token); |
| 126 | } | 114 | } |
| 127 | 115 | ||
| 128 | public ReadableToken getReadableToken(Token token) { | 116 | public ReadableToken getReadableToken(Token token) { |
| 129 | if (m_index == null) { | 117 | if (this.index == null) { |
| 130 | return null; | 118 | return null; |
| 131 | } | 119 | } |
| 132 | return new ReadableToken( | 120 | return new ReadableToken( |
| 133 | m_index.getLineNumber(token.start), | 121 | this.index.getLineNumber(token.start), |
| 134 | m_index.getColumnNumber(token.start), | 122 | this.index.getColumnNumber(token.start), |
| 135 | m_index.getColumnNumber(token.end) | 123 | this.index.getColumnNumber(token.end) |
| 136 | ); | 124 | ); |
| 137 | } | 125 | } |
| 138 | 126 | ||
| 139 | public boolean entryHasDeobfuscatedName(Entry deobfEntry) { | 127 | public boolean entryHasDeobfuscatedName(Entry deobfEntry) { |
| 140 | return m_deobfuscator.hasDeobfuscatedName(m_deobfuscator.obfuscateEntry(deobfEntry)); | 128 | return this.deobfuscator.hasDeobfuscatedName(this.deobfuscator.obfuscateEntry(deobfEntry)); |
| 141 | } | 129 | } |
| 142 | 130 | ||
| 143 | public boolean entryIsInJar(Entry deobfEntry) { | 131 | public boolean entryIsInJar(Entry deobfEntry) { |
| 144 | return m_deobfuscator.isObfuscatedIdentifier(m_deobfuscator.obfuscateEntry(deobfEntry)); | 132 | return this.deobfuscator.isObfuscatedIdentifier(this.deobfuscator.obfuscateEntry(deobfEntry)); |
| 145 | } | 133 | } |
| 146 | 134 | ||
| 147 | public boolean referenceIsRenameable(EntryReference<Entry, Entry> deobfReference) { | 135 | public boolean referenceIsRenameable(EntryReference<Entry, Entry> deobfReference) { |
| 148 | return m_deobfuscator.isRenameable(m_deobfuscator.obfuscateReference(deobfReference)); | 136 | return this.deobfuscator.isRenameable(this.deobfuscator.obfuscateReference(deobfReference)); |
| 149 | } | 137 | } |
| 150 | 138 | ||
| 151 | public ClassInheritanceTreeNode getClassInheritance(ClassEntry deobfClassEntry) { | 139 | public ClassInheritanceTreeNode getClassInheritance(ClassEntry deobfClassEntry) { |
| 152 | ClassEntry obfClassEntry = m_deobfuscator.obfuscateEntry(deobfClassEntry); | 140 | ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry); |
| 153 | ClassInheritanceTreeNode rootNode = m_deobfuscator.getJarIndex().getClassInheritance( | 141 | ClassInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getClassInheritance(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfClassEntry); |
| 154 | m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating), | ||
| 155 | obfClassEntry | ||
| 156 | ); | ||
| 157 | return ClassInheritanceTreeNode.findNode(rootNode, obfClassEntry); | 142 | return ClassInheritanceTreeNode.findNode(rootNode, obfClassEntry); |
| 158 | } | 143 | } |
| 159 | 144 | ||
| 160 | public ClassImplementationsTreeNode getClassImplementations(ClassEntry deobfClassEntry) { | 145 | public ClassImplementationsTreeNode getClassImplementations(ClassEntry deobfClassEntry) { |
| 161 | ClassEntry obfClassEntry = m_deobfuscator.obfuscateEntry(deobfClassEntry); | 146 | ClassEntry obfClassEntry = this.deobfuscator.obfuscateEntry(deobfClassEntry); |
| 162 | return m_deobfuscator.getJarIndex().getClassImplementations( | 147 | return this.deobfuscator.getJarIndex().getClassImplementations(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfClassEntry); |
| 163 | m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating), | ||
| 164 | obfClassEntry | ||
| 165 | ); | ||
| 166 | } | 148 | } |
| 167 | 149 | ||
| 168 | public MethodInheritanceTreeNode getMethodInheritance(MethodEntry deobfMethodEntry) { | 150 | public MethodInheritanceTreeNode getMethodInheritance(MethodEntry deobfMethodEntry) { |
| 169 | MethodEntry obfMethodEntry = m_deobfuscator.obfuscateEntry(deobfMethodEntry); | 151 | MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry); |
| 170 | MethodInheritanceTreeNode rootNode = m_deobfuscator.getJarIndex().getMethodInheritance( | 152 | MethodInheritanceTreeNode rootNode = this.deobfuscator.getJarIndex().getMethodInheritance(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfMethodEntry); |
| 171 | m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating), | ||
| 172 | obfMethodEntry | ||
| 173 | ); | ||
| 174 | return MethodInheritanceTreeNode.findNode(rootNode, obfMethodEntry); | 153 | return MethodInheritanceTreeNode.findNode(rootNode, obfMethodEntry); |
| 175 | } | 154 | } |
| 176 | 155 | ||
| 177 | public MethodImplementationsTreeNode getMethodImplementations(MethodEntry deobfMethodEntry) { | 156 | public MethodImplementationsTreeNode getMethodImplementations(MethodEntry deobfMethodEntry) { |
| 178 | MethodEntry obfMethodEntry = m_deobfuscator.obfuscateEntry(deobfMethodEntry); | 157 | MethodEntry obfMethodEntry = this.deobfuscator.obfuscateEntry(deobfMethodEntry); |
| 179 | List<MethodImplementationsTreeNode> rootNodes = m_deobfuscator.getJarIndex().getMethodImplementations( | 158 | List<MethodImplementationsTreeNode> rootNodes = this.deobfuscator.getJarIndex().getMethodImplementations(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfMethodEntry); |
| 180 | m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating), | ||
| 181 | obfMethodEntry | ||
| 182 | ); | ||
| 183 | if (rootNodes.isEmpty()) { | 159 | if (rootNodes.isEmpty()) { |
| 184 | return null; | 160 | return null; |
| 185 | } | 161 | } |
| @@ -190,45 +166,39 @@ public class GuiController { | |||
| 190 | } | 166 | } |
| 191 | 167 | ||
| 192 | public FieldReferenceTreeNode getFieldReferences(FieldEntry deobfFieldEntry) { | 168 | public FieldReferenceTreeNode getFieldReferences(FieldEntry deobfFieldEntry) { |
| 193 | FieldEntry obfFieldEntry = m_deobfuscator.obfuscateEntry(deobfFieldEntry); | 169 | FieldEntry obfFieldEntry = this.deobfuscator.obfuscateEntry(deobfFieldEntry); |
| 194 | FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode( | 170 | FieldReferenceTreeNode rootNode = new FieldReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfFieldEntry); |
| 195 | m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating), | 171 | rootNode.load(this.deobfuscator.getJarIndex(), true); |
| 196 | obfFieldEntry | ||
| 197 | ); | ||
| 198 | rootNode.load(m_deobfuscator.getJarIndex(), true); | ||
| 199 | return rootNode; | 172 | return rootNode; |
| 200 | } | 173 | } |
| 201 | 174 | ||
| 202 | public BehaviorReferenceTreeNode getMethodReferences(BehaviorEntry deobfBehaviorEntry) { | 175 | public BehaviorReferenceTreeNode getMethodReferences(BehaviorEntry deobfBehaviorEntry) { |
| 203 | BehaviorEntry obfBehaviorEntry = m_deobfuscator.obfuscateEntry(deobfBehaviorEntry); | 176 | BehaviorEntry obfBehaviorEntry = this.deobfuscator.obfuscateEntry(deobfBehaviorEntry); |
| 204 | BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode( | 177 | BehaviorReferenceTreeNode rootNode = new BehaviorReferenceTreeNode(this.deobfuscator.getTranslator(TranslationDirection.Deobfuscating), obfBehaviorEntry); |
| 205 | m_deobfuscator.getTranslator(TranslationDirection.Deobfuscating), | 178 | rootNode.load(this.deobfuscator.getJarIndex(), true); |
| 206 | obfBehaviorEntry | ||
| 207 | ); | ||
| 208 | rootNode.load(m_deobfuscator.getJarIndex(), true); | ||
| 209 | return rootNode; | 179 | return rootNode; |
| 210 | } | 180 | } |
| 211 | 181 | ||
| 212 | public void rename(EntryReference<Entry, Entry> deobfReference, String newName) { | 182 | public void rename(EntryReference<Entry, Entry> deobfReference, String newName) { |
| 213 | EntryReference<Entry, Entry> obfReference = m_deobfuscator.obfuscateReference(deobfReference); | 183 | EntryReference<Entry, Entry> obfReference = this.deobfuscator.obfuscateReference(deobfReference); |
| 214 | m_deobfuscator.rename(obfReference.getNameableEntry(), newName); | 184 | this.deobfuscator.rename(obfReference.getNameableEntry(), newName); |
| 215 | m_isDirty = true; | 185 | this.isDirty = true; |
| 216 | refreshClasses(); | 186 | refreshClasses(); |
| 217 | refreshCurrentClass(obfReference); | 187 | refreshCurrentClass(obfReference); |
| 218 | } | 188 | } |
| 219 | 189 | ||
| 220 | public void removeMapping(EntryReference<Entry, Entry> deobfReference) { | 190 | public void removeMapping(EntryReference<Entry, Entry> deobfReference) { |
| 221 | EntryReference<Entry, Entry> obfReference = m_deobfuscator.obfuscateReference(deobfReference); | 191 | EntryReference<Entry, Entry> obfReference = this.deobfuscator.obfuscateReference(deobfReference); |
| 222 | m_deobfuscator.removeMapping(obfReference.getNameableEntry()); | 192 | this.deobfuscator.removeMapping(obfReference.getNameableEntry()); |
| 223 | m_isDirty = true; | 193 | this.isDirty = true; |
| 224 | refreshClasses(); | 194 | refreshClasses(); |
| 225 | refreshCurrentClass(obfReference); | 195 | refreshCurrentClass(obfReference); |
| 226 | } | 196 | } |
| 227 | 197 | ||
| 228 | public void markAsDeobfuscated(EntryReference<Entry, Entry> deobfReference) { | 198 | public void markAsDeobfuscated(EntryReference<Entry, Entry> deobfReference) { |
| 229 | EntryReference<Entry, Entry> obfReference = m_deobfuscator.obfuscateReference(deobfReference); | 199 | EntryReference<Entry, Entry> obfReference = this.deobfuscator.obfuscateReference(deobfReference); |
| 230 | m_deobfuscator.markAsDeobfuscated(obfReference.getNameableEntry()); | 200 | this.deobfuscator.markAsDeobfuscated(obfReference.getNameableEntry()); |
| 231 | m_isDirty = true; | 201 | this.isDirty = true; |
| 232 | refreshClasses(); | 202 | refreshClasses(); |
| 233 | refreshCurrentClass(obfReference); | 203 | refreshCurrentClass(obfReference); |
| 234 | } | 204 | } |
| @@ -237,7 +207,7 @@ public class GuiController { | |||
| 237 | if (deobfEntry == null) { | 207 | if (deobfEntry == null) { |
| 238 | throw new IllegalArgumentException("Entry cannot be null!"); | 208 | throw new IllegalArgumentException("Entry cannot be null!"); |
| 239 | } | 209 | } |
| 240 | openReference(new EntryReference<Entry, Entry>(deobfEntry, deobfEntry.getName())); | 210 | openReference(new EntryReference<>(deobfEntry, deobfEntry.getName())); |
| 241 | } | 211 | } |
| 242 | 212 | ||
| 243 | public void openReference(EntryReference<Entry, Entry> deobfReference) { | 213 | public void openReference(EntryReference<Entry, Entry> deobfReference) { |
| @@ -246,51 +216,51 @@ public class GuiController { | |||
| 246 | } | 216 | } |
| 247 | 217 | ||
| 248 | // get the reference target class | 218 | // get the reference target class |
| 249 | EntryReference<Entry, Entry> obfReference = m_deobfuscator.obfuscateReference(deobfReference); | 219 | EntryReference<Entry, Entry> obfReference = this.deobfuscator.obfuscateReference(deobfReference); |
| 250 | ClassEntry obfClassEntry = obfReference.getLocationClassEntry().getOutermostClassEntry(); | 220 | ClassEntry obfClassEntry = obfReference.getLocationClassEntry().getOutermostClassEntry(); |
| 251 | if (!m_deobfuscator.isObfuscatedIdentifier(obfClassEntry)) { | 221 | if (!this.deobfuscator.isObfuscatedIdentifier(obfClassEntry)) { |
| 252 | throw new IllegalArgumentException("Obfuscated class " + obfClassEntry + " was not found in the jar!"); | 222 | throw new IllegalArgumentException("Obfuscated class " + obfClassEntry + " was not found in the jar!"); |
| 253 | } | 223 | } |
| 254 | if (m_currentObfClass == null || !m_currentObfClass.equals(obfClassEntry)) { | 224 | if (this.currentObfClass == null || !this.currentObfClass.equals(obfClassEntry)) { |
| 255 | // deobfuscate the class, then navigate to the reference | 225 | // deobfuscate the class, then navigate to the reference |
| 256 | m_currentObfClass = obfClassEntry; | 226 | this.currentObfClass = obfClassEntry; |
| 257 | deobfuscate(m_currentObfClass, obfReference); | 227 | deobfuscate(this.currentObfClass, obfReference); |
| 258 | } else { | 228 | } else { |
| 259 | showReference(obfReference); | 229 | showReference(obfReference); |
| 260 | } | 230 | } |
| 261 | } | 231 | } |
| 262 | 232 | ||
| 263 | private void showReference(EntryReference<Entry, Entry> obfReference) { | 233 | private void showReference(EntryReference<Entry, Entry> obfReference) { |
| 264 | EntryReference<Entry, Entry> deobfReference = m_deobfuscator.deobfuscateReference(obfReference); | 234 | EntryReference<Entry, Entry> deobfReference = this.deobfuscator.deobfuscateReference(obfReference); |
| 265 | Collection<Token> tokens = m_index.getReferenceTokens(deobfReference); | 235 | Collection<Token> tokens = this.index.getReferenceTokens(deobfReference); |
| 266 | if (tokens.isEmpty()) { | 236 | if (tokens.isEmpty()) { |
| 267 | // DEBUG | 237 | // DEBUG |
| 268 | System.err.println(String.format("WARNING: no tokens found for %s in %s", deobfReference, m_currentObfClass)); | 238 | System.err.println(String.format("WARNING: no tokens found for %s in %s", deobfReference, this.currentObfClass)); |
| 269 | } else { | 239 | } else { |
| 270 | m_gui.showTokens(tokens); | 240 | this.gui.showTokens(tokens); |
| 271 | } | 241 | } |
| 272 | } | 242 | } |
| 273 | 243 | ||
| 274 | public void savePreviousReference(EntryReference<Entry, Entry> deobfReference) { | 244 | public void savePreviousReference(EntryReference<Entry, Entry> deobfReference) { |
| 275 | m_referenceStack.push(m_deobfuscator.obfuscateReference(deobfReference)); | 245 | this.referenceStack.push(this.deobfuscator.obfuscateReference(deobfReference)); |
| 276 | } | 246 | } |
| 277 | 247 | ||
| 278 | public void openPreviousReference() { | 248 | public void openPreviousReference() { |
| 279 | if (hasPreviousLocation()) { | 249 | if (hasPreviousLocation()) { |
| 280 | openReference(m_deobfuscator.deobfuscateReference(m_referenceStack.pop())); | 250 | openReference(this.deobfuscator.deobfuscateReference(this.referenceStack.pop())); |
| 281 | } | 251 | } |
| 282 | } | 252 | } |
| 283 | 253 | ||
| 284 | public boolean hasPreviousLocation() { | 254 | public boolean hasPreviousLocation() { |
| 285 | return !m_referenceStack.isEmpty(); | 255 | return !this.referenceStack.isEmpty(); |
| 286 | } | 256 | } |
| 287 | 257 | ||
| 288 | private void refreshClasses() { | 258 | private void refreshClasses() { |
| 289 | List<ClassEntry> obfClasses = Lists.newArrayList(); | 259 | List<ClassEntry> obfClasses = Lists.newArrayList(); |
| 290 | List<ClassEntry> deobfClasses = Lists.newArrayList(); | 260 | List<ClassEntry> deobfClasses = Lists.newArrayList(); |
| 291 | m_deobfuscator.getSeparatedClasses(obfClasses, deobfClasses); | 261 | this.deobfuscator.getSeparatedClasses(obfClasses, deobfClasses); |
| 292 | m_gui.setObfClasses(obfClasses); | 262 | this.gui.setObfClasses(obfClasses); |
| 293 | m_gui.setDeobfClasses(deobfClasses); | 263 | this.gui.setDeobfClasses(deobfClasses); |
| 294 | } | 264 | } |
| 295 | 265 | ||
| 296 | private void refreshCurrentClass() { | 266 | private void refreshCurrentClass() { |
| @@ -298,29 +268,29 @@ public class GuiController { | |||
| 298 | } | 268 | } |
| 299 | 269 | ||
| 300 | private void refreshCurrentClass(EntryReference<Entry, Entry> obfReference) { | 270 | private void refreshCurrentClass(EntryReference<Entry, Entry> obfReference) { |
| 301 | if (m_currentObfClass != null) { | 271 | if (this.currentObfClass != null) { |
| 302 | deobfuscate(m_currentObfClass, obfReference); | 272 | deobfuscate(this.currentObfClass, obfReference); |
| 303 | } | 273 | } |
| 304 | } | 274 | } |
| 305 | 275 | ||
| 306 | private void deobfuscate(final ClassEntry classEntry, final EntryReference<Entry, Entry> obfReference) { | 276 | private void deobfuscate(final ClassEntry classEntry, final EntryReference<Entry, Entry> obfReference) { |
| 307 | 277 | ||
| 308 | m_gui.setSource("(deobfuscating...)"); | 278 | this.gui.setSource("(deobfuscating...)"); |
| 309 | 279 | ||
| 310 | // run the deobfuscator in a separate thread so we don't block the GUI event queue | 280 | // run the deobfuscator in a separate thread so we don't block the GUI event queue |
| 311 | new Thread() { | 281 | new Thread() { |
| 312 | @Override | 282 | @Override |
| 313 | public void run() { | 283 | public void run() { |
| 314 | // decompile,deobfuscate the bytecode | 284 | // decompile,deobfuscate the bytecode |
| 315 | CompilationUnit sourceTree = m_deobfuscator.getSourceTree(classEntry.getClassName()); | 285 | CompilationUnit sourceTree = deobfuscator.getSourceTree(classEntry.getClassName()); |
| 316 | if (sourceTree == null) { | 286 | if (sourceTree == null) { |
| 317 | // decompilation of this class is not supported | 287 | // decompilation of this class is not supported |
| 318 | m_gui.setSource("Unable to find class: " + classEntry); | 288 | gui.setSource("Unable to find class: " + classEntry); |
| 319 | return; | 289 | return; |
| 320 | } | 290 | } |
| 321 | String source = m_deobfuscator.getSource(sourceTree); | 291 | String source = deobfuscator.getSource(sourceTree); |
| 322 | m_index = m_deobfuscator.getSourceIndex(sourceTree, source); | 292 | index = deobfuscator.getSourceIndex(sourceTree, source); |
| 323 | m_gui.setSource(m_index.getSource()); | 293 | gui.setSource(index.getSource()); |
| 324 | if (obfReference != null) { | 294 | if (obfReference != null) { |
| 325 | showReference(obfReference); | 295 | showReference(obfReference); |
| 326 | } | 296 | } |
| @@ -329,8 +299,8 @@ public class GuiController { | |||
| 329 | List<Token> obfuscatedTokens = Lists.newArrayList(); | 299 | List<Token> obfuscatedTokens = Lists.newArrayList(); |
| 330 | List<Token> deobfuscatedTokens = Lists.newArrayList(); | 300 | List<Token> deobfuscatedTokens = Lists.newArrayList(); |
| 331 | List<Token> otherTokens = Lists.newArrayList(); | 301 | List<Token> otherTokens = Lists.newArrayList(); |
| 332 | for (Token token : m_index.referenceTokens()) { | 302 | for (Token token : index.referenceTokens()) { |
| 333 | EntryReference<Entry, Entry> reference = m_index.getDeobfReference(token); | 303 | EntryReference<Entry, Entry> reference = index.getDeobfReference(token); |
| 334 | if (referenceIsRenameable(reference)) { | 304 | if (referenceIsRenameable(reference)) { |
| 335 | if (entryHasDeobfuscatedName(reference.getNameableEntry())) { | 305 | if (entryHasDeobfuscatedName(reference.getNameableEntry())) { |
| 336 | deobfuscatedTokens.add(token); | 306 | deobfuscatedTokens.add(token); |
| @@ -341,7 +311,7 @@ public class GuiController { | |||
| 341 | otherTokens.add(token); | 311 | otherTokens.add(token); |
| 342 | } | 312 | } |
| 343 | } | 313 | } |
| 344 | m_gui.setHighlightedTokens(obfuscatedTokens, deobfuscatedTokens, otherTokens); | 314 | gui.setHighlightedTokens(obfuscatedTokens, deobfuscatedTokens, otherTokens); |
| 345 | } | 315 | } |
| 346 | }.start(); | 316 | }.start(); |
| 347 | } | 317 | } |