decompile

Discussion in 'C Programming' started by Fred, Jun 8, 2012.

  1. Fred

    Fred Guest

    Hello

    it is possible to decompile a program to c?







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

    Oh, so they have internet on computers now?” — Homer Simpson
    Fred, Jun 8, 2012
    #1
    1. Advertising

  2. In article <4fd245b6$4you.net>, Fred <> wrote:
    >
    >
    >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?
    Kenny McCormack, Jun 8, 2012
    #2
    1. Advertising

  3. Fred

    James Kuyper Guest

    On 06/08/2012 02:34 PM, Fred wrote:
    > 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.
    James Kuyper, Jun 8, 2012
    #3
  4. On 8 juin, 20:34, "Fred" :

    > 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.
    Jean-Christophe, Jun 8, 2012
    #4
  5. "Fred" <> writes:
    > 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.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    Will write code for food.
    "We must do something. This is something. Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"
    Keith Thompson, Jun 8, 2012
    #5
  6. Fred

    Eric Sosman Guest

    On 6/8/2012 5:15 PM, Keith Thompson wrote:
    > "Fred"<> writes:
    >> 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.


    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?

    --
    Eric Sosman
    d
    Eric Sosman, Jun 8, 2012
    #6
  7. On 8 juin, 23:38, Eric Sosman :

    > (...) 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:)
    Jean-Christophe, Jun 8, 2012
    #7
  8. Fred

    Stefan Ram Guest

    Keith Thompson <> writes:
    >"Fred" <> writes:
    >>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.


    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
    Stefan Ram, Jun 8, 2012
    #8
  9. Fred

    Geoff Guest

    On 8 Jun 2012 20:34:30 +0200, "Fred" <> wrote:

    >
    >
    >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.
    Geoff, Jun 9, 2012
    #9
  10. Kenneth Brody <> writes:

    > On 6/8/2012 2:34 PM, Fred wrote:
    >> Hello
    >>
    >> it is possible to decompile a program to c?

    >
    > 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: :)

    --
    Ben.
    Ben Bacarisse, Jun 9, 2012
    #10
  11. Fred

    BartC Guest

    "Kenneth Brody" <> wrote in message
    news:...
    > On 6/8/2012 2:34 PM, Fred wrote:


    >> it is possible to decompile a program to c?

    >
    > 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).

    --
    Bartc
    BartC, Jun 9, 2012
    #11
  12. Fred

    Fred Guest

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





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

    Oh, so they have internet on computers now?” — Homer Simpson
    Fred, Jun 9, 2012
    #12
  13. On 6/8/12 12:48:25 MDT, Kenny McCormack wrote:
    > 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
    Rowan K. Fullack III, Jun 9, 2012
    #13
  14. On 9 juin, 20:43, "Fred" :

    > 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)

    ----
    "Oh, so they have Fred on comp.lang.c now?"
    Jean-Christophe, Jun 9, 2012
    #14
  15. Fred

    Fred Guest

    Re: decompile Sorry you're right

    Jean-Christophe <> wrote:
    >On 9 juin, 20:43, "Fred" :
    >
    >> 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)
    >
    >----
    >"Oh, so they have Fred on comp.lang.c now?" LOL


    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
    Fred, Jun 9, 2012
    #15
  16. Fred

    gwowen Guest

    On Jun 9, 4:26 pm, Geoff <> wrote:

    > 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...
    gwowen, Jun 11, 2012
    #16
  17. Fred

    John Bode Guest

    On Friday, June 8, 2012 1:34:30 PM UTC-5, Fred wrote:
    > 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.
    John Bode, Jun 11, 2012
    #17
  18. On Friday, June 8, 2012 11:34:30 AM UTC-7, Fred wrote:
    > 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.
    Michael Angelo Ravera, Jun 13, 2012
    #18
  19. Fred

    Dann Corbit Guest

    In article <4fd245b6$4you.net>, says...
    >
    > 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
    Dann Corbit, Jun 14, 2012
    #19
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. chris kramer
    Replies:
    5
    Views:
    559
    chris kramer
    Apr 9, 2004
  2. Leo Jay
    Replies:
    4
    Views:
    10,995
    =?ISO-8859-1?Q?Jean-Fran=E7ois_Doyon?=
    Sep 24, 2005
  3. Leo Jay
    Replies:
    0
    Views:
    485
    Leo Jay
    Sep 24, 2005
  4. Peter
    Replies:
    0
    Views:
    548
    Peter
    Sep 24, 2005
  5. John J. Lee
    Replies:
    0
    Views:
    384
    John J. Lee
    Sep 25, 2005
Loading...

Share This Page