diff options
| author | 2014-08-10 22:13:01 -0400 | |
|---|---|---|
| committer | 2014-08-10 22:13:01 -0400 | |
| commit | 22b6c861df68557352fb5a87948f3e065f395ef3 (patch) | |
| tree | 98fc3de07b8a64a9466c42fc75adad25945bd482 /src | |
| parent | added go to entry feature (diff) | |
| download | enigma-22b6c861df68557352fb5a87948f3e065f395ef3.tar.gz enigma-22b6c861df68557352fb5a87948f3e065f395ef3.tar.xz enigma-22b6c861df68557352fb5a87948f3e065f395ef3.zip | |
refactored to remove ClassFile class to prep for upcoming stack navigation. It wasn't really necessary anymore.
Diffstat (limited to 'src')
| -rw-r--r-- | src/cuchaz/enigma/ClassFile.java | 41 | ||||
| -rw-r--r-- | src/cuchaz/enigma/Deobfuscator.java | 25 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/ClassInheritanceTreeNode.java | 2 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/ClassListCellRenderer.java (renamed from src/cuchaz/enigma/gui/ObfuscatedClassListCellRenderer.java) | 14 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/ClassSelectionListener.java | 18 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/DeobfuscatedClassListCellRenderer.java | 43 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/Gui.java | 63 | ||||
| -rw-r--r-- | src/cuchaz/enigma/gui/GuiController.java | 37 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/ArgumentEntry.java | 1 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/ClassEntry.java | 6 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/Entry.java | 1 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/FieldEntry.java | 1 | ||||
| -rw-r--r-- | src/cuchaz/enigma/mapping/MethodEntry.java | 1 |
13 files changed, 68 insertions, 185 deletions
diff --git a/src/cuchaz/enigma/ClassFile.java b/src/cuchaz/enigma/ClassFile.java deleted file mode 100644 index 043558d0..00000000 --- a/src/cuchaz/enigma/ClassFile.java +++ /dev/null | |||
| @@ -1,41 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma; | ||
| 12 | |||
| 13 | |||
| 14 | public class ClassFile | ||
| 15 | { | ||
| 16 | private String m_name; | ||
| 17 | |||
| 18 | public ClassFile( String name ) | ||
| 19 | { | ||
| 20 | if( name.indexOf( '.' ) >= 0 ) | ||
| 21 | { | ||
| 22 | throw new IllegalArgumentException( "Class name should be in JVM format!" ); | ||
| 23 | } | ||
| 24 | m_name = name; | ||
| 25 | } | ||
| 26 | |||
| 27 | public String getName( ) | ||
| 28 | { | ||
| 29 | return m_name; | ||
| 30 | } | ||
| 31 | |||
| 32 | public String getPath( ) | ||
| 33 | { | ||
| 34 | return m_name.replace( ".", "/" ) + ".class"; | ||
| 35 | } | ||
| 36 | |||
| 37 | public boolean isInPackage( ) | ||
| 38 | { | ||
| 39 | return m_name.indexOf( '/' ) >= 0; | ||
| 40 | } | ||
| 41 | } | ||
diff --git a/src/cuchaz/enigma/Deobfuscator.java b/src/cuchaz/enigma/Deobfuscator.java index 16c11d3f..8d4394cd 100644 --- a/src/cuchaz/enigma/Deobfuscator.java +++ b/src/cuchaz/enigma/Deobfuscator.java | |||
| @@ -17,7 +17,6 @@ import java.io.InputStream; | |||
| 17 | import java.io.StringWriter; | 17 | import java.io.StringWriter; |
| 18 | import java.util.Enumeration; | 18 | import java.util.Enumeration; |
| 19 | import java.util.List; | 19 | import java.util.List; |
| 20 | import java.util.Map; | ||
| 21 | import java.util.jar.JarEntry; | 20 | import java.util.jar.JarEntry; |
| 22 | import java.util.jar.JarFile; | 21 | import java.util.jar.JarFile; |
| 23 | 22 | ||
| @@ -139,43 +138,41 @@ public class Deobfuscator | |||
| 139 | return m_mappings.getTranslator( m_ancestries, direction ); | 138 | return m_mappings.getTranslator( m_ancestries, direction ); |
| 140 | } | 139 | } |
| 141 | 140 | ||
| 142 | public void getSeparatedClasses( List<ClassFile> obfClasses, Map<ClassFile,String> deobfClasses ) | 141 | public void getSeparatedClasses( List<String> obfClasses, List<String> deobfClasses ) |
| 143 | { | 142 | { |
| 144 | for( String obfClassName : m_obfClassNames ) | 143 | for( String obfClassName : m_obfClassNames ) |
| 145 | { | 144 | { |
| 146 | ClassFile classFile = new ClassFile( obfClassName ); | ||
| 147 | |||
| 148 | // separate the classes | 145 | // separate the classes |
| 149 | ClassMapping classMapping = m_mappings.getClassByObf( classFile.getName() ); | 146 | ClassMapping classMapping = m_mappings.getClassByObf( obfClassName ); |
| 150 | if( classMapping != null ) | 147 | if( classMapping != null ) |
| 151 | { | 148 | { |
| 152 | deobfClasses.put( classFile, classMapping.getDeobfName() ); | 149 | deobfClasses.add( classMapping.getDeobfName() ); |
| 153 | } | 150 | } |
| 154 | else if( classFile.isInPackage() ) | 151 | else if( obfClassName.indexOf( '/' ) >= 0 ) |
| 155 | { | 152 | { |
| 156 | deobfClasses.put( classFile, classFile.getName() ); | 153 | // this class is in a package and therefore is not obfuscated |
| 154 | deobfClasses.add( obfClassName ); | ||
| 157 | } | 155 | } |
| 158 | else | 156 | else |
| 159 | { | 157 | { |
| 160 | obfClasses.add( classFile ); | 158 | obfClasses.add( obfClassName ); |
| 161 | } | 159 | } |
| 162 | } | 160 | } |
| 163 | } | 161 | } |
| 164 | 162 | ||
| 165 | public SourceIndex getSource( final ClassFile classFile ) | 163 | public SourceIndex getSource( String className ) |
| 166 | { | 164 | { |
| 167 | // is this class deobfuscated? | 165 | // is this class deobfuscated? |
| 168 | // we need to tell the decompiler the deobfuscated name so it doesn't get freaked out | 166 | // we need to tell the decompiler the deobfuscated name so it doesn't get freaked out |
| 169 | // the decompiler only sees the deobfuscated class, so we need to load it by the deobfuscated name | 167 | // the decompiler only sees the deobfuscated class, so we need to load it by the deobfuscated name |
| 170 | String deobfName = classFile.getName(); | 168 | ClassMapping classMapping = m_mappings.getClassByObf( className ); |
| 171 | ClassMapping classMapping = m_mappings.getClassByObf( classFile.getName() ); | ||
| 172 | if( classMapping != null ) | 169 | if( classMapping != null ) |
| 173 | { | 170 | { |
| 174 | deobfName = classMapping.getDeobfName(); | 171 | className = classMapping.getDeobfName(); |
| 175 | } | 172 | } |
| 176 | 173 | ||
| 177 | // decompile it! | 174 | // decompile it! |
| 178 | TypeDefinition resolvedType = new MetadataSystem( m_settings.getTypeLoader() ).lookupType( deobfName ).resolve(); | 175 | TypeDefinition resolvedType = new MetadataSystem( m_settings.getTypeLoader() ).lookupType( className ).resolve(); |
| 179 | DecompilerContext context = new DecompilerContext(); | 176 | DecompilerContext context = new DecompilerContext(); |
| 180 | context.setCurrentType( resolvedType ); | 177 | context.setCurrentType( resolvedType ); |
| 181 | context.setSettings( m_settings ); | 178 | context.setSettings( m_settings ); |
diff --git a/src/cuchaz/enigma/gui/ClassInheritanceTreeNode.java b/src/cuchaz/enigma/gui/ClassInheritanceTreeNode.java index 61e582df..295bebe4 100644 --- a/src/cuchaz/enigma/gui/ClassInheritanceTreeNode.java +++ b/src/cuchaz/enigma/gui/ClassInheritanceTreeNode.java | |||
| @@ -62,7 +62,7 @@ public class ClassInheritanceTreeNode extends DefaultMutableTreeNode | |||
| 62 | nodes.add( new ClassInheritanceTreeNode( m_deobfuscatingTranslator, subclassName ) ); | 62 | nodes.add( new ClassInheritanceTreeNode( m_deobfuscatingTranslator, subclassName ) ); |
| 63 | } | 63 | } |
| 64 | 64 | ||
| 65 | // add then to this node | 65 | // add them to this node |
| 66 | for( ClassInheritanceTreeNode node : nodes ) | 66 | for( ClassInheritanceTreeNode node : nodes ) |
| 67 | { | 67 | { |
| 68 | this.add( node ); | 68 | this.add( node ); |
diff --git a/src/cuchaz/enigma/gui/ObfuscatedClassListCellRenderer.java b/src/cuchaz/enigma/gui/ClassListCellRenderer.java index d46e1ae6..d9d65788 100644 --- a/src/cuchaz/enigma/gui/ObfuscatedClassListCellRenderer.java +++ b/src/cuchaz/enigma/gui/ClassListCellRenderer.java | |||
| @@ -19,24 +19,20 @@ import javax.swing.JLabel; | |||
| 19 | import javax.swing.JList; | 19 | import javax.swing.JList; |
| 20 | import javax.swing.ListCellRenderer; | 20 | import javax.swing.ListCellRenderer; |
| 21 | 21 | ||
| 22 | import cuchaz.enigma.ClassFile; | 22 | public class ClassListCellRenderer implements ListCellRenderer<String> |
| 23 | |||
| 24 | public class ObfuscatedClassListCellRenderer implements ListCellRenderer<ClassFile> | ||
| 25 | { | 23 | { |
| 26 | private DefaultListCellRenderer m_defaultRenderer; | 24 | private DefaultListCellRenderer m_defaultRenderer; |
| 27 | 25 | ||
| 28 | public ObfuscatedClassListCellRenderer( ) | 26 | public ClassListCellRenderer( ) |
| 29 | { | 27 | { |
| 30 | m_defaultRenderer = new DefaultListCellRenderer(); | 28 | m_defaultRenderer = new DefaultListCellRenderer(); |
| 31 | } | 29 | } |
| 32 | 30 | ||
| 33 | @Override | 31 | @Override |
| 34 | public Component getListCellRendererComponent( JList<? extends ClassFile> list, ClassFile classFile, int index, boolean isSelected, boolean hasFocus ) | 32 | public Component getListCellRendererComponent( JList<? extends String> list, String className, int index, boolean isSelected, boolean hasFocus ) |
| 35 | { | 33 | { |
| 36 | JLabel label = (JLabel)m_defaultRenderer.getListCellRendererComponent( list, classFile, index, isSelected, hasFocus ); | 34 | JLabel label = (JLabel)m_defaultRenderer.getListCellRendererComponent( list, className, index, isSelected, hasFocus ); |
| 37 | 35 | label.setText( Descriptor.toJavaName( className ) ); | |
| 38 | label.setText( Descriptor.toJavaName( classFile.getName() ) ); | ||
| 39 | |||
| 40 | return label; | 36 | return label; |
| 41 | } | 37 | } |
| 42 | } | 38 | } |
diff --git a/src/cuchaz/enigma/gui/ClassSelectionListener.java b/src/cuchaz/enigma/gui/ClassSelectionListener.java deleted file mode 100644 index 4a2aa8d0..00000000 --- a/src/cuchaz/enigma/gui/ClassSelectionListener.java +++ /dev/null | |||
| @@ -1,18 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.gui; | ||
| 12 | |||
| 13 | import cuchaz.enigma.ClassFile; | ||
| 14 | |||
| 15 | public interface ClassSelectionListener | ||
| 16 | { | ||
| 17 | void classSelected( ClassFile classFile ); | ||
| 18 | } | ||
diff --git a/src/cuchaz/enigma/gui/DeobfuscatedClassListCellRenderer.java b/src/cuchaz/enigma/gui/DeobfuscatedClassListCellRenderer.java deleted file mode 100644 index 3a8729d2..00000000 --- a/src/cuchaz/enigma/gui/DeobfuscatedClassListCellRenderer.java +++ /dev/null | |||
| @@ -1,43 +0,0 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2014 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Public License v3.0 | ||
| 5 | * which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/gpl.html | ||
| 7 | * | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | package cuchaz.enigma.gui; | ||
| 12 | |||
| 13 | import java.awt.Component; | ||
| 14 | import java.util.Map; | ||
| 15 | |||
| 16 | import javassist.bytecode.Descriptor; | ||
| 17 | |||
| 18 | import javax.swing.DefaultListCellRenderer; | ||
| 19 | import javax.swing.JLabel; | ||
| 20 | import javax.swing.JList; | ||
| 21 | import javax.swing.ListCellRenderer; | ||
| 22 | |||
| 23 | import cuchaz.enigma.ClassFile; | ||
| 24 | |||
| 25 | public class DeobfuscatedClassListCellRenderer implements ListCellRenderer<Map.Entry<ClassFile,String>> | ||
| 26 | { | ||
| 27 | private DefaultListCellRenderer m_defaultRenderer; | ||
| 28 | |||
| 29 | public DeobfuscatedClassListCellRenderer( ) | ||
| 30 | { | ||
| 31 | m_defaultRenderer = new DefaultListCellRenderer(); | ||
| 32 | } | ||
| 33 | |||
| 34 | @Override | ||
| 35 | public Component getListCellRendererComponent( JList<? extends Map.Entry<ClassFile,String>> list, Map.Entry<ClassFile,String> entry, int index, boolean isSelected, boolean hasFocus ) | ||
| 36 | { | ||
| 37 | JLabel label = (JLabel)m_defaultRenderer.getListCellRendererComponent( list, entry, index, isSelected, hasFocus ); | ||
| 38 | |||
| 39 | label.setText( Descriptor.toJavaName( entry.getValue() ) ); | ||
| 40 | |||
| 41 | return label; | ||
| 42 | } | ||
| 43 | } | ||
diff --git a/src/cuchaz/enigma/gui/Gui.java b/src/cuchaz/enigma/gui/Gui.java index bf72c85d..6666b4c4 100644 --- a/src/cuchaz/enigma/gui/Gui.java +++ b/src/cuchaz/enigma/gui/Gui.java | |||
| @@ -31,7 +31,6 @@ import java.io.IOException; | |||
| 31 | import java.util.Collections; | 31 | import java.util.Collections; |
| 32 | import java.util.Comparator; | 32 | import java.util.Comparator; |
| 33 | import java.util.List; | 33 | import java.util.List; |
| 34 | import java.util.Map; | ||
| 35 | import java.util.Vector; | 34 | import java.util.Vector; |
| 36 | 35 | ||
| 37 | import javax.swing.BorderFactory; | 36 | import javax.swing.BorderFactory; |
| @@ -66,7 +65,6 @@ import jsyntaxpane.DefaultSyntaxKit; | |||
| 66 | 65 | ||
| 67 | import com.google.common.collect.Lists; | 66 | import com.google.common.collect.Lists; |
| 68 | 67 | ||
| 69 | import cuchaz.enigma.ClassFile; | ||
| 70 | import cuchaz.enigma.Constants; | 68 | import cuchaz.enigma.Constants; |
| 71 | import cuchaz.enigma.analysis.Token; | 69 | import cuchaz.enigma.analysis.Token; |
| 72 | import cuchaz.enigma.mapping.ArgumentEntry; | 70 | import cuchaz.enigma.mapping.ArgumentEntry; |
| @@ -79,35 +77,34 @@ import cuchaz.enigma.mapping.MethodEntry; | |||
| 79 | 77 | ||
| 80 | public class Gui | 78 | public class Gui |
| 81 | { | 79 | { |
| 82 | private static Comparator<ClassFile> m_obfuscatedClassSorter; | 80 | private static Comparator<String> m_obfClassSorter; |
| 83 | private static Comparator<Map.Entry<ClassFile,String>> m_deobfuscatedClassSorter; | 81 | private static Comparator<String> m_deobfClassSorter; |
| 84 | 82 | ||
| 85 | static | 83 | static |
| 86 | { | 84 | { |
| 87 | m_obfuscatedClassSorter = new Comparator<ClassFile>( ) | 85 | m_obfClassSorter = new Comparator<String>( ) |
| 88 | { | 86 | { |
| 89 | @Override | 87 | @Override |
| 90 | public int compare( ClassFile a, ClassFile b ) | 88 | public int compare( String a, String b ) |
| 91 | { | 89 | { |
| 92 | if( a.getName().length() != b.getName().length() ) | 90 | if( a.length() != b.length() ) |
| 93 | { | 91 | { |
| 94 | return a.getName().length() - b.getName().length(); | 92 | return a.length() - b.length(); |
| 95 | } | 93 | } |
| 96 | 94 | return a.compareTo( b ); | |
| 97 | return a.getName().compareTo( b.getName() ); | ||
| 98 | } | 95 | } |
| 99 | }; | 96 | }; |
| 100 | 97 | ||
| 101 | m_deobfuscatedClassSorter = new Comparator<Map.Entry<ClassFile,String>>( ) | 98 | m_deobfClassSorter = new Comparator<String>( ) |
| 102 | { | 99 | { |
| 103 | @Override | 100 | @Override |
| 104 | public int compare( Map.Entry<ClassFile,String> a, Map.Entry<ClassFile,String> b ) | 101 | public int compare( String a, String b ) |
| 105 | { | 102 | { |
| 106 | // I can never keep this rule straight when writing these damn things... | 103 | // I can never keep this rule straight when writing these damn things... |
| 107 | // a < b => -1, a == b => 0, a > b => +1 | 104 | // a < b => -1, a == b => 0, a > b => +1 |
| 108 | 105 | ||
| 109 | String[] aparts = a.getValue().split( "\\." ); | 106 | String[] aparts = a.split( "\\." ); |
| 110 | String[] bparts = b.getValue().split( "\\." ); | 107 | String[] bparts = b.split( "\\." ); |
| 111 | for( int i=0; true; i++ ) | 108 | for( int i=0; true; i++ ) |
| 112 | { | 109 | { |
| 113 | if( i >= aparts.length ) | 110 | if( i >= aparts.length ) |
| @@ -133,8 +130,8 @@ public class Gui | |||
| 133 | 130 | ||
| 134 | // controls | 131 | // controls |
| 135 | private JFrame m_frame; | 132 | private JFrame m_frame; |
| 136 | private JList<ClassFile> m_obfClasses; | 133 | private JList<String> m_obfClasses; |
| 137 | private JList<Map.Entry<ClassFile,String>> m_deobfClasses; | 134 | private JList<String> m_deobfClasses; |
| 138 | private JEditorPane m_editor; | 135 | private JEditorPane m_editor; |
| 139 | private JPanel m_infoPanel; | 136 | private JPanel m_infoPanel; |
| 140 | private BoxHighlightPainter m_obfuscatedHighlightPainter; | 137 | private BoxHighlightPainter m_obfuscatedHighlightPainter; |
| @@ -170,10 +167,10 @@ public class Gui | |||
| 170 | pane.setLayout( new BorderLayout() ); | 167 | pane.setLayout( new BorderLayout() ); |
| 171 | 168 | ||
| 172 | // init obfuscated classes list | 169 | // init obfuscated classes list |
| 173 | m_obfClasses = new JList<ClassFile>(); | 170 | m_obfClasses = new JList<String>(); |
| 174 | m_obfClasses.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); | 171 | m_obfClasses.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); |
| 175 | m_obfClasses.setLayoutOrientation( JList.VERTICAL ); | 172 | m_obfClasses.setLayoutOrientation( JList.VERTICAL ); |
| 176 | m_obfClasses.setCellRenderer( new ObfuscatedClassListCellRenderer() ); | 173 | m_obfClasses.setCellRenderer( new ClassListCellRenderer() ); |
| 177 | m_obfClasses.addMouseListener( new MouseAdapter() | 174 | m_obfClasses.addMouseListener( new MouseAdapter() |
| 178 | { | 175 | { |
| 179 | @Override | 176 | @Override |
| @@ -181,10 +178,10 @@ public class Gui | |||
| 181 | { | 178 | { |
| 182 | if( event.getClickCount() == 2 ) | 179 | if( event.getClickCount() == 2 ) |
| 183 | { | 180 | { |
| 184 | ClassFile selected = m_obfClasses.getSelectedValue(); | 181 | String selected = m_obfClasses.getSelectedValue(); |
| 185 | if( selected != null ) | 182 | if( selected != null ) |
| 186 | { | 183 | { |
| 187 | m_controller.deobfuscateClass( selected ); | 184 | m_controller.openEntry( new ClassEntry( selected ) ); |
| 188 | } | 185 | } |
| 189 | } | 186 | } |
| 190 | } | 187 | } |
| @@ -196,10 +193,10 @@ public class Gui | |||
| 196 | obfPanel.add( obfScroller, BorderLayout.CENTER ); | 193 | obfPanel.add( obfScroller, BorderLayout.CENTER ); |
| 197 | 194 | ||
| 198 | // init deobfuscated classes list | 195 | // init deobfuscated classes list |
| 199 | m_deobfClasses = new JList<Map.Entry<ClassFile,String>>(); | 196 | m_deobfClasses = new JList<String>(); |
| 200 | m_deobfClasses.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); | 197 | m_deobfClasses.setSelectionMode( ListSelectionModel.SINGLE_SELECTION ); |
| 201 | m_deobfClasses.setLayoutOrientation( JList.VERTICAL ); | 198 | m_deobfClasses.setLayoutOrientation( JList.VERTICAL ); |
| 202 | m_deobfClasses.setCellRenderer( new DeobfuscatedClassListCellRenderer() ); | 199 | m_deobfClasses.setCellRenderer( new ClassListCellRenderer() ); |
| 203 | m_deobfClasses.addMouseListener( new MouseAdapter() | 200 | m_deobfClasses.addMouseListener( new MouseAdapter() |
| 204 | { | 201 | { |
| 205 | @Override | 202 | @Override |
| @@ -207,10 +204,10 @@ public class Gui | |||
| 207 | { | 204 | { |
| 208 | if( event.getClickCount() == 2 ) | 205 | if( event.getClickCount() == 2 ) |
| 209 | { | 206 | { |
| 210 | Map.Entry<ClassFile,String> selected = m_deobfClasses.getSelectedValue(); | 207 | String selected = m_deobfClasses.getSelectedValue(); |
| 211 | if( selected != null ) | 208 | if( selected != null ) |
| 212 | { | 209 | { |
| 213 | m_controller.deobfuscateClass( selected.getKey() ); | 210 | m_controller.openEntry( new ClassEntry( selected ) ); |
| 214 | } | 211 | } |
| 215 | } | 212 | } |
| 216 | } | 213 | } |
| @@ -330,7 +327,7 @@ public class Gui | |||
| 330 | ClassInheritanceTreeNode node = (ClassInheritanceTreeNode)m_inheritanceTree.getSelectionPath().getLastPathComponent(); | 327 | ClassInheritanceTreeNode node = (ClassInheritanceTreeNode)m_inheritanceTree.getSelectionPath().getLastPathComponent(); |
| 331 | if( node != null ) | 328 | if( node != null ) |
| 332 | { | 329 | { |
| 333 | m_controller.deobfuscateClass( new ClassFile( node.getObfClassName() ) ); | 330 | m_controller.openEntry( new ClassEntry( node.getDeobfClassName() ) ); |
| 334 | } | 331 | } |
| 335 | } | 332 | } |
| 336 | } | 333 | } |
| @@ -566,31 +563,31 @@ public class Gui | |||
| 566 | m_closeMappingsMenu.setEnabled( false ); | 563 | m_closeMappingsMenu.setEnabled( false ); |
| 567 | } | 564 | } |
| 568 | 565 | ||
| 569 | public void setObfClasses( List<ClassFile> obfClasses ) | 566 | public void setObfClasses( List<String> obfClasses ) |
| 570 | { | 567 | { |
| 571 | if( obfClasses != null ) | 568 | if( obfClasses != null ) |
| 572 | { | 569 | { |
| 573 | Vector<ClassFile> sortedClasses = new Vector<ClassFile>( obfClasses ); | 570 | Vector<String> sortedClasses = new Vector<String>( obfClasses ); |
| 574 | Collections.sort( sortedClasses, m_obfuscatedClassSorter ); | 571 | Collections.sort( sortedClasses, m_obfClassSorter ); |
| 575 | m_obfClasses.setListData( sortedClasses ); | 572 | m_obfClasses.setListData( sortedClasses ); |
| 576 | } | 573 | } |
| 577 | else | 574 | else |
| 578 | { | 575 | { |
| 579 | m_obfClasses.setListData( new Vector<ClassFile>() ); | 576 | m_obfClasses.setListData( new Vector<String>() ); |
| 580 | } | 577 | } |
| 581 | } | 578 | } |
| 582 | 579 | ||
| 583 | public void setDeobfClasses( Map<ClassFile,String> deobfClasses ) | 580 | public void setDeobfClasses( List<String> deobfClasses ) |
| 584 | { | 581 | { |
| 585 | if( deobfClasses != null ) | 582 | if( deobfClasses != null ) |
| 586 | { | 583 | { |
| 587 | Vector<Map.Entry<ClassFile,String>> sortedClasses = new Vector<Map.Entry<ClassFile,String>>( deobfClasses.entrySet() ); | 584 | Vector<String> sortedClasses = new Vector<String>( deobfClasses ); |
| 588 | Collections.sort( sortedClasses, m_deobfuscatedClassSorter ); | 585 | Collections.sort( sortedClasses, m_deobfClassSorter ); |
| 589 | m_deobfClasses.setListData( sortedClasses ); | 586 | m_deobfClasses.setListData( sortedClasses ); |
| 590 | } | 587 | } |
| 591 | else | 588 | else |
| 592 | { | 589 | { |
| 593 | m_deobfClasses.setListData( new Vector<Map.Entry<ClassFile,String>>() ); | 590 | m_deobfClasses.setListData( new Vector<String>() ); |
| 594 | } | 591 | } |
| 595 | } | 592 | } |
| 596 | 593 | ||
diff --git a/src/cuchaz/enigma/gui/GuiController.java b/src/cuchaz/enigma/gui/GuiController.java index 834afecc..6a7a7da6 100644 --- a/src/cuchaz/enigma/gui/GuiController.java +++ b/src/cuchaz/enigma/gui/GuiController.java | |||
| @@ -15,12 +15,9 @@ import java.io.FileReader; | |||
| 15 | import java.io.FileWriter; | 15 | import java.io.FileWriter; |
| 16 | import java.io.IOException; | 16 | import java.io.IOException; |
| 17 | import java.util.List; | 17 | import java.util.List; |
| 18 | import java.util.Map; | ||
| 19 | 18 | ||
| 20 | import com.google.common.collect.Lists; | 19 | import com.google.common.collect.Lists; |
| 21 | import com.google.common.collect.Maps; | ||
| 22 | 20 | ||
| 23 | import cuchaz.enigma.ClassFile; | ||
| 24 | import cuchaz.enigma.Deobfuscator; | 21 | import cuchaz.enigma.Deobfuscator; |
| 25 | import cuchaz.enigma.analysis.SourceIndex; | 22 | import cuchaz.enigma.analysis.SourceIndex; |
| 26 | import cuchaz.enigma.analysis.Token; | 23 | import cuchaz.enigma.analysis.Token; |
| @@ -37,7 +34,7 @@ public class GuiController | |||
| 37 | private Deobfuscator m_deobfuscator; | 34 | private Deobfuscator m_deobfuscator; |
| 38 | private Gui m_gui; | 35 | private Gui m_gui; |
| 39 | private SourceIndex m_index; | 36 | private SourceIndex m_index; |
| 40 | private ClassFile m_currentFile; | 37 | private ClassEntry m_currentClass; |
| 41 | private boolean m_isDirty; | 38 | private boolean m_isDirty; |
| 42 | 39 | ||
| 43 | public GuiController( Gui gui ) | 40 | public GuiController( Gui gui ) |
| @@ -45,7 +42,7 @@ public class GuiController | |||
| 45 | m_gui = gui; | 42 | m_gui = gui; |
| 46 | m_deobfuscator = null; | 43 | m_deobfuscator = null; |
| 47 | m_index = null; | 44 | m_index = null; |
| 48 | m_currentFile = null; | 45 | m_currentClass = null; |
| 49 | m_isDirty = false; | 46 | m_isDirty = false; |
| 50 | } | 47 | } |
| 51 | 48 | ||
| @@ -97,12 +94,6 @@ public class GuiController | |||
| 97 | refreshCurrentClass(); | 94 | refreshCurrentClass(); |
| 98 | } | 95 | } |
| 99 | 96 | ||
| 100 | public void deobfuscateClass( ClassFile classFile ) | ||
| 101 | { | ||
| 102 | m_currentFile = classFile; | ||
| 103 | deobfuscate( m_currentFile ); | ||
| 104 | } | ||
| 105 | |||
| 106 | public Token getToken( int pos ) | 97 | public Token getToken( int pos ) |
| 107 | { | 98 | { |
| 108 | if( m_index == null ) | 99 | if( m_index == null ) |
| @@ -168,10 +159,10 @@ public class GuiController | |||
| 168 | public void openEntry( Entry obfEntry ) | 159 | public void openEntry( Entry obfEntry ) |
| 169 | { | 160 | { |
| 170 | Entry deobfEntry = m_deobfuscator.deobfuscateEntry( obfEntry ); | 161 | Entry deobfEntry = m_deobfuscator.deobfuscateEntry( obfEntry ); |
| 171 | if( !m_currentFile.getName().equals( obfEntry.getClassName() ) ) | 162 | if( m_currentClass == null || !m_currentClass.equals( deobfEntry.getClassEntry() ) ) |
| 172 | { | 163 | { |
| 173 | m_currentFile = new ClassFile( obfEntry.getClassName() ); | 164 | m_currentClass = new ClassEntry( obfEntry.getClassEntry() ); |
| 174 | deobfuscate( m_currentFile, deobfEntry ); | 165 | deobfuscate( m_currentClass, deobfEntry ); |
| 175 | } | 166 | } |
| 176 | else | 167 | else |
| 177 | { | 168 | { |
| @@ -181,8 +172,8 @@ public class GuiController | |||
| 181 | 172 | ||
| 182 | private void refreshClasses( ) | 173 | private void refreshClasses( ) |
| 183 | { | 174 | { |
| 184 | List<ClassFile> obfClasses = Lists.newArrayList(); | 175 | List<String> obfClasses = Lists.newArrayList(); |
| 185 | Map<ClassFile,String> deobfClasses = Maps.newHashMap(); | 176 | List<String> deobfClasses = Lists.newArrayList(); |
| 186 | m_deobfuscator.getSeparatedClasses( obfClasses, deobfClasses ); | 177 | m_deobfuscator.getSeparatedClasses( obfClasses, deobfClasses ); |
| 187 | m_gui.setObfClasses( obfClasses ); | 178 | m_gui.setObfClasses( obfClasses ); |
| 188 | m_gui.setDeobfClasses( deobfClasses ); | 179 | m_gui.setDeobfClasses( deobfClasses ); |
| @@ -195,20 +186,14 @@ public class GuiController | |||
| 195 | 186 | ||
| 196 | private void refreshCurrentClass( Entry entryToShow ) | 187 | private void refreshCurrentClass( Entry entryToShow ) |
| 197 | { | 188 | { |
| 198 | if( m_currentFile != null ) | 189 | if( m_currentClass != null ) |
| 199 | { | 190 | { |
| 200 | deobfuscate( m_currentFile, entryToShow ); | 191 | deobfuscate( m_currentClass, entryToShow ); |
| 201 | } | 192 | } |
| 202 | } | 193 | } |
| 203 | |||
| 204 | private void deobfuscate( final ClassFile classFile ) | ||
| 205 | { | ||
| 206 | deobfuscate( classFile, null ); | ||
| 207 | } | ||
| 208 | 194 | ||
| 209 | private void deobfuscate( final ClassFile classFile, final Entry entryToShow ) | 195 | private void deobfuscate( final ClassEntry classEntry, final Entry entryToShow ) |
| 210 | { | 196 | { |
| 211 | m_currentFile = classFile; | ||
| 212 | m_gui.setSource( "(deobfuscating...)" ); | 197 | m_gui.setSource( "(deobfuscating...)" ); |
| 213 | 198 | ||
| 214 | // run the deobfuscator in a separate thread so we don't block the GUI event queue | 199 | // run the deobfuscator in a separate thread so we don't block the GUI event queue |
| @@ -218,7 +203,7 @@ public class GuiController | |||
| 218 | public void run( ) | 203 | public void run( ) |
| 219 | { | 204 | { |
| 220 | // decompile,deobfuscate the bytecode | 205 | // decompile,deobfuscate the bytecode |
| 221 | m_index = m_deobfuscator.getSource( classFile ); | 206 | m_index = m_deobfuscator.getSource( classEntry.getClassName() ); |
| 222 | m_gui.setSource( m_index.getSource() ); | 207 | m_gui.setSource( m_index.getSource() ); |
| 223 | if( entryToShow != null ) | 208 | if( entryToShow != null ) |
| 224 | { | 209 | { |
diff --git a/src/cuchaz/enigma/mapping/ArgumentEntry.java b/src/cuchaz/enigma/mapping/ArgumentEntry.java index 0c25c4d3..27dcc41d 100644 --- a/src/cuchaz/enigma/mapping/ArgumentEntry.java +++ b/src/cuchaz/enigma/mapping/ArgumentEntry.java | |||
| @@ -65,6 +65,7 @@ public class ArgumentEntry implements Entry, Serializable | |||
| 65 | return m_name; | 65 | return m_name; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | @Override | ||
| 68 | public ClassEntry getClassEntry( ) | 69 | public ClassEntry getClassEntry( ) |
| 69 | { | 70 | { |
| 70 | return m_methodEntry.getClassEntry(); | 71 | return m_methodEntry.getClassEntry(); |
diff --git a/src/cuchaz/enigma/mapping/ClassEntry.java b/src/cuchaz/enigma/mapping/ClassEntry.java index 513862d9..738e8e3b 100644 --- a/src/cuchaz/enigma/mapping/ClassEntry.java +++ b/src/cuchaz/enigma/mapping/ClassEntry.java | |||
| @@ -37,6 +37,12 @@ public class ClassEntry implements Entry, Serializable | |||
| 37 | { | 37 | { |
| 38 | m_name = other.m_name; | 38 | m_name = other.m_name; |
| 39 | } | 39 | } |
| 40 | |||
| 41 | @Override | ||
| 42 | public ClassEntry getClassEntry( ) | ||
| 43 | { | ||
| 44 | return this; | ||
| 45 | } | ||
| 40 | 46 | ||
| 41 | @Override | 47 | @Override |
| 42 | public String getName( ) | 48 | public String getName( ) |
diff --git a/src/cuchaz/enigma/mapping/Entry.java b/src/cuchaz/enigma/mapping/Entry.java index 3ff80276..e1591f02 100644 --- a/src/cuchaz/enigma/mapping/Entry.java +++ b/src/cuchaz/enigma/mapping/Entry.java | |||
| @@ -14,4 +14,5 @@ public interface Entry | |||
| 14 | { | 14 | { |
| 15 | String getName( ); | 15 | String getName( ); |
| 16 | String getClassName( ); | 16 | String getClassName( ); |
| 17 | ClassEntry getClassEntry( ); | ||
| 17 | } | 18 | } |
diff --git a/src/cuchaz/enigma/mapping/FieldEntry.java b/src/cuchaz/enigma/mapping/FieldEntry.java index 6148c84a..435490bd 100644 --- a/src/cuchaz/enigma/mapping/FieldEntry.java +++ b/src/cuchaz/enigma/mapping/FieldEntry.java | |||
| @@ -49,6 +49,7 @@ public class FieldEntry implements Entry, Serializable | |||
| 49 | m_name = other.m_name; | 49 | m_name = other.m_name; |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | @Override | ||
| 52 | public ClassEntry getClassEntry( ) | 53 | public ClassEntry getClassEntry( ) |
| 53 | { | 54 | { |
| 54 | return m_classEntry; | 55 | return m_classEntry; |
diff --git a/src/cuchaz/enigma/mapping/MethodEntry.java b/src/cuchaz/enigma/mapping/MethodEntry.java index ff232c59..b4b9c9bf 100644 --- a/src/cuchaz/enigma/mapping/MethodEntry.java +++ b/src/cuchaz/enigma/mapping/MethodEntry.java | |||
| @@ -56,6 +56,7 @@ public class MethodEntry implements Entry, Serializable | |||
| 56 | m_signature = other.m_signature; | 56 | m_signature = other.m_signature; |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | @Override | ||
| 59 | public ClassEntry getClassEntry( ) | 60 | public ClassEntry getClassEntry( ) |
| 60 | { | 61 | { |
| 61 | return m_classEntry; | 62 | return m_classEntry; |