Sunday, July 12, 2009

How can i retrieve .c source file from an exe file?

i was finishing my project and accidentaly overwrite the .c and all i have is executable file from the compiler, pls i badly nid help hir...can i decompile the executable to make c source? please help..

How can i retrieve .c source file from an exe file?
What you are looking for is called a "reverse compiler".





I have heard of them.





This may be one:


http://www.backerstreet.com/rec/rec.htm





Otherwise you are, indeed, out of luck.





If you stay in programming long enough, you will overwrite many files and each one will re-remind you to, "back up, back up, back up".
Reply:This just cannot be done since the compiler passed through various stages on the way to the EXE file. During each stage information is lost. So it is one way.


The only thing I think can be done is disassemble but it will not produce C but the assembley language
Reply:Some free utilities to do disassembly exist. Some for assembly to C exist. However, they will NOT recover variable names, strucutre names, comments and other declarations in any way other than the convention of the decompiler/disassembler. So, what you'll get will be really strange looking code, with nothing familiar in it. I've seen programmers try and pull this trick with there own code and still not recreate it very well. The site below has a variety of such tools, but if I were you, I'd just start over. It'll be easier and probably improve your knowledge more than disassembling it would any way.


EDIT --


There is one glimmer of hope that may help you out. You say that you "overwrite" the file? On some medium, such as floppy or hard drive, you might be able to use a data retrieval utility to find the magnetic remanants of the file's image. Just because the file is truncated, overwritten once or "deleted" doesn't mean that it is physically gone, it just can't be found and read by the computer's normal methods. Try searching for a free demo of the software.


I wish you luck.
Reply:If only, if only. Sorry.
Reply:Yes, you can use a "DEcompiler" that will generate C code from the exe. However, it will not look like the C code you wrote because a program looks at the machine instructions and produces C statements from those instructions. So it might help you start over, but the output from the decompiler is messy to read.
Reply:No, source code is not stored in the executeable file. As others have mentioned, you could use a decompiler ... but if you weren't backing up your data externally, then I'm guessing your project is not worth the trouble/effort of attempting to recover source code.





Sorry ... you'll need to write it again.


No comments:

Post a Comment