Changeset View
Changeset View
Standalone View
Standalone View
source/lib/sysdep/os/win/wsysdep.cpp
/* Copyright (C) 2011 Wildfire Games. | /* Copyright (C) 2018 Wildfire Games. | ||||
* | * | ||||
* Permission is hereby granted, free of charge, to any person obtaining | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* "Software"), to deal in the Software without restriction, including | * "Software"), to deal in the Software without restriction, including | ||||
* without limitation the rights to use, copy, modify, merge, publish, | * without limitation the rights to use, copy, modify, merge, publish, | ||||
* distribute, sublicense, and/or sell copies of the Software, and to | * distribute, sublicense, and/or sell copies of the Software, and to | ||||
* permit persons to whom the Software is furnished to do so, subject to | * permit persons to whom the Software is furnished to do so, subject to | ||||
* the following conditions: | * the following conditions: | ||||
▲ Show 20 Lines • Show All 450 Lines • ▼ Show 20 Lines | Status sys_pick_directory(OsPath& path) | ||||
CoUninitialize(); | CoUninitialize(); | ||||
WARN_RETURN(StatusFromWin()); | WARN_RETURN(StatusFromWin()); | ||||
} | } | ||||
Status sys_open_url(const std::string& url) | Status sys_open_url(const std::string& url) | ||||
{ | { | ||||
HINSTANCE r = ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); | HINSTANCE r = ShellExecuteA(nullptr, "open", url.c_str(), nullptr, nullptr, SW_SHOWNORMAL); | ||||
if ((int)(intptr_t)r > 32) | if ((int)(intptr_t)r > 32) | ||||
return INFO::OK; | return INFO::OK; | ||||
WARN_RETURN(ERR::FAIL); | WARN_RETURN(ERR::FAIL); | ||||
} | } | ||||
Status sys_generate_random_bytes(u8* buffer, size_t size) | Status sys_generate_random_bytes(u8* buffer, size_t size) | ||||
▲ Show 20 Lines • Show All 48 Lines • ▼ Show 20 Lines | Status sys_get_proxy_config(const std::wstring& url, std::wstring& proxy) | ||||
autoProxyOptions.fAutoLogonIfChallenged = TRUE; | autoProxyOptions.fAutoLogonIfChallenged = TRUE; | ||||
WINHTTP_PROXY_INFO proxyInfo; | WINHTTP_PROXY_INFO proxyInfo; | ||||
memset(&proxyInfo, 0, sizeof(proxyInfo)); | memset(&proxyInfo, 0, sizeof(proxyInfo)); | ||||
WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieConfig; | WINHTTP_CURRENT_USER_IE_PROXY_CONFIG ieConfig; | ||||
memset(&ieConfig, 0, sizeof(ieConfig)); | memset(&ieConfig, 0, sizeof(ieConfig)); | ||||
HINTERNET hSession = NULL; | HINTERNET hSession = nullptr; | ||||
Status err = INFO::SKIPPED; | Status err = INFO::SKIPPED; | ||||
bool useAutoDetect; | bool useAutoDetect; | ||||
if(WinHttpGetIEProxyConfigForCurrentUser(&ieConfig)) | if(WinHttpGetIEProxyConfigForCurrentUser(&ieConfig)) | ||||
{ | { | ||||
if(ieConfig.lpszAutoConfigUrl) | if(ieConfig.lpszAutoConfigUrl) | ||||
Show All 12 Lines | Status sys_get_proxy_config(const std::wstring& url, std::wstring& proxy) | ||||
else | else | ||||
{ | { | ||||
// Can't find IE config settings - fall back to auto-discovery | // Can't find IE config settings - fall back to auto-discovery | ||||
useAutoDetect = true; | useAutoDetect = true; | ||||
} | } | ||||
if(useAutoDetect) | if(useAutoDetect) | ||||
{ | { | ||||
hSession = WinHttpOpen(NULL, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, | hSession = WinHttpOpen(nullptr, WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, | ||||
WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); | WINHTTP_NO_PROXY_NAME, WINHTTP_NO_PROXY_BYPASS, 0); | ||||
if(hSession && WinHttpGetProxyForUrl(hSession, url.c_str(), &autoProxyOptions, &proxyInfo) && proxyInfo.lpszProxy) | if(hSession && WinHttpGetProxyForUrl(hSession, url.c_str(), &autoProxyOptions, &proxyInfo) && proxyInfo.lpszProxy) | ||||
{ | { | ||||
proxy = parse_proxy(proxyInfo.lpszProxy); | proxy = parse_proxy(proxyInfo.lpszProxy); | ||||
if(!proxy.empty()) | if(!proxy.empty()) | ||||
{ | { | ||||
err = INFO::OK; | err = INFO::OK; | ||||
▲ Show 20 Lines • Show All 42 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator