Tutorial :Recompiling a VB.NET application



Question:

So I have this VB.Net Application. It uses SQL Server database, for which it "hard-codes" the IP Address of the database inside its compiled code.

The server IP has changed and I can't start the software anymore. Also, I can't change the IP Address of the server (another server is using the same IP and it can't be changed).

It is just 2 EXE files with no external DLLs or anything else. So I opened both of them in HEX Editor, tried to search for the ascii of my IP address, but couldn't find it, tried also a HEX search but with no result.

Then I used .NET REFLECTOR (http://www.red-gate.com/products/reflector/), and exported the code. I could see where the IP address is located: in Form2 a string variable named "strMyConnectionString". However, recompiling from the files exported by Reflector didn't work for me: I got 100 error and alot of warnings; obviously, the forms were missing but only their codes where decompiled. It has like 100 forms, and it is hard to redesign them (if that is even a considered a solution - not sure).

How do you suggest solving this? I need to change the IP as I can't use the software anymore!

Thanks!


Solution:1

If you have a .NET exe that you don't have the source code for, you're going to need to brush up on Ildasm and Ilasm. Use Ildasm to covert the .EXE into Microsoft's Intermediate Language. Change the code there - it'll be in a text format, but the IL code will look more like assembly language than a 3GL. Once you've changed the IL, you can recompile to an .EXE with Ilasm. Yucky, but functional and probably your best choice without the original source.


Solution:2

You could try editing your local DNS settings. Open C:\WINDOWS\system32\drivers\etc\hosts and specify a redirect from the old IP to the new one.

You could also try contacting the original author and requesting a new build.

If you authored it you should definitely not hard code changeable variables such as IP addresses and domain names :)


Solution:3

Instead of reflector, try ildasm

http://www.mactech.com/articles/mactech/Vol.19/19.12/NETbinaries/index.html


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »