September 23, 2009 13:56 by Vic
We had a bit of an issue with some of our legacy applications this morning, one of our infrastructure engineers had "accidentally" changed a password on a domain account which was causing certain aspects of our applications to fail. WHY?
Because someone had hard coded the user name and password within the source code. (not me!)
We couldn't change the password back to the original as our domain policy would not permit it, and we could not change the domain policy to get around the issue. This only left us with three options
1. Go back to the branched code and change the passwords in the code, re-compile the whole application, re-run all the test and put the new code through our deployment process.
2. Disassemble the problem assemblies, change the hard coded passwords and then recompile the code and replace the DLLs on the live systems
3. Fix the code so these credentials are stored in a more suitable place (i.e. not in the code!)
Well, we're doing 1 and 2 for now. We have already done 3 in a to be released branch, but can't really retro fit those changes easily in to a previous release branch.
Anyway, here's how I used the Ildasm and ilasm to achieve this
First, we need to disassemble our .NET code into IL code. You can do this using the ildasm tool via command line you would do the following
ildasm /out=e:\app\PowerProgramming.Domain.il e:\app\original_dlls\PowerProgramming.Domain.dll
Alternatively, if you just type in ildasm in the command line you will get a user inteface to do the same. Simply open up the assembly, and the "Dump" the IL code.
Secondly, you need to update your IL code with any modifications you need to make.
Finally, you use ilasm to recompile the IL code into an assembly.
ilasm e:\app\PowerProgramming.Domain.il /resource=e:\app\PowerProgramming.Domain.res /dll /output=e:\app\PowerProgramming.Domain.dll /include=e:\app\original_dlls
Simple as that... The only question to answer is where do you find these utilities?
ildasm = C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin
ilasm = C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727