views:

11007

answers:

7

I have a program in which I've lost the C++ source code. Are there any good C++ decompilers out there?

I've already ran across Boomerang.

+12  A: 

You can use IDA Pro by Hex-Rays. You will usually not get good C++ out of a binary unless you compiled in debugging information. Prepare to spend a lot of manual labor reversing the code.

If you didn't strip the binaries there is some hope as IDA Pro can produce C-alike code for you to work with. Usually it is very rough though, at least when I used it a couple of years ago.

David Holm
A: 

Duplicate? (C vs. C++?): http://stackoverflow.com/questions/193896/whats-a-good-c-decompiler

Michael Burr
I considered that before posting, but it seems that most decompilers go to C. I was wondering if there was one actually for C++.
Bryan Denny
+2  A: 

Maybe I'm way off, but once a program has been compiled, couldn't you disassemble it to any language? For example, if you compile a C++ program, couldn't you decompile it into, say, Pascal?

warren
Not really, as there may not be a high-level command to match the one in the original language. What you are saying is correct in a framework that was designed to do this, such as different languages under .NET or the JVM framework.
Yuval F
You can decompile to anything. The question is whether the result will be more useful than a machine emulator attached to the binary.
David Thornley
+7  A: 

Yes, but none of them will manage to produce readable enough code to worth the effort. You will spend more time trying to read the decompiled source with assembler blocks inside, than rewriting your old app from scratch.

m_pGladiator
+3  A: 

information is discarded in the compiling process. Even if a decompiler could produce the logical equivalent code with classes and everything (it probably can't), the self-documenting part is gone in optimized release code. No variable names, no routine names, no class names - just addresses.

Dustin Getz
+3  A: 

Depending on how large and how well-written the original code was, it might be worth starting again in your favourite language (which might still be C++) and learning from any mistakes made in the last version. Didn't someone once say about writing one to throw away?

n.b. Clearly if this is a huge product, then it may not be worth the time.

harriyott
http://www.joelonsoftware.com/articles/fog0000000069.html
Dustin Getz
Joel is a great columnist, but at times wrong. And then there are times when he's quoted wrong. Like here, since the question centers around the loss of source code. Joels article explains why source code is valuable.
MSalters
+1  A: 

I haven't seen any decompilers that generate C++ code. I've seen a few experimental ones that make a reasonable attempt at generating C code, but they tended to be dependent on matching the code-generation patterns of a particular compiler (that may have changed, it's been awhile since I last looked into this). Of course any symbolic information will be gone. Google for "decompiler".

Ferruccio