diff options
Diffstat (limited to 'src/cuchaz/enigma/ConvertMain.java')
| -rw-r--r-- | src/cuchaz/enigma/ConvertMain.java | 50 |
1 files changed, 39 insertions, 11 deletions
diff --git a/src/cuchaz/enigma/ConvertMain.java b/src/cuchaz/enigma/ConvertMain.java index c3a2ad5..15658d9 100644 --- a/src/cuchaz/enigma/ConvertMain.java +++ b/src/cuchaz/enigma/ConvertMain.java | |||
| @@ -49,15 +49,10 @@ public class ConvertMain { | |||
| 49 | 49 | ||
| 50 | // match methods/constructors | 50 | // match methods/constructors |
| 51 | //computeMethodMatches(methodMatchesFile, destJar, outMappingsFile, classMatchesFile); | 51 | //computeMethodMatches(methodMatchesFile, destJar, outMappingsFile, classMatchesFile); |
| 52 | editMethodMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, methodMatchesFile); | 52 | //editMethodMatches(sourceJar, destJar, outMappingsFile, mappings, classMatchesFile, methodMatchesFile); |
| 53 | 53 | ||
| 54 | /* TODO | 54 | // write final converted mappings |
| 55 | // write out the converted mappings | 55 | writeFinalMappings(outMappingsFile, sourceJar, destJar, mappings, classMatchesFile, fieldMatchesFile, methodMatchesFile); |
| 56 | FileWriter writer = new FileWriter(outMappingsFile); | ||
| 57 | new MappingsWriter().write(writer, mappings); | ||
| 58 | writer.close(); | ||
| 59 | System.out.println("Wrote converted mappings to:\n\t" + outMappingsFile.getAbsolutePath()); | ||
| 60 | */ | ||
| 61 | } | 56 | } |
| 62 | 57 | ||
| 63 | private static void computeClassMatches(File classMatchesFile, JarFile sourceJar, JarFile destJar, Mappings mappings) | 58 | private static void computeClassMatches(File classMatchesFile, JarFile sourceJar, JarFile destJar, Mappings mappings) |
| @@ -93,7 +88,7 @@ public class ConvertMain { | |||
| 93 | Deobfuscators deobfuscators = new Deobfuscators(sourceJar, destJar); | 88 | Deobfuscators deobfuscators = new Deobfuscators(sourceJar, destJar); |
| 94 | deobfuscators.source.setMappings(mappings); | 89 | deobfuscators.source.setMappings(mappings); |
| 95 | 90 | ||
| 96 | Mappings newMappings = MappingsConverter.newMappings(classMatches, mappings, deobfuscators.source, deobfuscators.source); | 91 | Mappings newMappings = MappingsConverter.newMappings(classMatches, mappings, deobfuscators.source, deobfuscators.dest); |
| 97 | 92 | ||
| 98 | try (FileWriter out = new FileWriter(outMappingsFile)) { | 93 | try (FileWriter out = new FileWriter(outMappingsFile)) { |
| 99 | new MappingsWriter().write(out, newMappings); | 94 | new MappingsWriter().write(out, newMappings); |
| @@ -114,7 +109,12 @@ public class ConvertMain { | |||
| 114 | System.out.println("Writing matches..."); | 109 | System.out.println("Writing matches..."); |
| 115 | 110 | ||
| 116 | // get the matched and unmatched mappings | 111 | // get the matched and unmatched mappings |
| 117 | MemberMatches<FieldEntry> fieldMatches = MappingsConverter.computeFieldMatches(destDeobfuscator, destMappings, classMatches); | 112 | MemberMatches<FieldEntry> fieldMatches = MappingsConverter.computeMemberMatches( |
| 113 | destDeobfuscator, | ||
| 114 | destMappings, | ||
| 115 | classMatches, | ||
| 116 | MappingsConverter.getFieldDoer() | ||
| 117 | ); | ||
| 118 | 118 | ||
| 119 | MatchesWriter.writeMembers(fieldMatches, memberMatchesFile); | 119 | MatchesWriter.writeMembers(fieldMatches, memberMatchesFile); |
| 120 | System.out.println("Wrote:\n\t" + memberMatchesFile.getAbsolutePath()); | 120 | System.out.println("Wrote:\n\t" + memberMatchesFile.getAbsolutePath()); |
| @@ -160,7 +160,12 @@ public class ConvertMain { | |||
| 160 | System.out.println("Writing method matches..."); | 160 | System.out.println("Writing method matches..."); |
| 161 | 161 | ||
| 162 | // get the matched and unmatched mappings | 162 | // get the matched and unmatched mappings |
| 163 | MemberMatches<BehaviorEntry> methodMatches = MappingsConverter.computeBehaviorMatches(destDeobfuscator, destMappings, classMatches); | 163 | MemberMatches<BehaviorEntry> methodMatches = MappingsConverter.computeMemberMatches( |
| 164 | destDeobfuscator, | ||
| 165 | destMappings, | ||
| 166 | classMatches, | ||
| 167 | MappingsConverter.getMethodDoer() | ||
| 168 | ); | ||
| 164 | 169 | ||
| 165 | MatchesWriter.writeMembers(methodMatches, methodMatchesFile); | 170 | MatchesWriter.writeMembers(methodMatches, methodMatchesFile); |
| 166 | System.out.println("Wrote:\n\t" + methodMatchesFile.getAbsolutePath()); | 171 | System.out.println("Wrote:\n\t" + methodMatchesFile.getAbsolutePath()); |
| @@ -192,6 +197,29 @@ public class ConvertMain { | |||
| 192 | } | 197 | } |
| 193 | }); | 198 | }); |
| 194 | } | 199 | } |
| 200 | |||
| 201 | private static void writeFinalMappings(File outMappingsFile, JarFile sourceJar, JarFile destJar, Mappings mappings, File classMatchesFile, File fieldMatchesFile, File methodMatchesFile) | ||
| 202 | throws IOException { | ||
| 203 | |||
| 204 | System.out.println("Reading matches..."); | ||
| 205 | ClassMatches classMatches = MatchesReader.readClasses(classMatchesFile); | ||
| 206 | MemberMatches<FieldEntry> fieldMatches = MatchesReader.readMembers(fieldMatchesFile); | ||
| 207 | MemberMatches<BehaviorEntry> methodMatches = MatchesReader.readMembers(methodMatchesFile); | ||
| 208 | |||
| 209 | Deobfuscators deobfuscators = new Deobfuscators(sourceJar, destJar); | ||
| 210 | deobfuscators.source.setMappings(mappings); | ||
| 211 | |||
| 212 | // apply matches | ||
| 213 | Mappings newMappings = MappingsConverter.newMappings(classMatches, mappings, deobfuscators.source, deobfuscators.dest); | ||
| 214 | MappingsConverter.applyMemberMatches(newMappings, fieldMatches, MappingsConverter.getFieldDoer()); | ||
| 215 | MappingsConverter.applyMemberMatches(newMappings, methodMatches, MappingsConverter.getMethodDoer()); | ||
| 216 | |||
| 217 | // write out the converted mappings | ||
| 218 | try (FileWriter out = new FileWriter(outMappingsFile)) { | ||
| 219 | new MappingsWriter().write(out, newMappings); | ||
| 220 | } | ||
| 221 | System.out.println("Wrote converted mappings to:\n\t" + outMappingsFile.getAbsolutePath()); | ||
| 222 | } | ||
| 195 | 223 | ||
| 196 | private static class Deobfuscators { | 224 | private static class Deobfuscators { |
| 197 | 225 | ||