Allegro.cc - Online Community

Allegro.cc Forums » Off-Topic Ordeals » Any decompiler experts out there?

This thread is locked; no one can reply to it. rss feed Print
Any decompiler experts out there?
Bob Keane
Member #7,342
June 2006

I was curious about decompilers, so I got this from github:

https://github.com/uxmal/reko

After fumbling around I thought I figured it out. So I wrote a simple "Hello World" project, compiled and decompiled it. I assumed I would get something similar to this:

#include <stdio.h>
#include <stdlib.h>

int main()
{
    printf("Hello world!\n");
    return 0;
}

but got the attached, too long for code tags. Are my expectations wrong or is this over my head?

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

jmasterx
Member #11,410
October 2009

Well if you think your computer is executing 4 lines of code to print text to the screen you're mistaken hahah.

You're going to get a disassembly of all the statically linked machine code in the executable. This includes a bunch of stuff that's inline from the c standard library.

Probably if you play with the compiler optimization flags and other stuff you can significantly thin down your output. But you're going to get all the static linked symbols too, and all the crap needed to enter your main function using winapi.

bamccaig
Member #7,536
July 2006
avatar

Are you particularly attached to Reko? It sounds like there are better alternatives (but there are limitations to decompiling C).

There is no pure decompiled C, like you're suggesting. It's not like compiled Java or .NET, where the original code can be pulled out. P-Code is the best you're going to get, and IDA's Hexrays is the best at it. But, for a cost.

Hopper's p-code is decent, usable, but makes some really weird guesses.

RetDec and Snowman are the other two. RetDec has a plugin for Binary Ninja. And there are many Snowman plugins, including for x64dbg.

You'll sometimes have to switch between RetDec and Snowman to get the better results, but IDA's are almost always the best.

Bob Keane
Member #7,342
June 2006

JMasterx said:

Well if you think your computer is executing 4 lines of code to print text to the screen you're mistaken hahah.

I expected a lot of unfamiliar code knowing something about how the precompiler works with #include. However, the only statement I recognized was the return at the end.

Bamccaig said:

Are you particularly attached to Reko? It sounds like there are better alternatives (but there are limitations to decompiling C).

I'm just trying out decompilers for fun, I'm not attached to any yet.

By reading this sig, I, the reader, agree to render my soul to Bob Keane. I, the reader, understand this is a legally binding contract and freely render my soul.
"Love thy neighbor as much as you love yourself means be nice to the people next door. Everyone else can go to hell. Missy Cooper.
The advantage to learning something on your own is that there is no one there to tell you something can't be done.

jmasterx
Member #11,410
October 2009

Maybe look into what they used https://github.com/n64decomp/sm64
I also like https://retdec.com/

Chris Katko
Member #1,881
January 2002
avatar

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Chris Katko
Member #1,881
January 2002
avatar

yeah, by clicking my link 8-)

-----sig:
“Programs should be written for people to read, and only incidentally for machines to execute.” - Structure and Interpretation of Computer Programs
"Political Correctness is fascism disguised as manners" --George Carlin

Simon Parzer
Member #3,330
March 2003
avatar

Use IDA Pro.

Go to: