I have a program i frequently use that is made with .NET. This program has a small bug that is very annoying and the developer to the app is nowhere to be found.
I have found the location of the problem in reflector and just want to add a single if-statement here and then recompile the program.
What is the easiest way to do this?
I have tried using the export-function in reflector but it doesn't seem to work perfectly. For example alot of using-directives are missing and enums that are cast back and forth to ints are also not exported properly. I believe i can fix this with some work but i'm wondering if there are any easier way to do this.
Update: Solved it by doing this:
The program is a single file executable
- Find the bug in reflector with C#-view. Then switch to IL-view to see what you should look for in step 5.
- Open the program you want to change with ildasm
- Press dump and select an empty folder, default settings worked for me.
- Find the .il file in this folder and open with any texteditor
- Find the code from step 1.
- Replace it with new code, in my case i just had to replace all the contents of a function with a simple return (IL_0000: ret). I don't think all fixes will be this easy.
- Open a commandwindow in the folder from step 3
- Run ilasm, i also had to include some resources from the original exe. These are automatically output with ildasm. I used this ilasm like this "C:\Windows\Microsoft.NET\Framework\v2.0.50727\ilasm.exe" test.il /resource=test.res /output=FixedProgram.exe
Done! I've only used the fixed program some minutes right now but it seems to work just like before except for the bug :)
I also ran into some problems with the application settings. In %appdata%\ProgramName there was a folder called something like ProgramName.exe_Url_qa5i3p42aomuvoxpuxuficvbmngksgjs where all settings are stored. My new executable created a new folder like this with different random letters at the end and with the default settings. To copy the settings you used before just copy all the contents of the old folder to the new one.