Commit 6f9e3308 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

urlmon: Build more appropriate user agent string.

The registry value we used previously seems to be ignored by recent IEs.
parent edcf723b
...@@ -532,31 +532,38 @@ static LPWSTR user_agent; ...@@ -532,31 +532,38 @@ static LPWSTR user_agent;
static void ensure_useragent(void) static void ensure_useragent(void)
{ {
DWORD size = sizeof(DWORD), res, type; OSVERSIONINFOW info = {sizeof(info)};
HKEY hkey; const WCHAR *os_type, *is_nt;
WCHAR buf[512];
static const WCHAR user_agentW[] = {'U','s','e','r',' ','A','g','e','n','t',0}; BOOL is_wow;
static const WCHAR formatW[] =
{'M','o','z','i','l','l','a','/','4','.','0',
' ','(','c','o','m','p','a','t','i','b','l','e',';',
' ','M','S','I','E',' ','8','.','0',';',
' ','W','i','n','d','o','w','s',' ','%','s','%','d','.','%','d',';',
' ','%','s',';',' ','T','r','i','d','e','n','t','/','5','.','0',')',0};
static const WCHAR ntW[] = {'N','T',' ',0};
static const WCHAR win32W[] = {'W','i','n','3','2',0};
static const WCHAR win64W[] = {'W','i','n','6','4',0};
static const WCHAR wow64W[] = {'W','O','W','6','4',0};
static const WCHAR emptyW[] = {0};
if(user_agent) if(user_agent)
return; return;
res = RegOpenKeyW(HKEY_CURRENT_USER, internet_settings_keyW, &hkey); GetVersionExW(&info);
if(res != ERROR_SUCCESS) is_nt = info.dwPlatformId == VER_PLATFORM_WIN32_NT ? ntW : emptyW;
return;
res = RegQueryValueExW(hkey, user_agentW, NULL, &type, NULL, &size); if(sizeof(void*) == 8)
if(res == ERROR_SUCCESS && type == REG_SZ) { os_type = win64W;
user_agent = heap_alloc(size); else if(IsWow64Process(GetCurrentProcess(), &is_wow) && is_wow)
res = RegQueryValueExW(hkey, user_agentW, NULL, &type, (LPBYTE)user_agent, &size); os_type = wow64W;
if(res != ERROR_SUCCESS) { else
heap_free(user_agent); os_type = win32W;
user_agent = NULL;
}
}else {
WARN("Could not find User Agent value: %u\n", res);
}
RegCloseKey(hkey); sprintfW(buf, formatW, is_nt, info.dwMajorVersion, info.dwMinorVersion, os_type);
user_agent = heap_strdupW(buf);
} }
LPWSTR get_useragent(void) LPWSTR get_useragent(void)
......
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