inetcpl.cpl: Add partial support for writing DefaultConnectionSettings registry setting.

IE 10+ saves connection information in this key. .NET 4.6.2 is using the
key to read proxy settings.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2018-06-28 16:02:45 +02:00 committed by Alexandre Julliard
parent 2499f225ee
commit b57d794796
1 changed files with 81 additions and 2 deletions

View File

@ -26,6 +26,7 @@
#include "inetcpl.h" #include "inetcpl.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
#include "wine/unicode.h" #include "wine/unicode.h"
WINE_DEFAULT_DEBUG_CHANNEL(inetcpl); WINE_DEFAULT_DEBUG_CHANNEL(inetcpl);
@ -36,9 +37,65 @@ static const WCHAR internet_settings[] = {'S','o','f','t','w','a','r','e','\\',
'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0}; 'I','n','t','e','r','n','e','t',' ','S','e','t','t','i','n','g','s',0};
static const WCHAR proxy_enable[] = {'P','r','o','x','y','E','n','a','b','l','e',0}; static const WCHAR proxy_enable[] = {'P','r','o','x','y','E','n','a','b','l','e',0};
static const WCHAR proxy_server[] = {'P','r','o','x','y','S','e','r','v','e','r',0}; static const WCHAR proxy_server[] = {'P','r','o','x','y','S','e','r','v','e','r',0};
static const WCHAR connections[] = {'C','o','n','n','e','c','t','i','o','n','s',0};
static const WCHAR default_connection_settings[] = {'D','e','f','a','u','l','t',
'C','o','n','n','e','c','t','i','o','n','S','e','t','t','i','n','g','s',0};
static BOOL initdialog_done; static BOOL initdialog_done;
#define CONNECTION_SETTINGS_VERSION 0x46
#define MANUAL_PROXY 0x2
typedef struct {
DWORD version;
DWORD id;
DWORD flags;
BYTE data[1];
/* DWORD proxy_server_len; */
/* UTF8 proxy_server[proxy_server_len]; */
/* DWORD bypass_list_len; */
/* UTF8 bypass_list[bypass_list_len]; */
/* DWORD configuration_script_len; */
/* UTF8 configuration_script[configuration_script_len]; */
/* DWORD unk[8]; set to 0 */
} connection_settings;
static DWORD create_connection_settings(BOOL manual_proxy, const WCHAR *proxy_server,
connection_settings **ret)
{
DWORD size = FIELD_OFFSET(connection_settings, data), pos;
DWORD proxy_server_len;
size += sizeof(DWORD);
if(proxy_server)
{
proxy_server_len = WideCharToMultiByte(CP_UTF8, 0, proxy_server, -1,
NULL, 0, NULL, NULL);
if(!proxy_server_len) return 0;
proxy_server_len--;
}
else
proxy_server_len = 0;
size += proxy_server_len;
size += sizeof(DWORD)*10;
*ret = heap_alloc_zero(size);
if(!*ret) return 0;
(*ret)->version = CONNECTION_SETTINGS_VERSION;
(*ret)->flags = 1;
if(manual_proxy) (*ret)->flags |= MANUAL_PROXY;
((DWORD*)(*ret)->data)[0] = proxy_server_len;
pos = sizeof(DWORD);
if(proxy_server_len)
{
WideCharToMultiByte(CP_UTF8, 0, proxy_server, -1,
(char*)(*ret)->data+pos, proxy_server_len, NULL, NULL);
pos += proxy_server_len;
}
return size;
}
static void connections_on_initdialog(HWND hwnd) static void connections_on_initdialog(HWND hwnd)
{ {
DWORD type, size, enabled; DWORD type, size, enabled;
@ -110,11 +167,12 @@ static INT_PTR connections_on_command(HWND hwnd, WPARAM wparam)
static INT_PTR connections_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam) static INT_PTR connections_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam)
{ {
connection_settings *default_connection;
WCHAR addr[INTERNET_MAX_URL_LENGTH]; WCHAR addr[INTERNET_MAX_URL_LENGTH];
PSHNOTIFY *psn = (PSHNOTIFY*)lparam; PSHNOTIFY *psn = (PSHNOTIFY*)lparam;
DWORD addr_len, port_len, enabled; DWORD addr_len, port_len, enabled, size;
LRESULT res; LRESULT res;
HKEY hkey; HKEY hkey, con;
if(psn->hdr.code != PSN_APPLY) if(psn->hdr.code != PSN_APPLY)
return FALSE; return FALSE;
@ -156,8 +214,29 @@ static INT_PTR connections_on_notify(HWND hwnd, WPARAM wparam, LPARAM lparam)
if(res == ERROR_FILE_NOT_FOUND) if(res == ERROR_FILE_NOT_FOUND)
res = ERROR_SUCCESS; res = ERROR_SUCCESS;
} }
if(res)
{
RegCloseKey(hkey);
return FALSE;
}
TRACE("ProxtServer set to %s\n", wine_dbgstr_w(addr)); TRACE("ProxtServer set to %s\n", wine_dbgstr_w(addr));
res = RegCreateKeyExW(hkey, connections, 0, NULL, 0, KEY_WRITE, NULL, &con, NULL);
RegCloseKey(hkey); RegCloseKey(hkey);
if(res)
return FALSE;
size = create_connection_settings(enabled, addr, &default_connection);
if(!size)
{
RegCloseKey(con);
return FALSE;
}
res = RegSetValueExW(con, default_connection_settings, 0, REG_BINARY,
(BYTE*)default_connection, size);
heap_free(default_connection);
RegCloseKey(con);
return !res; return !res;
} }