You fail to address several significant issues related to the hosts file that makes your suggested not practical.
First, this idea is not new in terms of using the hosts file to block ads and it goes back as far as 1991 and probably earlier.
Second, there is a physical limite to the number of entries that can be posted to the hosts file that makes your approach useless. In a simple test it is easy to get a list of over 13,000 ad sites in common usage and which I posted in a previous article posted here on your approach.
If you put 13,000 which is really the MINIMUM number of sites needed to get any significant blocking of ads many computers will completely LOCK UP and require a reboot of the system and will STOP working completelty! YOU FAIL TO POINT THIS OUT.
Why does this happen? It is due tothe fact there several of those annoying spyware programs open the hosts file and LOCK IT to prevent ad blockage dude!
While abstarct approaches likes yours are interesting, your approach fails to work in any practical manner because of the reality of the Internet the the way the hosts file is used by many programs. Anything over a few hundred lines will CRASH most computers and you should WARN people about this!
Again, while you idea to use the hosts file is not original your Winsock code is excellent but unfortunately your appraoch fails to achieve its goal because of the limitation on the size of the hosts file.
Like I said, it would take AT LEAST 13,000 entries in the hosts file to achieve any useful ad blocking results!
There are a few ad sites that make up the majority. A real easy way to address this problem is to look at the source for the web pages. Figure out where they're getting the ads from, such as ads.doubleclick.net, various akamai.net servers, etc.
Next, open up the hosts file (on my system it's in c:\winnt\system32\drivers\etc\). Ad each of these DNS entries and map it to 127.0.0.1
Goodbye ads, hello speed. I have maybe 12 entries and it's made a huge difference. Cool program, though.