Cicoparser: Full game reverse engineering [video]
youtube.com
youtube.com
But then I understood what CicoParser is doing: it translates machine instructions into C-statements, i.e. when your binary contains an instruction like "mov 123,sp", the output will be a C source file with a statement "memory16(_ds,123)=_sp;". On the github page, they say it is not a CPU emulator, but I would rather say it is a CPU emulator with AOT compilation of the binary.
Concerning access to video memory: I saw that you treat them "manually" in some cases. I am wondering whether you could avoid that by using virtual memory. You could mark the pages as invalid and when an instruction tries to access them, you catch it and replace the memory[...] access instruction by a call to memoryVideoGet. The JIT-Compiler of the Amiga emulator uses a similar technique for indirect accesses to hardware registers.
And it will improve over time if the developers continue to give it effort.
Of course, you could also say that a decompiler is any tool that produces something from a binary that you can compile again. But in that case, I could claim that this here is also a decompiled program:
byte[] programbinary={ put binary of the program here };
runEmulator(programbinary);I feel like you're effectively asking for an optimization step. Decompile to an IR, and then use some heuristics to get back to C that is more efficient for humans to read.
And if a compiler without an optimizer is still a compiler, then a decompiler without an "optimizer" should still be called a decompiler.
1: https://github.com/notaz/ia32rtools 2: https://www.giantpockets.com/starcraft-pandora-port-came/
All the areas where you currently need to manually change cicoparser, Dune does everywhere. It jumps based on flags, makes indirect jumps and calls (Dune dynamically loads in video, pcm audio and midi drivers), it jumps wildly around, into, and out of the middle of other procedures, and so on. I'd love to see you try, though.
Secondly, I don't really see a great advantage of cicoparser over emulating the CPU. You've converted the disassembled code to assembler-in-C, but you haven't reverse engineered the application. If I've successfully converted an application with cicoparser, yes, I can run it, but I haven't learned much about how the original application works. It can be a good starting point for reverse engineering though.
We had an engine in ScummVM that was created with a similar process. The application was organized well enough (with clear function boundaries, etc.) that the engine could gradually be transitioned to proper C.