Digging into old components through MSIL

Yesterday and today I had to deal with an old component who’s source code has already been ported from .net framework v1.1 to v3.5 (most of them rewritten from scratch). This asp.net based component was working fine till sometime last week and then suddenly started throwing up exceptions. Due to some legacy dependencies the web app had to be run in v1.1 and I do not have VS2003 with me.

The old architecture worked in a manner where a particular variable was passed from web app 1 to web app 2 through query string and the web app 2’s initial page stored that variable as a session variable for the rest of its pages to use them.So, when we were going through the initial steps of debugging the issue we figured out that a session stored variable was not getting passed to a stored procedure, and further investigation showed that for some odd reasons the session was getting expired and taking all the session stored variables into the oblivion along with it.

In order to get the application up and running in the shortest time, all we needed to do was change the stored procedure value to be taken from query string instead of the session variable. But since I didn’t have the means to recompile the source code into its own framework v1.1 form, I thought the best option would be to find tools which would allow me to just change the IL directly on the assembly.

After researching a while I found 2 great tools for it (apart from the ildasm / ilasm tools of the visual studio’s tool chest):

  1. Dotnet IL Editor
  2. RelexIL Addon for Reflector

Since I am not a pro on MSIL editing, I choose to go with the ReflexIL add-on for Reflector. After adding the add-on to the Reflector, I was able to locate the area that needed modification and carry out the changes.

Cheers to Jb Evain for the Mono.Cecil and Sebastien Lebreton for the ReflexIL!

comments powered by Disqus