views:

147

answers:

4

Hi,

The internet access code in our product works perfectly for 99.99% of people. However, for a few of them, it just doesn't work at all. We've been adding some trace code to try and figure out what the problem is, and it it turns out that InternetOpenURL is reporting error 2 - "The system cannot find the file specified" - from this function call:

options = INTERNET_FLAG_RAW_DATA | INTERNET_FLAG_RESYNCHRONIZE;
handle = InternetOpenUrl(internet,url,NULL,0,options,0);

(internet is the handle to an internet connection opened with InternetOpen, url is the URL to a simple text file that exists on our web server.)

We test two different web sites, one http and one https, which are located in totally different places (different domains, servers hosted geographically apart) and they both give the same error for this one guy and a few others. 99% of people, including ourselves, can access them with no problems at all. Not only that, the people affected can access the same URLs without a problem in their web browsers.

What on earth could be going on here? :(

A: 

GetLastError() is probably not the best way to find out what went wrong. From the docs:

To determine why access to the service was denied, call InternetGetLastResponseInfo.

Hugh Allen
The InternetGetLastResponseInfo docs say that you should only call it when GetLastError returns ERROR_INTERNET_EXTENDED_ERROR, which isn't happening. Is that incorrect?
Colen
@Colen: that sounds like it applies to FTP URLs. Just try it anyway and see what you get!
Hugh Allen
A: 

Are these users using a proxy? If they have a proxy set in IE, it is possible that information is being picked up and is causing your errors.

Also, I agree with Hugh. Sometimes GetLastError() can be misleading. If you want to use this, you should make sure that you SetLastError(0) before you make your call otherwise you could be getting an error code set by some previous method call.

Mike
We're already calling SetLastError(0) first, but thanks for the tip. The users say they do not have proxies set up - that was actually one of the things we checked, since a similar problem was caused by a user having "use proxy" checked but no actual proxy specified.
Colen
Do you see any information in the server logs for this request? Maybe the requests are making it to the server and the server is sending these users some bad/unexpected response? Essentially, Are we sure that this is a client problem and not a server problem?
Mike
A: 

Try something like the following:

On error, hook SetLastError function (manually by using hot-patch, or by using MS Detours or something other), and call InternetOpenUrl again.

In hooking function, if SetLastError argument in't zero, make a minidump. You will get a place where that error is set.

Abyx
A: 

Given this info, I would guess these users have a firewall (or some type of security software) that has hooked wininet and is interfering with your call. Alternatively, they may have malware infestation.

Jeremy Collake