From 0500a7d993c02220244832d25bf6f97ac6651251 Mon Sep 17 00:00:00 2001 From: Robert Shearman Date: Sun, 21 Nov 2004 15:42:57 +0000 Subject: [PATCH] - Make InternetGetConnectedStateExA not crash, by making InternetGetConnectedStateExW fill in the buffer correctly. - Remove the dumping of strings that will only contain garbage. - Document function. --- dlls/wininet/internet.c | 27 ++++++++++++++++++++++++--- dlls/wininet/resource.h | 2 ++ dlls/wininet/wininet_En.rc | 5 +++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index abc3266c9a6..1a7120afc8e 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -52,6 +52,7 @@ #include "windef.h" #include "winbase.h" #include "winreg.h" +#include "winuser.h" #include "wininet.h" #include "winnls.h" #include "wine/debug.h" @@ -63,6 +64,7 @@ #include "excpt.h" #include "internet.h" +#include "resource.h" #include "wine/unicode.h" @@ -98,6 +100,7 @@ HANDLE hEventArray[2]; CRITICAL_SECTION csQueue; LPWORKREQUEST lpHeadWorkQueue; LPWORKREQUEST lpWorkQueueTail; +HMODULE WININET_hModule; extern void URLCacheContainers_CreateDefaults(); extern void URLCacheContainers_DeleteAll(); @@ -280,6 +283,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) dwNumIdleThreads = 0; dwNumJobs = 0; + WININET_hModule = (HMODULE)hinstDLL; + case DLL_THREAD_ATTACH: { LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR)); @@ -650,16 +655,32 @@ BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved) * * Return connected state * + * PARAMS + * + * lpdwStatus [O] Flags specifying the status of the internet connection. + * lpszConnectionName [O] Pointer to buffer to receive the friendly name of the internet connection. + * dwNameLen [I] Size of the buffer, in characters. + * dwReserved [I] Reserved. Must be set to 0. + * * RETURNS * TRUE if connected * if lpdwStatus is not null, return the status (off line, * modem, lan...) in it. * FALSE if not connected + * + * NOTES + * If the system has no available network connections, an empty string is + * stored in lpszConnectionName. If there is a LAN connection, a localized + * "LAN Connection" string is stored. Presumably, if only a dial-up + * connection is available then the name of the dial-up connection is + * returned. Why any application, other than the "Internet Settings" CPL, + * would want to use this function instead of the simpler InternetGetConnectedStateW + * function is beyond me. */ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName, DWORD dwNameLen, DWORD dwReserved) { - TRACE("(%p, %s, %ld, 0x%08lx)\n", lpdwStatus, debugstr_w(lpszConnectionName), dwNameLen, dwReserved); + TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved); /* Must be zero */ if(dwReserved) @@ -669,7 +690,7 @@ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnecti FIXME("always returning LAN connection.\n"); *lpdwStatus = INTERNET_CONNECTION_LAN; } - return TRUE; + return LoadStringW(WININET_hModule, IDS_LANCONNECTION, lpszConnectionName, dwNameLen); } @@ -682,7 +703,7 @@ BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectio LPWSTR lpwszConnectionName = NULL; BOOL rc; - TRACE("(%p, %s, %ld, 0x%08lx)\n", lpdwStatus, debugstr_a(lpszConnectionName), dwNameLen, dwReserved); + TRACE("(%p, %p, %ld, 0x%08lx)\n", lpdwStatus, lpszConnectionName, dwNameLen, dwReserved); if (lpszConnectionName && dwNameLen > 0) lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR)); diff --git a/dlls/wininet/resource.h b/dlls/wininet/resource.h index 61793e55e54..66d7729fab0 100644 --- a/dlls/wininet/resource.h +++ b/dlls/wininet/resource.h @@ -25,3 +25,5 @@ #define IDC_USERNAME 0x403 #define IDC_PASSWORD 0x404 #define IDC_SAVEPASSWORD 0x405 + +#define IDS_LANCONNECTION 0x500 diff --git a/dlls/wininet/wininet_En.rc b/dlls/wininet/wininet_En.rc index 98f0f4cc2d5..1499b28f54f 100644 --- a/dlls/wininet/wininet_En.rc +++ b/dlls/wininet/wininet_En.rc @@ -37,3 +37,8 @@ FONT 8, "MS Shell Dlg" PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "Cancel", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP } + +STRINGTABLE DISCARDABLE +{ + IDS_LANCONNECTION "LAN Connection" +}