When a game’s “code is lost” what stops a company from dumping/decompiling code from a disk or cartridge copy of the game for things like remakes and remasters?

535 views

When a game’s “code is lost” what stops a company from dumping/decompiling code from a disk or cartridge copy of the game for things like remakes and remasters?

In: Technology

9 Answers

Anonymous 0 Comments

Software developer here, former game developer (not that it matters),

Compilation is a one-way transform. Take, for example:

bool less_than_seven(int x) {
return x < 7;
}

This is code, a text document written for humans, by humans, and only incidentally for computers to possibly compile and execute. Computers don’t need to know what a `bool` data type is, it doesn’t need to know that this is a function, and specifically, it doesn’t need to know that it’s named `less_than_seven`. It doesn’t need to know the variable is called `x`. It probably doesn’t even need the variable. It very likely doesn’t care that we’re doing a `<` comparison.

All this information can and likely will be lost when translating to machine instructions. You can’t search an executable program for `less_than_seven`. That information is gone. This code, this function, very likely won’t even generate machine instructions for a function call – the compiler might determine the cost of pushing and popping the call stack is more expensive than just performing the comparison in-place where this code is used elsewhere in the source. In place of a variable stored in memory, the compiler will probably store the value in a register. The compiler might even deduce that there are more clever tricks, faster instructions to use than the built-in less-than compare instruction; the program will produce the same result, but it won’t be intuitive.

So gone is all the context – function names, variable names, variables, and data types; gone is the intent as it was expressed for humans in the source code.

There are tools to decompile executable code, but it’s tricky at best for other technical reasons. And of course, the tools don’t know what it’s decompiling. So how does it know that some particular piece of memory stores hit points, or bullet counts? All the tool is going to do is deduce what might probably be a variable, and call it `variable_1234_`, and that’s all you’re going to get. And typically, these tools CANNOT produce reversible code – that is to say, what they generate won’t compile again back into the same binary from which it was deduced.

The best you can do is reverse-engineer an approximation of what the original source code might have been. And I emphasize *approximation*, because it won’t be exact, and it won’t be correct, and it won’t be a faithful reproduction. It is incredibly challenging.

You are viewing 1 out of 9 answers, click here to view all answers.