I see a lot about source codes being leaked and I’m wondering how it that you could make something like an exact replica of Super Mario Bros without the source code or how you can’t take the finished product and run it back through the compilation software?

  • howrar@lemmy.ca
    link
    fedilink
    arrow-up
    20
    ·
    11 months ago

    The best and simplest explanation I’ve seen: The machine code tells the computer what to do while the source code tells the human why it’s doing it.

    Your computer doesn’t need all the “why” information to run the game, so the compilation process gets rid of it. What you’re left with are instructions on exactly what computations to do, and that’s all the computer needs.

    For example, you can see in the machine code that two numbers are being added together. What do those numbers mean and why are we adding them? The source code can tell you that this is code that controls movement, one of the numbers is a velocity, the other is the player’s current position.

    • Squizzy@lemmy.worldOP
      link
      fedilink
      arrow-up
      5
      ·
      11 months ago

      Okay, I think that is sinking in.

      I was under the impression it wasn’t possible or just complete gibberish but it being just the results or instructions is helpful.

      • Ook the Librarian@lemmy.world
        link
        fedilink
        arrow-up
        4
        ·
        edit-2
        11 months ago

        Also, you only decompile to level of basic instructions that the processor understands. When you compile code to add two numbers, well, the processor only adds bytes. There are a quite a few steps that the compiler has to fill in.

        Ok, all that is not a big deal. But then you deal with compiler optimization. Optimizing basically tells the compiler to take its time and find some clever ways to save machine steps. So now the “standard way” for a compiler to implement adding numbers may have other stuff rolled into it because the compiler may see an opportunity to save steps in a seemly unrelated calculation by inserting steps into the addition it is implementing. Now it’s basically unrecognizable. A human didn’t write, and wouldn’t have written that mess that the decompiler gives.

        Edit: I would also like to add that when compile with the debugger flag, you are telling the compiler to produce decompilable code. Don’t change any steps and store variable names as written.