Hosts file not working?
Tags: Windows
Most of you might know for what the hosts file is used for. If not, Wikipedia will explain it to you.
Some days ago I've got a problem installing a Microsoft application at a customers site. The application was only available as a small setup file which connects to download.microsoft.com and downloads all the needed files from there. The problem at the customer was, that every single file from the internet is downloaded to a anti-virus server and after checking you can download it from there. The process is not transparent for the user and sometimes interaction is required to receive the file. And because of this, the installation of the application was not possible.
As a workaround I decided to download all the needed single files, put them on one of our web servers and create a hosts file entry on my client for download.microsoft.com and everything should work fine. Should work. But it didn't.
After creating the entry in the hosts file I tried to ping download.microsoft.com and recognised, that the hosts entry doesn't work and the ping command returns the "real" IP. Some minutes of research later I was aware that Microsoft hardcoded all host names for their websites in the dnsapi.dll which resides in the system32 folder. So you can't manipulate the DNS resolution for any Microsoft site (for example microsoft.com, msn.com, update.microsoft.com etc.) via the hosts file without a small trick.
The trick is to open the dnsapi.dll with a hex editor and change the needed host name (in my case I changed download.microsoft.com in download.microsoft.cCm). But you can't change that file while Windows is running, which means you should start a system (with a hex editor) from a CD, USB or what ever.
After restarting the system my hosts entry worked as expected. Also the application setup worked fine.
Most of you might know for what the hosts file is used for. If not, Wikipedia will explain it to you.
Some days ago I've got a problem installing a Microsoft application at a customers site. The application was only available as a small setup file which connects to download.microsoft.com and downloads all the needed files from there. The problem at the customer was, that every single file from the internet is downloaded to a anti-virus server and after checking you can download it from there. The process is not transparent for the user and sometimes interaction is required to receive the file. And because of this, the installation of the application was not possible.
As a workaround I decided to download all the needed single files, put them on one of our web servers and create a hosts file entry on my client for download.microsoft.com and everything should work fine. Should work. But it didn't.
After creating the entry in the hosts file I tried to ping download.microsoft.com and recognised, that the hosts entry doesn't work and the ping command returns the "real" IP. Some minutes of research later I was aware that Microsoft hardcoded all host names for their websites in the dnsapi.dll which resides in the system32 folder. So you can't manipulate the DNS resolution for any Microsoft site (for example microsoft.com, msn.com, update.microsoft.com etc.) via the hosts file without a small trick.
The trick is to open the dnsapi.dll with a hex editor and change the needed host name (in my case I changed download.microsoft.com in download.microsoft.cCm). But you can't change that file while Windows is running, which means you should start a system (with a hex editor) from a CD, USB or what ever.
After restarting the system my hosts entry worked as expected. Also the application setup worked fine.









