MCPcopy Create free account
hub / github.com/deathkiller/jazz2-native / GetCurrentElevation

Function GetCurrentElevation

Sources/Shared/Environment.cpp:27–49  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25 static ElevationState _currentElevation = ElevationState::Unknown;
26
27 ElevationState GetCurrentElevation() noexcept
28 {
29 if (_currentElevation != ElevationState::Unknown) {
30 return _currentElevation;
31 }
32
33#if defined(DEATH_TARGET_WINDOWS)
34 if (Environment::IsWindowsVista()) {
35 TOKEN_ELEVATION elevation;
36 DWORD returnLength;
37 if (::GetTokenInformation(::GetCurrentProcessToken(), TokenElevation, &elevation, sizeof(elevation), &returnLength) && returnLength == sizeof(elevation)) {
38 _currentElevation = (elevation.TokenIsElevated ? ElevationState::Full : ElevationState::Limited);
39 }
40 } else {
41 _currentElevation = ElevationState::Full;;
42 }
43#elif defined(DEATH_TARGET_APPLE) || defined(DEATH_TARGET_UNIX)
44 uid_t uid = getuid(), euid = geteuid();
45 // Check for "suid-root" or "root" as effective user
46 _currentElevation = (uid < 0 || uid != euid || euid == 0 ? ElevationState::Full : ElevationState::Limited);
47#endif
48 return _currentElevation;
49 }
50
51#if defined(DEATH_TARGET_EMSCRIPTEN)
52 bool IsEmbedded() noexcept

Callers 1

AppendLogFileHeaderMethod · 0.85

Calls 1

IsWindowsVistaFunction · 0.85

Tested by

no test coverage detected