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