I’ve heard many times that the reason the Silent Hill remaster collection didn’t turn out so well was because Konami lost the original source code and had to re-create it. But I don’t understand how that is possible. If they were selling copies of Silent Hill, why couldn’t they just take a single disk of it and datamine the source code off of it? How could they possess the game without possessing the game’s source code?
In: 1563
I’ve attempted to write a few decompilers. It’s not easy. Often code and data is interspersed throughout the binaries… to a disassembler it doesn’t ‘know’ what is code or data. Usually things like jump tables or string offsets.
jmp table[rax]
table: func1, func2, func3, func4
func1: inc rdx
….
running a disassembler on it, it would try to generate code from the data at the table address. Some disassemblers (ida pro etc) now are smart enough to figure this out. There are also certain signatures (function entry/exit) that are common, or common library functions (libc/libm, Windows GDI, etc) that can mostly be detected or ignored.
One problem is modern compilers are VERY good at optimizing, and with things like constexpr functions and lambda functions in C++, the compiler will do work from the source code that never ends up in the binary. And if debugging information is stripped out of the result (which it would be for a commercially released game) you have no idea what each memory location means.
You may be able to get a flowchart of code execution, or running it through an emulator or code coverage tool you can see which code is actually executed (vs data).
You still won’t always know what every result means. And at best you could (auto) generate code that has made up variables: instead of code like:
if (player->hit()) {
player->hp -= 10;
}
you’d get code like
if (func_2394(mem_3942)) {
mem_3948-= 10;
}
Latest Answers