Changeset View
Changeset View
Standalone View
Standalone View
source/lib/sysdep/os/win/wsysdep.cpp
/* Copyright (C) 2020 Wildfire Games. | /* Copyright (C) 2022 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 488 Lines • ▼ Show 20 Lines | Status sys_open_url(const std::string& url) | ||||
HINSTANCE r = ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, SW_SHOWNORMAL); | HINSTANCE r = ShellExecuteA(NULL, "open", url.c_str(), NULL, NULL, 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) | |||||
{ | |||||
HCRYPTPROV hCryptProv = 0; | |||||
if(!CryptAcquireContext(&hCryptProv, 0, 0, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) | |||||
WARN_RETURN(StatusFromWin()); | |||||
memset(buffer, 0, size); | |||||
if(!CryptGenRandom(hCryptProv, (DWORD)size, (BYTE*)buffer)) | |||||
WARN_RETURN(StatusFromWin()); | |||||
if(!CryptReleaseContext(hCryptProv, 0)) | |||||
WARN_RETURN(StatusFromWin()); | |||||
return INFO::OK; | |||||
} | |||||
#if CONFIG_ENABLE_BOOST | #if CONFIG_ENABLE_BOOST | ||||
/* | /* | ||||
* Given a string of the form | * Given a string of the form | ||||
* "example.com:80" | * "example.com:80" | ||||
* or | * or | ||||
* "ftp=ftp.example.com:80;http=example.com:80;https=example.com:80" | * "ftp=ftp.example.com:80;http=example.com:80;https=example.com:80" | ||||
* separated by semicolons or whitespace, | * separated by semicolons or whitespace, | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator