Is it possible to convert a binary executable into its original code and other files?
Asked Answered
M

3

5

Pretty much as the title asks. For example, if I took a Playstation disc, could a program be written that converts all the binary on the disk back into its original code files, art assets, etc? Isn't it just kidn of like decryption? If not, is it possible to make a language or add code to our current languages that would make future programs possible to convert backwards? Thanks!

Mason answered 22/2, 2014 at 8:52 Comment(1)
The original source has comments, but that information isn't contained in the bits on disc. Compiled languages aren't like scripting languages.Claver
C
12

Let's take it easy.

Suppose you know that x^2 = 4, you cannot tell whether x was 2 or -2.

similarly is you have a binary executable or assembly code you cannot tell which language it was written in.

But you can convert binary file to assembly code. There are many good tools available for linux and windows both paid and free. They are called disassemblers. You can use them to see if what is a program doing and can even modify it in runtime.

Claimant answered 6/11, 2017 at 7:22 Comment(1)
Great, straight forward example.Stubborn
C
3

In general, it's going to be extremely difficult or very time consuming to be able to retrieve anything that resembles that original source code for a PlayStation game from a disk. All you will have to likely work with is the game's binary executable which contains only CPU instructions that contain the logic for the game. You'd have to effectively reverse engineering the game files which can start posing some legal questions.

Most likely the game is written in C++ which will be directly translated into CPU instructions by a C++ compiler (e.g. gcc). It's very difficult (but not impossible) to guess what the original source code was before it got translating into the CPU instructions. Compiling C++ code is a very lossy operation in terms of the original source code (e.g. loss of variable names, function names, arithmetic and logic is optimized and simplified).

You'd have to use a sophisticated decompiler to begin to have any semblance of the original code. Even then, you'd have to spend a significant amount of time trying to understand what the machine code is doing. As an example, a decompiler such as Ghidra is free and open source and can interpret machine code and attempt to make sense of it. Tools like this are also especially useful for security researchers who have to reverse engineer malware executables.

In some cases, games will use scripting languages for in-game cut scenes or defining different behaviors and properties within the game. At least in that case, you likely would be able to see scripts in plain text files.

Conics answered 22/2, 2014 at 9:8 Comment(0)
C
0

Simply: nope. You can not convert binary 1 to 1 to original source code on C++ or something alike. But you can do reverse engineering.

Cristal answered 22/2, 2014 at 9:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.