I wrote a C# application for a client a couple of years ago, but I no longer have the source code. All I have is the EXE that I deployed on the client's PC. Compatibility with this version updater software may vary, but will generally run fine under Microsoft Windows 10, 8, 8.1, 7, Vista and XP on either a 32-bit or 64-bit setup. A separate x64 version of Patch My PC may be available from PatchMyPC. This download was signed by Patch My PC, LLC and distributed as PatchMyPC.exe. NOTICE: IF YOU ARE ON WINDOWS 7 USE 'C: Program Files (x64) SquareEnix FINAL FANTASY XIV - A Realm Reborn boot ffxivboot.exe' This should change the target location for the original shortcut to the correct link in order to boot into the launcher to launch from your desktop. Let me know if this solves your issue.
I wrote a C# application for a client a couple of years ago, but I no longer have the source code. All I have is the EXE that I deployed on the client's PC. Is there a way I can generate C# source code from the EXE?
7 Answers
Reflector and its add-in FileDisassembler.
Reflector will allow to see the source code. FileDisassembler will allow you to convert it into a VS solution.
Umar Farooq KhawajaWhen Red Gate said there would no longer be a free version of .Net Reflector, I started using ILSpy and Telerik's JustDecompile. I have found ILSpy to decompile more accurately than JustDecompile (which is still in Beta). Red Gate has changed their decision and still have a free version of .Net Reflector, but now I like ILSpy.
From the ILSpy website (http://www.ilspy.net/):
ILSpy is the open-source .NET assembly browser and decompiler.
ILSpy Features
- Assembly browsing
- IL Disassembly
- Decompilation to C#
- Supports lambdas and 'yield return'
- Shows XML documentation
- Saving of resources
- Search for types/methods/properties (substring)
- Hyperlink-based type/method/property navigation
- Base/Derived types navigation
- Navigation history
- BAML to XAML decompiler
- Save Assembly as C# Project
- Find usage of field/method
- Extensible via plugins (MEF)
Update:
April 15, 2012, ILSpy 2.0 was released. New features compared with version 1.0:
- Assembly Lists
- Support for decompiling Expression trees
- Support for lifted operatores on nullables
- Decompile to Visual Basic
- Search for multiple strings separated by space (searching for 'Assembly manager' in ILSpy.exe would find AssemblyListManager)
- Clicking on a local variable will highlight all other occurrences of that variable
- Ctrl+F can be used to search within the decompiled code view
Update:
- ILSpy 2.1 supports async/await decompilation
Reflector is no longer free in general, but they do offer it for free to open source developers: http://reflectorblog.red-gate.com/2013/07/open-source/
But a few companies like DevExtras and JetBrains have created free alternatives:
Reflector and the File Disassembler add-in from Denis Bauer. It actually produces source projects from assemblies, where Reflector on its own only displays the disassembled source.
ADDED: My latest favourite is JetBrains' dotPeek.
ProfKProfKTelerik JustDecompile is free and has a feature to create projects from .NET assemblies.
I'm surprised no one has mentioned Microsoft's ildasm. It may not be as pretty as ILSpy or Reflector, but it comes with Visual Studio so many developers already have it.
To run it (assuming VS 2013, should be similar for other versions):
- Select Start > All Programs > Visual Studio 2013 > Visual Studio Tools.
- Double-click on Developer Command Prompt for VS2013.
- Run 'ildasm' from the resulting command prompt.
- In the tool, select File > Open and open your executable or DLL.
Now you can navigate the DLL structure. Double-click on class members to see the IL. Use File > Dump to export IL to a file.
yoyoyoyoprotected by Raghav SoodFeb 11 '13 at 18:55
Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Not the answer you're looking for? Browse other questions tagged c#.netreverse-engineeringdecompiling or ask your own question.
How can I extract an exe from a setup file, modify its contents and then assemble it again.Is there a tool or somthing or is there a way of doing this by a programmatically?
mjv3 Answers
Not an .exe editor per se, but I have done similiar things to MSI installer files using Orca (most notably, installing iTunes on XP 64-bit successfully).
Josh StodolaJosh StodolaDepending on the type of setup package, there may be some setup package editors. (see Josh Stodola's suggestion of ORCA, for MSI type packages).
Otherwise, and in a nutshell...
not easily...
A Setup file typically has a CRC or other digest/checksum which enables it to assert its integrity prior to running its setup logic per-se. Therefore once the setup package has been altered, its calculated CRC differs from the stored CRC and the setup process is aborted.
Assuming the above is not a problem, one is also typically limited in terms of the changes that can be applied to an exe or more generally to a binary file. The safest changes are these which do not modify the file size and essentially replace a few bytes; sometimes a patch may require to add a piece of logic, at the end of the file (or at a location within the file known to be unused) and to provide a branch/jump instruction from some area of the existing logic where change is required.
Once a patched binary is available (or possibly a brand new exe, for example if one decompiled the orginal, modified the source and rebuilt it), the way to replace it in the setup program varies, depending on the type of setup package. Again speaking in general terms, the setup program/package typically includes a 'manifest' of sorts where the various parts are listed with an offset or reference of some kind, followed by the various parts which often are compressed with ZIP or similar compression format.
Alternative approach...
Rather than modifying the installation package, it may be easier to introduce an additional setup package, to be run after the original one (such setups can be 'chained' within an overall installation package), and which changes the exe and other binaries which require it.
This approach may not dispense one from figuring out the proper way of patching the binaries per-se, but it removes all the difficulties associated with the structure and integrity control devices of the original setup package.
Update Exe Application Errors
mjvthat generally depends upon how the setup file was constructed. Look at the tools offered by whoever offers the software with which the setup file was created. When you look at the tools, you should also check what options they have for patching - releasing a patch, rather than a full kit, is often preferable.
How To Patch Exe File
Or, if you really do have to release a full kit, why not just rebuild the whole kit, and release that?