mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-15 19:13:07 +01:00
Upgrade platform_process_is_elevated()
This commit is contained in:
@@ -430,7 +430,7 @@ namespace OpenRCT2
|
||||
}
|
||||
#endif
|
||||
|
||||
if (platform_process_is_elevated())
|
||||
if (Platform::ProcessIsElevated())
|
||||
{
|
||||
std::string elevationWarning = _localisationService->GetString(STR_ADMIN_NOT_RECOMMENDED);
|
||||
if (gOpenRCT2Headless)
|
||||
|
||||
@@ -309,6 +309,15 @@ namespace Platform
|
||||
}
|
||||
return TemperatureUnit::Celsius;
|
||||
}
|
||||
|
||||
bool ProcessIsElevated()
|
||||
{
|
||||
# ifndef __EMSCRIPTEN__
|
||||
return (geteuid() == 0);
|
||||
# else
|
||||
return false;
|
||||
# endif // __EMSCRIPTEN__
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
||||
@@ -802,6 +802,26 @@ namespace Platform
|
||||
|
||||
return TemperatureUnit::Celsius;
|
||||
}
|
||||
|
||||
bool ProcessIsElevated()
|
||||
{
|
||||
BOOL isElevated = FALSE;
|
||||
HANDLE hToken = nullptr;
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
|
||||
{
|
||||
TOKEN_ELEVATION Elevation;
|
||||
DWORD tokenSize = sizeof(TOKEN_ELEVATION);
|
||||
if (GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof(Elevation), &tokenSize))
|
||||
{
|
||||
isElevated = Elevation.TokenIsElevated;
|
||||
}
|
||||
}
|
||||
if (hToken)
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
}
|
||||
return isElevated;
|
||||
}
|
||||
} // namespace Platform
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace Platform
|
||||
|
||||
bool FindApp(std::string_view app, std::string* output);
|
||||
int32_t Execute(std::string_view command, std::string* output = nullptr);
|
||||
bool ProcessIsElevated();
|
||||
|
||||
bool OriginalGameDataExists(std::string_view path);
|
||||
|
||||
|
||||
@@ -185,15 +185,6 @@ datetime64 platform_get_datetime_now_utc()
|
||||
return utcNow;
|
||||
}
|
||||
|
||||
bool platform_process_is_elevated()
|
||||
{
|
||||
# ifndef __EMSCRIPTEN__
|
||||
return (geteuid() == 0);
|
||||
# else
|
||||
return false;
|
||||
# endif // __EMSCRIPTEN__
|
||||
}
|
||||
|
||||
std::string platform_get_rct1_steam_dir()
|
||||
{
|
||||
return "app_285310" PATH_SEPARATOR "depot_285311";
|
||||
|
||||
@@ -226,26 +226,6 @@ datetime64 platform_get_datetime_now_utc()
|
||||
return utcNow;
|
||||
}
|
||||
|
||||
bool platform_process_is_elevated()
|
||||
{
|
||||
BOOL isElevated = FALSE;
|
||||
HANDLE hToken = nullptr;
|
||||
if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &hToken))
|
||||
{
|
||||
TOKEN_ELEVATION Elevation;
|
||||
DWORD tokenSize = sizeof(TOKEN_ELEVATION);
|
||||
if (GetTokenInformation(hToken, TokenElevation, &Elevation, sizeof(Elevation), &tokenSize))
|
||||
{
|
||||
isElevated = Elevation.TokenIsElevated;
|
||||
}
|
||||
}
|
||||
if (hToken)
|
||||
{
|
||||
CloseHandle(hToken);
|
||||
}
|
||||
return isElevated;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// URI protocol association setup
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -99,7 +99,6 @@ void platform_sleep(uint32_t ms);
|
||||
void platform_get_user_directory(utf8* outPath, const utf8* subDirectory, size_t outSize);
|
||||
bool platform_open_common_file_dialog(utf8* outFilename, file_dialog_desc* desc, size_t outSize);
|
||||
utf8* platform_open_directory_browser(const utf8* title);
|
||||
bool platform_process_is_elevated();
|
||||
bool platform_get_steam_path(utf8* outPath, size_t outSize);
|
||||
std::string platform_get_rct1_steam_dir();
|
||||
std::string platform_get_rct2_steam_dir();
|
||||
|
||||
Reference in New Issue
Block a user