FabricMC / Enigma

This is a fork of cuchaz's Enigma, a deobfuscation/remapping tool for Java software.
GNU Lesser General Public License v3.0
426 stars 112 forks source link

Mapping format ProGuard not working correctly #539

Closed derklaro closed 3 months ago

derklaro commented 4 months ago

I've written some code to decompile a minecraft client jar file using the official provided mojang mappings (at the time of writing it's client + client mapping 24w07a):

    var enigma = Enigma.create();
    var project = enigma.openJar(this.inputJarFile, new ClasspathClassProvider(), PROGRESS_LISTENER);

    var idx = project.getJarIndex();
    var saveParameters = enigma.getProfile().getMappingSaveParameters();
    var mappingTree = MappingFormat.PROGUARD.read(this.mappingsPath, PROGRESS_LISTENER, saveParameters, idx);
    project.setMappings(mappingTree);

    var jarExport = project.exportRemappedJar(PROGRESS_LISTENER);
    jarExport.write(outputPath, PROGRESS_LISTENER);

The exported jar from this method still has all classes obfuscated (same outcome with the Swing version): image

However, when disabling the usage of mapping-io with System.setProperty("enigma.use_mappingio", "false") (or using the Proguard (Legacy) option in the Swing version), the code is deobfuscated correctly: image

NebelNidas commented 3 months ago

Hmm, that's due to a disparity between the old reader and Mapping-IO's. The actual mapping file is mojmap -> obfuscated:

net.minecraft.BlockUtil -> l:

Mapping-IO parses this as-is, but since the JAR file's names are obfuscated, nothing gets applied. Enigma's old reader only works because it always inverts the mappings for whatever reason, which is contrary to what you'd expect IMO.

@modmuss50 Should we make the new MIO reader behave like the existing Enigma reader or remove this behavior from the latter? I'd prefer not to auto-invert without prompting the user first.