Commit 0500a7d9 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Make InternetGetConnectedStateExA not crash, by making

InternetGetConnectedStateExW fill in the buffer correctly. - Remove the dumping of strings that will only contain garbage. - Document function.
parent 2ea15a56
...@@ -52,6 +52,7 @@ ...@@ -52,6 +52,7 @@
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winreg.h" #include "winreg.h"
#include "winuser.h"
#include "wininet.h" #include "wininet.h"
#include "winnls.h" #include "winnls.h"
#include "wine/debug.h" #include "wine/debug.h"
...@@ -63,6 +64,7 @@ ...@@ -63,6 +64,7 @@
#include "excpt.h" #include "excpt.h"
#include "internet.h" #include "internet.h"
#include "resource.h"
#include "wine/unicode.h" #include "wine/unicode.h"
...@@ -98,6 +100,7 @@ HANDLE hEventArray[2]; ...@@ -98,6 +100,7 @@ HANDLE hEventArray[2];
CRITICAL_SECTION csQueue; CRITICAL_SECTION csQueue;
LPWORKREQUEST lpHeadWorkQueue; LPWORKREQUEST lpHeadWorkQueue;
LPWORKREQUEST lpWorkQueueTail; LPWORKREQUEST lpWorkQueueTail;
HMODULE WININET_hModule;
extern void URLCacheContainers_CreateDefaults(); extern void URLCacheContainers_CreateDefaults();
extern void URLCacheContainers_DeleteAll(); extern void URLCacheContainers_DeleteAll();
...@@ -280,6 +283,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) ...@@ -280,6 +283,8 @@ BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
dwNumIdleThreads = 0; dwNumIdleThreads = 0;
dwNumJobs = 0; dwNumJobs = 0;
WININET_hModule = (HMODULE)hinstDLL;
case DLL_THREAD_ATTACH: case DLL_THREAD_ATTACH:
{ {
LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR)); LPWITHREADERROR lpwite = HeapAlloc(GetProcessHeap(), 0, sizeof(WITHREADERROR));
...@@ -650,16 +655,32 @@ BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved) ...@@ -650,16 +655,32 @@ BOOL WINAPI InternetGetConnectedState(LPDWORD lpdwStatus, DWORD dwReserved)
* *
* Return connected state * 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 * RETURNS
* TRUE if connected * TRUE if connected
* if lpdwStatus is not null, return the status (off line, * if lpdwStatus is not null, return the status (off line,
* modem, lan...) in it. * modem, lan...) in it.
* FALSE if not connected * 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, BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnectionName,
DWORD dwNameLen, DWORD dwReserved) 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 */ /* Must be zero */
if(dwReserved) if(dwReserved)
...@@ -669,7 +690,7 @@ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnecti ...@@ -669,7 +690,7 @@ BOOL WINAPI InternetGetConnectedStateExW(LPDWORD lpdwStatus, LPWSTR lpszConnecti
FIXME("always returning LAN connection.\n"); FIXME("always returning LAN connection.\n");
*lpdwStatus = INTERNET_CONNECTION_LAN; *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 ...@@ -682,7 +703,7 @@ BOOL WINAPI InternetGetConnectedStateExA(LPDWORD lpdwStatus, LPSTR lpszConnectio
LPWSTR lpwszConnectionName = NULL; LPWSTR lpwszConnectionName = NULL;
BOOL rc; 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) if (lpszConnectionName && dwNameLen > 0)
lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR)); lpwszConnectionName= HeapAlloc(GetProcessHeap(), 0, dwNameLen * sizeof(WCHAR));
......
...@@ -25,3 +25,5 @@ ...@@ -25,3 +25,5 @@
#define IDC_USERNAME 0x403 #define IDC_USERNAME 0x403
#define IDC_PASSWORD 0x404 #define IDC_PASSWORD 0x404
#define IDC_SAVEPASSWORD 0x405 #define IDC_SAVEPASSWORD 0x405
#define IDS_LANCONNECTION 0x500
...@@ -37,3 +37,8 @@ FONT 8, "MS Shell Dlg" ...@@ -37,3 +37,8 @@ FONT 8, "MS Shell Dlg"
PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON PUSHBUTTON "OK", IDOK, 98, 126, 56, 14, WS_GROUP | WS_TABSTOP | BS_DEFPUSHBUTTON
PUSHBUTTON "Cancel", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP PUSHBUTTON "Cancel", IDCANCEL, 158, 126, 56, 14, WS_GROUP | WS_TABSTOP
} }
STRINGTABLE DISCARDABLE
{
IDS_LANCONNECTION "LAN Connection"
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment