Upgrade platform_process_is_elevated()

This commit is contained in:
Gymnasiast committed 2022-01-16 13:17:54 +01:00
1 parent 8d6cb974bf
commit feeadb3c98
7 files changed
+31 -31

No files matched your search

+1 -1
View File
@@ -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)
+9
View File
@@ -309,6 +309,15 @@ namespace Platform
}
return TemperatureUnit::Celsius;
}
bool ProcessIsElevated()
{
# ifndef __EMSCRIPTEN__
return (geteuid() == 0);
# else
return false;
# endif // __EMSCRIPTEN__
}
} // namespace Platform
#endif
+20
View File
@@ -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
+1
View File
@@ -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);
-9
View File
@@ -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";
-20
View File
@@ -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
///////////////////////////////////////////////////////////////////////////////
-1
View File
@@ -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();