Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c++ decompiler?

Status
Not open for further replies.

A1METALHEAD

Programmer
May 21, 2004
76
US
has anyone herd of a free c++ decompiler? that turns a exe int a cpp file? or a method to do that?

~metalhead
 
There is no such thing.

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 

It doesn't generate a .cpp file, although it does generate assembly files (it's a little outdated though, so it might not be right on the ball)

-----------------------------------------------
"The night sky over the planet Krikkit is the least interesting sight in the entire universe."
-Hitch Hiker's Guide To The Galaxy
 
You mean to tell me that MS doesn't have a decompiler? If they can write a compiler I am darn sure they have a decompiler =)

-Ron

/**************
Me: When will the project be finished?
Them: What project?
Me: The one you have been working on for the last 3 years!
Them: Ohh, we can't finish it?
Me: Why?
Them: We don't know how to program...
 
How funny discussion!..
It's impossible to invent C++ decompiler. Most of C++ semantics have lost in compiled codes. No any classes (they converted into series of MOV/CALL machine instructions). Local and global optimizations erode source flow of control statements...
Take a paper with a simple algorithm description (in English, for example). Make a program in assembler language. Then take hexadecimal codes and let your friend try to restore the original description (in English). Compare texts...
 
>You mean to tell me that MS doesn't have a decompiler?

Noone has.

>If they can write a compiler I am darn sure they have a decompiler

"Darn sure", eh? Ahhh, you signature makes sense now. Your a project manager, right? ;-)

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Another illustration of the problem:

1) Go to your local bakery and buy a cookie.
2) Take it home, cut it up and analyze it.
3) Produce the original recipe, word for word, of the cookie, based on your analysis.

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
If Microsoft decided one day that their executables should contain extra data so it could be "decompiled", this could cause some serious problems for them. Just think, if you could actually do this, you could "decompile" Microsoft Office and make some minor modifications and say it's your own. Granted that would be illegal, but I'm sure someone would do it eventually.

-Bones
 
Actually, Microsoft is headed in that direction, thanks to the .NET framework, which can be "decompiled" much like Java.
 
cant someone see the relationship between the compiled code, and the .cpp file?
 
> cant someone see the relationship between the compiled code, and the .cpp file?
Yes, you can look at the object code, and a skilled human can derive a program which has the same functionality, but it will not be the original program. But this is an awful lot of work (which will cost you a lot of time and or money). It's usually easier to just observe what the program does and write a program to work in the same way. But this won't be the original code either.

Some decompilers can do this to a limited extent, but they are very limited. To make any real progress, they need a lot of additional information (like say a symbol table, and knowledge of the compiler used in the first place).

For example, you might have written
[tt] volume = width * height * depth;[/tt]
But most decompilers are likely to spit out
[tt] v1 = v2 * v3 * v4;[/tt]
You've got the code, but all the meaning has been lost.

Across 1000's of lines of code, this is not going to be a pretty sight.

for, while, switch etc are likely to be riddled with goto's in the decompiled version.

The short of it is, a compiler would be able to compile it, but no human would want to touch the code with a barge pole!

--
 
Of course there is a trivial way of getting the source of an .exe :

Use Open Source software

:)

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
PerFnurt, !!!
Excellent funeral oration...
 
A1METALHEAD :
Just out of interest what are you trying to decomp and why ?
 
i want to decompile some programs that i got free from the web, that edit the everquest UI, i dident have to accept any eula, so what im doing is perfectly legle, and i am aware that in most eulas, the prohibit decompiling/editing oringle sorce.
 
I am jsut joining and have a question for programmers. I have an old stock program (7 yrs old)that no longer works because the data feed is no longer available. Is there any way to have someone decompile and rewrite the program adding some updates that I would like and having it run through another data feed, or does it have to be rewrittne from scratch? At this point the current program will no longer run as the data feed does not exist and it is out of date.
 
How do you know it was even written in C or C++?

> Is there any way to have someone decompile and rewrite the program
See above - "no"
At least not in any way which is likely to be economically viable.

My first impression would be to create a filter which sits between your new feed and your old program, which converts a new feed into an old feed. However, this is only going to be effective in the short term, and perhaps sub-optimal (like missing data from the new feed).

Or have another really long look for the source code.

On the other hand, since it's 7 years old, perhaps now is the time to bite the bullet and rewrite the program from scratch so that it can optimally deal with the new feed, and you'll also have the source for future modifications.

--
 
Salem:

Thanks for the response. The program is pretty large so I was hoping that some of the code could simply be cut and pasted so to speak, or at least it could be read so that the new programmer sees what it needs to do and how it was orignally set up. Not being a programmer I am out of my element here.

Because I did not write the program and was only given it to use I have no idea about what it would take to create it from scratch.

You mentioned creating a filter to use the new data feed and convert it to the old. That is not a bad idea, however it would still only have 60% of it's potential as two new exchanges that were not in existance since this was written have been created.

How complex of a task would it be to create such a filter?
 
You asked how I new it was written is C++. It is because I sometimes forgot to turn on my data feed first and a window box would pop up saying that I had an assertion failure and that I should check my C++ documentation to see what causes these problems.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top