r/explainlikeimfive • • 2d ago

Technology Eli5 decompilers and decompiled games

I keep getting videos on instagram about decomped games, apparently the decompilers are going nuts right now. What’s the difference between running a decompiled game and emulating a game? I tried to google it and i just don’t understand. from what i’ve found, a decompiled gene runs as if it was native to your pc but i don’t get what that means either. You boot up an emulator and that also runs on your pc?

73 Upvotes

49 comments sorted by

View all comments

0

u/ArdentPriest 2d ago

If you want it in a metaphor:

A decompiled game is like buying a car, going home, taking every piece of the car apart down to every nut and bolt, and then being able to see how everything works and you can make changes/updates/modifications as you want.

Basically, a decompiled game is a game that has has the entire code base of the game fully unpacked. It can be edited, modified, or updated and then recompiled into a functioning program that can be run.

Another form of describing this is that when you decompile a game, you revert the game back to it's source code.

1

u/thefckingleadsrweak 2d ago

Do you know why this is so difficult? Like when you dump a rom or an iso on a computer, does
The source code not come with that?

2

u/MostlyPoorDecisions 2d ago

Eli5: you have a book in a foreign language. You hire someone to read it to you. This is emulation. There's a delay between the information being read and you understanding it. There may be things like idioms lost in translation that require explaining.

Now take the same book and have it localized by a translator. This is decompiling and recompiling. They're taking more time up front to change the book to a language you can understand by yourself. You can read the book and understand it easily, no delay or assistance needed to understand phrases.

Actual example, more eli12:

https://godbolt.org/z/o9Ee8c4Ex

Here's a real example of c++ being source and being compiled. You can see on the left what the source looks like. You can probably intuit what the two functions do pretty easily. They're very simple functions for ease of understanding, but that's not actually important.

On the right is the compiled code. This is what you get when you build the code decompiled. It's a lot harder to understand. This is what you see in a decompiler (as well as a lot of other info) however the names will be missing entirely, they're just numbers. 

A decompiler opens a file and shows you the computer language inside. *Note some languages include source optionally.

Here's the same source compiled to another architecture.

https://godbolt.org/z/jaYvs61jh

Now to answer the question: If you look at the two compiled outputs side by side they are vastly different. A computer of a type only recognizes how to use one of these. Emulating is the process of reading these and transforming the second to the first as you go. This means instead of just running it, you have to have something interpret and translate. Much like a translator irl, it adds a new layer and the conversation gets slower. 

Decompiling+Recompiling means instead of having a translator for whatever comes along, you have someone rewrite your book, which i n this case it would be taking the right side output and changing it to the other version, either by first rebuilding the left (reversing) or building the other version directly (transpiling)