diff options
Diffstat (limited to 'src/cuchaz/enigma/bytecode/ClassRenamer.java')
| -rw-r--r-- | src/cuchaz/enigma/bytecode/ClassRenamer.java | 31 |
1 files changed, 6 insertions, 25 deletions
diff --git a/src/cuchaz/enigma/bytecode/ClassRenamer.java b/src/cuchaz/enigma/bytecode/ClassRenamer.java index 9f0845d..849a323 100644 --- a/src/cuchaz/enigma/bytecode/ClassRenamer.java +++ b/src/cuchaz/enigma/bytecode/ClassRenamer.java | |||
| @@ -37,34 +37,25 @@ public class ClassRenamer | |||
| 37 | { | 37 | { |
| 38 | nameMap.put( entry.getKey().getName(), entry.getValue().getName() ); | 38 | nameMap.put( entry.getKey().getName(), entry.getValue().getName() ); |
| 39 | } | 39 | } |
| 40 | |||
| 40 | c.replaceClassName( nameMap ); | 41 | c.replaceClassName( nameMap ); |
| 41 | 42 | ||
| 42 | // translate the names in the InnerClasses attribute | 43 | // replace simple names in the InnerClasses attribute too |
| 43 | ConstPool constants = c.getClassFile().getConstPool(); | 44 | ConstPool constants = c.getClassFile().getConstPool(); |
| 44 | InnerClassesAttribute attr = (InnerClassesAttribute)c.getClassFile().getAttribute( InnerClassesAttribute.tag ); | 45 | InnerClassesAttribute attr = (InnerClassesAttribute)c.getClassFile().getAttribute( InnerClassesAttribute.tag ); |
| 45 | if( attr != null ) | 46 | if( attr != null ) |
| 46 | { | 47 | { |
| 47 | for( int i=0; i<attr.tableLength(); i++ ) | 48 | for( int i=0; i<attr.tableLength(); i++ ) |
| 48 | { | 49 | { |
| 49 | ClassEntry inClassEntry = new ClassEntry( Descriptor.toJvmName( attr.innerClass( i ) ) ); | 50 | ClassEntry classEntry = new ClassEntry( Descriptor.toJvmName( attr.innerClass( i ) ) ); |
| 50 | ClassEntry outClassEntry = map.get( inClassEntry ); | ||
| 51 | if( outClassEntry == null ) | ||
| 52 | { | ||
| 53 | continue; | ||
| 54 | } | ||
| 55 | attr.setInnerClassIndex( i, constants.addClassInfo( outClassEntry.getName() ) ); | ||
| 56 | if( attr.outerClassIndex( i ) != 0 ) | ||
| 57 | { | ||
| 58 | attr.setOuterClassIndex( i, constants.addClassInfo( outClassEntry.getOuterClassName() ) ); | ||
| 59 | } | ||
| 60 | if( attr.innerNameIndex( i ) != 0 ) | 51 | if( attr.innerNameIndex( i ) != 0 ) |
| 61 | { | 52 | { |
| 62 | attr.setInnerNameIndex( i, constants.addUtf8Info( outClassEntry.getInnerClassName() ) ); | 53 | attr.setInnerNameIndex( i, constants.addUtf8Info( classEntry.getInnerClassName() ) ); |
| 63 | } | 54 | } |
| 64 | 55 | ||
| 65 | /* DEBUG | 56 | /* DEBUG |
| 66 | System.out.println( String.format( "\tOBF: %s DEOBF: %s-> ATTR: %s,%s,%s", | 57 | System.out.println( String.format( "\tDEOBF: %s-> ATTR: %s,%s,%s", |
| 67 | obfClassEntry, deobfClassEntry, | 58 | classEntry, |
| 68 | attr.outerClass( i ), | 59 | attr.outerClass( i ), |
| 69 | attr.innerClass( i ), | 60 | attr.innerClass( i ), |
| 70 | attr.innerName( i ) | 61 | attr.innerName( i ) |
| @@ -109,16 +100,6 @@ public class ClassRenamer | |||
| 109 | }; | 100 | }; |
| 110 | c.replaceClassName( map ); | 101 | c.replaceClassName( map ); |
| 111 | 102 | ||
| 112 | // also check InnerClassesAttribute | ||
| 113 | InnerClassesAttribute attr = (InnerClassesAttribute)c.getClassFile().getAttribute( InnerClassesAttribute.tag ); | ||
| 114 | if( attr != null ) | ||
| 115 | { | ||
| 116 | for( int i=0; i<attr.tableLength(); i++ ) | ||
| 117 | { | ||
| 118 | entries.add( new ClassEntry( Descriptor.toJvmName( attr.innerClass( i ) ) ) ); | ||
| 119 | } | ||
| 120 | } | ||
| 121 | |||
| 122 | return entries; | 103 | return entries; |
| 123 | } | 104 | } |
| 124 | 105 | ||