views:

282

answers:

6

I've got some old Windows executable files. How can I edit them with Visual Studio 2010? What are the ways to see an exe's source code?

+8  A: 

If the program was written in C# you can get the source code in almost its original form using .NET Reflector. You won't be able to see comments and local variable names, but it is very readable.

If it was written C++ it's not so easy... even if you could decompile the code into valid C++ it is unlikely that it will resemble the original source because of inlined functions and optimizations which are hard to reverse.

Please note that by reverse engineering and modifying the source code you might breaking the terms of use of the programs unless you wrote them yourself or have permission from the author.

Mark Byers
thank you for your answer. its really helpfull. I tried .Net reflector but it's not working for my exe. peid says its microsoft visual c++ 6.0. i think no way to get source. thank you anyway
Ronnie Chester Lynwood
Like I said, nevermind.
Jamie Keeling
+4  A: 

If it is native code, you can disassemble it. But you wont see the original code as writte by the programmer. You will see the code produces by the compiler (assembler). This code is possibly optimized and although it is semantically equivalent, it can be much harder to read than normal ASM.

If it is bytecode (MSIL or javabytecode), there are decompiler which can product pretty good sourcecode. For .net, this would be reflector.

Henri
+10  A: 

You can't get the C++ source from an exe, and you can only get some version of the C# source via reflection. Neither will be of much use to you, judging from the way you asked the question.

jeffamaphone
A: 

There's nothing you can do about it i'm afraid as you won't be able to view it in a readable format, it's pretty much intentional and it'll show the interpreted machine code, there would be no formatting or comments as you normally get in .cs/.c files.

It's pretty much a hit and miss scenario.

Someone has already asked about it on another website

Jamie Keeling
Typical, down vote it with no explanation. Furthermore this answer isn't too far off the accepted answer. At least mention how my answer can be improved for my own sake as well as the author of the question.
Jamie Keeling
If you hadn't deleted your answer, we could have. Anyway, your answer is incorrect; see the other answers to the question. Reverse-engineering an executable image is possible in many circumstances and with the right tools.
Michael Petrotta
It's not completely incorrect, my answer has a point or two in relation to the accepted answer. The reason I deleted my answer is that it was downvoted by 3 within seconds and nobody had the decency to put a comment. Thank you for the response though, I appreciate the effort. It wants me to not bother contributing for the fear of people mercilessly down voting an answer with no explanation, granted I don't know everything but it's a knock to confidence, regardless of who it is that put an answer.
Jamie Keeling
Jamie, I understand your frustration, but with all due respect, you should have been able to figure out why your answer was downvoted without anyone commenting. When you started to receive downvotes, you should look at the other answers. Yours directly contradicts the top ones. "There's nothing you can do about it" != "You can do it easily if it's .NET, with more difficulty if it's native code".
Michael Petrotta
Apologies, I meant as in there's nothing you can do about the sometimes unreadable code. Thank you for clearing this up for me, I was speaking from experience as I've been able to do it using C# and Reflector but not C++ or C.
Jamie Keeling
I kinda agree with Jamie. Yeah ok, so his answer contradicts others and might be wrong. So go ahead an down-vote it, but tell him why as per SO: "Above all, be honest. If you see misinformation, vote it down. **Insert comments indicating what, specifically, is wrong**. Even better — edit and improve the information! Provide stronger, faster, superior answers of your own!"
RoLYroLLs
Thanks RoLYroLLs for understanding.
Jamie Keeling
+2  A: 

I would (and have) used IDA Pro to decompile executables. It creates semi-complete code, you can decompile to assembly or C.

If you have a copy of the debug symbols around, load those into IDA before decompiling and it will be able to name many of the functions, parameters, etc.

peachykeen
A: 

You can use Reverse Engineering. You can find Some Decompilers for the Languages. It gives not the exact code, only the asm code.

drorhan