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?
6 Answers
You can't get the C++ source from an exe, and you can only get some version of the C# source via reflection.
-
1I tried Reflector for a simple C# VS 2012 Express project exe I lost the source files to, and the stuff Reflector exported had 100+ errors when I opened the project it created for the code. I tried others but I only had luck with http://ilspy.net/ - Not only were there no errors that stopped building, it also seemed to preserve variable names and I was able to make my changes enough to make one final build and get a new .exe. I was NOT able to get the form to be displayed properly in VS 2012 Express though, so the changes I made were all in code. My recommendation is to only make minor tweaks. – Feb 21 '15 at 08:16
-
1Just to get clear, I also can't get the C source code, right? And what about Assembly? – Santiago Torrabadella Jun 07 '21 at 09:46
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.

- 811,555
- 193
- 1,581
- 1,452
-
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 – Ali Demirci Apr 17 '10 at 18:51
If it is native code, you can disassemble it. But you won't see the original code as written by the programmer. You will see the code produced by the compiler. 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.

- 9
- 6

- 5,065
- 23
- 24
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.

- 47,010
- 7
- 103
- 140
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

- 9,806
- 17
- 65
- 102
-
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 Apr 17 '10 at 19:05
-
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 Apr 17 '10 at 19:06
-
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 Apr 17 '10 at 19:13
-
3Jamie, 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 Apr 17 '10 at 19:20
-
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 Apr 17 '10 at 19:30
-
3I 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 Apr 21 '10 at 19:27
-
For Any *.Exe file written in any language .You can view the source code with hiew (otherwise Hackers view). You can download it at www.hiew.ru. It will be the demo version but still can view the code.
After this follow these steps:
Press alt+f2 to navigate to the file.
Press enter to see its assembly / c++ code.