[Bug 17796] Citavi: No network access (wininet.dll InternetGetConnectedStateExW returns incorrect network connection state)

wine-bugs at winehq.org wine-bugs at winehq.org
Thu Jan 30 16:01:14 CST 2014


http://bugs.winehq.org/show_bug.cgi?id=17796

--- Comment #7 from Anastasius Focht <focht at gmx.net> ---
Hello folks,

not fully fixed yet.

Although commit
http://source.winehq.org/git/wine.git/commitdiff/2ef27a232239bcd614e53ff48054ac5fecadd354
was technically correct, there is another problem in
InternetGetConnectedStateExA()

--- snip ---
$ pwd
/home/focht/.wine/drive_c/Program Files/Citavi/bin

$ WINEDEBUG=+tid,+seh,+relay,+wininet wine ./Citavi\ Program.exe >>log.txt 2>&1
...

002b:Call
wininet.InternetGetConnectedStateEx(0f6de084,114786b0,00000000,00000000)
ret=04950f05
002b:trace:wininet:InternetGetConnectedStateExA (0xf6de084, 0x114786b0, 0,
0x00000000)
002b:trace:wininet:InternetGetConnectedStateExW (0xf6de084, (nil), 0,
0x00000000)
002b:warn:wininet:InternetGetConnectedStateExW always returning LAN connection.
002b:Call user32.LoadStringW(7e020000,00000500,00000000,00000000) ret=7e04ae39
002b:Ret  user32.LoadStringW() retval=00000000 ret=7e04ae39
002b:Ret  wininet.InternetGetConnectedStateEx() retval=00000000 ret=04950f05
...
002b:Call KERNEL32.OutputDebugStringW(01128298 L"1/30/2014 9:59:01 PM - Value
of \"hasLAN\" flag: False\r\n") ret=049505de 
--- snip ---

Wine only allocates a wide-character buffer in InternetGetConnectedStateExA()
in case of non-NULL lpszConnectionName' _and_ non-zero 'dwNameLen'.

The .NET code passes a valid buffer ptr but zero 'dwNameLen' (see .NET code
from my comment #6) hence InternetGetConnectedStateExW() always gets NULL
buffer, leading to LoadStringW() failure.

Source:
http://source.winehq.org/git/wine.git/blob/2ef27a232239bcd614e53ff48054ac5fecadd354:/dlls/wininet/internet.c#l1229

--- snip ---
1229 BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR
lpszConnectionName,
1230                                    DWORD dwNameLen, DWORD dwReserved)
1231 {
1232     LPWSTR lpwszConnectionName = NULL;
1233     BOOL rc;
1234
1235     TRACE("(%p, %p, %d, 0x%08x)\n", lpdwStatus, lpszConnectionName,
dwNameLen, dwReserved);
1236
1237     if (lpszConnectionName && dwNameLen > 0)
1238         lpwszConnectionName = heap_alloc(dwNameLen * sizeof(WCHAR));
1239
1240     rc = InternetGetConnectedStateExW(lpdwStatus,lpwszConnectionName,
dwNameLen,
1241                                                 dwReserved);
1242     if (rc && lpwszConnectionName)
1243     {
1244        
WideCharToMultiByte(CP_ACP,0,lpwszConnectionName,-1,lpszConnectionName,
1245                        dwNameLen, NULL, NULL);
1246         heap_free(lpwszConnectionName);
1247     }
1248     return rc;
1249 }
--- snip ---

Native can somehow cope with this situation, probably ignoring 'dwNameLen',
using a fixed size temporary wide-character buffer which is passed to
InternetGetConnectedStateExW().

Even if the caller never gets a filled buffer due to 'dwNameLen' being zero,
the function can still return 'TRUE' when InternetGetConnectedStateExW()
returns 'TRUE'.
I think this is what the .NET code implies by passing zero 'dwNameLen': only
interested in return value, not the actual connection name.

$ sha1sum CitaviSetup.exe 
bf840b949f9210654a31ba8488046e1ac47d51e5  CitaviSetup.exe

$ du -sh CitaviSetup.exe 
26M    CitaviSetup.exe

$ wine --version
wine-1.7.11-206-g82b3813

Regards

-- 
Do not reply to this email, post in Bugzilla using the
above URL to reply.
You are receiving this mail because:
You are watching all bug changes.



More information about the wine-bugs mailing list