Friday, May 13, 2011

On Decompilers and Obfuscators

The guys at Minecraft Coders Pack have done a great job at lowering the entry barrier for Minecraft modders. Really.

Decompiling Java programs and recompiling them again has never been a real problem. However Minecraft is also obfuscated so that all class and method names are replaced with short meaningless labels.

Most obfuscators deliberately try to generate code which while still functionally identical to the original is as confusing as possible for a decompiler. This includes generating bytecode which can not be produced by a Java compiler or adding dead code with illegal functionality in hopes of disorienting the decompiler and forcing it to give up.

The decompiler used by MCP suffers from all this and is in fact not able to correctly decompile all the bytecode. However MCP uses a set of patches to help the decompiler where it has given up. These patches are updated manually for every Minecraft release.

Where MCP really has succeeded is at the returning of the meaning of the decompiled code. The MCP community has reverse engineered almost all of the Minecraft source and while some places are not quite right and one or two are totally wrong the final result is quite comprehensible.

MCP also includes the tools needed to recompile and reobfuscate the changed source so that the final result is compatible to the original Minecraft bytecode.

On IRC #mcp on irc.esper.net there is even a bot which can report the current deobfuscation mapping and accept names for the missing entries.

One just can not wish for more.