decompile

K

Kenny McCormack

Hello

it is possible to decompile a program to c?

Yes.

--
Here's a simple test for Fox viewers:

1) Sit back, close your eyes, and think (Yes, I know that's hard for you).
2) Think about and imagine all of your ridiculous fantasies about Barack Obama.
3) Now, imagine that he is white. Cogitate on how absurd your fantasies
seem now.

See? That wasn't hard, was it?
 
J

James Kuyper

Hello

it is possible to decompile a program to c?

It's possible to generate a C program which would behave the same as the
program you're decompiling; I believe that some people may have even
created such things. However, the output will, in general, be nearly
unintelligible. That's because the process of compiling a C program
tends to discard a large portion of the information needed for a human
to understand the program. First of all, it drops all of the comments.
Secondly, identifiers with internal linkage or no linkage (which is the
vast majority the identifiers in your program) are, in effect, converted
into other forms that are meaningful only to the hardware. Any
information stored in the identifier's spelling is just plain lost.
Finally, most modern compilers optimize your code by rearranging your
code extensively. It's possible to write C code that does the same thing
as the optimized code, but it's generally not possible to reconstruct
what the original code looked like before optimization.
 
J

Jean-Christophe

it is possible to decompile a program to c?

Yes it is - even if I don't know any actual
software to 'decompile' an executable program to C.

One can un-assemble an executabe program to asm.
( does anyone here remember 'sourcer' ? )
Now what you need is to write a
program to translate asm to C.

But you won't get the very original C source code,
because there are many ways to translate asm
to high(er)-level language.
 
K

Keith Thompson

Fred said:
it is possible to decompile a program to c?

It's possible (though it may or may not be practical). In other
words, for any executable, it should be possible to generate C code
that behaves the same way.

But don't expect the resulting C code to be legible or maintainable,
or to have any particular resemblance to the original code that
was compiled to produce the executable. A lot of information,
such as variable names, is discarded during compilation, and you
can't reliably distinguish between a for loop, a while loop, and
a goto statement. You can't unscramble an egg.
 
E

Eric Sosman

It's possible (though it may or may not be practical). In other
words, for any executable, it should be possible to generate C code
that behaves the same way.

But don't expect the resulting C code to be legible or maintainable,
or to have any particular resemblance to the original code that
was compiled to produce the executable. A lot of information,
such as variable names, is discarded during compilation, and you
can't reliably distinguish between a for loop, a while loop, and
a goto statement. You can't unscramble an egg.

One thing that's extremely likely to be lost in un-translation
is any hope of portability. When the C program was compiled in the
first place, it probably imported a lot of implementation-specific
stuff from headers like <stdio.h> and <limits.h> and so on. If the
decompiler sees that a variable is being compared to 127, should
the decompiled source have a comparison to `127', or to `CHAR_MAX',
or to `SCHAR_MAX', or to `_FILE_INTERNAL_BUFSIZ - 1'? Any of these
could well become wrong if the decompiled code then moves to another
system ...

So: What do you (Fred, O.P.) hope to do with the decompiled code,
assuming you're ever able to get some?
 
J

Jean-Christophe

(...) So: What do you (Fred, O.P.) hope to do with the
decompiled code, assuming you're ever able to get some?

Win the international obfuscated C code contest ? :eek:)
 
S

Stefan Ram

Keith Thompson said:
It's possible (though it may or may not be practical). In other
words, for any executable, it should be possible to generate C code
that behaves the same way.

A processor might have special opcodes for special-purpose
operations that are observable as behavior yet cannot be
activated via C. For example,

LED #$1 ; switch on the processor LED
 
G

Geoff

Hello

it is possible to decompile a program to c?

Only in some of the most trivial cases or where the insight into the
code is more valuable than the cost of reverse engineering the
program.

What you end up doing is disassembling the object code and then
translating that assembly code into an equivalent C source but that
source may not match the original. Often, the assembly gives more
insight into the code than the C source would. (Worms and viruses.)

The process is highly sensitive to the target environment.
 
B

Ben Bacarisse

Kenneth Brody said:
To summarize what the others have said:

You can't make a cow from hamburgers.

I don't think that's what's been said. To stick to the bovine analogy,
the summary would be that you can make something that *behaves* exactly
like a cow from hamburgers, but you may not be able to tell what the cow
does, modify it simply to behave like a bull, or make one able to live
anywhere other than where it was brought up in the first place.

Oh, yes, lest I forget: :)
 
B

BartC

Kenneth Brody said:
On 6/8/2012 2:34 PM, Fred wrote:

To summarize what the others have said:

You can't make a cow from hamburgers.

It may not be ethical, but you can probably feed hamburgers to a calf. End
result is a cow (depending on what sort of calf it was).
 
R

Rowan K. Fullack III

Here's a simple test for Fox viewers:

1) Sit back, close your eyes, and think (Yes, I know that's hard for
you).
2) Think about and imagine all of your ridiculous fantasies about
Barack Obama.
3) Now, imagine that he is white. Cogitate on how absurd your fantasies
seem now.

See? That wasn't hard, was it?

This is kind of offtopic for this group but this idiocy cannot go
unchallenged. This message is completely offensive.

Let's look at the facts here. Barack Hussein Obama:
1) was born in Kenya
2) has been a Moslem in the past, and maybe he still follows that
doctrine privately
3) when he tried to pass as a Christian, he fell in with a pastor who
curses America
4) has a wife who has said she is embarrassed to be American
5) has pursued policies that have cost American jobs and has started on
the road to full-scale European-style socialism with his healthcare
reforms.

None of these points has a damn thing to do with the guy's skin color.
It's the fact he's an anti-American socialist that people don't like,
nothing else. He has squandered Bush's golden legacy.

Hope that sets the record straight, let's get back to C.

Rowan
 
J

Jean-Christophe

which program can I use to decompile
i tried boomerang but it crasht.

You mean that the 'boomerang'
came straight back in yer face ?

Since you've got 12 ansers to your question
but didn't bother to say 'thanks'
now it's time for you to tell us
what program you want to 'decompile',
and why you want to do such thing.

(my guess is that you're posting to the wrong NG,
better take a chance to '3771tHackerZ' kids NG)
 
F

Fred

Jean-Christophe said:
You mean that the 'boomerang'
came straight back in yer face ?

Since you've got 12 ansers to your question
but didn't bother to say 'thanks'
now it's time for you to tell us
what program you want to 'decompile',
and why you want to do such thing.

(my guess is that you're posting to the wrong NG,
better take a chance to '3771tHackerZ' kids NG)

Sorry you're right thanks everyone for your response.


Posted Via http://www.usenet4you.net the free uncensored newsserver.

Oh, so they have internet on computers now?” — Homer Simpson
 
G

gwowen

What you end up doing is disassembling the object code and then
translating that assembly code into an equivalent C source but that
source may not match the original.

.... unless io_x wrote the original...
 
J

John Bode

Hello

it is possible to decompile a program to c?

The technical term for this is "turning hamburger back into a cow". Yes, it is possible to generate C source code from an executable; it may bear little to no resemblance to the original source code. It may not be very readable or understandable. Comments, symbol names, file names, etc., are (usually) not preserved in the binary itself.
 
M

Michael Angelo Ravera

Hello

it is possible to decompile a program to c?

If you have the executable produced by the compiler for the unoptimized debug version, depending upon how much of the source-related information is kept in it, you MIGHT be able to produce a source code that is actually useful. This would be for the case when you deleted the source code file, but have all of the other pieces.

Once the code is optimized or built for release (which usually discards allof the symbol information), you SHOULD be able to produce C code that doesthe same thing, but it will not likely resemble anything that any human would actually write.
 
D

Dann Corbit

Hello

it is possible to decompile a program to c?

Yes.

It is not possible to decompile all programs from executable code into
C.

It has been demonstrated that a generic decompiler is equivalent to
solving the halting problem.

All that having been said, there are decompilers that do a pretty good
job for special cases (e.g., assuming a certain operating system and
limited set of source compilers and a few other preconditions).

For example:
http://www.hex-rays.com/products/decompiler/index.shtml

However, the C code generated will not be spectacularly better than just
tracing through the assembly language to see what is going on.

HTH
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top