News for hackers. Stuff that matters.
Re:SpaceCadetPinball – Decompilation of 3D Pinball for Windows by bri3d on Thursday October 14, 2021 @12:05PM (#28866151)
I'm not aware of any good general-case automation for this.

When I've done this in the past, it basically consists of:

1) Decompile project using Ghidra/IDA, first pass.

2) Load symbols if present (sounds like there was a PDB for this one, which makes things a lot easier).

3) Read decompilation/asm for unnamed subs and try to name them based on what they do.

4) Export all decompiled source into an editor and start copy/paste/editing into readable source. Highly manual process, for some files it's just pattern matching / renaming and goes really quickly, for others it's full reimplementation and a bit harder.

And, if you look at most "decompiled game" projects, I think this is the industry standard way to do this. For example, OpenRCT2 started as a repository full of manually created source with Hex-Rays names and slowly evolved module-by-module into readable source code. (disclosure: per the child post, my original assumption that OpenRCT2 was copied out of Hex-Rays was inaccurate, since it was originally written in assembler it didn't follow a standard C ABI and the decompiler wouldn't work properly anyway).

Re:SpaceCadetPinball – Decompilation of 3D Pinball for Windows by duncanspumpkin on Thursday October 14, 2021 @12:49PM (#28866702)
For OpenRCT2 thats not quite how we did it. We didn't use IDA decomp output as its useless with Chris Sawyer calling conventions you had to just read the assembly. We did name things as per IDA when things were completely unknown hence why there was lots of sub_XXXX functions and byte_XXXX. I personally just used OllyDbg and read the assembly and wrote equivalent C code. I've a few videos of implementing functions for OpenRCT2 and OpenLoco if you are interested.
Re:SpaceCadetPinball – Decompilation of 3D Pinball for Windows by bri3d on Thursday October 14, 2021 @01:05PM (#28866932)
I stand corrected - I'll check them out! It makes sense that the Sawyer calling conventions wouldn't decompile correctly, since he was just making the ABI up as he programmed.
Re:SpaceCadetPinball – Decompilation of 3D Pinball for Windows by gavinray on Thursday October 14, 2021 @12:18PM (#28866312)

  > sounds like there was a PDB for this one, which makes things a lot easier
Ah yeah that certainly reduces the difficulty by an order of magnitude.

Do you know of anyone who has done this with high-skill as a recorded video tutorial? Seems like one of those things much easier to follow in video than text due to how complicated IDA/Ghidra are as tools.

Re:SpaceCadetPinball – Decompilation of 3D Pinball for Windows by bri3d on Thursday October 14, 2021 @12:31PM (#28866457)
Check out `wrongbaud` tutorials: https://hackaday.io/course/172292-introduction-to-reverse-en... .

wrongbaud's are the best trainings I've seen for Ghidra so far. I actually haven't watched this particular course (I confused it with some other ones) - but given what I've seen, I'm sure it's good.

Re:SpaceCadetPinball – Decompilation of 3D Pinball for Windows by gavinray on Thursday October 14, 2021 @12:35PM (#28866521)
Thanks a ton for the point in the right direction!