convert exe back to c source

This is a discussion on convert exe back to c source within the C Programming forums, part of the General Programming Boards category; hello can anyone tell me how i can convert exe back to c source. any program or disassembler?...

  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    1

    convert exe back to c source

    hello
    can anyone tell me how i can convert exe back to c source. any program or disassembler?

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,635
    Impossible to convert back to C.
    Get the source in form of assembly is not impossible, but makes it incredibly difficult to read the program.
    There are other reverse engineering tools out there, but none of them are easy.
    In short: there's no realistic way of doing it. If the source is lost, so is your program.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,484
    there are tools that convert exe to C, but this C-code is not far from assembler and is very hard to read...
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    7
    closest thing i could think of would be the "copy as C-source" option in a hex editor but shell code wouldn't help very much.

  5. #5
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    As someone else described it in the same question asked a few months ago, this is like expecting to be able to produce flour, milk and eggs from a cake. It's not going to happen.

    There are commercial and hobby programs that will make something that can be compiled by a compiler out of the machine code in an executable file, but it's not C code like you or I would write it - it may for example not make any difference between a for-loop and a while-loop, and do-while loops may also become while-loops. Switch statements can often become a sequence of if-statements, structs and regular variables will be hard to tell apart, etc, etc. Variable names and fucntion names will obviously also only be for those symbols that are available in the executable (such as calls to DLL's, etc).

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  6. #6
    Registered User
    Join Date
    Aug 2006
    Posts
    99
    http://www.hex-rays.com/decompiler.shtml

    Still not terribly good though, and you need to know a lot about the program you are decompiling.

    Especially with the optimizing compilers out there today, "going backwards" really isn't currently an option.

  7. #7
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    So you need a license at 1500 + a IDA Pro at 690. And whilst I'm sure it will produce OK code to recompile, it probably won't tell you much of what the source code actually looked like...

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  8. #8
    Cogito Ergo Sum
    Join Date
    Mar 2007
    Location
    Sydney, Australia
    Posts
    463
    Clever dick's little video in the browser froze my computer. Highly un-impressive
    =========================================
    Everytime you segfault, you murder some part of the world

  9. #9
    Registered User
    Join Date
    Aug 2006
    Posts
    99
    Quote Originally Posted by matsp View Post
    So you need a license at 1500 + a IDA Pro at 690. And whilst I'm sure it will produce OK code to recompile, it probably won't tell you much of what the source code actually looked like...

    --
    Mats
    Exactly Mats. Even on a very basic block of code, de-compiling back to C is virtually impossible, but there are lots of people out there that will tell you otherwise

  10. #10
    Ex scientia vera
    Join Date
    Sep 2007
    Posts
    478
    I was going to name hex-rays, but someone already did.

    Matsp is right though - it's impossible to get the exact same source code. Just consider the comments for example - those aren't even hinted, AT ALL, in the machine code.

    However, the code provided by hex-rays is the closest you can get. It *is* working C code, but it is very, very primitive and annoying to read. Vars are named like v1, v2, and so on, and the code pretty much just a direct translation of the machine code to C code.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Timers
    By Deb in forum C Programming
    Replies: 16
    Last Post: 04-23-2007, 10:15 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. extracting source code from exe
    By Lord CyKill in forum C++ Programming
    Replies: 6
    Last Post: 04-13-2003, 08:12 PM
  4. Exe to source code
    By Morgan in forum C Programming
    Replies: 2
    Last Post: 03-20-2003, 06:54 AM
  5. Do constructors get inherited?
    By Shadow12345 in forum C++ Programming
    Replies: 28
    Last Post: 08-21-2002, 11:41 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21