‹ BackHN Continuity

Thread

Resident Evil 4 (GameCube) – complete byte-identical decompilation to C/C++

140 points · 99 comments · metrofun

  1. groundzeros2015 · · focus · HN ↗
    I opened a file at random. This looks more like emulating the behavior in compilable C syntax rather than recovering the game's programming

    void Em1eWeaponSet(cEm10* em) { Em10Work* w = EM10_WK(em);

        w->mot[41] = 0;
        w->mot[42] = 0;
        …
        w->mot[62] = 0;
        w->mot[63] = ARC(0x26C);
        w->mot[64] = ARC(0x26D);
        w->mot[65] = ARC(0x276);
        w->mot[66] = ARC(0x277);
        w->mot[67] = 0;
        w->mot[68] = 0;
        w->mot[69] = ARC(0x26A);
        w->mot[70] = ARC(0x26B);
        w->mot[71] = ARC(0x270);
        w->mot[72] = ARC(0x271);
        w->mot[73] = ARC(0x272);
        w->mot[74] = ARC(0x273);
        w->mot[75] = ARC(0x274);
        w->mot[76] = ARC(0x275);
        w->mot[77] = 0;
        w->mot[78] = 0;
    }
    1. [deleted] · · focus · HN ↗

      [deleted]

    2. dezgeg · · focus · HN ↗
      There is more normal looking code in other files. It sounds like the original game had animation data (or similar) embedded in the C code.
      1. groundzeros2015 · · focus · HN ↗
        I just checked a few more. It looks it can sometimes tell the intent of a stack variable and give it a name. But anything working with data looks like above.
    3. corysama · · focus · HN ↗
      Not a surprise. Now the fun works starts: Deriving semantics from psuedo-assembly.
    4. kasool · · focus · HN ↗
      Yes, that is how decompilation projects work.

      The puzzle is then trying to piece the context back together by probing the game to recover something that approximately resembles what the original code might have looked like.

      Eventually you can do things like Dusklight for advanced modding and feature implementation.

    5. MiroslavPokorny · · focus · HN ↗
      How is this more readable to a human than the binary ?
      1. groundzeros2015 · · focus · HN ↗
        It’s not.
Open on Hacker News to reply ↗

Unofficial Hacker News client; not affiliated with Y Combinator.